本文整理汇总了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();
}