MCPcopy Create free account
hub / github.com/nodejs/node / testOndrain

Function testOndrain

test/parallel/test-stream-iter-push-writer.js:8–20  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6const { push, ondrain, text } = require('stream/iter');
7
8async function testOndrain() {
9 const { writer } = push({ highWaterMark: 1 });
10
11 // With space available, ondrain resolves immediately
12 const drainResult = ondrain(writer);
13 assert.ok(drainResult instanceof Promise);
14 const result = await drainResult;
15 assert.strictEqual(result, true);
16
17 // After close, ondrain returns null
18 writer.end();
19 assert.strictEqual(ondrain(writer), null);
20}
21
22async function testOndrainNonDrainable() {
23 // Non-drainable objects return null

Callers 1

Calls 4

pushFunction · 0.70
ondrainFunction · 0.70
okMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected