(Go: >> BACK << -|- >> HOME <<)

Skip to content

Commit

Permalink
deps + tests + TS updates
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Dec 20, 2020
1 parent 0d708c1 commit b41493c
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 34 deletions.
16 changes: 9 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ language: node_js
sudo: required
matrix:
include:
- node_js: "4"
script: "npm test"
- node_js: "10"
script: "npm test"
- node_js: "12"
script: "npm run travis"
- node_js: "8"
script: "npm test"
- node_js: "10"
script: "npm test"
- node_js: "12"
script: "npm test"
- node_js: "14"
script: "npm run travis"
env:
- BLUEBIRD_DEBUG=0
- BLUEBIRD_DEBUG=0
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
},
"devDependencies": {
"bluebird": "3.7.2",
"browserify": "16.5.1",
"browserify": "17.0.0",
"coveralls": "3.1.0",
"eslint": "7.3.1",
"eslint": "7.16.0",
"istanbul": "0.4.5",
"jasmine-node": "3.0.0",
"jsdoc": "3.6.4",
"typescript": "3.9.5"
"jsdoc": "3.6.6",
"typescript": "4.1.3"
}
}
9 changes: 9 additions & 0 deletions test/typescript/batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ spex.batch([])
.catch((error: BatchError) => {
const duration: number = error.stat.duration;
});

(async function () {
// must be able to deconstruct tuples:
const [first, second] = await spex.batch<number, number>([1, 2]);

// must be able to access extended properties:
const result = await spex.batch<number>([1]);
const d = result.duration;
})();
55 changes: 32 additions & 23 deletions typescript/spex.d.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
////////////////////////////////////////
// Requires SPEX v3.0.0 or later.
// Requires SPEX v3.1.0 or later.
////////////////////////////////////////

declare namespace spex {

interface IOriginData {
success: boolean;
result: any;
readonly success: boolean;
readonly result: any;
}

interface IBatchData {
success: boolean;
result: any;
origin?: IOriginData;
readonly success: boolean;
readonly result: any;
readonly origin?: IOriginData;
}

interface IBatchStat {
total: number;
succeeded: number;
failed: number;
duration: number;
readonly total: number;
readonly succeeded: number;
readonly failed: number;
readonly duration: number;
}

interface IStreamReadOptions {
Expand All @@ -29,25 +29,25 @@ declare namespace spex {
}

interface IStreamReadResult {
calls: number;
reads: number;
length: number;
duration: number;
readonly calls: number;
readonly reads: number;
readonly length: number;
readonly duration: number;
}

interface IPageResult {
pages: number;
total: number;
duration: number;
readonly pages: number;
readonly total: number;
readonly duration: number;
}

interface ISequenceResult {
total: number;
duration: number;
readonly total: number;
readonly duration: number;
}

interface IArrayExt<T> extends Array<T> {
duration: number;
readonly duration: number;
}

// Errors namespace
Expand Down Expand Up @@ -133,15 +133,24 @@ declare namespace spex {
interface ISpexBase {

// API: http://vitaly-t.github.io/spex/global.html#batch
batch<T>(values: (T | Promise<T>)[], options?: { cb?: (index: number, success: boolean, result: any, delay: number) => any}): Promise<IArrayExt<T>>;
batch<T>(values: (T | Promise<T>)[], options?: { cb?: (index: number, success: boolean, result: any, delay: number) => any }): Promise<IArrayExt<T>>;

batch<T1, T2>(values: [T1 | Promise<T1>, T2 | Promise<T2>], options?: { cb?: (index: number, success: boolean, result: any, delay: number) => any }): Promise<[T1, T2] & IArrayExt<T1 | T2>>;

batch<T1, T2, T3>(values: [T1 | Promise<T1>, T2 | Promise<T2>, T3 | Promise<T3>], options?: { cb?: (index: number, success: boolean, result: any, delay: number) => any }): Promise<[T1, T2, T3] & IArrayExt<T1 | T2 | T3>>;

batch<T1, T2, T3, T4>(values: [T1 | Promise<T1>, T2 | Promise<T2>, T3 | Promise<T3>, T4 | Promise<T4>], options?: { cb?: (index: number, success: boolean, result: any, delay: number) => any }): Promise<[T1, T2, T3, T4] & IArrayExt<T1 | T2 | T3 | T4>>;

batch<T1, T2, T3, T4, T5>(values: [T1 | Promise<T1>, T2 | Promise<T2>, T3 | Promise<T3>, T4 | Promise<T4>, T5 | Promise<T5>], options?: { cb?: (index: number, success: boolean, result: any, delay: number) => any }): Promise<[T1, T2, T3, T4, T5] & IArrayExt<T1 | T2 | T3 | T4 | T5>>;

batch<T1, T2, T3, T4, T5, T6>(values: [T1 | Promise<T1>, T2 | Promise<T2>, T3 | Promise<T3>, T4 | Promise<T4>, T5 | Promise<T5>, T6 | Promise<T6>], options?: { cb?: (index: number, success: boolean, result: any, delay: number) => any }): Promise<[T1, T2, T3, T4, T5, T6] & IArrayExt<T1 | T2 | T3 | T4 | T5 | T6>>;

batch<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | Promise<T1>, T2 | Promise<T2>, T3 | Promise<T3>, T4 | Promise<T4>, T5 | Promise<T5>, T6 | Promise<T6>, T7 | Promise<T7>], options?: { cb?: (index: number, success: boolean, result: any, delay: number) => any }): Promise<[T1, T2, T3, T4, T5, T6, T7] & IArrayExt<T1 | T2 | T3 | T4 | T5 | T6 | T7>>;

batch<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | Promise<T1>, T2 | Promise<T2>, T3 | Promise<T3>, T4 | Promise<T4>, T5 | Promise<T5>, T6 | Promise<T6>, T7 | Promise<T7>, T8 | Promise<T8>], options?: { cb?: (index: number, success: boolean, result: any, delay: number) => any }): Promise<[T1, T2, T3, T4, T5, T6, T7, T8] & IArrayExt<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8>>;

batch<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | Promise<T1>, T2 | Promise<T2>, T3 | Promise<T3>, T4 | Promise<T4>, T5 | Promise<T5>, T6 | Promise<T6>, T7 | Promise<T7>, T8 | Promise<T8>, T9 | Promise<T9>], options?: { cb?: (index: number, success: boolean, result: any, delay: number) => any }): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9] & IArrayExt<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>>;

batch<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | Promise<T1>, T2 | Promise<T2>, T3 | Promise<T3>, T4 | Promise<T4>, T5 | Promise<T5>, T6 | Promise<T6>, T7 | Promise<T7>, T8 | Promise<T8>, T9 | Promise<T9>, T10 | Promise<T10>], options?: { cb?: (index: number, success: boolean, result: any, delay: number) => any }): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10] & IArrayExt<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9 | T10>>;

// API: http://vitaly-t.github.io/spex/global.html#page
Expand All @@ -154,10 +163,10 @@ declare namespace spex {
interface ISpex extends ISpexBase {

// API: http://vitaly-t.github.io/spex/stream.html
stream: IStream;
readonly stream: IStream;

// API: http://vitaly-t.github.io/spex/errors.html
errors: typeof errors;
readonly errors: typeof errors;
}

}
Expand Down

0 comments on commit b41493c

Please sign in to comment.