UNPKG

462 BJavaScriptView Raw
1import {fileURLToPath} from 'node:url';
2import {Transform} from 'node:stream';
3
4export const toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
5
6export class FilterStream extends Transform {
7 constructor(filter) {
8 super({
9 objectMode: true,
10 transform(data, encoding, callback) {
11 callback(undefined, filter(data) ? data : undefined);
12 },
13 });
14 }
15}
16
17export const isNegativePattern = pattern => pattern[0] === '!';