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


TypeScript stream.Transform類代碼示例

本文整理匯總了TypeScript中stream.Transform的典型用法代碼示例。如果您正苦於以下問題:TypeScript Transform類的具體用法?TypeScript Transform怎麽用?TypeScript Transform使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Transform類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: checkFileForChanges

  public async checkFileForChanges(
    transform: Transform,
    file: File,
    enc: string,
    callback: (error: any, data: any) => any,
  ) {
    if (file.isNull()) {
      callback(null, null);
      return;
    }

    try {
      const changed = await this.hasFileOrDependenciesChanged(
        file,
        this.getOutputFileName(file.path),
      );

      if (changed) {
        transform.push(file);
      }
    } catch (error) {
      transform.emit(
        "error",
        new PluginError(
          MODULE_NAME,
          `Error processing \'${file.path}\': ${error}`,
        ),
      );
    } finally {
      callback(null, null);
    }
  }
開發者ID:bingnz,項目名稱:gulp-less-changed,代碼行數:32,代碼來源:main.ts

示例2: createStringStream

function createStringStream() {
    var s = new stream.Transform();
    s._transform = function (data, encoding, callback) {
        callback(null, data);
    };
    s.setEncoding("utf8");
    return s;
}
開發者ID:HardwareProjects,項目名稱:node-logger,代碼行數:8,代碼來源:logger-test.ts

示例3: createDecompressionStream

		static createDecompressionStream(): stream.Transform
		{
			var decompressor = new Decompressor();

			var NodeStream: typeof stream = require("stream");
			var decompressionStream = new NodeStream.Transform({ decodeStrings: true, highWaterMark: 65536 });

			decompressionStream._transform = (data: Buffer, encoding: string, done: Function) =>
			{
				var buffer = decompressor.decompressBlock(convertToByteArray(data));
				decompressionStream.push(buffer);

				done();
			}

			return decompressionStream;
		}
開發者ID:davidamir10,項目名稱:lzutf8.js,代碼行數:17,代碼來源:AsyncDecompressor.ts

示例4: createDecompressionStream

		static createDecompressionStream(): stream.Transform {
			const decompressor = new Decompressor();

			const NodeStream: typeof stream = require("stream");
			const decompressionStream = new NodeStream.Transform({ decodeStrings: true, highWaterMark: 65536 });

			decompressionStream._transform = (data: Buffer, encoding: string, done: Function) => {
				let buffer: Buffer;

				try {
					buffer = BufferTools.uint8ArrayToBuffer(decompressor.decompressBlock(BufferTools.bufferToUint8Array(data)));
				}
				catch (e) {
					decompressionStream.emit("error", e);
					return;
				}

				decompressionStream.push(buffer);

				done();
			}

			return decompressionStream;
		}
開發者ID:rotemdan,項目名稱:lzutf8.js,代碼行數:24,代碼來源:AsyncDecompressor.ts

示例5: StringifyStream

function StringifyStream() {
	stream.Transform.call(this);

	this._readableState.objectMode = false;
	this._writableState.objectMode = true;
}
開發者ID:spidgorny,項目名稱:umsaetze,代碼行數:6,代碼來源:runSpardaBank.ts

示例6: constructor

 constructor(options) {
   super(options);
   Transform.call(Inspector, Transform);
 }
開發者ID:TetuSecurity,項目名稱:Crypt,代碼行數:4,代碼來源:stream_inspector.ts

示例7: TimeoutError

		const handleRequest = (request: http.ClientRequest) => {
			if (shouldAbort) {
				request.abort();
				return;
			}

			currentRequest = request;

			request.on('error', error => {
				if (request.aborted || error.message === 'socket hang up') {
					return;
				}

				if (error instanceof TimedOutTimeoutError) {
					error = new TimeoutError(error, timings, options);
				} else {
					error = new RequestError(error, options);
				}

				if (emitter.retry(error) === false) {
					emitError(error);
				}
			});

			timings = timer(request);

			uploadProgress(request, emitter, uploadBodySize);

			if (options.gotTimeout) {
				// TODO: Properly type this. `preNormalizeArguments` coerces `gotTimeout` to `Delays`.
				timedOut(request, options.gotTimeout as Delays, options);
			}

			emitter.emit('request', request);

			const uploadComplete = () => {
				request.emit('upload-complete');
			};

			try {
				if (is.nodeStream(options.body)) {
					options.body.once('end', uploadComplete);
					options.body.pipe(request);
					options.body = undefined;
				} else if (options.body) {
					request.end(options.body, uploadComplete);
				} else if (input && (options.method === 'POST' || options.method === 'PUT' || options.method === 'PATCH')) {
					input.once('end', uploadComplete);
					input.pipe(request);
				} else {
					request.end(uploadComplete);
				}
			} catch (error) {
				emitError(new RequestError(error, options));
			}
		};
開發者ID:sindresorhus,項目名稱:got,代碼行數:56,代碼來源:request-as-event-emitter.ts

示例8:

			decompressionStream._transform = (data: Buffer, encoding: string, done: Function) => {
				let buffer: Buffer;

				try {
					buffer = BufferTools.uint8ArrayToBuffer(decompressor.decompressBlock(BufferTools.bufferToUint8Array(data)));
				}
				catch (e) {
					decompressionStream.emit("error", e);
					return;
				}

				decompressionStream.push(buffer);

				done();
			}
開發者ID:rotemdan,項目名稱:lzutf8.js,代碼行數:15,代碼來源:AsyncDecompressor.ts

示例9:

			decompressionStream._transform = (data: Buffer, encoding: string, done: Function) =>
			{
				var buffer = decompressor.decompressBlock(convertToByteArray(data));
				decompressionStream.push(buffer);

				done();
			}
開發者ID:davidamir10,項目名稱:lzutf8.js,代碼行數:7,代碼來源:AsyncDecompressor.ts


注:本文中的stream.Transform類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。