0.2.0 • Published 7 years ago

promise.series v0.2.0

Weekly downloads
258,222
License
MIT
Repository
github
Last release
7 years ago

promise.series

NPM version NPM downloads Build Status

Run Promise in series.

Install

$ npm install --save promise.series

Usage

const promiseSeries = require('promise.series')

const sleep = timeout => {
  return new Promise(resolve => {
    setTimeout(() => {
      console.log(new Date())
      resolve()
    }, timeout)
  })
}

// each item returns a Promise
promiseSeries([
  () => sleep(1000),
  () => sleep(2000)
]).then(() => {
  console.log('Completed')
})

API

promiseSeries(tasks, initialValue)

tasks

Type: array

An array of functions which return a Promise.

initialValue

Pass an initial value to the promise chain, eg:

promiseSeries([
  value => asyncOperation().then(() => value * 2),
  value => asyncOperation().then(() => value * 2)
], 1).then(result => {
  console.log(res)
  //=> 4
})

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT © EGOIST

vuedragdropuploadimagesark-server-configcloud-archive-s3@olivervorasai/slidercogoportutils@infinitebrahmanuniverse/nolb-promise_@saaspe/componentsexpand-react-bridge@everything-registry/sub-chunk-2481p149-tabletest-popupslitepie-datepicker-gabenka-gantt-task-reactnebenan-rollup-plugin-postcssminify-all-jsminify-all-js-single-quotemavectra@reimages/open-next@remax/rollup-plugin-postcss@quarkd/rollup-plugin-postcss@plrthink/rollup-plugin-postcss@skeetboothppq/component-library@slater/rollup-plugin-postcss@rea-scripts/plugin@rikishi/rollup-plugin-postcss@sstlv/open-next@sweetliquidmetal/rollup-plugin-postcss@sak1sham/react-toc-highlight@terenyeung/poeditor.cli@vue-helper/vue-keep-alive@zhijianren/rollup-plugin-postcss@wernfried/minify-all-js@webbio/rollup-plugin-postcss-webbio@aristidenf/streak-counter@arkasuryawan/m2-interfaceappcharge-checkoutappcharge-checkout-reactjs-sdkap-vue-captcha@alfalab/rollup-plugin-postcss@axa-ch/midgard@axa-ch/generic-release@axa-ch/create-pod-app@bimbeo160/open-next@blendle/rollup-plugin-postcss@benjamin-vanryseghem/rollup-plugin-postcss@bung87/rollup-plugin-postcss@carbonorm/rollup-plugin-postcssemr-tabulator-tableses-react-bridgehantil-cssrollup-plugin-postcss-retain-sass-datagarnish-uiex-ikon-components-libraryreact-dottiereact-lightbox-pack-18supportopen-nextp147-tablep148-tablepara-scriptspoeditor-cipoeditorsequelcomponentset-ip-addressvenus-scripts@img-arena/img-ui-mui-theme@img-arena/ui-core@itayn-fireberry-org/itayn-test@ideffix/rollup-plugin-postcsstestenvue-button-test1type-libaryvue3-google-login-with-state@meck/rollup-plugin-postcss@jonaslideen/rollup-plugin-postcss@kommunicate/kommunicate-chatbot-plugin@moda/rollup-plugin-postcss@moebius/rollup-plugin-postcss@jlkiri/rollup-plugin-postcssxxawodax-rollup-plugin-postcss-umi@lukeed/rollup-plugin-postcss@nikolay_makhonin/rollup-plugin-postcssstories-react-bdresponsis-gantt-task-reactrollup-plugin-postcssrollup-plugin-postcss-customlesspackagerollup-plugin-postcss-fixrollup-plugin-postcss-hotrollup-plugin-postcss-independedrollup-plugin-postcss-sapperrollup-plugin-postcss-separaterollup-plugin-postcss-umirollup-plugin-postcss-with-hashrollup-plugin-postcss2rollup-plugin-postcss_sec-forkrollup-plugin-postcss-mirollup-plugin-postcss-miniapprollup-plugin-postcss-posturlrollup-plugin-sky-postcsss3up-client
0.2.0

7 years ago

0.1.0

8 years ago