Skip to content

Commit

Permalink
Merge pull request #14 from TNT-03/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
TNT-03 committed Apr 28, 2023
2 parents da82903 + 511ea6d commit 5a501ab
Show file tree
Hide file tree
Showing 4 changed files with 3,761 additions and 11 deletions.
17 changes: 14 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "async-task-mapping",
"version": "1.0.0",
"version": "1.0.1",
"main": "dist/index.js",
"module": "dist/index.js",
"author": "Jiegang Liang (t.n.t)",
Expand All @@ -16,7 +16,7 @@
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"eslint": "^8.10.0",
"jest": "^29.4.2",
"jest": "^29.5.0",
"rollup": "^2.69.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-livereload": "^2.0.5",
Expand All @@ -36,7 +36,18 @@
"license": "MIT",
"description": "Asynchronous Task Manager.",
"npmName": "async-task-mapping",
"keywords": ["async", "task", "mapping", "list", "await", "promise", "manage"],
"keywords": [
"async",
"task",
"mapping",
"list",
"await",
"promise",
"batch",
"request",
"manage"

],
"npmFileMap": [
{
"basePath": "/dist/",
Expand Down
16 changes: 8 additions & 8 deletions task/cell.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { NOISE } from '../container/constant.js'
import { NOISE } from "../container/constant.js";

class Cell {
request() {
// 占位
}
constructor() {
const allMotheds = Reflect ? Reflect.ownKeys(Promise.prototype) : Object.getOwnPropertyNames(Promise.prototype)
const motheds = allMotheds.filter((item) => !NOISE.includes(item))
const allMotheds = Reflect
? Reflect.ownKeys(Promise.prototype)
: Object.getOwnPropertyNames(Promise.prototype);
const motheds = allMotheds.filter((item) => !NOISE.includes(item));
motheds.forEach((mothed) => {
this[mothed] = (...arg) => {
this.request()[mothed](...arg)
}
})
this[mothed] = (...arg) => this.request()[mothed](...arg);
});
}
}

export default Cell
export default Cell;
32 changes: 32 additions & 0 deletions task/stepTask.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class StepTask {
#index = 0;
taskList = [];
result = [];
err = [];
code = () => {
//
};
constructor(list, limit, code) {
this.taskList = list;
this.code = code;
for (let i = 0; i < limit; i++) {
checkTask();
}
}
checkTask() {
this.taskList[this.this.#index++]()
.then(
(data) => {
this.result.push(data);
checkTask();
},
(e) => {
this.err.push(e);
checkTask();
}
)
.then(this.code);
}
}

export default StepTask;
Loading

0 comments on commit 5a501ab

Please sign in to comment.