1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-02 20:00:05 +02:00

update packages to latest version

This commit is contained in:
s2
2022-08-20 18:51:33 +02:00
parent 09663a35a5
commit 806ebf9a57
4513 changed files with 366205 additions and 92512 deletions

View File

@@ -1,4 +1,4 @@
Copyright © 20162018 Domenic Denicola <d@domenic.me>
Copyright © Domenic Denicola <d@domenic.me>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View File

@@ -16,18 +16,18 @@ console.assert(whatwgEncoding.isSupported("UTF-32") === false);
// In the Encoding Standard, but this package can't decode it
console.assert(whatwgEncoding.isSupported("x-mac-cyrillic") === false);
console.assert(whatwgEncoding.getBOMEncoding(new Buffer([0xFE, 0xFF])) === "UTF-16BE");
console.assert(whatwgEncoding.getBOMEncoding(new Buffer([0x48, 0x69])) === null);
console.assert(whatwgEncoding.getBOMEncoding(new Uint8Array([0xFE, 0xFF])) === "UTF-16BE");
console.assert(whatwgEncoding.getBOMEncoding(new Uint8Array([0x48, 0x69])) === null);
console.assert(whatwgEncoding.decode(new Buffer([0x48, 0x69]), "UTF-8") === "Hi");
console.assert(whatwgEncoding.decode(new Uint8Array([0x48, 0x69]), "UTF-8") === "Hi");
```
## API
- `decode(buffer, fallbackEncodingName)`: performs the [decode](https://encoding.spec.whatwg.org/#decode) algorithm (in which any BOM will override the passed fallback encoding), and returns the resulting string
- `decode(uint8Array, fallbackEncodingName)`: performs the [decode](https://encoding.spec.whatwg.org/#decode) algorithm (in which any BOM will override the passed fallback encoding), and returns the resulting string
- `labelToName(label)`: performs the [get an encoding](https://encoding.spec.whatwg.org/#concept-encoding-get) algorithm and returns the resulting encoding's name, or `null` for failure
- `isSupported(name)`: returns whether the encoding is one of [the encodings](https://encoding.spec.whatwg.org/#names-and-labels) of the Encoding Standard, _and_ is an encoding that this package can decode (via iconv-lite)
- `getBOMEncoding(buffer)`: sniffs the first 23 bytes of the supplied `Buffer`, returning one of the encoding names `"UTF-8"`, `"UTF-16LE"`, or `"UTF-16BE"` if the appropriate BOM is present, or `null` if no BOM is present
- `getBOMEncoding(uint8Array)`: sniffs the first 23 bytes of the supplied `Uint8Array`, returning one of the encoding names `"UTF-8"`, `"UTF-16LE"`, or `"UTF-16BE"` if the appropriate BOM is present, or `null` if no BOM is present
## Unsupported encodings
@@ -47,4 +47,4 @@ This package was originally based on the excellent work of [@nicolashenry](https
## Alternatives
If you are looking for a JavaScript implementation of the Encoding Standard's `TextEncoder` and `TextDecoder` APIs, you'll want [@inexorabletash](https://github.com/inexorabletash)'s [text-encoding](https://github.com/inexorabletash/text-encoding) package.
If you are looking for a JavaScript implementation of the Encoding Standard's `TextEncoder` and `TextDecoder` APIs, you'll want [@inexorabletash](https://github.com/inexorabletash)'s [text-encoding](https://github.com/inexorabletash/text-encoding) package. Node.js also has them [built-in](https://nodejs.org/dist/latest/docs/api/globals.html#globals_textdecoder).

View File

@@ -1,8 +1,11 @@
{
"866": "IBM866",
"unicode-1-1-utf-8": "UTF-8",
"unicode11utf8": "UTF-8",
"unicode20utf8": "UTF-8",
"utf-8": "UTF-8",
"utf8": "UTF-8",
"x-unicode20utf8": "UTF-8",
"cp866": "IBM866",
"csibm866": "IBM866",
"ibm866": "IBM866",
@@ -201,7 +204,13 @@
"ksc5601": "EUC-KR",
"ksc_5601": "EUC-KR",
"windows-949": "EUC-KR",
"unicodefffe": "UTF-16BE",
"utf-16be": "UTF-16BE",
"csunicode": "UTF-16LE",
"iso-10646-ucs-2": "UTF-16LE",
"ucs-2": "UTF-16LE",
"unicode": "UTF-16LE",
"unicodefeff": "UTF-16LE",
"utf-16": "UTF-16LE",
"utf-16le": "UTF-16LE"
}

View File

@@ -13,29 +13,29 @@ exports.labelToName = label => {
};
// https://encoding.spec.whatwg.org/#decode
exports.decode = (buffer, fallbackEncodingName) => {
exports.decode = (uint8Array, fallbackEncodingName) => {
let encoding = fallbackEncodingName;
if (!exports.isSupported(encoding)) {
throw new RangeError(`"${encoding}" is not a supported encoding name`);
}
const bomEncoding = exports.getBOMEncoding(buffer);
const bomEncoding = exports.getBOMEncoding(uint8Array);
if (bomEncoding !== null) {
encoding = bomEncoding;
}
// iconv-lite will strip BOMs for us, so no need to do the stuff the spec does
return iconvLite.decode(buffer, encoding);
return iconvLite.decode(uint8Array, encoding);
};
// https://github.com/whatwg/html/issues/1910#issuecomment-254017369
exports.getBOMEncoding = buffer => {
if (buffer[0] === 0xFE && buffer[1] === 0xFF) {
exports.getBOMEncoding = uint8Array => {
if (uint8Array[0] === 0xFE && uint8Array[1] === 0xFF) {
return "UTF-16BE";
} else if (buffer[0] === 0xFF && buffer[1] === 0xFE) {
} else if (uint8Array[0] === 0xFF && uint8Array[1] === 0xFE) {
return "UTF-16LE";
} else if (buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
} else if (uint8Array[0] === 0xEF && uint8Array[1] === 0xBB && uint8Array[2] === 0xBF) {
return "UTF-8";
}

View File

@@ -1,27 +1,27 @@
{
"_from": "whatwg-encoding@^1.0.5",
"_id": "whatwg-encoding@1.0.5",
"_from": "whatwg-encoding@^2.0.0",
"_id": "whatwg-encoding@2.0.0",
"_inBundle": false,
"_integrity": "sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==",
"_integrity": "sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==",
"_location": "/whatwg-encoding",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "whatwg-encoding@^1.0.5",
"raw": "whatwg-encoding@^2.0.0",
"name": "whatwg-encoding",
"escapedName": "whatwg-encoding",
"rawSpec": "^1.0.5",
"rawSpec": "^2.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.5"
"fetchSpec": "^2.0.0"
},
"_requiredBy": [
"/html-encoding-sniffer",
"/jsdom"
],
"_resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz",
"_shasum": "5abacf777c32166a51d085d6b4f3e7d27113ddb0",
"_spec": "whatwg-encoding@^1.0.5",
"_resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz",
"_shasum": "e7635f597fd87020858626805a2729fa7698ac53",
"_spec": "whatwg-encoding@^2.0.0",
"_where": "D:\\Projects\\minifyfromhtml\\node_modules\\jsdom",
"author": {
"name": "Domenic Denicola",
@@ -33,14 +33,18 @@
},
"bundleDependencies": false,
"dependencies": {
"iconv-lite": "0.4.24"
"iconv-lite": "0.6.3"
},
"deprecated": false,
"description": "Decode strings according to the WHATWG Encoding Standard",
"devDependencies": {
"eslint": "^5.3.0",
"got": "^9.0.0",
"mocha": "^5.2.0"
"@domenic/eslint-config": "^1.3.0",
"eslint": "^7.32.0",
"minipass-fetch": "^1.4.1",
"mocha": "^9.1.1"
},
"engines": {
"node": ">=12"
},
"files": [
"lib/"
@@ -58,9 +62,9 @@
"url": "git+https://github.com/jsdom/whatwg-encoding.git"
},
"scripts": {
"lint": "eslint lib test",
"lint": "eslint .",
"prepare": "node scripts/update.js",
"test": "mocha"
},
"version": "1.0.5"
"version": "2.0.0"
}