async/await-ready array & collection utilities for Node.js
npm i @supercharge/collections
The package exports a function accepting an array as a parameter. From there, you can chain all collection methods.
The package is async/await-ready and supports async functions for most of the methods.
const User =const Collect =const users = awaitall// users = [ <list of newly-subscribed users> ]
Notice: when chaining methods like
filter, you'll receive a collection instance in return. You must actively end the call chain using the
.all() method to process the collection pipeline and retrieve the final result.
You can directly await the result for methods returning a definite value. The function returns a new instance of the collection without altering the original input array:
await// result: 600
Do you miss a collection function? We very much appreciate your contribution! Please send in a pull request 😊
- Create a fork
- Create your feature branch:
git checkout -b my-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request 🚀
MIT © Supercharge