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 |
|
6 | import "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.
|
11 | if (!Uint8Array.prototype.indexOf) {
|
12 | Object.defineProperty(Uint8Array.prototype, "indexOf", {
|
13 | value: Array.prototype.indexOf,
|
14 | writable: true,
|
15 | });
|
16 | }
|
17 | if (!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 | }
|
25 | if (!Uint8Array.prototype.forEach) {
|
26 | Object.defineProperty(Uint8Array.prototype, "forEach", {
|
27 | value: Array.prototype.forEach,
|
28 | writable: true,
|
29 | });
|
30 | }
|
31 |
|
32 | export * from "./index";
|