
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
callback2stream
Advanced tools
Transform sync, async or generator function to Stream. Correctly handle errors and optional arguments.
Transform sync, async or generator function to Stream. Correctly handle errors and optional arguments.
npm i callback2stream --save
For more use-cases see the tests
const callback2stream = require('callback2stream')
Create a stream from sync, async or generator function.
Params
fn
{Function}: Any kind of function.opts
{Object}: Directly passed to through2 from promise2stream.returns
{Function}: That when executed, returns transform stream, coming from promise2stream, using through2.Example
var fs = require('fs')
var cb2stream = require('callback2stream')
var readFileStream = cb2stream(fs.readFile)
var stream = readFileStream('package.json', 'utf8')
stream
.on('data', function (val) {
var json = JSON.parse(val)
console.log(json.name) // => 'callback2stream'
})
.once('error', console.error)
.once('end', function () {
console.log('reading finished')
})
// you also have access to the
// contents with promise
stream.promise
.then(JSON.parse, console.error)
.then(function (val) {
console.log(val.name) // => 'callback2stream'
}, console.error)
.catch(console.error)
co@4
(passing 100% tests), but… more | homepagePull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.
1.0.1 - 2016-05-06
value2stream
FAQs
Transform sync, async or generator function to Stream. Correctly handle errors and optional arguments.
The npm package callback2stream receives a total of 10 weekly downloads. As such, callback2stream popularity was classified as not popular.
We found that callback2stream 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.