Skip to content

Commit de77bc8

Browse files
committed
feat: add pFilter
1 parent 40ae540 commit de77bc8

18 files changed

+2590
-1996
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions/setup-node@v4
1414
with:
1515
node-version: lts/*
16-
cache: 'pnpm'
16+
cache: pnpm
1717

1818
- run: pnpm install
1919

.github/workflows/sync-tag-to-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- uses: actions/setup-node@v4
2323
with:
2424
node-version: 20
25-
cache: 'pnpm'
25+
cache: pnpm
2626

2727
# 1. publish local
2828
# 2. push tag to github

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# contents not in .gitignore
2+
pnpm-lock.yaml

bak/pmap-plain.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
export async function pmapPlain<T, R>(
2-
arr: T[],
3-
fn: (item: T, index: number, arr: T[]) => R,
4-
concurrency: number,
5-
) {
1+
export async function pmapPlain<T, R>(arr: T[], fn: (item: T, index: number, arr: T[]) => R, concurrency: number) {
62
return new Promise(function (resolve, reject) {
7-
var completed = 0
8-
var started = 0
9-
var running = 0
10-
var results = new Array(arr.length).fill(undefined)
11-
var rejected = false
3+
let completed = 0
4+
let started = 0
5+
let running = 0
6+
const results = Array.from({ length: arr.length }).fill(undefined)
7+
let rejected = false
128

139
function start(index: number) {
14-
var cur = arr[index]
10+
const cur = arr[index]
1511
Promise.resolve(fn.call(cur, cur, index, arr))
1612
.then(function (result) {
1713
running--

eslint.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { fromSxzz } from '@magicdawn/eslint-config'
2+
3+
export default fromSxzz(undefined, [
4+
{
5+
ignores: ['bak/'],
6+
},
7+
])

package.json

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
{
22
"name": "promise.map",
33
"version": "1.1.2",
4+
"packageManager": "pnpm@10.12.1+sha512.f0dda8580f0ee9481c5c79a1d927b9164f2c478e90992ad268bbb2465a736984391d6333d2c327913578b2804af33474ca554ba29c04a8b13060a717675ae3ac",
45
"description": "Promise.map",
56
"type": "module",
7+
"keywords": [
8+
"promise",
9+
"map",
10+
"parallel"
11+
],
12+
"license": "MIT",
13+
"homepage": "https://github.com/magicdawn/promise.map#readme",
14+
"bugs": {
15+
"url": "https://github.com/magicdawn/promise.map/issues"
16+
},
17+
"repository": {
18+
"type": "git",
19+
"url": "git+https://github.com/magicdawn/promise.map.git"
20+
},
21+
"author": "magicdawn",
622
"files": [
7-
"dist/",
8-
"package.json",
9-
"README.md",
1023
"CHANGELOG.md",
11-
"LICENSE"
24+
"LICENSE",
25+
"README.md",
26+
"dist/",
27+
"package.json"
1228
],
1329
"main": "./dist/index.cjs",
1430
"types": "./dist/index.d.cts",
@@ -25,6 +41,9 @@
2541
}
2642
}
2743
},
44+
"publishConfig": {
45+
"registry": "https://registry.npmjs.org/"
46+
},
2847
"scripts": {
2948
"prepare": "husky",
3049
"test": "vitest run",
@@ -37,39 +56,23 @@
3756
"typecheck": "tsc --noEmit",
3857
"prepublishOnly": "npm run build"
3958
},
40-
"packageManager": "pnpm@9.15.0+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c",
4159
"devDependencies": {
42-
"@magicdawn/eslint-config": "^0.1.0",
43-
"@magicdawn/prettier-config": "^0.0.4",
44-
"@types/node": "^22.10.2",
45-
"@vitest/coverage-v8": "^2.1.8",
46-
"chance": "^1.1.12",
47-
"es-toolkit": "^1.30.1",
48-
"eslint": "^9.17.0",
60+
"@magicdawn/eslint-config": "^1.5.4",
61+
"@magicdawn/prettier-config": "^0.1.0",
62+
"@types/node": "^24.0.1",
63+
"@vitest/coverage-v8": "^3.2.3",
64+
"chance": "^1.1.13",
65+
"es-toolkit": "^1.39.3",
66+
"eslint": "^9.28.0",
4967
"husky": "^9.1.7",
50-
"lint-staged": "^15.2.11",
51-
"prettier": "^3.4.2",
68+
"lint-staged": "^16.1.0",
69+
"prettier": "^3.5.3",
5270
"should": "^13.2.3",
53-
"tsd": "^0.31.2",
54-
"tsup": "^8.3.5",
55-
"typescript": "^5.7.2",
56-
"vitest": "^2.1.8"
57-
},
58-
"repository": {
59-
"type": "git",
60-
"url": "git+https://github.com/magicdawn/promise.map.git"
61-
},
62-
"keywords": [
63-
"promise",
64-
"map",
65-
"parallel"
66-
],
67-
"author": "magicdawn",
68-
"license": "MIT",
69-
"bugs": {
70-
"url": "https://github.com/magicdawn/promise.map/issues"
71+
"tsd": "^0.32.0",
72+
"tsup": "^8.5.0",
73+
"typescript": "^5.8.3",
74+
"vitest": "^3.2.3"
7175
},
72-
"homepage": "https://github.com/magicdawn/promise.map#readme",
7376
"husky": {
7477
"hooks": {
7578
"pre-commit": "lint-staged"
@@ -79,8 +82,5 @@
7982
"*.{ts,js}": [
8083
"prettier --write"
8184
]
82-
},
83-
"publishConfig": {
84-
"registry": "https://registry.npmjs.org/"
8585
}
8686
}

0 commit comments

Comments
 (0)