mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-02 07:43:42 +08:00
- TypedArray indexOf, lastIndexOf and includes on every element kind, typed
and checked-dynamic: strict equality (SameValueZero for includes) and
fromIndex as ToIntegerOrInfinity. A Buffer reached through a Uint8Array
value keeps Buffer's search.
- process.stdin 'readable' with read() and read(size), including sizes
above the read-ahead mark and input a once('readable') listener leaves
for a later 'data' listener. for await over process.stdin yields Buffers.
- Module bindings holding `new F()` of a constructor function can be read
and reassigned from other functions.
19 lines
467 B
JavaScript
19 lines
467 B
JavaScript
// Fixed-size reads of stdin: read(n) answers null until n bytes are
|
|
// buffered, and the rest once the input ended.
|
|
const input = process.stdin;
|
|
const chunks = [];
|
|
const counts = [];
|
|
input.on('readable', () => {
|
|
let reads = 0;
|
|
let chunk;
|
|
while ((chunk = input.read(4)) !== null) {
|
|
chunks.push(chunk.toString('ascii'));
|
|
reads++;
|
|
}
|
|
counts.push(reads);
|
|
});
|
|
input.on('end', () => {
|
|
console.log(chunks.join('|'));
|
|
console.log(counts.join(','));
|
|
});
|