{"name":"encoding-sniffer","version":"0.2.1","author":{"name":"Felix Boehm","email":"me@feedic.com"},"license":"MIT","_id":"encoding-sniffer@0.2.1","maintainers":[{"name":"feedic","email":"me@feedic.com"}],"homepage":"https://github.com/fb55/encoding-sniffer#readme","bugs":{"url":"https://github.com/fb55/encoding-sniffer/issues"},"dist":{"shasum":"396ec97ac22ce5a037ba44af1992ac9d46a7b819","tarball":"http://registry-npm.ywwl.com/encoding-sniffer/download/encoding-sniffer-0.2.1.tgz","fileCount":23,"integrity":"sha512-5gvq20T6vfpekVtqrYQsSCFZ1wEg5+wW0/QaZMWkFr6BqD3NfKs0rLCx4rrVlSWJeZb5NBJgVLswK/w2MWU+Gw==","signatures":[{"sig":"MEYCIQDMUOaH4kI9BZ3/duGgDrJsxDQrCokNlkxeI2UH6/mYAgIhAKJe8io4uqYLc6W2rw4FSMUbPdCMlSTEbzIORKrpJGP7","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":162226,"size":22612,"noattachment":false,"key":"/encoding-sniffer/-/encoding-sniffer-0.2.1.tgz"},"main":"./dist/commonjs/index.js","tshy":{"exclude":["src/**/*.spec.ts"],"exports":{".":"./src/index.ts","./sniffer":"./src/sniffer.ts"}},"type":"module","types":"./dist/commonjs/index.d.ts","module":"./dist/esm/index.js","exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./sniffer":{"import":{"types":"./dist/esm/sniffer.d.ts","default":"./dist/esm/sniffer.js"},"require":{"types":"./dist/commonjs/sniffer.d.ts","default":"./dist/commonjs/sniffer.js"}}},"funding":"https://github.com/fb55/encoding-sniffer?sponsor=1","gitHead":"4485c79b72a30c1f4e84eff6dd5ce4138d4f1b73","scripts":{"lint":"npm run lint:es && npm run lint:ts && npm run lint:prettier","test":"npm run test:vi && npm run lint","build":"tshy","format":"npm run format:es && npm run format:prettier","lint:es":"eslint --ignore-path .gitignore .","lint:ts":"tsc --noEmit","test:vi":"vitest run","prettier":"prettier '**/*.{ts,md,json,yml}'","format:es":"npm run lint:es -- --fix","build:docs":"typedoc --hideGenerator src/index.ts","lint:prettier":"npm run prettier -- --check","prepublishOnly":"npm run build","format:prettier":"npm run prettier -- --write"},"_npmUser":{"name":"feedic","email":"me@feedic.com"},"prettier":{"tabWidth":4,"proseWrap":"always"},"repository":{"url":"git://github.com/fb55/encoding-sniffer.git","type":"git"},"_npmVersion":"11.3.0","description":"Implementation of the HTML encoding sniffer algo, with stream support","directories":{},"_nodeVersion":"24.1.0","dependencies":{"iconv-lite":"^0.6.3","whatwg-encoding":"^3.1.1"},"_hasShrinkwrap":false,"devDependencies":{"tshy":"^3.0.2","eslint":"^8.57.1","vitest":"^2.0.2","typedoc":"^0.28.5","prettier":"^3.5.3","typescript":"^5.8.3","@types/node":"^22.15.30","eslint-plugin-n":"^17.19.0","@vitest/coverage-v8":"^2.1.8","eslint-plugin-unicorn":"^56.0.1","@types/whatwg-encoding":"^2.0.3","eslint-config-prettier":"^10.1.5","@typescript-eslint/parser":"^8.33.1","@typescript-eslint/eslint-plugin":"^8.27.0"},"_npmOperationalInternal":{"tmp":"tmp/encoding-sniffer_0.2.1_1749412299900_0.8460494574863429","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":1749412300116,"_cnpm_publish_time":1749412300116,"dist-tags":{"latest":"1.0.2"}}