Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/supercharge/arrays
Array utilities for Node.js
https://github.com/supercharge/arrays
array hacktoberfest nodejs supercharge utilities
Last synced: 9 days ago
JSON representation
Array utilities for Node.js
- Host: GitHub
- URL: https://github.com/supercharge/arrays
- Owner: supercharge
- License: mit
- Created: 2020-10-17T18:31:33.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-10T13:56:04.000Z (10 days ago)
- Last Synced: 2024-11-10T14:36:04.088Z (10 days ago)
- Topics: array, hacktoberfest, nodejs, supercharge, utilities
- Language: JavaScript
- Homepage: https://superchargejs.com/docs/arrays
- Size: 56.6 KB
- Stars: 4
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Arrays
Array utilities for JavaScript and Node.js
Installation ·
Docs ·
Usage
Follow @marcuspoehls and @superchargejs for updates!
---
## Introduction
The `@supercharge/arrays` package provides chainable array utilities for Node.js and JavaScript. It’s a wrapper around JavaScript arrays providing useful methods like `.isEmpty()`, `.length()`, `.flatMap()`, `.contains()`, and many more.## Installation
```
npm i @supercharge/arrays
```## Docs
Find all the [details for `@supercharge/arrays` in the extensive Supercharge docs](https://superchargejs.com/docs/arrays).## Usage
Using `@supercharge/arrays` is pretty straightforward. The package exports a function wrapping an array or individual items as an argument. You can then fluently chain methods interacting with your data:```js
const { Arr } = require('@supercharge/arrays')const users = Arr.from([])
users.isEmpty()
// trueusers
.push({ id: 1, name: 'Marcus' })
.push({ id: 2, name: 'Norman' })
.push({ id: 3, name: 'Christian' })users.isNotEmpty()
// trueusers.length()
// 3const usernamesArray = users
.map(user => user.name)
.toArray()
// [ 'Marcus', 'Norman', 'Christian' ]const marcus = users.find(user => {
return user.name === 'Marcus'
})
// { id: 1, name: 'Marcus' }
```Every method in the chain returns a `@supercharge/array` instance. This way, you can chain further methods without leaving the fluent interface. Call `.all()` to retrieve the plain JavaScript array.
## Contributing
Do you miss a function? We very much appreciate your contribution! Please send in a pull request 😊1. Create a fork
2. Create your feature branch: `git checkout -b my-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 🚀## License
MIT © [Supercharge](https://superchargejs.com)---
> [superchargejs.com](https://superchargejs.com) ·
> GitHub [@supercharge](https://github.com/supercharge) ·
> Twitter [@superchargejs](https://twitter.com/superchargejs)