{ "_args": [ [ { "raw": "html-encoding-sniffer@^1.0.2", "scope": null, "escapedName": "html-encoding-sniffer", "name": "html-encoding-sniffer", "rawSpec": "^1.0.2", "spec": ">=1.0.2 <2.0.0", "type": "range" }, "/home/jdaugherty/work/GT2/GT2-Android/node_modules/jsdom" ] ], "_from": "html-encoding-sniffer@>=1.0.2 <2.0.0", "_id": "html-encoding-sniffer@1.0.2", "_inCache": true, "_location": "/html-encoding-sniffer", "_nodeVersion": "8.6.0", "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/html-encoding-sniffer-1.0.2.tgz_1508717756193_0.17921806732192636" }, "_npmUser": { "name": "domenic", "email": "d@domenic.me" }, "_npmVersion": "5.4.2", "_phantomChildren": {}, "_requested": { "raw": "html-encoding-sniffer@^1.0.2", "scope": null, "escapedName": "html-encoding-sniffer", "name": "html-encoding-sniffer", "rawSpec": "^1.0.2", "spec": ">=1.0.2 <2.0.0", "type": "range" }, "_requiredBy": [ "/jsdom" ], "_resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz", "_shasum": "e70d84b94da53aa375e11fe3a351be6642ca46f8", "_shrinkwrap": null, "_spec": "html-encoding-sniffer@^1.0.2", "_where": "/home/jdaugherty/work/GT2/GT2-Android/node_modules/jsdom", "author": { "name": "Domenic Denicola", "email": "d@domenic.me", "url": "https://domenic.me/" }, "bugs": { "url": "https://github.com/jsdom/html-encoding-sniffer/issues" }, "dependencies": { "whatwg-encoding": "^1.0.1" }, "description": "Sniff the encoding from a HTML byte stream", "devDependencies": { "eslint": "^3.8.0", "mocha": "^3.1.2" }, "directories": {}, "dist": { "integrity": "sha512-71lZziiDnsuabfdYiUeWdCVyKuqwWi23L8YeIgV9jSSZHCtb6wB1BKWooH7L3tn4/FuZJMVWyNaIDr4RGmaSYw==", "shasum": "e70d84b94da53aa375e11fe3a351be6642ca46f8", "tarball": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz" }, "files": [ "lib/" ], "gitHead": "8d69308c38af4b19170d2caeac6e16c6f52f5e01", "homepage": "https://github.com/jsdom/html-encoding-sniffer#readme", "keywords": [ "encoding", "html" ], "license": "MIT", "main": "lib/html-encoding-sniffer.js", "maintainers": [ { "name": "domenic", "email": "d@domenic.me" } ], "name": "html-encoding-sniffer", "optionalDependencies": {}, "readme": "# Determine the Encoding of a HTML Byte Stream\n\nThis package implements the HTML Standard's [encoding sniffing algorithm](https://html.spec.whatwg.org/multipage/syntax.html#encoding-sniffing-algorithm) in all its glory. The most interesting part of this is how it pre-scans the first 1024 bytes in order to search for certain ``-related patterns.\n\n```js\nconst htmlEncodingSniffer = require(\"html-encoding-sniffer\");\nconst fs = require(\"fs\");\n\nconst htmlBuffer = fs.readFileSync(\"./html-page.html\");\nconst sniffedEncoding = htmlEncodingSniffer(htmlBuffer);\n```\n\nThe returned value will be a canonical [encoding name](https://encoding.spec.whatwg.org/#names-and-labels) (not a label). You might then combine this with the [whatwg-encoding](https://github.com/jsdom/whatwg-encoding) package to decode the result:\n\n```js\nconst whatwgEncoding = require(\"whatwg-encoding\");\nconst htmlString = whatwgEncoding.decode(htmlBuffer, sniffedEncoding);\n```\n\n## Options\n\nYou can pass two potential options to `htmlEncodingSniffer`:\n\n```js\nconst sniffedEncoding = htmlEncodingSniffer(htmlBuffer, {\n transportLayerEncodingLabel,\n defaultEncoding\n});\n```\n\nThese represent two possible inputs into the [encoding sniffing algorithm](https://html.spec.whatwg.org/multipage/syntax.html#encoding-sniffing-algorithm):\n\n- `transportLayerEncodingLabel` is an encoding label that is obtained from the \"transport layer\" (probably a HTTP `Content-Type` header), which overrides everything but a BOM.\n- `defaultEncoding` is the ultimate fallback encoding used if no valid encoding is supplied by the transport layer, and no encoding is sniffed from the bytes. It defaults to `\"windows-1252\"`, as recommended by the algorithm's table of suggested defaults for \"All other locales\" (including the `en` locale).\n\n## Credits\n\nThis package was originally based on the excellent work of [@nicolashenry](https://github.com/nicolashenry), [in jsdom](https://github.com/tmpvar/jsdom/blob/16fd85618f2705d181232f6552125872a37164bc/lib/jsdom/living/helpers/encoding.js). It has since been pulled out into this separate package.\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/jsdom/html-encoding-sniffer.git" }, "scripts": { "lint": "eslint lib test", "test": "mocha" }, "version": "1.0.2" }