Skip to content

Commit 8efef70

Browse files
authored
Merge pull request #92 from Sykander/develop
Object Release
2 parents 762beee + 56cb4ca commit 8efef70

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2595
-444
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
test/typings.js

.github/workflows/on-release.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: On Iterable Async new release
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
# Test Build
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v1
13+
- uses: actions/setup-node@v1
14+
with:
15+
node-version: 12
16+
- run: npm ci
17+
- run: npm test
18+
19+
# Publish to Node Package Registry
20+
publish-npm:
21+
needs: build
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v1
25+
- uses: actions/setup-node@v1
26+
with:
27+
node-version: 12
28+
registry-url: https://registry.npmjs.org/
29+
- run: npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
30+
- run: npm ci
31+
- run: npm publish
32+
env:
33+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
34+
35+
# Publish to Github Package Registry.
36+
publish-gpr:
37+
needs: build
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v1
41+
- uses: actions/setup-node@v1
42+
with:
43+
node-version: 12
44+
registry-url: https://npm.pkg.github.com/
45+
scope: '@your-github-username'
46+
- run: npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
47+
- run: npm ci
48+
- run: npm publish
49+
env:
50+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
node_modules
22
.env
33
.DS_Store
4+
.nyc_output
45
logs
6+
test/typings.js

.nycrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"branches": 80,
3+
"lines": 80,
4+
"functions": 80,
5+
"statements": 80
6+
}

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
test/typings.js

README.md

Lines changed: 38 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,68 @@
11
# Iterable Async Methods
22
[![Try iterable-async on RunKit](https://badge.runkitcdn.com/iterable-async.svg)](https://npm.runkit.com/iterable-async)
3+
[![Documentation](https://inch-ci.org/github/dwyl/hapi-auth-jwt2.svg?branch=master)](https://github.com/Sykander/iterable-async/wiki)
4+
[![Known Vulnerabilities](https://snyk.io/test/github/Sykander/iterable-async/badge.svg?targetFile=package.json)](https://snyk.io/test/github/Sykander/iterable-async?targetFile=package.json)
35

46
A collection of methods for looping iterable objects asynchronously using something similar to the Array api.
57

68
## Installation
79

810
```
9-
$ npm install iterable-async
11+
$ npm install iterable-async
1012
```
1113

12-
## Objects
14+
## Usage
1315

14-
* Async Array
16+
***ES6 Format***
1517

16-
### Async Array
17-
18-
An Array class with additional async array methods.
19-
```
20-
class AsyncArray extends Array {...}
21-
```
22-
23-
## Methods
24-
25-
* Async Filter
26-
* Async Find
27-
* Async Find Index
28-
* Async For Each
29-
* Async Map
30-
* Async Sort
31-
32-
### [Async Filter](https://github.com/Sykander/iterable-async/wiki/Async-Filter)
33-
34-
Filter an iterable object asynchronously
35-
```
36-
async function asyncFilter(callback, [thisArg]) {...}
18+
``` js
19+
const AsyncArray = require('iterable-async');
3720
```
3821

39-
### [Async Find](https://github.com/Sykander/iterable-async/wiki/Async-Find)
22+
***TypeScript Format***
4023

41-
Find an item in an iterable object asynchronously
42-
```
43-
async function asyncFind(callback, [thisArg]) {...}
44-
```
45-
46-
### [Async Find Index](https://github.com/Sykander/iterable-async/wiki/Async-Find-Index)
47-
48-
Find an item's index in an iterable object asynchronously
49-
```
50-
async function asyncFindIndex(callback, [thisArg]) {...}
24+
``` ts
25+
import * as AsyncArray from "iterable-async";
5126
```
5227

53-
### [Async For Each](https://github.com/Sykander/iterable-async/wiki/Async-For-Each)
28+
## Async Array
5429

55-
Loop over an iterable object asynchronously
56-
```
57-
async function asyncForEach(callback, [thisArg]) {...}
58-
```
30+
An Array class with additional async array methods.
5931

60-
### [Async Map](https://github.com/Sykander/iterable-async/wiki/Async-Map)
32+
### Methods
6133

62-
Map an iterable object asynchronously
63-
```
64-
async function asyncMap(callback, [thisArg]) {...}
65-
```
66-
67-
### [Async Sort](https://github.com/Sykander/iterable-async/wiki/Async-Sort)
68-
69-
Sort an iterable object asynchronously
70-
```
71-
async function asyncSort(callback) {...}
72-
```
34+
| Method | Description | Wiki |
35+
| -- | -- | -- |
36+
| **asyncFilter** | Filter an iterable object asynchronously. | [wiki](https://github.com/Sykander/iterable-async/wiki/Async-Filter) |
37+
| **asyncFind** | Find an item in an iterable object asynchronously | [wiki](https://github.com/Sykander/iterable-async/wiki/Async-Filter) |
38+
| **asyncFindIndex** | Find an item's index in an iterable object asynchronously | [wiki](https://github.com/Sykander/iterable-async/wiki/Async-Find-Index) |
39+
| **asyncForEach** | Loop over an iterable object asynchronously | [wiki](https://github.com/Sykander/iterable-async/wiki/Async-For-Each) |
40+
| **asyncMap** | Map an iterable object asynchronously | [wiki](https://github.com/Sykander/iterable-async/wiki/Async-Map) |
41+
| **asyncMapSort** | Map an iterable object asynchronously and then resolve when it's sorted, this method is much more efficient than running a regular `asyncSort` when done with a synchronous comparison function | [wiki](https://github.com/Sykander/iterable-async/wiki/Async-Map-Sort) |
42+
| **asyncSort** | Sort an iterable object asynchronously | [wiki](https://github.com/Sykander/iterable-async/wiki/Async-Sort) |
7343

7444
## Development
7545

7646
Development is open to contribution, check the project board "Development" for tickets.
7747

7848
### Scripts
7949

80-
```
81-
npm run lint
82-
# Lints the project and returns a report
83-
84-
npm run lint:check
85-
# Returns a report on lint issues in the project
86-
87-
npm run lint:fix
88-
# Fixes lint issues in the project and returns a report on the ones which couldn't be fixed
89-
90-
npm test
91-
# Runs all tests
50+
| Script | Description |
51+
|--|--|
52+
| lint | Lints the project and returns a report |
53+
| lint:check | Returns a report on lint issues in the project |
54+
| lint:fix | Fixes lint issues in the project and returns a report on the ones which couldn't be fixed |
55+
| test | Runs all tests and returns a report on which pass/fail |
56+
| test:unit-tests | Runs only unit tests and returns a report on which pass/fail |
57+
| test:code-style | Runs only code checks and returns a report on which pass/fail |
58+
| test:type-definitions | Attempts to compile and run a typescript file using this module |
59+
| test:coverage | Creates a testing coverage report and checks that testing meets minimum requirements |
60+
| test:coverage-report | Creates a testing coverage report |
61+
| test:coverage-check | Checks the last test coverage report to see if testing coverage meets the minimum requirements |
62+
63+
Eg. to run all lint tests
64+
```
65+
$ npm run lint
9266
```
9367

9468
### Commit Rules

docs/playground.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
const {
2-
AsyncArray,
3-
asyncFind,
4-
asyncFindIndex,
5-
asyncFilter,
6-
asyncForEach,
7-
asyncMap,
8-
asyncSort
9-
} = require('iterable-async');
1+
const AsyncArray = require('iterable-async'),
2+
faker = require('faker');
3+
4+
// Generate some fake users
5+
const users = [1, 2, 3, 4, 5].map(() => ({
6+
name: faker.name.findName(),
7+
email: faker.internet.email()
8+
}));
9+
10+
// Async Sort
11+
const sortedUsers = await AsyncArray.asyncSort(
12+
users,
13+
async ({ email: emailA }, { email: emailB }) =>
14+
await emailA.localeCompare(emailB)
15+
);
16+
17+
console.log('Asynchronously sorted users');
18+
console.table(sortedUsers);

0 commit comments

Comments
 (0)