# array-walk

> Walks arrays like a boss!

Latest version **1.0.5** (published 2016-04-01) · SEE LICENSE IN LICENSE FOLDER license · 0 weekly downloads

## Install

```sh
npm install array-walk
pnpm add array-walk
yarn add array-walk
bun add array-walk
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2016-04-01 |
| First published | 2016-03-29 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE FOLDER |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | sn0w |
| Maintainers | sn0w |
| Keywords | array, traverse, walk, sn0w |

## Links

- npm: https://www.npmjs.com/package/array-walk
- Repository: https://github.com/sn0w/array-walk
- Homepage: https://github.com/sn0w/array-walk#readme
- Issues: https://github.com/sn0w/array-walk/issues
- npm.io page: https://npm.io/package/array-walk

## Dependencies (1)

- [paralleljs](https://npm.io/package/paralleljs.md) latest

## Recent versions

- 1.0.5 (latest) — 2016-04-01
- 1.0.4 — 2016-03-31
- 1.0.3 — 2016-03-31
- 1.0.2 — 2016-03-30
- 1.0.1 — 2016-03-29

## README

# array-walk
Walk arrays like a boss

## Installation
```
# Yep, it's that simple
npm i --save array-walk
```

## Usage

#### .chop(size, array) - CUT MY LIFE INTO PIECES!
```javascript
const array = require('array-walk');

let test = [1,2,3,4,5,6,7,8,9];
let pieces = array.chop(3, test) // Chop pieces with size 3 from array "test"
/* Result: [[1,2,3], [4,5,6], [7,8,9]]*/
```

#### .map(array, iteratee, callback) - Call a function on every item
Walks your array and calls `iteratee(currentItem, next)` on every item.

You **need** to call `next()` in your `iteratee` or the loop won't continue to the next item.

After all items are processed, the `callback()` is called (no arguments).

Pure synctastic awesomeness!
 
```javascript
const array = require('array-walk');

let test = [1,2,3,4,5,6,7,8,9];

array.map(test, (item, next) => {
  console.log(`The current item is ${item}!`);
  next(); //Proceed to next item
}, () => {
  // Callback that is called after all items are walked
  console.log('Done! :)')
});
```

#### .splay(count, array, iteratee, callback) - Works like .map() but in parallel
`.splay()` walks your array with `count` pseudo-threads.

Every "Thread" has it's own queue with the items it will process.

After all Threads finish their work, a final callback will be executed.

```javascript
let fs = require('fs');
let array = require('array-walk');

let test = [...BIG ARRAY WITH 100000 ITEMS...];

/*
This Example checks if the current item exists 
as a file with a maximum of 25 operations at a time
*/
array.splay(25, test, (item, next) => {
  fs.exists(item, (exists) => {
    console.log(exists ? `WOO! ${item} exists!` : `Nope. No ${item} here`);
    next();
  });
}, () => {
  console.log('All done!');
});
```

#### Do you like it?
If so, I'd be **very** happy if you tell your friends about this project or star the repo :)

---
_Source: https://npm.io/package/array-walk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
