We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
finish
createWriteStream
1 parent 6fe0b5d commit 7818c4cCopy full SHA for 7818c4c
README.md
@@ -286,11 +286,13 @@ Make a write stream to append chunks as blocks.
286
``` js
287
const ws = core.createWriteStream()
288
289
+// Listen for stream finishing
290
+const done = new Promise(resolve => ws.on('finish', resolve))
291
+
292
for (const data of ['hello', 'world']) ws.write(data)
293
ws.end()
294
-// Wait for stream to finish
-await new Promise(resolve => ws.on('finish', resolve))
295
+await done
296
297
console.log(await core.get(core.length - 2)) // 'hello'
298
console.log(await core.get(core.length - 1)) // 'world'
0 commit comments