smarthash/ts/nodehash.helpers.ts

15 lines
364 B
TypeScript
Raw Permalink Normal View History

2022-06-26 09:34:09 +00:00
import * as plugins from './nodehash.plugins.js';
2016-08-16 01:37:40 +00:00
2022-06-26 09:37:07 +00:00
export const hashStreamPipeStop = (resolveFunctionArg: (inputArg: string) => any) => {
const forEach = (chunk: Buffer, enc: any, cb: any) => {
resolveFunctionArg(chunk.toString('utf8'));
cb(null, chunk);
};
2016-08-16 01:37:40 +00:00
2022-06-26 09:37:07 +00:00
const atEnd = (cb: any) => {
cb();
};
2016-08-16 01:37:40 +00:00
return plugins.through2(forEach, atEnd);
};