
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
ansi-stream
Advanced tools
Converts a text stream to a stream of strings and `EscapeCode` objects
Converts a text stream to a stream of strings and EscapeCode
objects
var ansiStream = require('ansi-stream');
var EscapeCode = ansiStream.EscapeCode;
stream = ansiStream();
stream.write('\x1b[31mabc\x1b[39m');
stream.end();
assert.deepEqual(
stream.read(),
new EscapeCode('\x1b[31m')
);
assert.strictEqual(
stream.read(),
'abc'
);
assert.deepEqual(
stream.read(),
new EscapeCode('\x1b[39m')
);
Creates a new stream instance, with an optional buffer size.
Optional
Type: number
Handles the (rare) case where an escape code sequence might span two chunks.
If it does not detect a complete escape code in the chunk, but there is a
control character (\u001b
, or \u009b
), it will buffer up to maxBuffer
characters
until the next chunk.
If you are sure that your input will NOT split escape code sequences across chunks, you can set this to zero for improved performance.
Can be used by streams further down the chain to discover if a given chunk is an EscapeCode or not. See escape-code for more details.
stream.on('data', function(chunk) {
if (chunk instanceof ansiStream.EscapeCode) {
// process the escape code
} else {
// process a chunk of plain old text.
}
});
MIT © James Talmage
FAQs
Converts a text stream to a stream of strings and `EscapeCode` objects
The npm package ansi-stream receives a total of 0 weekly downloads. As such, ansi-stream popularity was classified as not popular.
We found that ansi-stream demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.