2.0.1 • Published 7 years ago

promise-you v2.0.1

Weekly downloads
7
License
ISC
Repository
-
Last release
7 years ago

promise-you - a extened wrapper of es6's Promise.then function

===========================

Install with:

npm install --save promise-you

Usage Example

  • overwrite .then by default
const PromiseYou = require('../')

new Promise((resolve, reject) => {
  resolve(1)
})
.then((arg, you) => {
  // with argument 'you', it's wrapped in another Promise
  // must call 'you.resolve' to be continued
  console.log(arg, you)
  you.test = 1

  setTimeout(() => you.resolve(2), 1000)
})
.then((arg, you) => {
  // or return a new Promise to be continued
  console.log(arg, you)

  return Promise.resolve(3)
})
.then((arg) => {
  // without argument 'you', it's like in a normal 'then'
  console.log(arg)
})
.then((arg, you) => {
  // also can call 'you.reject'
  console.log(arg, you)
  you.reject(4)
})
.catch((err, you) => {
  // after catch, we can resolve again
  console.log(err, you)
  you.resolve(5)
})
.then((arg, you) => {
  // read all 'arg' values in 'you.args' array
  console.log('end', you.args)
})
2.0.1

7 years ago

2.0.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago