tree-stream
Advanced tools
Comparing version 1.0.6 to 1.0.7
import { Duplex, Readable, Writable } from 'stream' | ||
export type Callback = (error?: Error) => void | ||
export type WritableStreamTreeFilter = (writable: WritableStreamTree) => Promise<boolean> | ||
@@ -21,4 +22,5 @@ export interface ReadableStreamTree { | ||
const writable: (stream: Writable) => WritableStreamTree | ||
const writer: (writeCallback: (w: Writable) => Promise<void>) => WritableStreamTreeFilter | ||
} | ||
export = StreamTree |
14
index.js
@@ -233,5 +233,19 @@ var once = require('once') | ||
var streamTreeWriter = function(writeCallback) { | ||
return async (writable) => { | ||
const error = await new Promise(async (resolve, reject) => { | ||
const stream = writable.finish((err) => { | ||
if (err) reject(err) | ||
else resolve() | ||
}) | ||
await writeCallback(stream) | ||
}) | ||
return !error | ||
} | ||
} | ||
module.exports = { | ||
readable: readableStreamTree, | ||
writable: writableStreamTree, | ||
writer: streamTreeWriter, | ||
} |
{ | ||
"name": "tree-stream", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"repository": "git://github.com/wholenews/tree-stream", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4
16093
8
337