UNPKG

1.42 kBPlain TextView Raw
1// Copyright (c) .NET Foundation. All rights reserved.
2// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
4// This is where we add any polyfills we'll need for the browser. It is the entry module for browser-specific builds.
5
6import "es6-promise/dist/es6-promise.auto.js";
7
8// Copy from Array.prototype into Uint8Array to polyfill on IE. It's OK because the implementations of indexOf and slice use properties
9// that exist on Uint8Array with the same name, and JavaScript is magic.
10// We make them 'writable' because the Buffer polyfill messes with it as well.
11if (!Uint8Array.prototype.indexOf) {
12 Object.defineProperty(Uint8Array.prototype, "indexOf", {
13 value: Array.prototype.indexOf,
14 writable: true,
15 });
16}
17if (!Uint8Array.prototype.slice) {
18 Object.defineProperty(Uint8Array.prototype, "slice", {
19 // wrap the slice in Uint8Array so it looks like a Uint8Array.slice call
20 // tslint:disable-next-line:object-literal-shorthand
21 value: function(start?: number, end?: number) { return new Uint8Array(Array.prototype.slice.call(this, start, end)); },
22 writable: true,
23 });
24}
25if (!Uint8Array.prototype.forEach) {
26 Object.defineProperty(Uint8Array.prototype, "forEach", {
27 value: Array.prototype.forEach,
28 writable: true,
29 });
30}
31
32export * from "./index";