mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-24 06:14:01 +08:00
- Preserve callable properties, descriptors, and shared module bindings across native JavaScript code. - Add stored process streams with input control, output callbacks, and write interception. - Preserve Error identity and classification through native rethrows and promise rejection.
21 lines
561 B
JavaScript
21 lines
561 B
JavaScript
const input = process.stdin;
|
|
const chunks = [];
|
|
function removed() { throw new Error('removed listener ran'); }
|
|
input.on('data', removed);
|
|
input.removeListener('data', removed);
|
|
input.on('data', function(chunk) {
|
|
chunks.push(String(chunk));
|
|
console.log('receiver', this === input);
|
|
input.pause();
|
|
setTimeout(() => input.resume(), 20);
|
|
});
|
|
input.on('end', function() {
|
|
console.log('end', this === input, chunks.join(''));
|
|
});
|
|
input.pause();
|
|
console.log('paused', input.isPaused());
|
|
setTimeout(() => {
|
|
console.log('resume');
|
|
input.resume();
|
|
}, 30);
|