Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F4401193
test_process_nexttick_bound_receiver.cjs
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
899 B
Referenced Files
None
Subscribers
None
test_process_nexttick_bound_receiver.cjs
View Options
async function main() {
const receiver = {
tag: 'receiver',
seen: [],
callback(arg) {
this.seen.push({ thisTag: this.tag, arg });
},
};
const bound = receiver.callback.bind(receiver);
process.nextTick(bound, 'queued');
await new Promise((resolve) => setTimeout(resolve, 0));
if (receiver.seen.length !== 1) {
throw new Error(`expected 1 callback invocation, got ${receiver.seen.length}`);
}
const [entry] = receiver.seen;
if (entry.thisTag !== 'receiver') {
throw new Error(`expected bound receiver, got ${JSON.stringify(entry.thisTag)}`);
}
if (entry.arg !== 'queued') {
throw new Error(`expected queued arg, got ${JSON.stringify(entry.arg)}`);
}
console.log('process.nextTick preserves bound receiver and queued args');
}
main().catch((err) => {
console.error(err && err.stack ? err.stack : String(err));
process.exit(1);
});
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Fri, May 1, 3:47 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
543018
Default Alt Text
test_process_nexttick_bound_receiver.cjs (899 B)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment