Git Product home page Git Product logo

tunnckocore / each-promise Goto Github PK

View Code? Open in Web Editor NEW
27.0 3.0 1.0 553 KB

:cyclone: Asynchronous control flow library for now and then. :sparkles: Iterate over promises, promise-returning or async/await functions in series or parallel. Works on node 0.10 if you give it a Promise.

License: MIT License

JavaScript 100.00%
promises async control control-flow each parallel concurrent series serial concurrency

each-promise's Introduction

I'm Charlike! πŸ‘‹

Software Engineer for a decade, with a passion for minimalism and music. Delivering delightful digital solutions, marketing, and consultancy. Currently excited even more about decentralized software and protocols, P2P, cryptocurrencies, and Rust.

I'm actively using Web technologies to create delightful digital experiences for the Web, Desktop, Mobile, and the Terminal. I'm helping other developers to build amazing software, apps, and products by making better and smarter developer experiences.

In the past 7 years, I'm writing daily a lot of Free and Open Source software, contributing to other projects, tweeting from @tunnckoCore about interesting ones or sharing some of my thoughts.

I'm not just open-sourcing some random stuff by and for me. I've participated in a number of small and big projects like @JSTransformers, @date-fns, the @Conventional-Commits specification & @Conventional-Changelog, @Node-Formidable (lead maintainer and contributor) which is also part of the growing @Tidelift network, @MicroJS (non-active currently). And also started other projects like @DateTime & @RegexHQ, where we collaborate and maintain date & time utilities and regular expressions, with some of the biggest names in the (JavaScript) Open Source world - @johno, @jonschlinkert, @sindresorhus, @AddyOsmani, @MathiasBynens, Tom Byrer and more. The organizations are not that active, but in general they are stable small packages and not that bad.

Combined, my software has ~140 million downloads per month, growing at a fast pace, and is used by some small and big projects & companies like

...and many more. It's just hard to track or at least takes a lot of time.

You can always dig in at my account charts on Npm-Stat.com (takes time to load). Or the ever-pumping charts of formidable.

As of March 27, 2024, it grown to 5.8 billion total downloads, and 125 million per month.
image

As of March 1, 2023, it grown to 4.392 billion total downloads, and 140 million per month.
image

As of June 1, 2022, it grown to 3.439 billion total downloads, and 120 million per month.
image

As of August 2021, it grown to 2.4 billion total downloads, and 110 million per month.
image

As of November 18, 2020

Love and Support

  • For smaller recurring or one-time donations, check https://ko-fi.com/tunnckoCore
  • For crypto lovers - tunnckocore.eth is my ENS and accepts BTC, ETH, DOGE, LTC
  • If ENS domains is not supported by your wallet:
    • BTC bc1qdfe7najz9wg9hrl0heaze8k3v9vqvewf846ct8
    • LTC LdKg5ubACw8dGb8ZieFwfEReyLg4frw9bc
    • DOGE DEhgA3xDN5CohxDMnzFdq78WHhJYYrVoC5
    • ETH, WBTC, ERC20, & NFTs 0xA20C07F94A127fD76E61fbeA1019cCe759225002
  • Contact me at Twitter, or via email dev at tunnckocore.com
  • Half of each GitHub donation will go to other people and causes
    • (you will get monthly info about me and my donations)

Github Stats

each-promise's People

Contributors

greenkeeper[bot] avatar greenkeeperio-bot avatar tunnckocore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

each-promise's Issues

An in-range update of redolent is breaking the build 🚨

Version 2.0.4 of redolent just got published.

Branch Build failing 🚨
Dependency redolent
Current Version 2.0.3
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

As redolent is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • βœ… ci/circleci Your tests passed on CircleCI! Details

  • βœ… continuous-integration/travis-ci/push The Travis CI build passed Details

  • ❌ continuous-integration/appveyor/branch AppVeyor build failed Details

Commits

The new version differs by 4 commits .

  • 05d8745 chore(release): 2.0.4
  • 3577762 fix(ci): appveyor-retry
  • 181f41b fix(tweak): tests
  • 631823a fix(return): handle when done is present, but return promise

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of nyc is breaking the build 🚨

Version 10.2.0 of nyc just got published.

Branch Build failing 🚨
Dependency nyc
Current Version 10.1.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As nyc is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details

  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Commits

The new version differs by 6 commits .

  • 455619f chore(release): 10.2.0
  • 95cc09a feat: upgrade to version of yargs with extend support (#541)
  • 43535f9 chore: explicit update of istanbuljs dependencies (#535)
  • 98ebdff feat: allow babel cache to be enabled (#517)
  • 50adde4 feat: exclude the coverage/ folder by default πŸš€ (#502)
  • 6a59834 chore(package): update tap to version 10.0.0 (#507)

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

example backup

// var foo = 'initial'
// var arr = [
//   function one () {
//     return delay(200).then(() => {
//       // console.log(11)
//       return 123
//     })
//   },
//   Promise.resolve('foobar'),
//   function two () {
//     return delay(1500).then(() => {
//       // console.log(22)
//       foo += '~third'
//       return 345
//     })
//   },
//   delay(10).then(() => 'zero'),
//   function three () {
//     return delay(400).then(() => {
//       // console.log(33, foo)
//       coffffnsole.log(3) // eslint-disable-line no-undef
//       return 567
//     })
//   },
//   'abc',
//   function four () {
//     return delay(250).then(() => {
//       console.log(44)
//       return 789
//     })
//   },
//   function five () {
//     return delay(100).then(() => {
//       sasasa // eslint-disable-line no-undef
//       // console.log(55)
//       return 444
//     })
//   },
//   function six () {
//     return delay(80).then(() => {
//       console.log(66)
//       return 'last'
//     })
//   }
// ]

// // .serial/.series:
// // - works correctly
// // .parallel:
// // - ?? (not sure) bug when `settle: false` and `concurrency < arr.length`
// //
// var settle = false
// each.parallel(arr/*, function mapper (item, index) {
//   console.log(item, index)
// } */, {
//   concurrency: 5,
//   settle: settle,
//   start: function () {
//     console.log('start')
//     console.log('====')
//   },
//   finish: function (err, res) {
//     console.log('====')
//     console.log('finish')
//     if (err) console.log('err:', err)
//     console.log('res:', res, res.length)
//   },
//   beforeEach: function (item, index) {
//     if (index === 2) foo += '~beforeEach'
//     if (index === 3) foo = 'reset'
//     console.log('beforeEach', index)
//   },
//   afterEach: function (item, index) {
//     if (item.reason) {
//       console.log('error', index, item.reason)
//     }
//     if (index === 3) foo = 'reset'
//     console.log('afterEach', index, foo === 'initial~beforeEach~third')
//   }
// })
// .then(function (res) {
//   console.log('ok')
// })
// .catch(function (er) {
//   console.log('fail')
//   if (settle === false) process.exit(0)
// })

use try-catch-core?

utils.iterator = function iterator (arr, results) {
  return function (options, resolve, reject) {
    return function next (index) {
      if (index >= arr.length) {
        return
      }

      var item = arr[index]
      options.beforeEach({ value: item, index: index }, index, arr)

      // changed
      var promise = null

      if (typeof item === 'function') {
        promise = options.Promise(function (resolve, reject) {
          utils.tryCatchCore(item, options, function (err, res) {
            if (err) {
              return reject(err)
            }
            if (res instanceof Error) {
              return reject(res)
            }
            resolve(res)
          })
        })
      } else {
        promise = item instanceof Error
          ? options.Promise.reject(item)
          : options.Promise.resolve(item)
      }
      // changed

      var handle = utils.handleResults({
        arr: arr,
        index: index,
        results: results
      }, options)

      promise
        .then(handle('value'), handle('reason'))
        .then(function onresolved () {
          if (arr.doneCount++ === arr.length - 1) {
            options.finish(null, results)
            resolve(results)
            return
          }
          next(index + options.concurrency)
        }, function onrejected (err) {
          if (options.settle === false) {
            options.finish(err, results)
            reject(err)
            return
          }
        })
    }
  }
}

An in-range update of nyc is breaking the build 🚨

Version 11.0.3 of nyc just got published.

Branch Build failing 🚨
Dependency nyc
Current Version 11.0.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As nyc is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • βœ… ci/circleci Your tests passed on CircleCI! Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details
  • ❌ continuous-integration/appveyor/branch AppVeyor build failed Details

Commits

The new version differs by 4 commits.

  • e9fad9f docs: add note about tap-nyc to README (#614)
  • f86b0b1 chore(release): 11.0.3
  • 923b062 fix: upgrade to spawn-wrap version that works with babel-register (#617)
  • b1eb4d6 fix: update help link to list of reporters (#601)

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Consider how to handle if some is not finished

It even not calls finish hook when in serial mode.

Say you have 5 functions in array. Say the 3rd one is using cb to be considered done and others returns promises, so when this cb isn't called next functions in the stack is not called too

var arr = [
  () => delay(900).then(() => 1),
  () => delay(620).then(() => 2),
  function sasa (cb) {
    // cb()
  },
  () => delay(400).then(() => 4),
  () => delay(700).then(() => 5),
]

maybe it can be fixed in https://github.com/hybridables/try-catch-callback

An in-range update of redolent is breaking the build 🚨

Version 2.0.2 of redolent just got published.

Branch Build failing 🚨
Dependency redolent
Current Version 2.0.1
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

As redolent is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details

  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 3 commits .

  • c5152d2 chore(release): 2.0.2
  • 56e97a4 fix(docs): update docs
  • b3edc4e fix(deps): switch to use "native-or-another"

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Improve one test: parallel + settle:false

It's not correct. It no matter that .catch is called. In parallel mode, currently, "fail fast" more means "call .catch when fail-fast, otherwise don't call .catch, but always then()", instead of "stop executing the other tests after the first error"

An in-range update of redolent is breaking the build 🚨

Version 2.0.5 of redolent just got published.

Branch Build failing 🚨
Dependency redolent
Current Version 2.0.4
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

As redolent is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • βœ… ci/circleci Your tests passed on CircleCI! Details

  • βœ… continuous-integration/travis-ci/push The Travis CI build passed Details

  • ❌ continuous-integration/appveyor/branch AppVeyor build failed Details

Commits

The new version differs by 5 commits .

  • 59fd760 chore(release): 2.0.5
  • 54ac357 fix(ci): add CircleCI yaml
  • b390b23 fix(services): add .eslintrc instead, so CodeClimate will respect it
  • 074a728 fix(deps): update deps, add eslintConfig field
  • 67ae2b6 fix(returns): should return rejected error when non Promise value

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

finish hook not called when settle: false and has failing item

nah, probably because https://github.com/tunnckoCore/each-promise/blob/master/utils.js#L73 is instabul ignored and not test, heh.

WHOAAH!! Found and fixed locally!

      function onFulfilled () {
        if (arr.doneCount++ === arr.length - 1) {
          options.finish(null, results)
          resolve(results)
          return
        }
        next(index + options.concurrency)
      }

      function onRejected (err) {
        if (options.settle === false) {
          options.finish(err, results)
          reject(err)
        }
      }

      promise
        .then(handle('value'), handle('reason'))
        .catch(onRejected) // this mate here
        .then(onFulfilled, onRejected)
        .catch(onRejected)

An in-range update of redolent is breaking the build 🚨

Version 2.0.3 of redolent just got published.

Branch Build failing 🚨
Dependency redolent
Current Version 2.0.2
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

As redolent is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details

  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Commits

The new version differs by 2 commits .

  • 229bbf2 chore(release): 2.0.3
  • c465abe fix(deps): dont resolve "native-or-another" and ES6-ify

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.