Skip to content

Commit 5287704

Browse files
committed
fix: allow spreading of strings within arrays (microsoft#175)
1 parent 5bfaf87 commit 5287704

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

tslib.es6.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,15 @@ export function __spreadArrays() {
167167
}
168168

169169
export function __spreadArray(to, from, pack) {
170-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
171-
if (ar || !(i in from)) {
172-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
173-
ar[i] = from[i];
170+
if (pack || arguments.length === 2) {
171+
if (typeof from === "string") from = Array.prototype.slice.call(from);
172+
for (var i = 0, l = from.length, ar; i < l; i++) {
173+
if (ar || !(i in from)) {
174+
if (!ar) {
175+
ar = Array.prototype.slice.call(from, 0, i);
176+
}
177+
ar[i] = from[i];
178+
}
174179
}
175180
}
176181
return to.concat(ar || Array.prototype.slice.call(from));

tslib.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,15 @@ var __createBinding;
209209
};
210210

211211
__spreadArray = function (to, from, pack) {
212-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
213-
if (ar || !(i in from)) {
214-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
215-
ar[i] = from[i];
212+
if (pack || arguments.length === 2) {
213+
if (typeof from === "string") from = Array.prototype.slice.call(from);
214+
for (var i = 0, l = from.length, ar; i < l; i++) {
215+
if (ar || !(i in from)) {
216+
if (!ar) {
217+
ar = Array.prototype.slice.call(from, 0, i);
218+
}
219+
ar[i] = from[i];
220+
}
216221
}
217222
}
218223
return to.concat(ar || Array.prototype.slice.call(from));

0 commit comments

Comments
 (0)