Skip to content

Commit

Permalink
fix: allow spreading of strings within arrays (microsoft#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfranco committed May 16, 2022
1 parent 5bfaf87 commit 5287704
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
13 changes: 9 additions & 4 deletions tslib.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,15 @@ export function __spreadArrays() {
}

export function __spreadArray(to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
if (pack || arguments.length === 2) {
if (typeof from === "string") from = Array.prototype.slice.call(from);
for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) {
ar = Array.prototype.slice.call(from, 0, i);
}
ar[i] = from[i];
}
}
}
return to.concat(ar || Array.prototype.slice.call(from));
Expand Down
13 changes: 9 additions & 4 deletions tslib.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,15 @@ var __createBinding;
};

__spreadArray = function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
if (pack || arguments.length === 2) {
if (typeof from === "string") from = Array.prototype.slice.call(from);
for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) {
ar = Array.prototype.slice.call(from, 0, i);
}
ar[i] = from[i];
}
}
}
return to.concat(ar || Array.prototype.slice.call(from));
Expand Down

0 comments on commit 5287704

Please sign in to comment.