mirror of
https://github.com/nodejs/node.git
synced 2025-05-01 08:42:45 +00:00

Experimental implementation of the WHATWG streams standard. Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: https://github.com/nodejs/node/pull/39062 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
71 lines
1.5 KiB
JavaScript
71 lines
1.5 KiB
JavaScript
// Flags: --no-warnings --expose-internals
|
|
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const {
|
|
ByteLengthQueuingStrategy,
|
|
CountQueuingStrategy,
|
|
} = require('stream/web');
|
|
|
|
const {
|
|
inspect,
|
|
} = require('util');
|
|
|
|
const {
|
|
isPromisePending,
|
|
} = require('internal/webstreams/util');
|
|
|
|
const assert = require('assert');
|
|
|
|
assert(!isPromisePending({}));
|
|
assert(!isPromisePending(Promise.resolve()));
|
|
assert(isPromisePending(new Promise(() => {})));
|
|
|
|
// Brand checking works
|
|
assert.throws(() => {
|
|
Reflect.get(ByteLengthQueuingStrategy.prototype, 'highWaterMark', {});
|
|
}, {
|
|
code: 'ERR_INVALID_THIS'
|
|
});
|
|
|
|
assert.throws(() => {
|
|
Reflect.get(ByteLengthQueuingStrategy.prototype, 'size', {});
|
|
}, {
|
|
code: 'ERR_INVALID_THIS'
|
|
});
|
|
|
|
assert.throws(() => {
|
|
Reflect.get(CountQueuingStrategy.prototype, 'highWaterMark', {});
|
|
}, {
|
|
code: 'ERR_INVALID_THIS'
|
|
});
|
|
|
|
assert.throws(() => {
|
|
Reflect.get(CountQueuingStrategy.prototype, 'size', {});
|
|
}, {
|
|
code: 'ERR_INVALID_THIS'
|
|
});
|
|
|
|
// Custom Inspect Works
|
|
|
|
{
|
|
const strategy = new CountQueuingStrategy({ highWaterMark: 1 });
|
|
|
|
assert.strictEqual(
|
|
inspect(strategy, { depth: null }),
|
|
'CountQueuingStrategy { highWaterMark: 1 }');
|
|
|
|
assert.strictEqual(
|
|
inspect(strategy),
|
|
'CountQueuingStrategy { highWaterMark: 1 }');
|
|
|
|
assert.strictEqual(
|
|
inspect(strategy, { depth: 0 }),
|
|
'CountQueuingStrategy [Object]');
|
|
|
|
assert.strictEqual(
|
|
inspect(new ByteLengthQueuingStrategy({ highWaterMark: 1 })),
|
|
'ByteLengthQueuingStrategy { highWaterMark: 1 }');
|
|
}
|