@datastream/charset
Advanced tools
| { | ||
| "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}\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;AACA,MAAM,uBAAuB,CAAC,YAAY;AACxC,MAAI,YAAY;AAAgB,cAAU;AAC1C,MAAI,CAAC,MAAM,eAAe,OAAO;AAAG,cAAU;AAC9C,SAAO;AACT;AACA,IAAO,sBAAQ;", | ||
| "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;AAAgB,cAAU;AAC1C,MAAI,CAAC,MAAM,eAAe,OAAO;AAAG,cAAU;AAC9C,SAAO;AACT;AACA,IAAO,sBAAQ;", | ||
| "names": [] | ||
| } |
+4
-4
| { | ||
| "name": "@datastream/charset", | ||
| "version": "0.0.35", | ||
| "version": "0.0.36", | ||
| "description": "", | ||
@@ -128,8 +128,8 @@ "type": "module", | ||
| "dependencies": { | ||
| "@datastream/charset": "0.0.35", | ||
| "@datastream/core": "0.0.35", | ||
| "@datastream/charset": "0.0.36", | ||
| "@datastream/core": "0.0.36", | ||
| "charset-detector": "0.0.2", | ||
| "iconv-lite": "0.6.3" | ||
| }, | ||
| "gitHead": "b4cd8a408e44aaa7ae8a68c5e9a796fe4cc0b7b3" | ||
| "gitHead": "8c4f4c5f1482516f56b589fc567cc7cc23e00543" | ||
| } |
19279
4.47%+ Added
- Removed
Updated
Updated