Skip to content

queckezz/pull-promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pull-promise

Pull the value from a promise using pull-streams

build status npm version dependency status license code style: standard

Installation

$ npm install pull-promise

Example

const toPull = require('pull-promise')
const pull = require('pull-stream')
const axios = require('axios')

pull(
  toPull.source(axios.get('http://example.org/posts/1')),
  pull.map((response) => response.body),
  pull.log()
)
// -> "quia et suscipit\nsuscipit recusandae..."

API

.source(Promise)

Also available as require('pull-promise/source')

Creates a source stream with the resolved promise value.

const toPull = require('pull-promise')

pull(
  toPull.source(Promise.resolve(5)),
  pull.log()
)
// -> 5

.through((v) => Promise)

Also available as require('pull-promise/through')

Creates a through stream with the resolved promise value as output. fn is a function accepting the incoming value and returning a Promise.

const toPull = require('pull-promise')

pull(
  pull.values([2, 4, 8]),
  toPull.through((v) => Promise.resolve(v * v)),
  pull.log()
)
// -> 4, 16, 64

Run tests

$ npm test 

License

MIT

About

Pull the value from a promise using pull-streams

Resources

License

Stars

Watchers

Forks

Packages

No packages published