|
21 | 21 | "snippet::array-last": { |
22 | 22 | "id": "snippet::array-last", |
23 | 23 | "type": "simple", |
24 | | - "description": "You can use arr.at(-1) if supported or arr[arr.length - 1] to get the last element of an array.", |
25 | | - "example": "const last = (arr) => arr.at(-1);\n// or in older environments\nconst last = (arr) => arr[arr.length - 1]" |
| 24 | + "description": "You can use `arr.at(-1)` if supported or `arr[arr.length - 1]` to get the last element of an array.", |
| 25 | + "example": "const last = (arr) => arr.at(-1);\n// or in older environments\nconst lastLegacy = (arr) => arr[arr.length - 1]" |
26 | 26 | }, |
27 | 27 | "snippet::array-slice-exclude-last-n": { |
28 | 28 | "id": "snippet::array-slice-exclude-last-n", |
|
64 | 64 | "id": "snippet::char-last", |
65 | 65 | "type": "simple", |
66 | 66 | "description": "You can use `str.at(-1)` if supported or `str[str.length - 1]` to get the last character of a string.", |
67 | | - "example": "const last = (str) => str.at(-1);\n// or in older environments\nconst last = (str) => str[str.length - 1]" |
| 67 | + "example": "const last = (str) => str.at(-1);\n// or in older environments\nconst lastLegacy = (str) => str[str.length - 1]" |
68 | 68 | }, |
69 | 69 | "snippet::for-own": { |
70 | 70 | "id": "snippet::for-own", |
|
232 | 232 | "id": "snippet::json-file", |
233 | 233 | "type": "simple", |
234 | 234 | "description": "You can use `JSON` and 'node:fs' to read and write json file.", |
235 | | - "example": "import * as fs from 'node:fs/promises'\nfs.readFile(file, 'utf8').then(JSON.parse)\nfs.writeFile(file, JSON.stringify(data, null, 2) + '\n')" |
| 235 | + "example": "import * as fs from 'node:fs/promises'\nfs.readFile(file, 'utf8').then(JSON.parse)\nfs.writeFile(file, JSON.stringify(data, null, 2) + '\\n')" |
236 | 236 | }, |
237 | 237 | "snippet::math-random": { |
238 | 238 | "id": "snippet::math-random", |
|
304 | 304 | "id": "snippet::unix-paths", |
305 | 305 | "type": "simple", |
306 | 306 | "description": "You can check the start of a path for the Windows extended-length path prefix and if it's not present, replace backslashes with forward slashes.", |
307 | | - "example": "path.startsWith('\\\\?\\') ? path : path.replace(/\\/g, '/')" |
| 307 | + "example": "path.startsWith('\\\\\\\\?\\\\') ? path : path.replace(/\\\\/g, '/')" |
308 | 308 | }, |
309 | 309 | "snippet:is-number": { |
310 | 310 | "id": "snippet:is-number", |
|
0 commit comments