Skip to content

Commit ceb8a17

Browse files
authored
Merge pull request #47 from Sykander/develop
Release 1.0.2
2 parents d7dcdf3 + d44de7c commit ceb8a17

File tree

8 files changed

+60
-8
lines changed

8 files changed

+60
-8
lines changed

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ A collection of methods for looping iterable objects asynchronously using someth
99
$ npm install iterable-async
1010
```
1111

12+
## Objects
13+
14+
* Async Array
15+
16+
### Async Array
17+
18+
An Array class with additional async array methods.
19+
```
20+
class AsyncArray extends Array {...}
21+
```
22+
1223
## Methods
1324

1425
* Async Filter
@@ -21,14 +32,14 @@ $ npm install iterable-async
2132

2233
Filter an iterable object asynchronously
2334
```
24-
function asyncFilter(callback, [thisArg]) {...}
35+
async function asyncFilter(callback, [thisArg]) {...}
2536
```
2637

2738
### Async Find
2839

2940
Find an item in an iterable object asynchronously
3041
```
31-
function asyncFind(callback, [thisArg]) {...}
42+
async function asyncFind(callback, [thisArg]) {...}
3243
```
3344

3445
### Async Find Index
@@ -42,14 +53,14 @@ async function asyncFindIndex(callback, [thisArg]) {...}
4253

4354
Loop over an iterable object asynchronously
4455
```
45-
function asyncForEach(callback, [thisArg]) {...}
56+
async function asyncForEach(callback, [thisArg]) {...}
4657
```
4758

4859
### Async Map
4960

5061
Map an iterable object asynchronously
5162
```
52-
function asyncMap(callback, [thisArg]) {...}
63+
async function asyncMap(callback, [thisArg]) {...}
5364
```
5465

5566

docs/playground.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const {
2+
AsyncArray,
23
asyncFind,
34
asyncFindIndex,
45
asyncFilter,

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "iterable-async",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "A Collection of useful patterns.",
55
"main": "src",
66
"scripts": {
77
"test": "./node_modules/.bin/mocha test",
88
"lint:fix": "./node_modules/.bin/prettier --write 'src/**/*.{js,ts,css,html}' --write 'test/**/*.{js,ts,css,html}' --write 'docs/**/*.{js,ts,css,html}'",
9-
"lint:check": "./node_modules/.bin/eslint src test",
9+
"lint:check": "./node_modules/.bin/eslint src test && ./node_modules/.bin/eslint --no-eslintrc --env es6,node --rule 'no-unused-var: off' docs",
1010
"lint": "npm run lint:fix && npm run lint:check",
1111
"prepublishOnly": "npm run lint:check && npm test"
1212
},

src/async-array.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const asyncMap = require('./async-map'),
2+
asyncForEach = require('./async-for-each'),
3+
asyncFilter = require('./async-filter'),
4+
asyncFind = require('./async-find'),
5+
asyncFindIndex = require('./async-find-index');
6+
7+
/**
8+
* Create new constructor for Async Array
9+
* @type {AsyncArray}
10+
*/
11+
class AsyncArray extends Array {}
12+
13+
// Bind async methods
14+
(AsyncArray.prototype.asyncFind = asyncFind),
15+
(AsyncArray.prototype.asyncFindIndex = asyncFindIndex),
16+
(AsyncArray.prototype.asyncFilter = asyncFilter),
17+
(AsyncArray.prototype.asyncForEach = asyncForEach),
18+
(AsyncArray.prototype.asyncMap = asyncMap);
19+
20+
module.exports = AsyncArray;

src/async-for-each.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const { mapIterable } = require('./helpers'),
55
/**
66
* Async For Each
77
* Loop over an iterable object asynchronously and resolve when all callbacks are resolved
8-
* Will loop independently from order when callbacks are async
98
* @async
109
* @param {Function} callback - callback(currentValue, index, array)
1110
* @param {Object} [thisArg] - must be iterable

src/async-map.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const { mapIterable } = require('./helpers'),
55
/**
66
* Async Map
77
* Map an iterable object asynchronously and resolve when all callbacks are resolved
8-
* Will map independently from order when callbacks are async
98
* @async
109
* @param {Function} callback - callback(currentValue, index, array)
1110
* @param {Object} [thisArg] - must be iterable

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Complete collection of patterns
33
*/
44
module.exports = {
5+
AsyncArray: require('./async-array'),
56
asyncMap: require('./async-map'),
67
asyncForEach: require('./async-for-each'),
78
asyncFilter: require('./async-filter'),

test/async-array.spec.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const { expect } = require('./support/chai'),
2+
{ AsyncArray } = require('../src');
3+
4+
context('Async Array', () => {
5+
describe('Class attributes and properties', () => {
6+
it('Should inherit from Array', () =>
7+
expect(AsyncArray.prototype).to.be.instanceOf(Array));
8+
9+
it('Should have access asyncFilter method', () =>
10+
expect(AsyncArray.prototype.asyncFilter).to.be.a('function'));
11+
12+
it('Should have access asyncFind method', () =>
13+
expect(AsyncArray.prototype.asyncFind).to.be.a('function'));
14+
15+
it('Should have access asyncFindIndex method', () =>
16+
expect(AsyncArray.prototype.asyncFindIndex).to.be.a('function'));
17+
18+
it('Should have access asyncMap method', () =>
19+
expect(AsyncArray.prototype.asyncMap).to.be.a('function'));
20+
});
21+
});

0 commit comments

Comments
 (0)