本文整理汇总了TypeScript中iconv-lite.decodeStream函数的典型用法代码示例。如果您正苦于以下问题:TypeScript decodeStream函数的具体用法?TypeScript decodeStream怎么用?TypeScript decodeStream使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了decodeStream函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
(() => {
// Decode stream (from binary stream to js strings)
http.createServer(function(req, res) {
var converterStream = iconv.decodeStream('win1251');
req.pipe(converterStream);
converterStream.on('data', function(str: string) {
console.log(str); // Do something with decoded strings, chunk-by-chunk.
});
});
// Convert encoding streaming example
fs.createReadStream('file-in-win1251.txt')
.pipe(iconv.decodeStream('win1251'))
.pipe(iconv.encodeStream('ucs2'))
.pipe(fs.createWriteStream('file-in-ucs2.txt'));
// Sugar: all encode/decode streams have .collect(cb) method to accumulate data.
http.createServer(function(req, res) {
req.pipe(iconv.decodeStream('win1251')).collect(function(err, body) {
assert(typeof body == 'string');
console.log(body); // full request body string
});
});
})();
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:25,代码来源:iconv-lite-tests.ts
示例2: reject
storage.createBlobService().getBlobToStream(process.env.AZURE_BLOB_STORAGE, targetBlob, fs.createWriteStream(localFile), err => {
if (err) {
return reject(err);
}
let stream = fs.createWriteStream(localFile, {flags:'a'});
const readableStream = fs.createReadStream(localFile)
.pipe(iconv.decodeStream('SJIS'))
.pipe(iconv.encodeStream('UTF-8'))
.pipe(csv.parse());
readableStream.on('data', (record) => {
docs.push(record);
});
readableStream.on('end', () => {
if (configs.csv.csv_101.useHeader) docs.shift();
fs.unlink(localFile, () => {});
return resolve(docs);
});
});
开发者ID:motionpicture,项目名称:ttts-functions,代码行数:20,代码来源:index.ts
示例3: resolveTerminalEncoding
resolveTerminalEncoding(verbose).then(encoding => {
const converterStream = iconv.decodeStream(encoding);
process.stdin.pipe(converterStream).pipe(stdinFileStream);
});
开发者ID:VishalMadhvani,项目名称:vscode,代码行数:4,代码来源:cli.ts
示例4:
http.createServer(function(req, res) {
req.pipe(iconv.decodeStream('win1251')).collect(function(err, body) {
assert(typeof body == 'string');
console.log(body); // full request body string
});
});
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:6,代码来源:iconv-lite-tests.ts
注:本文中的iconv-lite.decodeStream函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论