当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript zlib.createGunzip函数代码示例

本文整理汇总了TypeScript中zlib.createGunzip函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createGunzip函数的具体用法?TypeScript createGunzip怎么用?TypeScript createGunzip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了createGunzip函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: switch

			let request = http.request(options, (response: Server.IRequestResponseData) => {
				let data: string[] = [];
				let isRedirect = helpers.isResponseRedirect(response);
				let successful = helpers.isRequestSuccessful(response);
				if (!successful) {
					pipeTo = undefined;
				}

				let responseStream = response;
				switch (response.headers["content-encoding"]) {
					case "gzip":
						responseStream = responseStream.pipe(zlib.createGunzip());
						break;
					case "deflate":
						responseStream = responseStream.pipe(zlib.createInflate());
						break;
				}

				if (pipeTo) {
					pipeTo.on("finish", () => {
						this.$logger.trace("httpRequest: Piping done. code = %d", response.statusCode.toString());
						if(!result.isResolved()) {
							result.return({
								response: response,
								headers: response.headers
							});
						}
					});

					pipeTo = this.trackDownloadProgress(pipeTo);

					responseStream.pipe(pipeTo);
				} else {
					responseStream.on("data", (chunk: string) => {
						data.push(chunk);
					});

					responseStream.on("end", () => {
						this.$logger.trace("httpRequest: Done. code = %d", response.statusCode.toString());
						let responseBody = data.join("");

						if (successful || isRedirect) {
							if(!result.isResolved()) {
								result.return({
									body: responseBody,
									response: response,
									headers: response.headers
								});
							}
						} else {
							let errorMessage = this.getErrorMessage(response, responseBody);
							let theError: any = new Error(errorMessage);
							theError.response = response;
							theError.body = responseBody;
							result.throw(theError);
						}
					});
				}
			});
开发者ID:enchev,项目名称:mobile-cli-lib,代码行数:59,代码来源:http-client.ts

示例2: unTarGz

 private async unTarGz(zipLocation: string, unzipLocation: string): Promise<void> {
     return Promise.resolve(
         fs
             .createReadStream(zipLocation)
             .pipe(zlib.createGunzip())
             .pipe(tar.extract(unzipLocation))
     );
 }
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:8,代码来源:packagefile.ts

示例3: fromFileSync

export function fromFileSync(filename:string) : NiftiStream {
    accessSync(filename, R_OK);
    let stream:NodeJS.ReadableStream = createReadStream(filename);
    if (filename.substr(-'.gz'.length) === '.gz') {
        stream = stream.pipe(createGunzip());
    }
    return new NiftiStream(stream);
}
开发者ID:Enet4,项目名称:nifti-stream,代码行数:8,代码来源:index.ts

示例4: getContentStream

function getContentStream(stream: Readable, headers: RequestHeaders): Maybe<Readable> {
  const ce = String(headers['content-encoding'] || 'identity').toLowerCase();

  return ce === 'identity' ? just(stream)
    : ce === 'gzip' ? just(stream.pipe(createGunzip()))
      : ce === 'deflate' ? just(stream.pipe(createInflate()))
        : nothing;
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:8,代码来源:parser.ts

示例5: asyncTest

asyncTest("gzip roundtrip", 1, (_) => {
	const sampleReader1 = ez.devices.file.text.reader(sample);
	var sampleReader2 = ez.devices.file.text.reader(sample);
	const stringify = ez.mappers.convert.stringify();
	const cutter = ez.transforms.cut.transform(10);
	const out = require('fs').createWriteStream(__dirname + '/../../test/fixtures/rss-sample.zip');
	sampleReader2 = sampleReader2.nodeTransform(zlib.createGzip()).nodeTransform(zlib.createGunzip()).map(stringify);
	const cmp = sampleReader1.transform(cutter).compare(_, sampleReader2.transform(cutter));
	equal(cmp, 0);
	start();
});
开发者ID:Sage,项目名称:ez-streams,代码行数:11,代码来源:nodify-test.ts

示例6: access

 access(filename, R_OK, function(err) {
     if (err) {
         callback(err, null);
         return;
     }
     let stream:NodeJS.ReadableStream = createReadStream(filename);
     if (filename.substr(-'.gz'.length) === '.gz') {
         stream = stream.pipe(createGunzip());
     }
     callback(null, new NiftiStream(stream));
 });
开发者ID:Enet4,项目名称:nifti-stream,代码行数:11,代码来源:index.ts

示例7: resolve

	http.get({...requestOptions, headers: {'Accept-Encoding': 'compress, gzip', sig: type.getSignature()}}, res => {
		try {
			resolve(
				promisify(io.readValue)({type, inStream: res.pipe(zlib.createGunzip())})
					.then(value =>
						assert.deepEqual(value, responseValue)
					)
			)
		}
		catch (e) { reject(e) }
	})
开发者ID:calebsander,项目名称:structure-bytes,代码行数:11,代码来源:http-respond.ts

示例8: Buffer

 conn.query(q, args, (qerr, results) => {
     conn.release();
     if (qerr) {
         console.log('Error validating file id', qerr);
         return res.status(500).send({ Error: 'Internal Server Error' });
     }
     if (results.length < 1) {
         return res.status(404).send({ Error: 'No such file ID' });
     }
     const decipher = crypto.createDecipher('aes256', new Buffer(APP_CONFIG.storage_key, 'base64'));
     store.get(fileid).pipe(decipher).pipe(zlib.createGunzip()).pipe(res).once('close', () => res.end());
 });
开发者ID:TetuSecurity,项目名称:Crypt,代码行数:12,代码来源:files.ts

示例9: before

 before(function(done) {
   this.timeout(TIMEOUT);
   console.log(
     "Loading in complete array of postcodes (this might take a while)..."
   );
   const inputFile = resolve(__dirname, "./data/postcodes.csv.gz");
   createReadStream(inputFile)
     .pipe(createGunzip())
     .pipe(parse({ delimiter: "," }))
     .on("data", (data: CsvRecord) => testData.push(data[0]))
     .on("error", done)
     .on("end", done);
 });
开发者ID:ideal-postcodes,项目名称:postcode.js,代码行数:13,代码来源:exhaustive_unit.ts


注:本文中的zlib.createGunzip函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。