Skip to content

Commit 1f2daa7

Browse files
authoredJun 11, 2021
Update __spreadArray helper (#151)
1 parent 4f0f29b commit 1f2daa7

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed
 

‎tslib.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export declare function __read(o: any, n?: number): any[];
2727
export declare function __spread(...args: any[][]): any[];
2828
/** @deprecated since TypeScript 4.2 */
2929
export declare function __spreadArrays(...args: any[][]): any[];
30-
export declare function __spreadArray(to: any[], from: any[]): any[];
30+
export declare function __spreadArray(to: any[], from: any[], pack?: boolean): any[];
3131
export declare function __await(v: any): any;
3232
export declare function __asyncGenerator(thisArg: any, _arguments: any, generator: Function): any;
3333
export declare function __asyncDelegator(o: any): any;

‎tslib.es6.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,14 @@ export function __spreadArrays() {
162162
return r;
163163
}
164164

165-
export function __spreadArray(to, from) {
166-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
167-
to[j] = from[i];
168-
return to;
165+
export function __spreadArray(to, from, pack) {
166+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
167+
if (ar || !(i in from)) {
168+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
169+
ar[i] = from[i];
170+
}
171+
}
172+
return to.concat(ar || from);
169173
}
170174

171175
export function __await(v) {

‎tslib.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,14 @@ var __createBinding;
203203
return r;
204204
};
205205

206-
__spreadArray = function (to, from) {
207-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
208-
to[j] = from[i];
209-
return to;
206+
__spreadArray = function (to, from, pack) {
207+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
208+
if (ar || !(i in from)) {
209+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
210+
ar[i] = from[i];
211+
}
212+
}
213+
return to.concat(ar || from);
210214
};
211215

212216
__await = function (v) {

0 commit comments

Comments
 (0)
Please sign in to comment.