Skip to content

Commit

Permalink
🔀 Merge branch 'devel' into release
Browse files Browse the repository at this point in the history
- 📝 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
kei-g committed Aug 31, 2021
2 parents 1166a5f + 4dc5884 commit d1f3860
Show file tree
Hide file tree
Showing 16 changed files with 216 additions and 39 deletions.
Empty file added .github/.gitkeep
Empty file.
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
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
5 changes: 3 additions & 2 deletions .gitignore
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
5 changes: 4 additions & 1 deletion .npmignore
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
28 changes: 28 additions & 0 deletions .nycrc.json
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]
}
}
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
branches:
except:
- /^v\d+\.\d+\.\d+$/
only:
- main
cache:
directories:
- ~/.npm
language: node_js
node_js:
- 14
- 15
- 16
notifications:
email: false
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# ChangeLogs

## Version 1.0.6

- :memo: Badge for Travis CI is corrected
- :hammer: Build script is optimized
- :children_crossing: Example code is added
- :green_heart: Github Action for CI
- :arrow_up: 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
- :memo: README is updated
- Badges for both CI and coverage are added
- Installation section is added
- Usage section is added
- :green_heart: Travis CI
- Node.js v15.x is excepted from test target
- Only 'main' branch is made to be tested

## Version 1.0.5

- :see_no_evil: .npmignore is added
Expand Down
69 changes: 64 additions & 5 deletions README.md
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
46 changes: 46 additions & 0 deletions example.ts
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()
1 change: 0 additions & 1 deletion lib/.npmignore

This file was deleted.

38 changes: 18 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,18 @@
"devDependencies": {
"@types/chai": "^4.2.21",
"@types/mocha": "^9.0.0",
"@types/node": "^16.7.1",
"@typescript-eslint/eslint-plugin": "^4.29.2",
"@typescript-eslint/parser": "^4.29.2",
"@types/node": "^16.7.8",
"@typescript-eslint/eslint-plugin": "^4.30.0",
"@typescript-eslint/parser": "^4.30.0",
"chai": "^4.3.4",
"eslint": "^7.32.0",
"mocha": "^9.1.0",
"mocha": "^9.1.1",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"rimraf": "^3.0.2",
"terser": "^5.7.1",
"terser": "^5.7.2",
"ts-node": "^10.2.1",
"typescript": "^4.3.5",
"typescript": "^4.4.2",
"uuid": "^8.3.2"
},
"homepage": "https://github.com/kei-g/async-iterable-queue",
Expand All @@ -68,14 +69,8 @@
"queue"
],
"license": "BSD-3-Clause",
"main": "lib/async-iterable-queue.js",
"main": "index.js",
"name": "async-iterable-queue",
"nyc": {
"branches": 100,
"functions": 100,
"lines": 100,
"statements": 100
},
"publishConfig": {
"access": "public"
},
Expand All @@ -84,14 +79,17 @@
"url": "https://github.com/kei-g/async-iterable-queue.git"
},
"scripts": {
"build": "npm run lint && tsc && terser build/async-iterable-queue.js -c -m -o lib/async-iterable-queue.js --toplevel",
"clean": "rimraf .nyc_output/ build/ coverage/ lib/*.d.ts lib/*.js",
"build": "npm-run-all -p clean lint -s build:tsc -p build:terse:*",
"build:terse:async-iterable-queue": "terser build/lib/async-iterable-queue.js -c -m -o lib/async-iteable-queue.js --toplevel",
"build:terse:index": "terser build/index.js -c -m -o index.js --toplevel",
"build:tsc": "tsc",
"clean": "rimraf .nyc_output/ build/ coverage/ index.d.ts index.js lib/",
"cover": "nyc --check-coverage -r html -r text _mocha",
"lint": "eslint *.ts",
"prebuild": "rimraf build/ lib/*.d.ts lib/*.js",
"prepublishOnly": "npm run build",
"test": "npm run lint && npm run cover"
"lint": "eslint src/*.ts src/lib/*.ts",
"prebuild": "run-s clean",
"prepublishOnly": "run-s build",
"test": "run-p lint cover"
},
"types": "lib/async-iterable-queue.d.ts",
"types": "index.d.ts",
"version": "1.0.6"
}
1 change: 1 addition & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!**/lib/
3 changes: 3 additions & 0 deletions src/index.ts
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.
2 changes: 1 addition & 1 deletion test/async-iterable-queue.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AsyncIterableQueue } from '../async-iterable-queue'
import { AsyncIterableQueue } from '../src'
import { describe, it } from 'mocha'
import { expect } from 'chai'

Expand Down
10 changes: 4 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"alwaysStrict": true,
"charset": "utf8",
"declaration": true,
"declarationDir": "lib",
"declarationDir": ".",
"downlevelIteration": true,
"emitBOM": false,
"emitDeclarationOnly": false,
Expand All @@ -26,9 +26,7 @@
],
},
"files": [
"async-iterable-queue.ts",
],
"include": [
"async-iterable-queue.ts",
],
"src/index.ts",
"src/lib/async-iterable-queue.ts",
]
}

0 comments on commit d1f3860

Please sign in to comment.