本文整理匯總了TypeScript中stream.Transform.push方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Transform.push方法的具體用法?TypeScript Transform.push怎麽用?TypeScript Transform.push使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類stream.Transform
的用法示例。
在下文中一共展示了Transform.push方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
}
示例2:
decompressionStream._transform = (data: Buffer, encoding: string, done: Function) =>
{
var buffer = decompressor.decompressBlock(convertToByteArray(data));
decompressionStream.push(buffer);
done();
}
示例3: catch
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();
}