chore: move out async-hook

This commit is contained in:
thinkinggis 2020-02-26 22:23:43 +08:00
parent 00381c54bc
commit 31c60da4b2
17 changed files with 10 additions and 176 deletions

View File

@ -29,7 +29,6 @@ module.exports = {
modulePathIgnorePatterns: [ 'dist' ],
moduleNameMapper: {
'@antv/l7-(.+)$': '<rootDir>packages/$1/src',
'@antv/async-hook$': '<rootDir>packages/async-hook/src'
},
notify: true,
notifyMode: 'always',

View File

@ -27,7 +27,6 @@
"@rollup/plugin-json": "^4.0.0",
"@rollup/plugin-node-resolve": "^6.0.0",
"@storybook/react": "^5.1.9",
"@types/async": "^3.0.8",
"@types/dat.gui": "^0.7.1",
"@types/enzyme": "^3.1.14",
"@types/enzyme-adapter-react-16": "^1.0.3",
@ -36,7 +35,6 @@
"@types/node": "^12.12.22",
"@types/storybook__react": "^4.0.2",
"@types/supercluster": "^5.0.1",
"async-es": "^3.2.0",
"awesome-typescript-loader": "^5.2.1",
"babel-jest": "^24.9.0",
"babel-loader": "^8.0.6",

View File

@ -1,11 +0,0 @@
# `async-hook`
> TODO: description
## Usage
```
const asyncHook = require('async-hook');
// TODO: DEMONSTRATE API
```

View File

@ -1,40 +0,0 @@
{
"name": "@antv/async-hook",
"version": "2.0.28-alpha.2",
"description": "",
"main": "lib/index.js",
"module": "es/index.js",
"types": "es/index.d.ts",
"sideEffects": true,
"files": [
"lib",
"es",
"README.md"
],
"scripts": {
"tsc": "tsc --project tsconfig.build.json",
"clean": "rimraf dist; rimraf es; rimraf lib;",
"build": "run-p build:*",
"build:cjs": "BABEL_ENV=cjs babel src --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
"build:esm": "BABEL_ENV=esm babel src --root-mode upward --out-dir es --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
"watch": "BABEL_ENV=cjs babel src --watch --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
"lint:ts": "run-p -c lint:ts-*",
"test": "jest"
},
"author": "lzxue",
"license": "ISC",
"bugs": {
"url": "https://github.com/antvis/L7/issues"
},
"homepage": "https://github.com/antvis/L7#readme",
"dependencies": {
"async": "^3.1.1"
},
"devDependencies": {
"@types/async": "^3.0.8"
},
"gitHead": "a5d354b66873f700730248d015c5e539c54b34b7",
"publishConfig": {
"access": "public"
}
}

View File

@ -1,20 +0,0 @@
// @ts-ignore
// tslint:disable-next-line:no-submodule-imports
import async from 'async/dist/async.js';
import { CallBack } from './IHook';
export default class AsyncParallelHook {
private tasks: any[];
constructor(...args: any[]) {
this.tasks = [];
}
public promise(...args: any[]) {
return async.parallel(this.tasks);
}
public tapPromise(name: string, cb: CallBack) {
this.tasks.push(async (callback: any) => {
await cb();
callback(null, name);
});
}
}

View File

@ -1,5 +0,0 @@
export type CallBack = (...args: any[]) => any;
export interface IHook {
call: (...args: any[]) => void;
tap(name: string, task: CallBack): void;
}

View File

@ -1,20 +0,0 @@
// @ts-ignore
// tslint:disable-next-line:no-submodule-imports
import async from 'async/dist/async.js';
import { CallBack, IHook } from './IHook';
export default class SyncBailHook implements IHook {
private tasks: any[];
constructor(...args: any[]) {
this.tasks = [];
}
public call(...args: any[]): void {
return async.series(this.tasks);
}
public tap(name: string, cb: CallBack) {
this.tasks.push((callback: any) => {
const err = cb();
callback(err, name);
});
}
}

View File

@ -1,22 +0,0 @@
// @ts-ignore
// tslint:disable-next-line:no-submodule-imports
import async from 'async/dist/async.js';
import { CallBack, IHook } from './IHook';
export default class SyncHook implements IHook {
private tasks: any[];
private args: any[];
constructor(...args: any[]) {
this.tasks = [];
}
public call(...args: any[]): void {
this.args = args;
return async.series(this.tasks);
}
public tap(name: string, cb: CallBack) {
this.tasks.push((callback: any) => {
cb(...this.args);
callback(null, name);
});
}
}

View File

@ -1,27 +0,0 @@
// @ts-ignore
// tslint:disable-next-line:no-submodule-imports
import async from 'async/dist/async.js';
import { CallBack, IHook } from './IHook';
export default class SyncWaterfallHook implements IHook {
private tasks: any[];
constructor(...args: any[]) {
this.tasks = [];
}
public call(...args: any[]): void {
return async.waterfall(this.tasks);
}
public tap(name: string, cb: CallBack) {
if (this.tasks.length === 0) {
this.tasks.push((callback: any) => {
const value = cb();
callback(value ? null : false, value);
});
} else {
this.tasks.push((arg: any, callback: any) => {
const value = cb();
callback(value ? null : false, name);
});
}
}
}

View File

@ -1,4 +0,0 @@
export { default as SyncHook } from './core/SyncHook';
export { default as AsyncParallelHook } from './core/AsyncParallelHook';
export { default as SyncWaterfallHook } from './core/SyncWaterfallHook';
export { default as SyncBailHook } from './core/SyncBailHook';

View File

@ -1,9 +0,0 @@
{
"extends": "../../tsconfig.build.json",
"compilerOptions": {
"declarationDir": "./es",
"rootDir": "./src",
"baseUrl": "./",
},
"include": ["./src"]
}

View File

@ -22,7 +22,7 @@
"author": "xiaoiver",
"license": "ISC",
"dependencies": {
"@antv/async-hook": "^2.0.28-alpha.2",
"@antv/async-hook": "^2.1.0",
"@antv/l7-utils": "^2.0.28-alpha.2",
"@babel/runtime": "^7.7.7",
"@mapbox/tiny-sdf": "^1.1.1",

View File

@ -22,7 +22,7 @@
"author": "xiaoiver",
"license": "ISC",
"dependencies": {
"@antv/async-hook": "^2.0.28-alpha.2",
"@antv/async-hook": "^2.1.0",
"@antv/l7-core": "^2.0.28-alpha.2",
"@antv/l7-source": "^2.0.28-alpha.2",
"@antv/l7-utils": "^2.0.28-alpha.2",

View File

@ -24,7 +24,7 @@
"author": "lzxue",
"license": "ISC",
"dependencies": {
"@antv/async-hook": "^2.0.28-alpha.2",
"@antv/async-hook": "^2.1.0",
"@antv/l7-core": "^2.0.28-alpha.2",
"@antv/l7-utils": "^2.0.28-alpha.2",
"@babel/runtime": "^7.7.7",

View File

@ -7,7 +7,6 @@
"rootDir": "./",
"baseUrl": "./",
"paths": {
"@antv/async-hook": ["packages/async-hook/src"],
"@antv/l7-*": ["packages/*/src"],
"@antv/l7": ["packages/l7/src"],
"*": ["node_modules", "packages"]

View File

@ -19,7 +19,6 @@
"paths": {
"@antv/l7-*": ["packages/*/src"],
"@antv/l7": ["packages/l7/src"],
"@antv/async-hook": ["packages/async-hook/src"],
"*": ["node_modules", "packages", "typings/*"]
}
},

View File

@ -37,6 +37,13 @@
dependencies:
"@antv/util" "~1.3.1"
"@antv/async-hook@^2.1.0":
version "2.1.0"
resolved "https://registry.npmjs.org/@antv/async-hook/-/async-hook-2.1.0.tgz#17f57a6ae5e9c55adac3cdfac7d441258c3f9aeb"
integrity sha512-q7Rup5jTDAiWh77Xb2vgkCURJGczmU2iWTCkBDq28PuK5KUoenyeGGrFKAVkgqaL663wdpw0Vzn+sYriTfT9hA==
dependencies:
async "^3.1.1"
"@antv/attr@~0.1.2":
version "0.1.2"
resolved "https://registry.npmjs.org/@antv/attr/-/attr-0.1.2.tgz#2eeb122fcaaf851a2d8749abc7c60519d3f77e37"
@ -3419,11 +3426,6 @@
resolved "https://registry.npmjs.org/@types/amap-js-api/-/amap-js-api-1.4.7.tgz#565342799c14c0b112cfea237aaa4b700360f406"
integrity sha512-YWU1cWVtZ3d25/0rLiVH1ecJfEPRh+WiCShOsDbOa4woW7oP55OCoxKXuvkD+GjePv9Ye7dKR78HtDuF6s+OFQ==
"@types/async@^3.0.8":
version "3.0.8"
resolved "https://registry.npmjs.org/@types/async/-/async-3.0.8.tgz#8c183f149d8cc91f944d58e5594d2a614ceb33ff"
integrity sha512-wIM8bCrHeQHCUyDqJYXyvG8P98YeERaOB1NeOvcjnjlM32pn21S13j6tZqhiWX+nkpU3EvhtE/nuO1ItCpZ+HQ==
"@types/babel__core@^7.1.0":
version "7.1.5"
resolved "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.5.tgz#e4d84704b4df868b3ad538365a13da2fa6dbc023"
@ -4801,11 +4803,6 @@ async-each@^1.0.1:
resolved "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz#b727dbf87d7651602f06f4d4ac387f47d91b0cbf"
integrity sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==
async-es@^3.2.0:
version "3.2.0"
resolved "https://registry.npmjs.org/async-es/-/async-es-3.2.0.tgz#8837aa12f675de80fac56b94a4b4cef515343de3"
integrity sha512-dMWVIUBi/ejt+QERtMdIin2rlzSNK7GAfEwIyaOGDy536s0OqH+aUNkj9MQ01hq2rB1f7x6w7RJchtthCk0IDA==
async-foreach@^0.1.3:
version "0.1.3"
resolved "https://registry.npmjs.org/async-foreach/-/async-foreach-0.1.3.tgz#36121f845c0578172de419a97dbeb1d16ec34542"