{"name":"encoding-sniffer","version":"1.0.0","author":{"name":"Felix Boehm","email":"me@feedic.com"},"license":"MIT","_id":"encoding-sniffer@1.0.0","maintainers":[{"name":"fb55","email":"me@feedic.com"}],"homepage":"https://github.com/fb55/encoding-sniffer#readme","bugs":{"url":"https://github.com/fb55/encoding-sniffer/issues"},"dist":{"shasum":"5841e819bea89b3edadcb8110917b9ad84439e6b","tarball":"http://registry-npm.ywwl.com/encoding-sniffer/download/encoding-sniffer-1.0.0.tgz","fileCount":11,"integrity":"sha512-Ty8AiAA0gM2YvtjtQB/B902xKoaR3YsPb5sLYROEBgyJl003i/Bm3/N0sXXpmJZBPlZr1D/9nl7jJWu5uVGPIQ==","signatures":[{"sig":"MEUCIDEOb3AZj+5HajbMHoEEs0AsOWGfPYiKAmEPedm3LZncAiEAyIss6TwGm+prKnoSbNV+XYueKQ3F3mGOee5RMR7DW74=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/encoding-sniffer@1.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":84451,"size":16281,"noattachment":false,"key":"/encoding-sniffer/-/encoding-sniffer-1.0.0.tgz"},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=20.19.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./sniffer":{"types":"./dist/sniffer.d.ts","default":"./dist/sniffer.js"}},"funding":{"url":"https://github.com/fb55/encoding-sniffer?sponsor=1","type":"github"},"gitHead":"f4decfbcb989f9c7d2df73d6c20344ab6e97761e","scripts":{"lint":"npm run lint:es && npm run lint:ts && npm run lint:biome","test":"npm run test:vi && npm run lint","build":"tsc","format":"npm run format:es && npm run format:biome","lint:es":"eslint .","lint:ts":"tsc --noEmit","test:vi":"vitest run","format:es":"npm run lint:es -- --fix","build:docs":"typedoc --hideGenerator src/index.ts","lint:biome":"biome check .","format:biome":"biome check --write .","prepublishOnly":"npm run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:a7a80939-4ddd-4555-94bf-e057dcca4731"}},"repository":{"url":"git://github.com/fb55/encoding-sniffer.git","type":"git"},"_npmVersion":"11.9.0","description":"Implementation of the HTML encoding sniffer algo, with stream support","directories":{},"sideEffects":false,"_nodeVersion":"24.14.0","dependencies":{"@exodus/bytes":"^1.15.0"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^10.0.3","vitest":"^4.0.17","globals":"^17.4.0","typescript":"^5.9.3","@types/node":"^25.5.0","@biomejs/biome":"^2.4.7","typescript-eslint":"^8.57.1","eslint-config-biome":"^2.1.3","@feedic/eslint-config":"^0.3.1"},"_npmOperationalInternal":{"tmp":"tmp/encoding-sniffer_1.0.0_1773764329856_0.3622913293984682","host":"s3://npm-registry-packages-npm-production"},"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":1773764330025,"_cnpm_publish_time":1773764330025,"dist-tags":{"latest":"1.0.2"}}