From 87e182ade62d52fc2d64ee8776e91fae7213cb2f Mon Sep 17 00:00:00 2001 From: Sam Thorogood Date: Fri, 6 Mar 2020 14:34:46 +1100 Subject: [PATCH] fallback to subarray if slice isn't available --- text.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/text.js b/text.js index a43d755..1b7dc59 100644 --- a/text.js +++ b/text.js @@ -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); } /**