Support IE11 for streaming
This commit is contained in:
parent
721e522b17
commit
c75e2323c0
|
@ -69,7 +69,7 @@
|
|||
"istanbul": "^0.4.5",
|
||||
"mocha": "^5.0.0",
|
||||
"sinon": "^4.3.0",
|
||||
"text-encoder-lite": "^1.0.1",
|
||||
"text-encoding-utf-8": "^1.0.2",
|
||||
"whatwg-fetch": "^2.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
@ -65,7 +65,7 @@ Literal.prototype.setText = function(text, format='utf8') {
|
|||
Literal.prototype.getText = function(clone=false) {
|
||||
if (this.text === null || util.isStream(this.text)) { // Assume that this.text has been read
|
||||
let lastChar = '';
|
||||
const decoder = new TextDecoder('utf8');
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
// eslint-disable-next-line no-inner-declarations
|
||||
function process(value, lastChunk=false) {
|
||||
// decode UTF8
|
||||
|
|
|
@ -20,6 +20,9 @@ if (typeof window !== 'undefined') {
|
|||
if (typeof Array.prototype.find === 'undefined') {
|
||||
require('core-js/fn/array/find');
|
||||
}
|
||||
if (typeof Array.prototype.includes === 'undefined') {
|
||||
require('core-js/fn/array/includes');
|
||||
}
|
||||
if (typeof Array.from === 'undefined') {
|
||||
require('core-js/fn/array/from');
|
||||
}
|
||||
|
@ -48,5 +51,5 @@ if (typeof TextDecoder === 'undefined') {
|
|||
global.TextDecoder = util.getNodeTextDecoder();
|
||||
}
|
||||
if (typeof TextDecoder === 'undefined') {
|
||||
global.TextDecoder = require('text-encoder-lite');
|
||||
global.TextDecoder = require('text-encoding-utf-8').TextDecoder;
|
||||
}
|
||||
|
|
|
@ -361,7 +361,7 @@ function slice(input, begin=0, end=Infinity) {
|
|||
if (input[externalBuffer]) {
|
||||
input = util.concat(input[externalBuffer].concat([input]));
|
||||
}
|
||||
if (util.isUint8Array(input)) {
|
||||
if (util.isUint8Array(input) && !util.isIE11) { // IE11 subarray is buggy
|
||||
return input.subarray(begin, end);
|
||||
}
|
||||
return input.slice(begin, end);
|
||||
|
|
|
@ -34,6 +34,8 @@ import stream from './stream';
|
|||
const isIE11 = typeof navigator !== 'undefined' && !!navigator.userAgent.match(/Trident\/7\.0.*rv:([0-9.]+).*\).*Gecko$/);
|
||||
|
||||
export default {
|
||||
isIE11,
|
||||
|
||||
isString: function(data) {
|
||||
return typeof data === 'string' || String.prototype.isPrototypeOf(data);
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user