browser-index.js 1.3 KB

12345678910111213141516171819202122232425262728
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // This is where we add any polyfills we'll need for the browser. It is the entry module for browser-specific builds.
  4. // Copy from Array.prototype into Uint8Array to polyfill on IE. It's OK because the implementations of indexOf and slice use properties
  5. // that exist on Uint8Array with the same name, and JavaScript is magic.
  6. // We make them 'writable' because the Buffer polyfill messes with it as well.
  7. if (!Uint8Array.prototype.indexOf) {
  8. Object.defineProperty(Uint8Array.prototype, "indexOf", {
  9. value: Array.prototype.indexOf,
  10. writable: true,
  11. });
  12. }
  13. if (!Uint8Array.prototype.slice) {
  14. Object.defineProperty(Uint8Array.prototype, "slice", {
  15. // wrap the slice in Uint8Array so it looks like a Uint8Array.slice call
  16. // eslint-disable-next-line object-shorthand
  17. value: function (start, end) { return new Uint8Array(Array.prototype.slice.call(this, start, end)); },
  18. writable: true,
  19. });
  20. }
  21. if (!Uint8Array.prototype.forEach) {
  22. Object.defineProperty(Uint8Array.prototype, "forEach", {
  23. value: Array.prototype.forEach,
  24. writable: true,
  25. });
  26. }
  27. export * from "./index";
  28. //# sourceMappingURL=browser-index.js.map