{
  "While ..": {
    "body": [
      "while (${1:condition}) {",
      "\t$0",
      "}"
    ],
    "prefix": "while .."
  },
  "argv (node)": {
    "body": "const argv = process.argv.slice(2);",
    "description": "Arguments from the command line. [0] is the node executable path, [1] the path of the file being executed, making [2] the first positional argument.",
    "prefix": "argv (node)"
  },
  "cast (JSDoc)": {
    "body": "/** @type {${1:string}} */ (${2:bracketedVar})",
    "prefix": "cast (JSDoc)"
  },
  "class (JSDoc) + typedef (JSDoc)": {
    "body": [
      "/** @typedef {Object} ${1:name}",
      " * @property {${2:string}} ${3:prop1}",
      " */"
    ],
    "description": "https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#typedef-callback-and-param",
    "prefix": [
      "class (JSDoc)",
      "typedef (JSDoc)"
    ]
  },
  "do .. while ..": {
    "body": [
      "do {",
      "\t$0",
      "} while (${1:condition});"
    ],
    "prefix": [
      "do .. while",
      "repeat until"
    ]
  },
  "ec (export const)": {
    "body": "export const ${1:CONSTANT}",
    "prefix": "ec (export const)"
  },
  "ef (export function)": {
    "body": [
      "export function ${1:name}($2) {",
      "\t$0",
      "}"
    ],
    "prefix": "ef (export function)"
  },
  "filter ( => )": {
    "body": "filter(${1:item} => ${1:item}$0)",
    "prefix": "filter ( => )"
  },
  "for (i++)": {
    "body": [
      "for (let i = 0; i < ${1:array}.length; i++) {",
      "\tconst ${2:element} = ${1:array}[i];",
      "\t$0",
      "}"
    ],
    "prefix": "for (i++)"
  },
  "for (i--)": {
    "body": [
      "for (let i = ${1:array}.length - 1; i >= 0; i--) {",
      "\tconst ${2:element} = ${1:array}[i];",
      "\t$0",
      "}"
    ],
    "prefix": "for (i--)"
  },
  "for (key, value)": {
    "body": [
      "for (const [key, value] of Object.entries(${1:dict})) {",
      "\t$0",
      "}"
    ],
    "prefix": "for (key, value)"
  },
  "for .. in (key)": {
    "body": [
      "for (const ${1:key} in ${2:object}) {",
      "\t$0",
      "}"
    ],
    "prefix": "for .. in (key)"
  },
  "for .. of (array)": {
    "body": [
      "for (const ${1:iterator} of ${2:array}) {",
      "\t$0",
      "}"
    ],
    "prefix": "for .. of (array)"
  },
  "forEach": {
    "body": [
      "forEach(${1:item} => {",
      "\t$0",
      "});"
    ],
    "prefix": "forEach =>"
  },
  "function_trad": {
    "body": [
      "function ${1:name}() {",
      "\t$0",
      "}"
    ],
    "prefix": "function"
  },
  "if ..": {
    "body": [
      "if (${1:condition}) {",
      "\t$0",
      "}"
    ],
    "prefix": "if"
  },
  "if .. else": {
    "body": [
      "if (${1:condition}) {",
      "\t$0",
      "} else {",
      "\t",
      "}"
    ],
    "prefix": "if .. else"
  },
  "ignore (biome formatter)": {
    "body": "// biome-ignore format: ${1:explanation}",
    "description": "Ignores the next block of code.",
    "prefix": "ignore (biome formatter)"
  },
  "ignore file (TypeScript) + nocheck (TypeScript)": {
    "body": "// @ts-nocheck",
    "prefix": [
      "ignore file (TypeScript)",
      "nocheck (TypeScript)"
    ]
  },
  "map ( () => {} )": {
    "body": [
      "map(${1:item} => {",
      "\t$0",
      "\treturn;",
      "})"
    ],
    "prefix": "map ( () => {} )"
  },
  "map ( => )": {
    "body": "map(${1:item} => ${1:item}$0)",
    "prefix": "map ( => )"
  },
  "reduce()": {
    "body": [
      ".reduce((acc, ${1:item}) => {",
      "\t$0",
      "\treturn acc;",
      "}, ${2:initialValue})"
    ],
    "prefix": "reduce()"
  },
  "relative date": {
    "body": [
      "/**",
      " * @param {string} absoluteDate string to be converted to a date",
      " * @return {string} relative date",
      " */",
      "function relativeDate(absoluteDate) {",
      "\tconst deltaSecs = (+new Date() - +new Date(absoluteDate)) / 1000;",
      "\t/** @type {\"year\"|\"month\"|\"week\"|\"day\"|\"hour\"|\"minute\"|\"second\"} */",
      "\tlet unit;",
      "\tlet delta;",
      "\tif (deltaSecs < 60) {",
      "\t\tunit = \"second\";",
      "\t\tdelta = deltaSecs;",
      "\t} else if (deltaSecs < 60 * 60) {",
      "\t\tunit = \"minute\";",
      "\t\tdelta = Math.ceil(deltaSecs / 60);",
      "\t} else if (deltaSecs < 60 * 60 * 24) {",
      "\t\tunit = \"hour\";",
      "\t\tdelta = Math.ceil(deltaSecs / 60 / 60);",
      "\t} else if (deltaSecs < 60 * 60 * 24 * 7) {",
      "\t\tunit = \"day\";",
      "\t\tdelta = Math.ceil(deltaSecs / 60 / 60 / 24);",
      "\t} else if (deltaSecs < 60 * 60 * 24 * 7 * 4) {",
      "\t\tunit = \"week\";",
      "\t\tdelta = Math.ceil(deltaSecs / 60 / 60 / 24 / 7);",
      "\t} else if (deltaSecs < 60 * 60 * 24 * 7 * 4 * 12) {",
      "\t\tunit = \"month\";",
      "\t\tdelta = Math.ceil(deltaSecs / 60 / 60 / 24 / 7 / 4);",
      "\t} else {",
      "\t\tunit = \"year\";",
      "\t\tdelta = Math.ceil(deltaSecs / 60 / 60 / 24 / 7 / 4 / 12);",
      "\t}",
      "\tconst formatter = new Intl.RelativeTimeFormat(\"en\", { style: \"long\", numeric: \"auto\" });",
      "\treturn formatter.format(-delta, unit);",
      "}"
    ],
    "prefix": "relative date"
  },
  "replace": {
    "body": "replace(/${1:regexp}/, \"$2\")",
    "prefix": "replace"
  },
  "sort ( () => {} )": {
    "body": [
      "sort((a, b) => {",
      "\treturn ${1:b - a};",
      "})"
    ],
    "description": "Sort Array with basic a-b-comparator function",
    "prefix": "sort ( () => {} )"
  },
  "split by \\n": {
    "body": ".split(\"\\n\")",
    "prefix": ".split by \\n"
  },
  "split by \\r": {
    "body": ".split(\"\\r\")",
    "description": "required for output from app.doShellScript()",
    "prefix": ".split by \\r"
  },
  "switch .. case": {
    "body": [
      "switch (${1:key}) {",
      "\tcase ${2:value}:",
      "\t\t$0",
      "\t\tbreak;",
      "\tdefault:",
      "}"
    ],
    "prefix": "switch .. case"
  },
  "ternary": {
    "body": "${1:condition} ? ${2:value1} : ${3:value2}",
    "prefix": "ternary"
  },
  "thousand separator": {
    "body": ".toLocaleString(\"de-DE\")",
    "description": "insert thousand separator into a digit string",
    "prefix": "thousand separator"
  },
  "timeout + delay": {
    "body": [
      "setTimeout(() => {",
      "\t$0",
      "}, ${1:timeoutMs});"
    ],
    "prefix": [
      "timeout",
      "delay"
    ]
  },
  "today as ISO 8601 string": {
    "body": "new Date().toISOString().slice(0, 10);",
    "prefix": "ISO date"
  },
  "today's date": {
    "body": "const today = new Date();",
    "prefix": [
      "today",
      "date"
    ]
  },
  "tomorrow's date": {
    "body": [
      "const tomorrow = new Date();",
      "tomorrow.setDate(tomorrow.getDate() + 1);"
    ],
    "prefix": [
      "tomorrow",
      "date"
    ]
  },
  "try .. catch": {
    "body": [
      "try {",
      "\t$0",
      "} catch (_error) {",
      "\t",
      "}"
    ],
    "description": "leading underscore so the variable is ignored by biome when not used.",
    "prefix": "try .. catch"
  },
  "type (JSDoc)": {
    "body": "/** @type {${1:string}} */",
    "prefix": "type (JSDoc)"
  },
  "type: Record (JSDoc)": {
    "body": "/** @type {Record<string, string>} */",
    "prefix": "type: Record (JSDoc)"
  },
  "unique items": {
    "body": "${1:arr} = [...new Set(${2:arr})];",
    "prefix": "unique items"
  },
  "Class": {
    "prefix": [
      "clax"
    ],
    "body": [
      "export class $1 ${2:extends ${3:Parent} }{",
      "\tconstructor(${4:props}) {",
      "\t\tthis.$4 = $4;",
      "\t}",
      "",
      "\t$0",
      "}"
    ],
    "description": "Class definition template."
  },
  "test": {
    "prefix": [
      "it"
    ],
    "body": [
      "it('${1:should ${2}}', async () => {",
      "\t$0",
      "});"
    ],
    "description": "Test template"
  },
  "method": {
    "prefix": [
      "mtd"
    ],
    "body": [
      "${1:async ${2:method}}(${3:params}) {",
      "\t$0",
      "}"
    ],
    "description": "method"
  },
  "function": {
    "prefix": [
      "fun"
    ],
    "body": [
      "${1:async }${2:(${3:params})} => {$0}"
    ],
    "description": "function"
  },
  "const": {
    "prefix": [
      "const"
    ],
    "body": [
      "const $1 = $0;"
    ],
    "description": "const"
  },
  "let": {
    "prefix": [
      "let"
    ],
    "body": [
      "let $1 = $0;"
    ],
    "description": "let"
  },
  "Console log": {
    "prefix": [
      "cl"
    ],
    "body": [
      "console.log($0);"
    ],
    "description": "Console log"
  },
  "Console debug": {
    "prefix": [
      "cd"
    ],
    "body": [
      "console.debug($0);"
    ],
    "description": "Console debug"
  },
  "Console log all": {
    "prefix": [
      "clj"
    ],
    "body": [
      "console.log(JSON.stringify($0, null, 2));"
    ],
    "description": "Console log whole object"
  },
  "Console debug all": {
    "prefix": [
      "cdj"
    ],
    "body": [
      "console.debug(JSON.stringify($0, null, 2));"
    ],
    "description": "Console debug whole object"
  },
  "If": {
    "prefix": [
      "if"
    ],
    "body": [
      "if (${1:condition}) {",
      "\t$0",
      "}"
    ],
    "description": "Console debug whole object"
  },
  "If-else": {
    "prefix": [
      "ifelse"
    ],
    "body": [
      "if (${1:condition}) {",
      "\t$2",
      "} else {",
      "\t$0",
      "}"
    ],
    "description": "Console debug whole object"
  },
  "docblock": {
    "prefix": [
      "/**"
    ],
    "body": [
      "/**",
      " * $0",
      " */"
    ]
  },
  "trycatch": {
    "prefix": [
      "tc"
    ],
    "body": [
      "try {",
      "\t$0",
      "} catch (e) {",
      "\tthrow e;",
      "}"
    ],
    "description": "Try catch block"
  },
  "Describe test": {
    "prefix": [
      "desc"
    ],
    "body": [
      "describe('${1}', () => {",
      "\t$0",
      "})"
    ],
    "description": "Describe test"
  }
}
