UNPKG

1.2 kBMarkdownView Raw
1# each-arg
2
3Iterates through arguments or any other array-like object starting from specific index.
4
5## Install
6
7```bach
8npm i each-arg
9```
10
11## Usage
12
13##### syntax
14
15```typescript
16eachArg(arr, start, callback(value, index, ...extra): any, ...extra): void;
17```
18
19Iterates over the `array` or `array-like` `arr` starting from the `start` index. The `callback` function will be called for every `value` in the array, with the `value` itself, the `index` of the current item and any `extra` argument passed to `eachArg` function.
20
21Any `extra` argument passed to `eachArg` function will be passed down to the `callback` function.
22
23The `callback` function inherits the `this` value form the `eachArg` function call. If you need a specific value inside the `callback`, call `eachArg` using it's `call` method.
24
25```typescript
26eachArg.call(thisArg, arr, start, callback, ..extra);
27```
28
29##### example
30
31```javascript
32import eachArg from "each-arg";
33
34eachArg([1, 2, 3, 4, 5], 1, (value, index, num) => {
35 console.log(value + " >> " + (index + num));
36 return index === 3;
37}, 100);
38```
39
40```console
412 >> 101
423 >> 102
434 >> 103
44```
45
46## License
47
48[MIT](LICENSE) © [Manuel Fernández](https://github.com/manferlo81)