-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 📝 Badge for Travis CI is corrected - 🔨 Build script is optimized - 🚸 Example code is added - 💚 Github Action for CI - ⬆️ Packages for development are updated - `@types/node` is upgraded from 16.7.1 to 16.7.8 - `@typescript-eslint/eslint-plugin` is upgraded from 4.29.2 to 4.30.0 - `@typescript-eslint/parser` is upgraded from 4.29.2 to 4.30.0 - `mocha` is upgraded from 9.1.0 to 9.1.1 - `terser` is upgraded from 5.7.1 to 5.7.2 - `typescript` is upgraded from 4.3.5 to 4.4.2 - 📝 README is updated - Badges for both CI and coverage are added - Installation section is added - Usage section is added - 💚 Travis CI - Node.js v15.x is excepted from test target - Only 'main' branch is made to be tested Signed-off-by: kei-g <km.8k6ce+github@gmail.com>
- Loading branch information
Showing
16 changed files
with
216 additions
and
39 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: test | ||
on: | ||
push: | ||
branches: [ main ] | ||
jobs: | ||
npm-test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node: [ '14.17.5', '16.8.0' ] | ||
name: Test on Node.js ${{ matrix.node }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
- name: Setup modules | ||
run: npm i | ||
- name: Test | ||
run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
**/*.d.ts | ||
**/*.js | ||
**/.nyc_output/ | ||
**/.vscode/ | ||
**/build/ | ||
**/coverage/ | ||
**/lib/*.js | ||
**/lib/*.ts | ||
**/lib/ | ||
**/node_modules/ | ||
**/package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
**/*.ts | ||
**/.editorconfig | ||
**/.eslintrc.json | ||
**/.github/ | ||
**/.mocharc.json | ||
**/.nycrc.json | ||
**/.travis.yml | ||
**/CODE_OF_CONDUCT.md | ||
**/build/ | ||
**/example.ts | ||
**/src/ | ||
**/test/ | ||
**/tsconfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"all": true, | ||
"branches": 100, | ||
"check-coverage": true, | ||
"exclude": [ | ||
"**/*.spec.ts", | ||
"**/index.ts" | ||
], | ||
"extension": [ | ||
".ts" | ||
], | ||
"functions": 100, | ||
"include": [ | ||
"**/*.ts" | ||
], | ||
"lines": 100, | ||
"reporter": [ | ||
"html", | ||
"text" | ||
], | ||
"statements": 100, | ||
"watermarks": { | ||
"branches": [80, 95], | ||
"functions": [80, 95], | ||
"lines": [80, 95], | ||
"statements": [80, 95] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,76 @@ | ||
# async-iterable-queue [![License][license-image]][license-url] [![Dependency][depencency-image]][dependency-url] [![Travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] | ||
# async-iterable-queue [![License][license-image]][license-url] [![Dependency][depencency-image]][dependency-url] [![GitHub][github-test-image]][github-url] [![Travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] | ||
|
||
[![maintenance][maintenance-image]][npmsio-url] [![quality][quality-image]][npmsio-url] | ||
[![coverage][nyc-cov-image]][github-url] [![maintenance][maintenance-image]][npmsio-url] [![quality][quality-image]][npmsio-url] | ||
|
||
Async Iterable Queue | ||
`async-iterable-queue` - A library for 'Queue' class which implements AsyncIterable\<T\> works on [Node.js](https://nodejs.org/) | ||
|
||
## Installation | ||
|
||
```shell | ||
npm i async-iterable-queue | ||
``` | ||
|
||
## Usage | ||
|
||
```typescript | ||
import { AsyncIterableQueue } from 'async-iterable-queue' | ||
|
||
type Foo = { | ||
id: number | ||
name: string | ||
} | ||
|
||
async function example1(queue: AsyncIterableQueue<Foo>): Promise<void> { | ||
console.debug('pushing 123') | ||
await queue.push({ | ||
id: 123, | ||
name: 'foo', | ||
}) | ||
console.debug('123 has been pushed') | ||
await queue.push({ | ||
id: 456, | ||
name: 'bar', | ||
}) | ||
console.debug('456 has been pushed') | ||
await queue.push({ | ||
id: 789, | ||
name: 'baz', | ||
}) | ||
console.debug('789 has been pushed') | ||
await queue.end() | ||
console.debug('\'end\' has been pushed') | ||
} | ||
|
||
async function example2(queue: AsyncIterableQueue<Foo>): Promise<void> { | ||
for await (const value of queue) | ||
console.debug(value) | ||
console.debug('all elements have been popped from queue') | ||
} | ||
|
||
async function example(): Promise<void> { | ||
console.debug('example for AsyncIterableQueue has begun') | ||
const queue = new AsyncIterableQueue<Foo>() | ||
await Promise.all([ | ||
example1(queue), | ||
example2(queue), | ||
]) | ||
console.debug('example for AsyncIterableQueue has finished') | ||
} | ||
|
||
example() | ||
``` | ||
|
||
[depencency-image]:https://img.shields.io/librariesio/release/npm/async-iterable-queue?logo=nodedotjs | ||
[dependency-url]:https://npmjs.com/package/async-iterable-queue?activeTab=dependencies | ||
[github-test-image]:https://img.shields.io/github/workflow/status/kei-g/async-iterable-queue/test/main?label=build%20%26%20test&logo=github | ||
[github-url]:https://github.com/kei-g/async-iterable-queue | ||
[license-image]:https://img.shields.io/github/license/kei-g/async-iterable-queue | ||
[license-url]:https://opensource.org/licenses/BSD-3-Clause | ||
[maintenance-image]:https://img.shields.io/npms-io/maintenance-score/async-iterable-queue?logo=npm | ||
[npm-image]:https://img.shields.io/npm/v/async-iterable-queue.svg?logo=npm | ||
[npm-url]:https://npmjs.org/package/async-iterable-queue | ||
[npmsio-url]:https://npms.io/search?q=async-iterable-queue | ||
[nyc-cov-image]:https://img.shields.io/nycrc/kei-g/async-iterable-queue?config=.nycrc.json&label=coverage | ||
[quality-image]:https://img.shields.io/npms-io/quality-score/async-iterable-queue?logo=npm | ||
[travis-image]:https://img.shields.io/travis/kei-g/async-iterable-queue/main.svg?logo=travis | ||
[travis-url]:https://travis-ci.org/kei-g/async-iterable-queue | ||
[travis-image]:https://img.shields.io/travis/com/kei-g/async-iterable-queue/main?label=build%20%26%20test&logo=travis | ||
[travis-url]:https://app.travis-ci.com/kei-g/async-iterable-queue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
import { AsyncIterableQueue } from './src' | ||
|
||
type Foo = { | ||
id: number | ||
name: string | ||
} | ||
|
||
async function example1(queue: AsyncIterableQueue<Foo>): Promise<void> { | ||
console.debug('pushing 123') | ||
await queue.push({ | ||
id: 123, | ||
name: 'foo', | ||
}) | ||
console.debug('123 has been pushed') | ||
await queue.push({ | ||
id: 456, | ||
name: 'bar', | ||
}) | ||
console.debug('456 has been pushed') | ||
await queue.push({ | ||
id: 789, | ||
name: 'baz', | ||
}) | ||
console.debug('789 has been pushed') | ||
await queue.end() | ||
console.debug('\'end\' has been pushed') | ||
} | ||
|
||
async function example2(queue: AsyncIterableQueue<Foo>): Promise<void> { | ||
for await (const value of queue) | ||
console.debug(value) | ||
console.debug('all elements have been popped from queue') | ||
} | ||
|
||
async function example(): Promise<void> { | ||
console.debug('example for AsyncIterableQueue has begun') | ||
const queue = new AsyncIterableQueue<Foo>() | ||
await Promise.all([ | ||
example1(queue), | ||
example2(queue), | ||
]) | ||
console.debug('example for AsyncIterableQueue has finished') | ||
} | ||
|
||
example() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!**/lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const name = 'async-iterable-queue' | ||
|
||
export * from './lib/async-iterable-queue' |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters