
Company News
Socket Joins the OpenJS Foundation
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.
co-stream-map
Advanced tools
Map a co stream over each chunk of another co stream.
Given a stream twice that emits strings and a stream
chars the emits a string's chars, map chars over twice:
var map = require('co-stream-map');
// a stream that emits `str` twice
function twice(str){
var i = 0;
return function*(end){
if (end) return;
if (++i <3) return str;
}
}
// a stream that emits `str` split up into chars
function chars(str){
return function*(end){
if (end) return;
var first = str[0];
str = str.slice(1);
return first;
}
}
var source = twice('bar');
var read = map(source, chars);
assert.equal('b', yield read());
assert.equal('a', yield read());
assert.equal('r', yield read());
assert.equal('b', yield read());
assert.equal('a', yield read());
assert.equal('r', yield read());
assert(!(yield read()));
For every chunk stream emits, call fn with that chunk and read from the
returned stream.
fn can be a Function or a GeneratorFunction.
Returns a readable stream.
$ npm install co-stream-map
MIT
FAQs
Map streams over streams
The npm package co-stream-map receives a total of 0 weekly downloads. As such, co-stream-map popularity was classified as not popular.
We found that co-stream-map 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.

Company News
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.

Security News
A compromised npm publish token was used to push a malicious postinstall script in cline@2.3.0, affecting the popular AI coding agent CLI with 90k weekly downloads.