Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including blue-iterate with all npm packages installed. Try it out:

import { parallelMap, map, collect } from 'blue-iterate' import got from 'got' const pokeGenerator = async function* () { let offset = 0 while(true) { const url = `https://pokeapi.co/api/v2/pokemon/?offset=${offset}` const { body: pokemon } = await got(url, { json: true }) if (pokemon.results.length > 0) { offset += pokemon.results.length for (const monster of pokemon.results) { yield monster } } else { return } } } const loadUrl = ({ url }) => got(url, { json: true }).then(resp => resp.body) const loadPages = parallelMap(2, loadUrl) const logMonsters = map(pokemon => console.log(pokemon.name, pokemon.sprites.front_default)) await collect(logMonsters(loadPages(pokeGenerator()))) console.log('caught them all')

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

blue-iterate v1.0.0

A collection of streams that work well with promises (through, map, reduce). Through2 with promise support

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free