0.0.1 • Published 8 years ago

pull-from-promise v0.0.1

Weekly downloads
6,915
License
MIT
Repository
github
Last release
8 years ago

Pull stream from Promise

Convert a Promise into a pull stream source.

fromPromise(Promise <promise>[, Boolean <spread>])	-> PullStream

fromPromise(Promise <promise>)						-> PullStream
fromPromise(Promise(Array) <promise>, true)			-> PullStream

Call with true for the spread parameter and the promise will be expected to resolve to an array and each item be pushed to the pull stream.

var pull = require('pull-stream');
var formPromise = require('pull-from-promise');

pull(
	fromPromise(Promise.resolve('something')),
	pull.collect(function( err, array ){
		console.log(array);	// [ 'something' ]
	})
);
var pull = require('pull-stream');
var formPromise = require('pull-from-promise');

pull(
	fromPromise(Promise.resolve([ 1, 2, 3 ]), true),
	pull.collect(function( err, array ){
		console.log(array);	// [ 1, 2, 3 ]
	})
);