@artus/pipeline
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -10,3 +10,3 @@ export interface ParamsDictionary { | ||
} | ||
export interface BaseContext { | ||
export interface BaseContext extends ParamsDictionary { | ||
input: BaseInput; | ||
@@ -13,0 +13,0 @@ output: BaseOutput; |
{ | ||
"name": "@artus/pipeline", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"main": "dist/index.js", | ||
@@ -8,6 +8,8 @@ "scripts": { | ||
"build:dist": "tsc --version && tsc -b ./tsconfig.json", | ||
"test": "tsc --version && jest" | ||
"test": "tsc --version && jest", | ||
"ci": "npm run test" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^27.4.1", | ||
"egg-ci": "^1.19.0", | ||
"jest": "^27.5.1", | ||
@@ -19,3 +21,10 @@ "ts-jest": "^27.1.3", | ||
"tslib": "^2.3.1" | ||
}, | ||
"ci": { | ||
"type": "github", | ||
"os": { | ||
"github": "linux, windows, macos" | ||
}, | ||
"version": "12, 14, 16" | ||
} | ||
} |
@@ -17,7 +17,7 @@ import { | ||
export class Storage implements ContextStorage<any>{ | ||
#storageMap = new Map(); | ||
private storageMap = new Map(); | ||
get(key?: string | symbol): any { | ||
key ??= ContextStorageSymbol; | ||
return this.#storageMap.get(key); | ||
return this.storageMap.get(key); | ||
} | ||
@@ -27,3 +27,3 @@ | ||
key ??= ContextStorageSymbol; | ||
this.#storageMap.set(key, value); | ||
this.storageMap.set(key, value); | ||
} | ||
@@ -35,3 +35,3 @@ } | ||
public output: BaseOutput = new Output(); | ||
#stogrageMap = new Map<string, ContextStorage<any>>(); | ||
private stogrageMap = new Map<string, ContextStorage<any>>(); | ||
@@ -44,6 +44,6 @@ constructor(input?: Input, output?: Output) { | ||
namespace(namespace: string): ContextStorage<any> { | ||
let storage = this.#stogrageMap.get(namespace); | ||
let storage = this.stogrageMap.get(namespace); | ||
if (!storage) { | ||
storage = new Storage(); | ||
this.#stogrageMap.set(namespace, storage); | ||
this.stogrageMap.set(namespace, storage); | ||
} | ||
@@ -50,0 +50,0 @@ |
@@ -6,3 +6,3 @@ | ||
middlewares: Middlewares = []; | ||
#index: number = -1; | ||
private index: number = -1; | ||
@@ -31,9 +31,9 @@ use(middleware: MiddlewareInput) { | ||
#dispatch(i: number, ctx: Context): Promise<any> { | ||
if (i <= this.#index) return Promise.reject(new Error('next() called multiple times')); | ||
this.#index = i; | ||
dispatch(i: number, ctx: Context): Promise<any> { | ||
if (i <= this.index) return Promise.reject(new Error('next() called multiple times')); | ||
this.index = i; | ||
let fn = this.middlewares[i]; | ||
if (!fn) return Promise.resolve(); | ||
try { | ||
return Promise.resolve(fn(ctx, this.#dispatch.bind(this, i + 1, ctx))); | ||
return Promise.resolve(fn(ctx, this.dispatch.bind(this, i + 1, ctx))); | ||
} catch (err: any) { | ||
@@ -45,4 +45,4 @@ return Promise.reject(err); | ||
run(ctx: Context): Promise<any> { | ||
return this.#dispatch(0, ctx); | ||
return this.dispatch(0, ctx); | ||
} | ||
} |
@@ -13,3 +13,3 @@ export interface ParamsDictionary { | ||
export interface BaseContext { | ||
export interface BaseContext extends ParamsDictionary { | ||
input: BaseInput, | ||
@@ -16,0 +16,0 @@ output: BaseOutput, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19427
23
5