@datastream/charset
Advanced tools
+1
-1
| import { createTransformStream } from "@datastream/core"; | ||
| import iconv from "iconv-lite"; | ||
| const charsetDecodeStream = ({ charset } = {}, streamOptions) => { | ||
| const charsetDecodeStream = ({ charset } = {}, streamOptions = {}) => { | ||
| charset = getSupportedEncoding(charset); | ||
@@ -5,0 +5,0 @@ const conv = iconv.getDecoder(charset); |
| { | ||
| "version": 3, | ||
| "sources": ["decode.node.js"], | ||
| "sourcesContent": ["import { createTransformStream } from '@datastream/core'\nimport iconv from 'iconv-lite'\n\nexport const charsetDecodeStream = ({ charset } = {}, streamOptions) => {\n charset = getSupportedEncoding(charset)\n\n const conv = iconv.getDecoder(charset)\n\n const transform = (chunk, enqueue) => {\n const res = conv.write(chunk)\n if (res?.length) {\n enqueue(res, 'utf8')\n }\n }\n const flush = (enqueue) => {\n const res = conv.end()\n if (res?.length) {\n enqueue(res, 'utf8')\n }\n }\n return createTransformStream(transform, flush, streamOptions)\n}\n\n// TODO to peek ahead and determin charset from that\n/*\nexport const charsetDetectDecodeStream = (\n { charset, peekAhead } = { peekAhead: 0 },\n streamOptions\n) => {\n charset = getSupportedEncoding(charset)\n\n let conv,\n peekAheadChunk = ''\n\n const transform = (chunk, enqueue) => {\n if (!conv && peekahead && peekahead < peekAheadChunk.length) {\n peekAheadChunk += chunk\n return\n }\n if (!conv) {\n conv = iconv.getDecoder(charset)\n chunk = peekAheadChunk + chunk\n }\n\n const res = conv.write(chunk)\n if (res?.length) {\n enqueue(res, 'utf8')\n }\n }\n const flush = (enqueue) => {\n const res = conv.end()\n if (res?.length) {\n enqueue(res, 'utf8')\n }\n }\n return createTransformStream(transform, flush, streamOptions)\n} */\n\nconst getSupportedEncoding = (charset) => {\n if (charset === 'ISO-8859-8-I') charset = 'ISO-8859-8'\n if (!iconv.encodingExists(charset)) charset = 'UTF-8'\n return charset\n}\nexport default charsetDecodeStream\n"], | ||
| "mappings": "AAAA,SAAS,6BAA6B;AACtC,OAAO,WAAW;AAEX,MAAM,sBAAsB,CAAC,EAAE,QAAQ,IAAI,CAAC,GAAG,kBAAkB;AACtE,YAAU,qBAAqB,OAAO;AAEtC,QAAM,OAAO,MAAM,WAAW,OAAO;AAErC,QAAM,YAAY,CAAC,OAAO,YAAY;AACpC,UAAM,MAAM,KAAK,MAAM,KAAK;AAC5B,QAAI,KAAK,QAAQ;AACf,cAAQ,KAAK,MAAM;AAAA,IACrB;AAAA,EACF;AACA,QAAM,QAAQ,CAAC,YAAY;AACzB,UAAM,MAAM,KAAK,IAAI;AACrB,QAAI,KAAK,QAAQ;AACf,cAAQ,KAAK,MAAM;AAAA,IACrB;AAAA,EACF;AACA,SAAO,sBAAsB,WAAW,OAAO,aAAa;AAC9D;AAqCA,MAAM,uBAAuB,CAAC,YAAY;AACxC,MAAI,YAAY,eAAgB,WAAU;AAC1C,MAAI,CAAC,MAAM,eAAe,OAAO,EAAG,WAAU;AAC9C,SAAO;AACT;AACA,IAAO,sBAAQ;", | ||
| "sourcesContent": ["import { createTransformStream } from \"@datastream/core\";\nimport iconv from \"iconv-lite\";\n\nexport const charsetDecodeStream = ({ charset } = {}, streamOptions = {}) => {\n\tcharset = getSupportedEncoding(charset);\n\n\tconst conv = iconv.getDecoder(charset);\n\n\tconst transform = (chunk, enqueue) => {\n\t\tconst res = conv.write(chunk);\n\t\tif (res?.length) {\n\t\t\tenqueue(res, \"utf8\");\n\t\t}\n\t};\n\tconst flush = (enqueue) => {\n\t\tconst res = conv.end();\n\t\tif (res?.length) {\n\t\t\tenqueue(res, \"utf8\");\n\t\t}\n\t};\n\treturn createTransformStream(transform, flush, streamOptions);\n};\n\n// TODO to peek ahead and determin charset from that\n/*\nexport const charsetDetectDecodeStream = (\n { charset, peekAhead } = { peekAhead: 0 },\n streamOptions\n) => {\n charset = getSupportedEncoding(charset)\n\n let conv,\n peekAheadChunk = ''\n\n const transform = (chunk, enqueue) => {\n if (!conv && peekahead && peekahead < peekAheadChunk.length) {\n peekAheadChunk += chunk\n return\n }\n if (!conv) {\n conv = iconv.getDecoder(charset)\n chunk = peekAheadChunk + chunk\n }\n\n const res = conv.write(chunk)\n if (res?.length) {\n enqueue(res, 'utf8')\n }\n }\n const flush = (enqueue) => {\n const res = conv.end()\n if (res?.length) {\n enqueue(res, 'utf8')\n }\n }\n return createTransformStream(transform, flush, streamOptions)\n} */\n\nconst getSupportedEncoding = (charset) => {\n\tif (charset === \"ISO-8859-8-I\") charset = \"ISO-8859-8\";\n\tif (!iconv.encodingExists(charset)) charset = \"UTF-8\";\n\treturn charset;\n};\nexport default charsetDecodeStream;\n"], | ||
| "mappings": "AAAA,SAAS,6BAA6B;AACtC,OAAO,WAAW;AAEX,MAAM,sBAAsB,CAAC,EAAE,QAAQ,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM;AAC5E,YAAU,qBAAqB,OAAO;AAEtC,QAAM,OAAO,MAAM,WAAW,OAAO;AAErC,QAAM,YAAY,CAAC,OAAO,YAAY;AACrC,UAAM,MAAM,KAAK,MAAM,KAAK;AAC5B,QAAI,KAAK,QAAQ;AAChB,cAAQ,KAAK,MAAM;AAAA,IACpB;AAAA,EACD;AACA,QAAM,QAAQ,CAAC,YAAY;AAC1B,UAAM,MAAM,KAAK,IAAI;AACrB,QAAI,KAAK,QAAQ;AAChB,cAAQ,KAAK,MAAM;AAAA,IACpB;AAAA,EACD;AACA,SAAO,sBAAsB,WAAW,OAAO,aAAa;AAC7D;AAqCA,MAAM,uBAAuB,CAAC,YAAY;AACzC,MAAI,YAAY,eAAgB,WAAU;AAC1C,MAAI,CAAC,MAAM,eAAe,OAAO,EAAG,WAAU;AAC9C,SAAO;AACR;AACA,IAAO,sBAAQ;", | ||
| "names": [] | ||
| } |
+1
-1
@@ -1,2 +0,2 @@ | ||
| const charsetDecodeStream = ({ charset } = {}, streamOptions) => { | ||
| const charsetDecodeStream = ({ charset } = {}, _streamOptions = {}) => { | ||
| return new TextDecoderStream(charset); | ||
@@ -3,0 +3,0 @@ }; |
| { | ||
| "version": 3, | ||
| "sources": ["decode.web.js"], | ||
| "sourcesContent": ["/* global TextDecoderStream */\n\nexport const charsetDecodeStream = ({ charset } = {}, streamOptions) => {\n // doesn't support signal?\n return new TextDecoderStream(charset)\n}\n\nexport default charsetDecodeStream\n"], | ||
| "mappings": "AAEO,MAAM,sBAAsB,CAAC,EAAE,QAAQ,IAAI,CAAC,GAAG,kBAAkB;AAEtE,SAAO,IAAI,kBAAkB,OAAO;AACtC;AAEA,IAAO,qBAAQ;", | ||
| "sourcesContent": ["/* global TextDecoderStream */\n\nexport const charsetDecodeStream = ({ charset } = {}, _streamOptions = {}) => {\n\t// doesn't support signal?\n\treturn new TextDecoderStream(charset);\n};\n\nexport default charsetDecodeStream;\n"], | ||
| "mappings": "AAEO,MAAM,sBAAsB,CAAC,EAAE,QAAQ,IAAI,CAAC,GAAG,iBAAiB,CAAC,MAAM;AAE7E,SAAO,IAAI,kBAAkB,OAAO;AACrC;AAEA,IAAO,qBAAQ;", | ||
| "names": [] | ||
| } |
+1
-1
@@ -32,3 +32,3 @@ import { createPassThroughStream } from "@datastream/core"; | ||
| }; | ||
| const charsetDetectStream = ({ resultKey } = {}, streamOptions) => { | ||
| const charsetDetectStream = ({ resultKey } = {}, streamOptions = {}) => { | ||
| const passThrough = (chunk) => { | ||
@@ -35,0 +35,0 @@ const matches = detect(chunk); |
| { | ||
| "version": 3, | ||
| "sources": ["detect.js"], | ||
| "sourcesContent": ["import { createPassThroughStream } from '@datastream/core'\nimport detect from 'charset-detector'\n\nconst charsets = {\n 'UTF-8': 0,\n 'UTF-16BE': 0,\n 'UTF-16LE': 0,\n 'UTF-32BE': 0,\n 'UTF-32LE': 0,\n Shift_JIS: 0,\n 'ISO-2022-JP': 0,\n 'ISO-2022-CN': 0,\n 'ISO-2022-KR': 0,\n GB18030: 0,\n 'EUC-JP': 0,\n 'EUC-KR': 0,\n Big5: 0,\n 'ISO-8859-1': 0,\n 'ISO-8859-2': 0,\n 'ISO-8859-5': 0,\n 'ISO-8859-6': 0,\n 'ISO-8859-7': 0,\n 'ISO-8859-8-I': 0,\n 'ISO-8859-8': 0,\n 'windows-1251': 0,\n 'windows-1256': 0,\n 'windows-1252': 0,\n 'windows-1254': 0,\n 'windows-1250': 0,\n 'KOIR8-R': 0,\n 'ISO-8859-9': 0\n}\n\nexport const charsetDetectStream = ({ resultKey } = {}, streamOptions) => {\n const passThrough = (chunk) => {\n const matches = detect(chunk)\n if (matches.length) {\n for (const match of matches) {\n charsets[match.charsetName] += match.confidence\n }\n }\n }\n const stream = createPassThroughStream(passThrough, streamOptions)\n stream.result = () => {\n const values = Object.entries(charsets)\n .map(([charset, confidence]) => ({ charset, confidence }))\n .sort((a, b) => b.confidence - a.confidence)\n return { key: resultKey ?? 'charset', value: values[0] }\n }\n return stream\n}\n\nexport default charsetDetectStream\n"], | ||
| "mappings": "AAAA,SAAS,+BAA+B;AACxC,OAAO,YAAY;AAEnB,MAAM,WAAW;AAAA,EACf,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,eAAe;AAAA,EACf,eAAe;AAAA,EACf,eAAe;AAAA,EACf,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,MAAM;AAAA,EACN,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,cAAc;AAChB;AAEO,MAAM,sBAAsB,CAAC,EAAE,UAAU,IAAI,CAAC,GAAG,kBAAkB;AACxE,QAAM,cAAc,CAAC,UAAU;AAC7B,UAAM,UAAU,OAAO,KAAK;AAC5B,QAAI,QAAQ,QAAQ;AAClB,iBAAW,SAAS,SAAS;AAC3B,iBAAS,MAAM,WAAW,KAAK,MAAM;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AACA,QAAM,SAAS,wBAAwB,aAAa,aAAa;AACjE,SAAO,SAAS,MAAM;AACpB,UAAM,SAAS,OAAO,QAAQ,QAAQ,EACnC,IAAI,CAAC,CAAC,SAAS,UAAU,OAAO,EAAE,SAAS,WAAW,EAAE,EACxD,KAAK,CAAC,GAAG,MAAM,EAAE,aAAa,EAAE,UAAU;AAC7C,WAAO,EAAE,KAAK,aAAa,WAAW,OAAO,OAAO,CAAC,EAAE;AAAA,EACzD;AACA,SAAO;AACT;AAEA,IAAO,iBAAQ;", | ||
| "sourcesContent": ["import { createPassThroughStream } from \"@datastream/core\";\nimport detect from \"charset-detector\";\n\nconst charsets = {\n\t\"UTF-8\": 0,\n\t\"UTF-16BE\": 0,\n\t\"UTF-16LE\": 0,\n\t\"UTF-32BE\": 0,\n\t\"UTF-32LE\": 0,\n\tShift_JIS: 0,\n\t\"ISO-2022-JP\": 0,\n\t\"ISO-2022-CN\": 0,\n\t\"ISO-2022-KR\": 0,\n\tGB18030: 0,\n\t\"EUC-JP\": 0,\n\t\"EUC-KR\": 0,\n\tBig5: 0,\n\t\"ISO-8859-1\": 0,\n\t\"ISO-8859-2\": 0,\n\t\"ISO-8859-5\": 0,\n\t\"ISO-8859-6\": 0,\n\t\"ISO-8859-7\": 0,\n\t\"ISO-8859-8-I\": 0,\n\t\"ISO-8859-8\": 0,\n\t\"windows-1251\": 0,\n\t\"windows-1256\": 0,\n\t\"windows-1252\": 0,\n\t\"windows-1254\": 0,\n\t\"windows-1250\": 0,\n\t\"KOIR8-R\": 0,\n\t\"ISO-8859-9\": 0,\n};\n\nexport const charsetDetectStream = ({ resultKey } = {}, streamOptions = {}) => {\n\tconst passThrough = (chunk) => {\n\t\tconst matches = detect(chunk);\n\t\tif (matches.length) {\n\t\t\tfor (const match of matches) {\n\t\t\t\tcharsets[match.charsetName] += match.confidence;\n\t\t\t}\n\t\t}\n\t};\n\tconst stream = createPassThroughStream(passThrough, streamOptions);\n\tstream.result = () => {\n\t\tconst values = Object.entries(charsets)\n\t\t\t.map(([charset, confidence]) => ({ charset, confidence }))\n\t\t\t.sort((a, b) => b.confidence - a.confidence);\n\t\treturn { key: resultKey ?? \"charset\", value: values[0] };\n\t};\n\treturn stream;\n};\n\nexport default charsetDetectStream;\n"], | ||
| "mappings": "AAAA,SAAS,+BAA+B;AACxC,OAAO,YAAY;AAEnB,MAAM,WAAW;AAAA,EAChB,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,eAAe;AAAA,EACf,eAAe;AAAA,EACf,eAAe;AAAA,EACf,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,MAAM;AAAA,EACN,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,cAAc;AACf;AAEO,MAAM,sBAAsB,CAAC,EAAE,UAAU,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM;AAC9E,QAAM,cAAc,CAAC,UAAU;AAC9B,UAAM,UAAU,OAAO,KAAK;AAC5B,QAAI,QAAQ,QAAQ;AACnB,iBAAW,SAAS,SAAS;AAC5B,iBAAS,MAAM,WAAW,KAAK,MAAM;AAAA,MACtC;AAAA,IACD;AAAA,EACD;AACA,QAAM,SAAS,wBAAwB,aAAa,aAAa;AACjE,SAAO,SAAS,MAAM;AACrB,UAAM,SAAS,OAAO,QAAQ,QAAQ,EACpC,IAAI,CAAC,CAAC,SAAS,UAAU,OAAO,EAAE,SAAS,WAAW,EAAE,EACxD,KAAK,CAAC,GAAG,MAAM,EAAE,aAAa,EAAE,UAAU;AAC5C,WAAO,EAAE,KAAK,aAAa,WAAW,OAAO,OAAO,CAAC,EAAE;AAAA,EACxD;AACA,SAAO;AACR;AAEA,IAAO,iBAAQ;", | ||
| "names": [] | ||
| } |
+1
-1
@@ -32,3 +32,3 @@ import { createPassThroughStream } from "@datastream/core"; | ||
| }; | ||
| const charsetDetectStream = ({ resultKey } = {}, streamOptions) => { | ||
| const charsetDetectStream = ({ resultKey } = {}, streamOptions = {}) => { | ||
| const passThrough = (chunk) => { | ||
@@ -35,0 +35,0 @@ const matches = detect(chunk); |
| { | ||
| "version": 3, | ||
| "sources": ["detect.js"], | ||
| "sourcesContent": ["import { createPassThroughStream } from '@datastream/core'\nimport detect from 'charset-detector'\n\nconst charsets = {\n 'UTF-8': 0,\n 'UTF-16BE': 0,\n 'UTF-16LE': 0,\n 'UTF-32BE': 0,\n 'UTF-32LE': 0,\n Shift_JIS: 0,\n 'ISO-2022-JP': 0,\n 'ISO-2022-CN': 0,\n 'ISO-2022-KR': 0,\n GB18030: 0,\n 'EUC-JP': 0,\n 'EUC-KR': 0,\n Big5: 0,\n 'ISO-8859-1': 0,\n 'ISO-8859-2': 0,\n 'ISO-8859-5': 0,\n 'ISO-8859-6': 0,\n 'ISO-8859-7': 0,\n 'ISO-8859-8-I': 0,\n 'ISO-8859-8': 0,\n 'windows-1251': 0,\n 'windows-1256': 0,\n 'windows-1252': 0,\n 'windows-1254': 0,\n 'windows-1250': 0,\n 'KOIR8-R': 0,\n 'ISO-8859-9': 0\n}\n\nexport const charsetDetectStream = ({ resultKey } = {}, streamOptions) => {\n const passThrough = (chunk) => {\n const matches = detect(chunk)\n if (matches.length) {\n for (const match of matches) {\n charsets[match.charsetName] += match.confidence\n }\n }\n }\n const stream = createPassThroughStream(passThrough, streamOptions)\n stream.result = () => {\n const values = Object.entries(charsets)\n .map(([charset, confidence]) => ({ charset, confidence }))\n .sort((a, b) => b.confidence - a.confidence)\n return { key: resultKey ?? 'charset', value: values[0] }\n }\n return stream\n}\n\nexport default charsetDetectStream\n"], | ||
| "mappings": "AAAA,SAAS,+BAA+B;AACxC,OAAO,YAAY;AAEnB,MAAM,WAAW;AAAA,EACf,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,eAAe;AAAA,EACf,eAAe;AAAA,EACf,eAAe;AAAA,EACf,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,MAAM;AAAA,EACN,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,cAAc;AAChB;AAEO,MAAM,sBAAsB,CAAC,EAAE,UAAU,IAAI,CAAC,GAAG,kBAAkB;AACxE,QAAM,cAAc,CAAC,UAAU;AAC7B,UAAM,UAAU,OAAO,KAAK;AAC5B,QAAI,QAAQ,QAAQ;AAClB,iBAAW,SAAS,SAAS;AAC3B,iBAAS,MAAM,WAAW,KAAK,MAAM;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AACA,QAAM,SAAS,wBAAwB,aAAa,aAAa;AACjE,SAAO,SAAS,MAAM;AACpB,UAAM,SAAS,OAAO,QAAQ,QAAQ,EACnC,IAAI,CAAC,CAAC,SAAS,UAAU,OAAO,EAAE,SAAS,WAAW,EAAE,EACxD,KAAK,CAAC,GAAG,MAAM,EAAE,aAAa,EAAE,UAAU;AAC7C,WAAO,EAAE,KAAK,aAAa,WAAW,OAAO,OAAO,CAAC,EAAE;AAAA,EACzD;AACA,SAAO;AACT;AAEA,IAAO,iBAAQ;", | ||
| "sourcesContent": ["import { createPassThroughStream } from \"@datastream/core\";\nimport detect from \"charset-detector\";\n\nconst charsets = {\n\t\"UTF-8\": 0,\n\t\"UTF-16BE\": 0,\n\t\"UTF-16LE\": 0,\n\t\"UTF-32BE\": 0,\n\t\"UTF-32LE\": 0,\n\tShift_JIS: 0,\n\t\"ISO-2022-JP\": 0,\n\t\"ISO-2022-CN\": 0,\n\t\"ISO-2022-KR\": 0,\n\tGB18030: 0,\n\t\"EUC-JP\": 0,\n\t\"EUC-KR\": 0,\n\tBig5: 0,\n\t\"ISO-8859-1\": 0,\n\t\"ISO-8859-2\": 0,\n\t\"ISO-8859-5\": 0,\n\t\"ISO-8859-6\": 0,\n\t\"ISO-8859-7\": 0,\n\t\"ISO-8859-8-I\": 0,\n\t\"ISO-8859-8\": 0,\n\t\"windows-1251\": 0,\n\t\"windows-1256\": 0,\n\t\"windows-1252\": 0,\n\t\"windows-1254\": 0,\n\t\"windows-1250\": 0,\n\t\"KOIR8-R\": 0,\n\t\"ISO-8859-9\": 0,\n};\n\nexport const charsetDetectStream = ({ resultKey } = {}, streamOptions = {}) => {\n\tconst passThrough = (chunk) => {\n\t\tconst matches = detect(chunk);\n\t\tif (matches.length) {\n\t\t\tfor (const match of matches) {\n\t\t\t\tcharsets[match.charsetName] += match.confidence;\n\t\t\t}\n\t\t}\n\t};\n\tconst stream = createPassThroughStream(passThrough, streamOptions);\n\tstream.result = () => {\n\t\tconst values = Object.entries(charsets)\n\t\t\t.map(([charset, confidence]) => ({ charset, confidence }))\n\t\t\t.sort((a, b) => b.confidence - a.confidence);\n\t\treturn { key: resultKey ?? \"charset\", value: values[0] };\n\t};\n\treturn stream;\n};\n\nexport default charsetDetectStream;\n"], | ||
| "mappings": "AAAA,SAAS,+BAA+B;AACxC,OAAO,YAAY;AAEnB,MAAM,WAAW;AAAA,EAChB,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,eAAe;AAAA,EACf,eAAe;AAAA,EACf,eAAe;AAAA,EACf,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,MAAM;AAAA,EACN,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,cAAc;AACf;AAEO,MAAM,sBAAsB,CAAC,EAAE,UAAU,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM;AAC9E,QAAM,cAAc,CAAC,UAAU;AAC9B,UAAM,UAAU,OAAO,KAAK;AAC5B,QAAI,QAAQ,QAAQ;AACnB,iBAAW,SAAS,SAAS;AAC5B,iBAAS,MAAM,WAAW,KAAK,MAAM;AAAA,MACtC;AAAA,IACD;AAAA,EACD;AACA,QAAM,SAAS,wBAAwB,aAAa,aAAa;AACjE,SAAO,SAAS,MAAM;AACrB,UAAM,SAAS,OAAO,QAAQ,QAAQ,EACpC,IAAI,CAAC,CAAC,SAAS,UAAU,OAAO,EAAE,SAAS,WAAW,EAAE,EACxD,KAAK,CAAC,GAAG,MAAM,EAAE,aAAa,EAAE,UAAU;AAC5C,WAAO,EAAE,KAAK,aAAa,WAAW,OAAO,OAAO,CAAC,EAAE;AAAA,EACxD;AACA,SAAO;AACR;AAEA,IAAO,iBAAQ;", | ||
| "names": [] | ||
| } |
+1
-1
| import { createTransformStream } from "@datastream/core"; | ||
| import iconv from "iconv-lite"; | ||
| const charsetEncodeStream = ({ charset } = {}, streamOptions) => { | ||
| const charsetEncodeStream = ({ charset } = {}, streamOptions = {}) => { | ||
| charset = getSupportedEncoding(charset); | ||
@@ -5,0 +5,0 @@ const conv = iconv.getEncoder(charset); |
| { | ||
| "version": 3, | ||
| "sources": ["encode.node.js"], | ||
| "sourcesContent": ["import { createTransformStream } from '@datastream/core'\nimport iconv from 'iconv-lite'\n\nexport const charsetEncodeStream = ({ charset } = {}, streamOptions) => {\n charset = getSupportedEncoding(charset)\n\n const conv = iconv.getEncoder(charset)\n const transform = (chunk, enqueue) => {\n const res = conv.write(chunk)\n if (res?.length) {\n enqueue(res)\n }\n }\n const flush = (enqueue) => {\n const res = conv.end()\n if (res?.length) {\n enqueue(res)\n }\n }\n return createTransformStream(transform, flush, streamOptions)\n}\n\nconst getSupportedEncoding = (charset) => {\n if (charset === 'ISO-8859-8-I') charset = 'ISO-8859-8'\n if (!iconv.encodingExists(charset)) charset = 'UTF-8'\n return charset\n}\nexport default charsetEncodeStream\n"], | ||
| "mappings": "AAAA,SAAS,6BAA6B;AACtC,OAAO,WAAW;AAEX,MAAM,sBAAsB,CAAC,EAAE,QAAQ,IAAI,CAAC,GAAG,kBAAkB;AACtE,YAAU,qBAAqB,OAAO;AAEtC,QAAM,OAAO,MAAM,WAAW,OAAO;AACrC,QAAM,YAAY,CAAC,OAAO,YAAY;AACpC,UAAM,MAAM,KAAK,MAAM,KAAK;AAC5B,QAAI,KAAK,QAAQ;AACf,cAAQ,GAAG;AAAA,IACb;AAAA,EACF;AACA,QAAM,QAAQ,CAAC,YAAY;AACzB,UAAM,MAAM,KAAK,IAAI;AACrB,QAAI,KAAK,QAAQ;AACf,cAAQ,GAAG;AAAA,IACb;AAAA,EACF;AACA,SAAO,sBAAsB,WAAW,OAAO,aAAa;AAC9D;AAEA,MAAM,uBAAuB,CAAC,YAAY;AACxC,MAAI,YAAY,eAAgB,WAAU;AAC1C,MAAI,CAAC,MAAM,eAAe,OAAO,EAAG,WAAU;AAC9C,SAAO;AACT;AACA,IAAO,sBAAQ;", | ||
| "sourcesContent": ["import { createTransformStream } from \"@datastream/core\";\nimport iconv from \"iconv-lite\";\n\nexport const charsetEncodeStream = ({ charset } = {}, streamOptions = {}) => {\n\tcharset = getSupportedEncoding(charset);\n\n\tconst conv = iconv.getEncoder(charset);\n\tconst transform = (chunk, enqueue) => {\n\t\tconst res = conv.write(chunk);\n\t\tif (res?.length) {\n\t\t\tenqueue(res);\n\t\t}\n\t};\n\tconst flush = (enqueue) => {\n\t\tconst res = conv.end();\n\t\tif (res?.length) {\n\t\t\tenqueue(res);\n\t\t}\n\t};\n\treturn createTransformStream(transform, flush, streamOptions);\n};\n\nconst getSupportedEncoding = (charset) => {\n\tif (charset === \"ISO-8859-8-I\") charset = \"ISO-8859-8\";\n\tif (!iconv.encodingExists(charset)) charset = \"UTF-8\";\n\treturn charset;\n};\nexport default charsetEncodeStream;\n"], | ||
| "mappings": "AAAA,SAAS,6BAA6B;AACtC,OAAO,WAAW;AAEX,MAAM,sBAAsB,CAAC,EAAE,QAAQ,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM;AAC5E,YAAU,qBAAqB,OAAO;AAEtC,QAAM,OAAO,MAAM,WAAW,OAAO;AACrC,QAAM,YAAY,CAAC,OAAO,YAAY;AACrC,UAAM,MAAM,KAAK,MAAM,KAAK;AAC5B,QAAI,KAAK,QAAQ;AAChB,cAAQ,GAAG;AAAA,IACZ;AAAA,EACD;AACA,QAAM,QAAQ,CAAC,YAAY;AAC1B,UAAM,MAAM,KAAK,IAAI;AACrB,QAAI,KAAK,QAAQ;AAChB,cAAQ,GAAG;AAAA,IACZ;AAAA,EACD;AACA,SAAO,sBAAsB,WAAW,OAAO,aAAa;AAC7D;AAEA,MAAM,uBAAuB,CAAC,YAAY;AACzC,MAAI,YAAY,eAAgB,WAAU;AAC1C,MAAI,CAAC,MAAM,eAAe,OAAO,EAAG,WAAU;AAC9C,SAAO;AACR;AACA,IAAO,sBAAQ;", | ||
| "names": [] | ||
| } |
+1
-1
@@ -1,2 +0,2 @@ | ||
| const charsetDecodeStream = ({ charset } = {}, streamOptions) => { | ||
| const charsetDecodeStream = ({ charset } = {}, _streamOptions = {}) => { | ||
| return new TextEncoderStream(charset); | ||
@@ -3,0 +3,0 @@ }; |
| { | ||
| "version": 3, | ||
| "sources": ["encode.web.js"], | ||
| "sourcesContent": ["/* global TextEncoderStream */\n\nexport const charsetDecodeStream = ({ charset } = {}, streamOptions) => {\n // doesn't support signal?\n return new TextEncoderStream(charset)\n}\n\nexport default charsetDecodeStream\n"], | ||
| "mappings": "AAEO,MAAM,sBAAsB,CAAC,EAAE,QAAQ,IAAI,CAAC,GAAG,kBAAkB;AAEtE,SAAO,IAAI,kBAAkB,OAAO;AACtC;AAEA,IAAO,qBAAQ;", | ||
| "sourcesContent": ["/* global TextEncoderStream */\n\nexport const charsetDecodeStream = ({ charset } = {}, _streamOptions = {}) => {\n\t// doesn't support signal?\n\treturn new TextEncoderStream(charset);\n};\n\nexport default charsetDecodeStream;\n"], | ||
| "mappings": "AAEO,MAAM,sBAAsB,CAAC,EAAE,QAAQ,IAAI,CAAC,GAAG,iBAAiB,CAAC,MAAM;AAE7E,SAAO,IAAI,kBAAkB,OAAO;AACrC;AAEA,IAAO,qBAAQ;", | ||
| "names": [] | ||
| } |
+1
-1
@@ -0,3 +1,3 @@ | ||
| export * from "@datastream/charset/decode"; | ||
| export * from "@datastream/charset/detect"; | ||
| export * from "@datastream/charset/decode"; | ||
| export * from "@datastream/charset/encode"; |
| { | ||
| "version": 3, | ||
| "sources": ["index.js"], | ||
| "sourcesContent": ["export * from '@datastream/charset/detect'\nexport * from '@datastream/charset/decode'\nexport * from '@datastream/charset/encode'\n"], | ||
| "sourcesContent": ["export * from \"@datastream/charset/decode\";\nexport * from \"@datastream/charset/detect\";\nexport * from \"@datastream/charset/encode\";\n"], | ||
| "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;", | ||
| "names": [] | ||
| } |
+1
-1
@@ -0,3 +1,3 @@ | ||
| export * from "@datastream/charset/decode"; | ||
| export * from "@datastream/charset/detect"; | ||
| export * from "@datastream/charset/decode"; | ||
| export * from "@datastream/charset/encode"; |
| { | ||
| "version": 3, | ||
| "sources": ["index.js"], | ||
| "sourcesContent": ["export * from '@datastream/charset/detect'\nexport * from '@datastream/charset/decode'\nexport * from '@datastream/charset/encode'\n"], | ||
| "sourcesContent": ["export * from \"@datastream/charset/decode\";\nexport * from \"@datastream/charset/detect\";\nexport * from \"@datastream/charset/encode\";\n"], | ||
| "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;", | ||
| "names": [] | ||
| } |
+132
-132
| { | ||
| "name": "@datastream/charset", | ||
| "version": "0.0.40", | ||
| "description": "", | ||
| "type": "module", | ||
| "engines": { | ||
| "node": ">=18" | ||
| }, | ||
| "engineStrict": true, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "main": "./index.web.mjs", | ||
| "module": "./index.web.mjs", | ||
| "exports": { | ||
| ".": { | ||
| "node": { | ||
| "webstream": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.web.mjs" | ||
| }, | ||
| "import": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.node.mjs" | ||
| }, | ||
| "__require": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.node.cjs" | ||
| } | ||
| }, | ||
| "import": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.web.mjs" | ||
| } | ||
| }, | ||
| "./detect": { | ||
| "node": { | ||
| "webstream": { | ||
| "types": "./detect.d.ts", | ||
| "default": "./detect.web.mjs" | ||
| }, | ||
| "import": { | ||
| "types": "./detect.d.ts", | ||
| "default": "./detect.node.mjs" | ||
| }, | ||
| "__require": { | ||
| "types": "./detect.d.ts", | ||
| "default": "./detect.node.cjs" | ||
| } | ||
| }, | ||
| "import": { | ||
| "types": "./detect.d.ts", | ||
| "default": "./detect.web.mjs" | ||
| } | ||
| }, | ||
| "./decode": { | ||
| "node": { | ||
| "webstream": { | ||
| "types": "./decode.d.ts", | ||
| "default": "./decode.web.mjs" | ||
| }, | ||
| "import": { | ||
| "types": "./decode.d.ts", | ||
| "default": "./decode.node.mjs" | ||
| }, | ||
| "__require": { | ||
| "types": "./decode.d.ts", | ||
| "default": "./decode.node.cjs" | ||
| } | ||
| }, | ||
| "import": { | ||
| "types": "./decode.d.ts", | ||
| "default": "./decode.web.mjs" | ||
| } | ||
| }, | ||
| "./encode": { | ||
| "node": { | ||
| "webstream": { | ||
| "types": "./encode.d.ts", | ||
| "default": "./encode.web.mjs" | ||
| }, | ||
| "import": { | ||
| "types": "./encode.d.ts", | ||
| "default": "./encode.node.mjs" | ||
| }, | ||
| "__require": { | ||
| "types": "./encode.d.ts", | ||
| "default": "./encode.node.cjs" | ||
| } | ||
| }, | ||
| "import": { | ||
| "types": "./encode.d.ts", | ||
| "default": "./encode.web.mjs" | ||
| } | ||
| } | ||
| }, | ||
| "types": "index.d.ts", | ||
| "files": [ | ||
| "*.mjs", | ||
| "*.cjs", | ||
| "*.map", | ||
| "*.d.ts" | ||
| ], | ||
| "scripts": { | ||
| "test": "npm run test:unit", | ||
| "test:unit": "node --test", | ||
| "test:benchmark": "node __benchmarks__/index.js" | ||
| }, | ||
| "license": "MIT", | ||
| "keywords": [ | ||
| "Web Stream API", | ||
| "Node Stream API" | ||
| ], | ||
| "author": { | ||
| "name": "datastream contributors", | ||
| "url": "https://github.com/willfarrell/datastream/graphs/contributors" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "github:willfarrell/datastream", | ||
| "directory": "packages/file-read" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/willfarrell/datastream/issues" | ||
| }, | ||
| "homepage": "https://datastream.js.org", | ||
| "dependencies": { | ||
| "@datastream/charset": "0.0.40", | ||
| "@datastream/core": "0.0.40", | ||
| "charset-detector": "0.0.2", | ||
| "iconv-lite": "0.6.3" | ||
| }, | ||
| "gitHead": "4dbeb8efee8daea0f19b14573f064afc77499094" | ||
| "name": "@datastream/charset", | ||
| "version": "0.0.41", | ||
| "description": "", | ||
| "type": "module", | ||
| "engines": { | ||
| "node": ">=22" | ||
| }, | ||
| "engineStrict": true, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "main": "./index.web.mjs", | ||
| "module": "./index.web.mjs", | ||
| "exports": { | ||
| ".": { | ||
| "node": { | ||
| "import": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.node.mjs" | ||
| }, | ||
| "__require": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.node.cjs" | ||
| } | ||
| }, | ||
| "import": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.web.mjs" | ||
| } | ||
| }, | ||
| "./webstream": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.web.mjs" | ||
| }, | ||
| "./detect": { | ||
| "node": { | ||
| "import": { | ||
| "types": "./detect.d.ts", | ||
| "default": "./detect.node.mjs" | ||
| }, | ||
| "__require": { | ||
| "types": "./detect.d.ts", | ||
| "default": "./detect.node.cjs" | ||
| } | ||
| }, | ||
| "import": { | ||
| "types": "./detect.d.ts", | ||
| "default": "./detect.web.mjs" | ||
| } | ||
| }, | ||
| "./detect/webstream": { | ||
| "types": "./detect.d.ts", | ||
| "default": "./detect.web.mjs" | ||
| }, | ||
| "./decode": { | ||
| "node": { | ||
| "import": { | ||
| "types": "./decode.d.ts", | ||
| "default": "./decode.node.mjs" | ||
| }, | ||
| "__require": { | ||
| "types": "./decode.d.ts", | ||
| "default": "./decode.node.cjs" | ||
| } | ||
| }, | ||
| "import": { | ||
| "types": "./decode.d.ts", | ||
| "default": "./decode.web.mjs" | ||
| } | ||
| }, | ||
| "./decode/webstream": { | ||
| "types": "./decode.d.ts", | ||
| "default": "./decode.web.mjs" | ||
| }, | ||
| "./encode": { | ||
| "node": { | ||
| "import": { | ||
| "types": "./encode.d.ts", | ||
| "default": "./encode.node.mjs" | ||
| }, | ||
| "__require": { | ||
| "types": "./encode.d.ts", | ||
| "default": "./encode.node.cjs" | ||
| } | ||
| }, | ||
| "import": { | ||
| "types": "./encode.d.ts", | ||
| "default": "./encode.web.mjs" | ||
| } | ||
| }, | ||
| "./encode/webstream": { | ||
| "types": "./encode.d.ts", | ||
| "default": "./encode.web.mjs" | ||
| } | ||
| }, | ||
| "types": "index.d.ts", | ||
| "files": [ | ||
| "*.mjs", | ||
| "*.cjs", | ||
| "*.map", | ||
| "*.d.ts" | ||
| ], | ||
| "scripts": { | ||
| "test": "npm run test:unit", | ||
| "test:unit": "node --test", | ||
| "test:benchmark": "node __benchmarks__/index.js" | ||
| }, | ||
| "license": "MIT", | ||
| "keywords": [ | ||
| "Web Stream API", | ||
| "Node Stream API" | ||
| ], | ||
| "author": { | ||
| "name": "datastream contributors", | ||
| "url": "https://github.com/willfarrell/datastream/graphs/contributors" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "github:willfarrell/datastream", | ||
| "directory": "packages/file-read" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/willfarrell/datastream/issues" | ||
| }, | ||
| "homepage": "https://datastream.js.org", | ||
| "dependencies": { | ||
| "@datastream/charset": "0.0.41", | ||
| "@datastream/core": "0.0.41", | ||
| "charset-detector": "0.0.2", | ||
| "iconv-lite": "0.7.0" | ||
| }, | ||
| "gitHead": "6ddc0fadabf5f3702a51aebae1fc6b252c6ae8d4" | ||
| } |
| export * from "@datastream/charset/detect"; | ||
| export * from "@datastream/charset/decode"; | ||
| export * from "@datastream/charset/encode"; |
-21
| MIT License | ||
| Copyright (c) 2022 will Farrell | ||
| 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: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
18020
-6.45%17
-10.53%184
-1.6%+ Added
+ Added
- Removed
- Removed
Updated
Updated
Updated