當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript iconv-lite.decodeStream函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。