Spaces:
Build error
Build error
| ; | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| exports.decodeFileStream = decodeFileStream; | |
| exports.readFile = readFile; | |
| const fs_1 = require("fs"); | |
| const stream_1 = require("stream"); | |
| const web_1 = require("stream/web"); | |
| async function decodeFileStream(fileStream, encoding = 'utf-8') { | |
| const decodeStream = new web_1.TextDecoderStream(encoding, { fatal: false, ignoreBOM: false }); | |
| stream_1.Readable.toWeb(fileStream).pipeThrough(decodeStream); | |
| const chunks = []; | |
| for await (const chunk of decodeStream.readable) { | |
| chunks.push(chunk); | |
| } | |
| return chunks.join(''); | |
| } | |
| async function readFile(filePath, encoding = 'utf-8') { | |
| const decodeStream = new web_1.TextDecoderStream(encoding, { fatal: false, ignoreBOM: false }); | |
| stream_1.Readable.toWeb((0, fs_1.createReadStream)(filePath)).pipeThrough(decodeStream); | |
| const chunks = []; | |
| for await (const chunk of decodeStream.readable) { | |
| chunks.push(chunk); | |
| } | |
| return chunks.join(''); | |
| } | |
| //# sourceMappingURL=encoding.js.map |