|
150 | 150 | "description": "You can use `instanceof Date`, or if cross-realm, use `Object.prototype.toString.call(v) === \"[object Date]\"`", |
151 | 151 | "example": "const isDate = v instanceof Date;\n// for cross-realm\nconst isDateCrossRealm = Object.prototype.toString.call(v) === \"[object Date]\"" |
152 | 152 | }, |
| 153 | + "snippet::is-deflate-buffer": { |
| 154 | + "id": "snippet::is-deflate-buffer", |
| 155 | + "type": "simple", |
| 156 | + "description": "You can check the first two bytes of a buffer to detect if it's compressed using deflate.", |
| 157 | + "example": "function isDeflate(buf) {\n if (buf.length < 2 || buf[0] !== 0x78) return false;\n const b = buf[1];\n return b === 1 || b === 0x9c || b === 0xda;\n}" |
| 158 | + }, |
153 | 159 | "snippet::is-equal": { |
154 | 160 | "id": "snippet::is-equal", |
155 | 161 | "type": "simple", |
|
174 | 180 | "description": "You can use `typeof` and `Object.prototype.toString.call` to check if a value is a generator function", |
175 | 181 | "example": "const isGeneratorFunction = (obj) => typeof obj === \"function\" && Object.prototype.toString.call(obj) === \"[object GeneratorFunction]\"" |
176 | 182 | }, |
| 183 | + "snippet::is-gzip-buffer": { |
| 184 | + "id": "snippet::is-gzip-buffer", |
| 185 | + "type": "simple", |
| 186 | + "description": "You can check first three bytes of a buffer to detect if it is a gzip file.", |
| 187 | + "example": "function isGzip(buf) {\n if (buf.length < 3) return false;\n return buf[0] === 31 && buf[1] === 139 && buf[2] === 8;\n}" |
| 188 | + }, |
177 | 189 | "snippet::is-in-ssh": { |
178 | 190 | "id": "snippet::is-in-ssh", |
179 | 191 | "type": "simple", |
|
529 | 541 | "moduleName": "is-date-object", |
530 | 542 | "replacements": ["snippet::is-date"] |
531 | 543 | }, |
| 544 | + "is-deflate": { |
| 545 | + "type": "module", |
| 546 | + "moduleName": "is-deflate", |
| 547 | + "replacements": ["snippet::is-deflate-buffer"] |
| 548 | + }, |
532 | 549 | "is-even": { |
533 | 550 | "type": "module", |
534 | 551 | "moduleName": "is-even", |
|
539 | 556 | "moduleName": "is-generator-function", |
540 | 557 | "replacements": ["snippet::is-generator-function"] |
541 | 558 | }, |
| 559 | + "is-gzip": { |
| 560 | + "type": "module", |
| 561 | + "moduleName": "is-gzip", |
| 562 | + "replacements": ["snippet::is-gzip-buffer"] |
| 563 | + }, |
542 | 564 | "is-in-ci": { |
543 | 565 | "type": "module", |
544 | 566 | "moduleName": "is-in-ci", |
|
0 commit comments