legacy-encoding
Advanced tools
Comparing version 2.0.0 to 3.0.0
44
index.js
'use strict' | ||
var iconv; | ||
try { | ||
iconv = require('iconv-lite'); | ||
} catch (ex) { | ||
// missing optional dependency iconv-lite | ||
} | ||
var iconv = require('iconv-lite'); | ||
var jconv = require('jconv'); | ||
var encodings = require('./encodings.js'); | ||
var mappings = { | ||
'euc-jp': 'eucjp', | ||
'shift_jis': 'sjis', | ||
'utf-16le': 'utf16le', | ||
'ucs-2': 'ucs2' | ||
}; | ||
var jconvEncodings = [ | ||
'iso-2022-jp', | ||
'iso-2022-jp-1', | ||
'iso2022jp', | ||
'jis', | ||
'unicode' | ||
]; | ||
exports.labels = encodings.map(function (enc) { | ||
return enc.labels; | ||
}).concat(iconv ? Object.keys(require('iconv-lite/encodings')) : []).reduce(function (acc, next) { | ||
}).concat(Object.keys(require('iconv-lite/encodings'))).reduce(function (acc, next) { | ||
return acc.concat(next); | ||
}, []).sort(); | ||
}, []).filter(function (enc) { | ||
return enc[0] !== '_'; | ||
}).concat(jconvEncodings).concat(Object.keys(mappings)).sort(); | ||
exports.labels = exports.labels.filter(function (enc, i) { | ||
return exports.labels[i - 1] != enc; | ||
}); | ||
exports.decode = decode; | ||
function decode(source, encoding, options) { | ||
if (iconv && iconv.encodingExists(encoding)) { | ||
if (encoding in mappings) encoding = mappings[encoding]; | ||
if (iconv.encodingExists(encoding)) { | ||
return iconv.decode(source, encoding); | ||
} | ||
if (jconv.encodingExists(encoding)) { | ||
return jconv.decode(source, encoding); | ||
} | ||
for (var i = 0; i < encodings.length; i++) { | ||
@@ -32,5 +52,9 @@ if (encodings[i].labels.indexOf(encoding) !== -1) { | ||
function encode(source, encoding, options) { | ||
if (iconv && iconv.encodingExists(encoding)) { | ||
if (encoding in mappings) encoding = mappings[encoding]; | ||
if (iconv.encodingExists(encoding)) { | ||
return iconv.encode(source, encoding); | ||
} | ||
if (jconv.encodingExists(encoding)) { | ||
return jconv.encode(source, encoding); | ||
} | ||
for (var i = 0; i < encodings.length; i++) { | ||
@@ -37,0 +61,0 @@ if (encodings[i].labels.indexOf(encoding) !== -1) { |
{ | ||
"name": "legacy-encoding", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "Support as many legacy encodings as possible", | ||
@@ -82,5 +82,2 @@ "files": [ | ||
"950", | ||
"_dbcs", | ||
"_internal", | ||
"_sbcs", | ||
"ansi_x3.4-1968", | ||
@@ -91,7 +88,5 @@ "ansix3.4", | ||
"arabic", | ||
"arabic", | ||
"arabic8", | ||
"armscii8", | ||
"ascii", | ||
"ascii", | ||
"ascii8bit", | ||
@@ -119,19 +114,10 @@ "asmo-708", | ||
"cp1250", | ||
"cp1250", | ||
"cp1251", | ||
"cp1251", | ||
"cp1252", | ||
"cp1252", | ||
"cp1253", | ||
"cp1253", | ||
"cp1254", | ||
"cp1254", | ||
"cp1255", | ||
"cp1255", | ||
"cp1256", | ||
"cp1256", | ||
"cp1257", | ||
"cp1257", | ||
"cp1258", | ||
"cp1258", | ||
"cp20866", | ||
@@ -160,3 +146,2 @@ "cp21866", | ||
"cp819", | ||
"cp819", | ||
"cp850", | ||
@@ -221,26 +206,15 @@ "cp852", | ||
"csisolatin1", | ||
"csisolatin1", | ||
"csisolatin2", | ||
"csisolatin2", | ||
"csisolatin3", | ||
"csisolatin3", | ||
"csisolatin4", | ||
"csisolatin4", | ||
"csisolatin5", | ||
"csisolatin5", | ||
"csisolatin6", | ||
"csisolatin9", | ||
"csisolatinarabic", | ||
"csisolatinarabic", | ||
"csisolatincyrillic", | ||
"csisolatincyrillic", | ||
"csisolatingreek", | ||
"csisolatingreek", | ||
"csisolatinhebrew", | ||
"csisolatinhebrew", | ||
"cskoi8r", | ||
"cskoi8r", | ||
"csksc56011987", | ||
"csmacintosh", | ||
"csmacintosh", | ||
"cspc775baltic", | ||
@@ -253,3 +227,2 @@ "cspc850multilingual", | ||
"cyrillic", | ||
"cyrillic", | ||
"dos-874", | ||
@@ -262,2 +235,3 @@ "ecma-114", | ||
"elot_928", | ||
"euc-jp", | ||
"euccn", | ||
@@ -275,7 +249,4 @@ "eucjp", | ||
"greek", | ||
"greek", | ||
"greek8", | ||
"greek8", | ||
"hebrew", | ||
"hebrew", | ||
"hebrew8", | ||
@@ -300,3 +271,2 @@ "hex", | ||
"ibm819", | ||
"ibm819", | ||
"ibm850", | ||
@@ -318,2 +288,4 @@ "ibm852", | ||
"ibm922", | ||
"iso-2022-jp", | ||
"iso-2022-jp-1", | ||
"iso-8859-1", | ||
@@ -343,2 +315,3 @@ "iso-8859-11", | ||
"iso-ir-148", | ||
"iso2022jp", | ||
"iso646.irv", | ||
@@ -360,27 +333,16 @@ "iso646cn", | ||
"iso88591", | ||
"iso88591", | ||
"iso885910", | ||
"iso885911", | ||
"iso885911", | ||
"iso885913", | ||
"iso885914", | ||
"iso885915", | ||
"iso885915", | ||
"iso885916", | ||
"iso88592", | ||
"iso88592", | ||
"iso88593", | ||
"iso88593", | ||
"iso88594", | ||
"iso88594", | ||
"iso88595", | ||
"iso88595", | ||
"iso88596", | ||
"iso88596", | ||
"iso88597", | ||
"iso88597", | ||
"iso88598", | ||
"iso88598", | ||
"iso88599", | ||
"iso88599", | ||
"iso_8859-1", | ||
@@ -426,2 +388,3 @@ "iso_8859-15", | ||
"isoir6", | ||
"jis", | ||
"jisc62201969ro", | ||
@@ -442,12 +405,7 @@ "jp", | ||
"l1", | ||
"l1", | ||
"l10", | ||
"l2", | ||
"l2", | ||
"l3", | ||
"l3", | ||
"l4", | ||
"l4", | ||
"l5", | ||
"l5", | ||
"l6", | ||
@@ -457,14 +415,8 @@ "l7", | ||
"l9", | ||
"l9", | ||
"latin1", | ||
"latin1", | ||
"latin10", | ||
"latin2", | ||
"latin2", | ||
"latin3", | ||
"latin3", | ||
"latin4", | ||
"latin4", | ||
"latin5", | ||
"latin5", | ||
"latin6", | ||
@@ -476,3 +428,2 @@ "latin7", | ||
"mac", | ||
"mac", | ||
"maccenteuro", | ||
@@ -484,3 +435,2 @@ "maccroatian", | ||
"macintosh", | ||
"macintosh", | ||
"macroman", | ||
@@ -503,2 +453,3 @@ "macromania", | ||
"roman8", | ||
"shift_jis", | ||
"shiftjis", | ||
@@ -520,3 +471,5 @@ "sjis", | ||
"turkish8", | ||
"ucs-2", | ||
"ucs2", | ||
"unicode", | ||
"unicode11utf8", | ||
@@ -526,2 +479,3 @@ "us", | ||
"usascii", | ||
"utf-16le", | ||
"utf16", | ||
@@ -600,2 +554,3 @@ "utf16be", | ||
"iso-8859-8-i": "^0.1.2", | ||
"jconv": "^0.1.5", | ||
"koi8-r": "^0.1.2", | ||
@@ -621,2 +576,2 @@ "macintosh": "^0.1.2", | ||
"license": "MIT" | ||
} | ||
} |
@@ -122,5 +122,2 @@ # legacy-encoding | ||
- 950 | ||
- _dbcs | ||
- _internal | ||
- _sbcs | ||
- ansi_x3.4-1968 | ||
@@ -131,7 +128,5 @@ - ansix3.4 | ||
- arabic | ||
- arabic | ||
- arabic8 | ||
- armscii8 | ||
- ascii | ||
- ascii | ||
- ascii8bit | ||
@@ -159,19 +154,10 @@ - asmo-708 | ||
- cp1250 | ||
- cp1250 | ||
- cp1251 | ||
- cp1251 | ||
- cp1252 | ||
- cp1252 | ||
- cp1253 | ||
- cp1253 | ||
- cp1254 | ||
- cp1254 | ||
- cp1255 | ||
- cp1255 | ||
- cp1256 | ||
- cp1256 | ||
- cp1257 | ||
- cp1257 | ||
- cp1258 | ||
- cp1258 | ||
- cp20866 | ||
@@ -200,3 +186,2 @@ - cp21866 | ||
- cp819 | ||
- cp819 | ||
- cp850 | ||
@@ -261,26 +246,15 @@ - cp852 | ||
- csisolatin1 | ||
- csisolatin1 | ||
- csisolatin2 | ||
- csisolatin2 | ||
- csisolatin3 | ||
- csisolatin3 | ||
- csisolatin4 | ||
- csisolatin4 | ||
- csisolatin5 | ||
- csisolatin5 | ||
- csisolatin6 | ||
- csisolatin9 | ||
- csisolatinarabic | ||
- csisolatinarabic | ||
- csisolatincyrillic | ||
- csisolatincyrillic | ||
- csisolatingreek | ||
- csisolatingreek | ||
- csisolatinhebrew | ||
- csisolatinhebrew | ||
- cskoi8r | ||
- cskoi8r | ||
- csksc56011987 | ||
- csmacintosh | ||
- csmacintosh | ||
- cspc775baltic | ||
@@ -293,3 +267,2 @@ - cspc850multilingual | ||
- cyrillic | ||
- cyrillic | ||
- dos-874 | ||
@@ -302,2 +275,3 @@ - ecma-114 | ||
- elot_928 | ||
- euc-jp | ||
- euccn | ||
@@ -315,7 +289,4 @@ - eucjp | ||
- greek | ||
- greek | ||
- greek8 | ||
- greek8 | ||
- hebrew | ||
- hebrew | ||
- hebrew8 | ||
@@ -340,3 +311,2 @@ - hex | ||
- ibm819 | ||
- ibm819 | ||
- ibm850 | ||
@@ -358,2 +328,4 @@ - ibm852 | ||
- ibm922 | ||
- iso-2022-jp | ||
- iso-2022-jp-1 | ||
- iso-8859-1 | ||
@@ -383,2 +355,3 @@ - iso-8859-11 | ||
- iso-ir-148 | ||
- iso2022jp | ||
- iso646.irv | ||
@@ -400,27 +373,16 @@ - iso646cn | ||
- iso88591 | ||
- iso88591 | ||
- iso885910 | ||
- iso885911 | ||
- iso885911 | ||
- iso885913 | ||
- iso885914 | ||
- iso885915 | ||
- iso885915 | ||
- iso885916 | ||
- iso88592 | ||
- iso88592 | ||
- iso88593 | ||
- iso88593 | ||
- iso88594 | ||
- iso88594 | ||
- iso88595 | ||
- iso88595 | ||
- iso88596 | ||
- iso88596 | ||
- iso88597 | ||
- iso88597 | ||
- iso88598 | ||
- iso88598 | ||
- iso88599 | ||
- iso88599 | ||
- iso_8859-1 | ||
@@ -466,2 +428,3 @@ - iso_8859-15 | ||
- isoir6 | ||
- jis | ||
- jisc62201969ro | ||
@@ -482,12 +445,7 @@ - jp | ||
- l1 | ||
- l1 | ||
- l10 | ||
- l2 | ||
- l2 | ||
- l3 | ||
- l3 | ||
- l4 | ||
- l4 | ||
- l5 | ||
- l5 | ||
- l6 | ||
@@ -497,14 +455,8 @@ - l7 | ||
- l9 | ||
- l9 | ||
- latin1 | ||
- latin1 | ||
- latin10 | ||
- latin2 | ||
- latin2 | ||
- latin3 | ||
- latin3 | ||
- latin4 | ||
- latin4 | ||
- latin5 | ||
- latin5 | ||
- latin6 | ||
@@ -516,3 +468,2 @@ - latin7 | ||
- mac | ||
- mac | ||
- maccenteuro | ||
@@ -524,3 +475,2 @@ - maccroatian | ||
- macintosh | ||
- macintosh | ||
- macroman | ||
@@ -543,2 +493,3 @@ - macromania | ||
- roman8 | ||
- shift_jis | ||
- shiftjis | ||
@@ -560,3 +511,5 @@ - sjis | ||
- turkish8 | ||
- ucs-2 | ||
- ucs2 | ||
- unicode | ||
- unicode11utf8 | ||
@@ -566,2 +519,3 @@ - us | ||
- usascii | ||
- utf-16le | ||
- utf16 | ||
@@ -568,0 +522,0 @@ - utf16be |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
84
0
20078
24
565
+ Addedjconv@^0.1.5
+ Addedjconv@0.1.5(transitive)