
Product
Introducing Rust Support in Socket
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
stream-mock
Advanced tools
Mock nodejs streams.
yarn add stream-mock
Or, if you are more a npm
person
npm i stream-mock
You are building an awesome brand new Transform stream that rounds all your values.
import { Transform } from 'stream';
export default class Rounder extends Transform {
_transform(chunk, encoding, callback) {
this.push(Math.round(chunk));
callback();
}
}
Now you need / want to test it.
import {ObjectReadableMock, ObjectWritableMock, DuplexMock } from 'stream-mock';
import chai from 'chai';
import Rounder from 'the/seven/bloody/hells';
chai.should();
describe('Test me if you can', (done) => {
it('Round me like one of your french girls', {
// Given
const input = [1.2, 2.6, 3.7];
const transform = new Rounder({objectMode: true});
const reader = new ObjectReadableMock(input);
const writer = new ObjectWritableMock();
// When
reader.pipe(transform).pipe(writer);
// Then
writer.on('finish', ()=>{
writer.data.should.deep.equal(input.map(Math.round));
})
});
});
Full API doc is hosted here
stream-mock is currently on early stage. I'm happily receiving new PR or discussing about new features, improvement or bug report. If you need something that this module is lacking (related to Nodejs stream mock obviously), do not hesitate to raise an issue.
To run test :
yarn run test
Linter is run on commit hook base.
MIT
[2.0.2] - 2019-04-13
FAQs
Node stream mock module
The npm package stream-mock receives a total of 46,526 weekly downloads. As such, stream-mock popularity was classified as popular.
We found that stream-mock 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.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.