|
12 | 12 | "description": "You can use a combination of `filter` and `includes` to calculate the difference between two arrays.", |
13 | 13 | "example": "const difference = (a, b) => a.filter((item) => !b.includes(item))" |
14 | 14 | }, |
| 15 | + "snippet::array-flatten": { |
| 16 | + "id": "snippet::array-flatten", |
| 17 | + "type": "simple", |
| 18 | + "description": "You can use `Array.prototype.flat` with `Infinity` as an argument to fully flatten an array.", |
| 19 | + "example": "array.flat(Infinity)" |
| 20 | + }, |
15 | 21 | "snippet::array-from-count": { |
16 | 22 | "id": "snippet::array-from-count", |
17 | 23 | "type": "simple", |
18 | 24 | "description": "You can use `Array.from` to create an array of sequential integers", |
19 | 25 | "example": "Array.from({ length: n }, (_, i) => i);" |
20 | 26 | }, |
| 27 | + "snippet::array-from-count-with-start": { |
| 28 | + "id": "snippet::array-from-count-with-start", |
| 29 | + "type": "simple", |
| 30 | + "description": "You can use `Array.from` to create an array of sequential integers starting from a specific integer", |
| 31 | + "example": "Array.from({ length: end - start }, (_, i) => i + start);" |
| 32 | + }, |
21 | 33 | "snippet::array-last": { |
22 | 34 | "id": "snippet::array-last", |
23 | 35 | "type": "simple", |
|
162 | 174 | "description": "If the current environment is npm the `npm_config_user_agent` environment variable will be set and start with `\"npm\"`.", |
163 | 175 | "example": "const isNpm = process.env.npm_config_user_agent?.startsWith(\"npm\")" |
164 | 176 | }, |
| 177 | + "snippet::is-number": { |
| 178 | + "id": "snippet::is-number", |
| 179 | + "type": "simple", |
| 180 | + "description": "You can check if a value is a number by using `typeof` or coercing it to a number and using `Number.isFinite`.", |
| 181 | + "example": "const isNumber = (v) => typeof v === \"number\" || (typeof v === \"string\" && Number.isFinite(+v));" |
| 182 | + }, |
165 | 183 | "snippet::is-object": { |
166 | 184 | "id": "snippet::is-object", |
167 | 185 | "type": "simple", |
|
306 | 324 | "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 | 325 | "example": "path.startsWith('\\\\\\\\?\\\\') ? path : path.replace(/\\\\/g, '/')" |
308 | 326 | }, |
309 | | - "snippet:is-number": { |
310 | | - "id": "snippet:is-number", |
| 327 | + "snippet::year": { |
| 328 | + "id": "snippet::year", |
311 | 329 | "type": "simple", |
312 | | - "description": "You can check if a value is a number by using `typeof` or coercing it to a number and using `Number.isFinite`.", |
313 | | - "example": "const isNumber = (v) => typeof v === \"number\" || (typeof v === \"string\" && Number.isFinite(+v));" |
| 330 | + "description": "You can use `new Date().getUTCFullYear()` to get the current year.", |
| 331 | + "example": "new Date().getUTCFullYear()" |
314 | 332 | } |
315 | 333 | }, |
316 | 334 | "mappings": { |
|
319 | 337 | "moduleName": "arr-diff", |
320 | 338 | "replacements": ["snippet::array-difference"] |
321 | 339 | }, |
| 340 | + "arr-flatten": { |
| 341 | + "type": "module", |
| 342 | + "moduleName": "arr-flatten", |
| 343 | + "replacements": ["snippet::array-flatten"] |
| 344 | + }, |
322 | 345 | "array-back": { |
323 | 346 | "type": "module", |
324 | 347 | "moduleName": "array-back", |
|
339 | 362 | "moduleName": "array-last", |
340 | 363 | "replacements": ["snippet::array-last"] |
341 | 364 | }, |
| 365 | + "array-range": { |
| 366 | + "type": "module", |
| 367 | + "moduleName": "array-range", |
| 368 | + "replacements": ["snippet::array-from-count-with-start"] |
| 369 | + }, |
342 | 370 | "array-union": { |
343 | 371 | "type": "module", |
344 | 372 | "moduleName": "array-union", |
|
482 | 510 | "is-number": { |
483 | 511 | "type": "module", |
484 | 512 | "moduleName": "is-number", |
485 | | - "replacements": ["snippet:is-number"] |
| 513 | + "replacements": ["snippet::is-number"] |
486 | 514 | }, |
487 | 515 | "is-number-object": { |
488 | 516 | "type": "module", |
489 | 517 | "moduleName": "is-number-object", |
490 | | - "replacements": ["snippet:is-number"] |
| 518 | + "replacements": ["snippet::is-number"] |
491 | 519 | }, |
492 | 520 | "is-obj": { |
493 | 521 | "type": "module", |
|
643 | 671 | "type": "module", |
644 | 672 | "moduleName": "upper-case", |
645 | 673 | "replacements": ["snippet::to-uppercase"] |
| 674 | + }, |
| 675 | + "year": { |
| 676 | + "type": "module", |
| 677 | + "moduleName": "year", |
| 678 | + "replacements": ["snippet::year"] |
646 | 679 | } |
647 | 680 | } |
648 | 681 | } |
0 commit comments