28 lines
1.3 KiB
JavaScript
28 lines
1.3 KiB
JavaScript
// Licensed to the .NET Foundation under one or more agreements.
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
// This is where we add any polyfills we'll need for the browser. It is the entry module for browser-specific builds.
|
|
// Copy from Array.prototype into Uint8Array to polyfill on IE. It's OK because the implementations of indexOf and slice use properties
|
|
// that exist on Uint8Array with the same name, and JavaScript is magic.
|
|
// We make them 'writable' because the Buffer polyfill messes with it as well.
|
|
if (!Uint8Array.prototype.indexOf) {
|
|
Object.defineProperty(Uint8Array.prototype, "indexOf", {
|
|
value: Array.prototype.indexOf,
|
|
writable: true,
|
|
});
|
|
}
|
|
if (!Uint8Array.prototype.slice) {
|
|
Object.defineProperty(Uint8Array.prototype, "slice", {
|
|
// wrap the slice in Uint8Array so it looks like a Uint8Array.slice call
|
|
// eslint-disable-next-line object-shorthand
|
|
value: function (start, end) { return new Uint8Array(Array.prototype.slice.call(this, start, end)); },
|
|
writable: true,
|
|
});
|
|
}
|
|
if (!Uint8Array.prototype.forEach) {
|
|
Object.defineProperty(Uint8Array.prototype, "forEach", {
|
|
value: Array.prototype.forEach,
|
|
writable: true,
|
|
});
|
|
}
|
|
export * from "./index";
|
|
//# sourceMappingURL=browser-index.js.map
|