Skip to content

Commit

Permalink
Add '__spreadArrays' helper (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckton authored Jun 4, 2019
1 parent 57efce4 commit ab40523
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tslib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export declare function __generator(thisArg: any, body: Function): any;
export declare function __exportStar(m: any, exports: any): void;
export declare function __values(o: any): any;
export declare function __read(o: any, n?: number): any[];
export declare function __spread(...args: any[]): any[];
export declare function __spread(...args: any[][]): any[];
export declare function __spreadArrays(...args: any[][]): any[];
export declare function __await(v: any): any;
export declare function __asyncGenerator(thisArg: any, _arguments: any, generator: Function): any;
export declare function __asyncDelegator(o: any): any;
Expand Down
8 changes: 8 additions & 0 deletions tslib.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ export function __spread() {
return ar;
}

export function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};

export function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
Expand Down
10 changes: 10 additions & 0 deletions tslib.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var __exportStar;
var __values;
var __read;
var __spread;
var __spreadArrays;
var __await;
var __asyncGenerator;
var __asyncDelegator;
Expand Down Expand Up @@ -176,6 +177,14 @@ var __importDefault;
return ar;
};

__spreadArrays = function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};

__await = function (v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
};
Expand Down Expand Up @@ -235,6 +244,7 @@ var __importDefault;
exporter("__values", __values);
exporter("__read", __read);
exporter("__spread", __spread);
exporter("__spreadArrays", __spreadArrays);
exporter("__await", __await);
exporter("__asyncGenerator", __asyncGenerator);
exporter("__asyncDelegator", __asyncDelegator);
Expand Down

0 comments on commit ab40523

Please sign in to comment.