Skip to content

Commit 0497d47

Browse files
authored
[refactor] transform .execute() from Recursion to Iteration (#1)
1 parent 8e2d022 commit 0497d47

File tree

15 files changed

+7596
-121
lines changed

15 files changed

+7596
-121
lines changed

.eslintrc.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,13 @@
88
"parserOptions": {
99
"sourceType": "module"
1010
},
11-
"extends": ["eslint:recommended", "plugin:prettier/recommended"]
11+
"plugins": ["@typescript-eslint"],
12+
"extends": [
13+
"eslint:recommended",
14+
"plugin:@typescript-eslint/recommended",
15+
"prettier"
16+
],
17+
"rules": {
18+
"@typescript-eslint/no-explicit-any": "warn"
19+
}
1220
}

.github/workflows/main.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI & CD
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
jobs:
7+
Build-and-Publish:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
id-token: write
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: pnpm/action-setup@v4
16+
with:
17+
version: 9
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: 20
21+
registry-url: https://registry.npmjs.org
22+
cache: pnpm
23+
- name: Install Dependencies
24+
run: pnpm i --frozen-lockfile
25+
26+
- name: Build & Publish
27+
run: npm publish
28+
env:
29+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
30+
31+
- name: Update document
32+
uses: peaceiris/actions-gh-pages@v3
33+
with:
34+
publish_dir: ./docs
35+
personal_token: ${{ secrets.GITHUB_TOKEN }}
36+
force_orphan: true

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
# Node.JS
22
node_modules/
33
package-lock.json
4+
yarn.lock
45

56
# Building
67
dist/
78
.rts2_cache_*/
89
docs/
910

1011
# IDE
11-
.vscode/
12+
.vscode/settings.json
1213
.idea/
1314

14-
# Online platform
15-
.github/
16-
1715
# OS
1816
.DS_Store

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm test

.husky/pre-push

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm run build

.npmignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
test/
44
.rts2_cache_*/
55
docs/
6-
.travis.yml
6+
.vscode/
7+
.husky/
8+
.github/

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
provenance = true
2+
auto-install-peers = false

.travis.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.vscode/launch.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Debug Jest",
6+
"type": "node",
7+
"request": "launch",
8+
"runtimeArgs": [
9+
"--inspect-brk",
10+
"${workspaceRoot}/node_modules/jest/bin/jest.js",
11+
"--runInBand"
12+
],
13+
"console": "integratedTerminal",
14+
"internalConsoleOptions": "neverOpen"
15+
}
16+
]
17+
}

ReadMe.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
**Middleware** framework based on [Async Generator][1] & [TypeScript][2], inspired by [Koa 2][3].
44

5-
[![NPM Dependency](https://david-dm.org/TechQuery/onion-stack.svg)][4]
6-
[![Build Status](https://travis-ci.com/TechQuery/onion-stack.svg?branch=master)][5]
5+
[![NPM Dependency](https://img.shields.io/librariesio/github/TechQuery/onion-stack.svg)][4]
6+
[![CI & CD](https://github.com/TechQuery/onion-stack/actions/workflows/main.yml/badge.svg)][5]
77
[![](https://data.jsdelivr.com/v1/package/npm/onion-stack/badge?style=rounded)][6]
88

99
[![NPM](https://nodei.co/npm/onion-stack.png?downloads=true&downloadRank=true&stars=true)][7]
1010

1111
## Example
1212

13-
```JavaScript
13+
```javascript
1414
import OnionStack from 'onion-stack';
1515

16-
const list = [ ];
16+
const list = [];
1717

1818
const stack = new OnionStack(
19-
function*() {
19+
function* () {
2020
list.push(1);
2121

2222
yield;
@@ -27,7 +27,7 @@ const stack = new OnionStack(
2727

2828
list.push(3);
2929
},
30-
async function*() {
30+
async function* () {
3131
await delay(0.1);
3232

3333
list.push(4);
@@ -36,20 +36,20 @@ const stack = new OnionStack(
3636

3737
list.push(5);
3838
},
39-
function() {
39+
function () {
4040
list.push(6);
4141
}
4242
);
4343

44-
stack.execute().then(() => console.log( list )); // [1, 4, 6, 5, 2]
44+
stack.execute().then(() => console.log(list)); // [1, 4, 6, 5, 2]
4545
```
4646

4747
[More cases](https://github.com/TechQuery/onion-stack/tree/master/test)
4848

4949
[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of#Iterating_over_async_generators
5050
[2]: https://www.typescriptlang.org
5151
[3]: https://koajs.com
52-
[4]: https://david-dm.org/TechQuery/onion-stack
53-
[5]: https://travis-ci.com/TechQuery/onion-stack
52+
[4]: https://libraries.io/npm/onion-stack
53+
[5]: https://github.com/TechQuery/onion-stack/actions/workflows/main.yml
5454
[6]: https://www.jsdelivr.com/package/npm/onion-stack
5555
[7]: https://nodei.co/npm/onion-stack/

0 commit comments

Comments
 (0)