Skip to content

Commit

Permalink
fallback to subarray if slice isn't available
Browse files Browse the repository at this point in the history
  • Loading branch information
samthor committed Mar 6, 2020
1 parent 1479659 commit 87e182a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion text.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ FastTextEncoder.prototype.encode = function(string, options={stream: false}) {
target[at++] = (value & 0x3f) | 0x80;
}

return target.slice(0, at);
// Use subarray if slice isn't supported (IE11). This will use more memory
// because the original array still exists.
return output.slice ? output.slice(0, at) : output.subarray(0, at);
}

/**
Expand Down

0 comments on commit 87e182a

Please sign in to comment.