mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
Provides a slim TextDecoder polyfill for Edge
This commit is contained in:
16
ui/app/utils/classes/text-decoder.js
Normal file
16
ui/app/utils/classes/text-decoder.js
Normal file
@@ -0,0 +1,16 @@
|
||||
// This is a very incomplete polyfill for TextDecoder used only
|
||||
// by browsers that don't provide one but still provide a ReadableStream
|
||||
// interface for fetch.
|
||||
|
||||
// A complete polyfill exists if this becomes problematic:
|
||||
// https://github.com/inexorabletash/text-encoding
|
||||
export default window.TextDecoder ||
|
||||
function() {
|
||||
this.decode = function(value) {
|
||||
let text = '';
|
||||
for (let i = 3; i < value.byteLength; i++) {
|
||||
text += String.fromCharCode(value[i]);
|
||||
}
|
||||
return text;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user