{"name":"encoding-sniffer","version":"1.0.2","description":"Implementation of the HTML encoding sniffer algo, with stream support","bugs":{"url":"https://github.com/fb55/encoding-sniffer/issues"},"repository":{"type":"git","url":"git://github.com/fb55/encoding-sniffer.git"},"funding":{"type":"github","url":"https://github.com/fb55/encoding-sniffer?sponsor=1"},"license":"MIT","author":{"name":"Felix Boehm","email":"me@feedic.com"},"sideEffects":false,"type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./sniffer":{"types":"./dist/sniffer.d.ts","default":"./dist/sniffer.js"}},"main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"tsc","build:docs":"typedoc --hideGenerator src/index.ts","format":"npm run format:es && npm run format:biome","format:biome":"biome check --write .","format:es":"npm run lint:es -- --fix","lint":"npm run lint:es && npm run lint:ts && npm run lint:biome","lint:biome":"biome check .","lint:es":"eslint .","lint:ts":"tsc --noEmit","prepublishOnly":"npm run build","test":"npm run test:vi && npm run lint","test:vi":"vitest run"},"dependencies":{"@exodus/bytes":"^1.15.0"},"devDependencies":{"@biomejs/biome":"^2.4.7","@feedic/eslint-config":"^0.3.1","@types/node":"^25.5.0","eslint":"^10.0.3","eslint-config-biome":"^2.1.3","globals":"^17.4.0","typescript":"^5.9.3","typescript-eslint":"^8.57.1","vitest":"^4.0.17"},"engines":{"node":">=20.19.0"},"gitHead":"47f6a45211bdaca7e2d374dc4ac6c1bcf781e434","_id":"encoding-sniffer@1.0.2","homepage":"https://github.com/fb55/encoding-sniffer#readme","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-dlQ0jlnDJ2ElE1Ky4crYX0pPEPxQY9F2j+ZMIXlBedLJToEfDed9pvPqXg4fZnuu4qVBbcIrZVeg3S4aibTYGw==","shasum":"548073cefb4cbe8530b4c17fb4b08d719c235427","tarball":"http://registry-npm.ywwl.com/encoding-sniffer/download/encoding-sniffer-1.0.2.tgz","fileCount":31,"unpackedSize":132616,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/encoding-sniffer@1.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD+WHKaqGDB5+qy2+vJbachpkwWMtjURVwiH0ZAL1rXWwIgX6x1UQltvegSDgmRJNjLJq9cGlz4QGnLexI1cVIg2l8="}],"size":23902,"noattachment":false,"key":"/encoding-sniffer/-/encoding-sniffer-1.0.2.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:a7a80939-4ddd-4555-94bf-e057dcca4731"}},"directories":{},"maintainers":[{"name":"fb55","email":"me@feedic.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/encoding-sniffer_1.0.2_1773789194647_0.7258839802973116"},"_hasShrinkwrap":false,"readme":"# encoding-sniffer [![Node.js CI](https://github.com/fb55/encoding-sniffer/actions/workflows/nodejs-test.yml/badge.svg)](https://github.com/fb55/encoding-sniffer/actions/workflows/nodejs-test.yml)\n\nAn implementation of the HTML Standard's\n[encoding sniffing algorithm](https://html.spec.whatwg.org/multipage/syntax.html#encoding-sniffing-algorithm),\nwith stream support.\n\nThis module wraps around [`@exodus/bytes`](https://github.com/ExodusOSS/bytes)\nto make decoding buffers and streams incredibly easy.\n\n## Features\n\n- Support for streams\n- Support for XML encoding types, including UTF-16 prefixes and\n  `<?xml encoding=\"...\">`\n- Allows decoding streams and buffers with a single function call\n\n## Installation\n\n```bash\nnpm install encoding-sniffer\n```\n\n## Usage\n\n```js\nimport { DecodeStream, getEncoding, decodeBuffer } from \"encoding-sniffer\";\n\n/**\n * All functions accept an optional options object.\n *\n * Available options are (with default values):\n */\nconst options = {\n    /**\n     * The maximum number of bytes to sniff. Defaults to `1024`.\n     */\n    maxBytes: 1024,\n    /**\n     * The encoding specified by the user. If set, this will only be overridden\n     * by a Byte Order Mark (BOM).\n     */\n    userEncoding: undefined,\n    /**\n     * The encoding specified by the transport layer. If set, this will only be\n     * overridden by a Byte Order Mark (BOM) or the user encoding.\n     */\n    transportLayerEncodingLabel: undefined,\n    /**\n     * The default encoding to use, if no encoding can be detected.\n     *\n     * Defaults to `\"windows-1252\"`.\n     */\n    defaultEncoding: \"windows-1252\",\n};\n\n// Use the `DecodeStream` transform stream to automatically decode\n// the contents of a stream as they are read\nconst decodeStream = new DecodeStream(options);\n\n// Or, use the `getEncoding` function to detect the encoding of a buffer\nconst encoding = getEncoding(buffer, options);\n\n// Use the `decodeBuffer` function to decode the contents of a buffer\nconst decodedBuffer = decodeBuffer(buffer, options);\n```\n\n## Security contact information\n\nTo report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).\nTidelift will coordinate the fix and disclosure.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](/LICENSE) file\nfor more information.\n","publish_time":1773789194803,"_cnpm_publish_time":1773789194803,"dist-tags":{"latest":"1.0.2"}}