UNPKG

2.21 kBJavaScriptView Raw
1/**
2@license
3Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
4This code may only be used under the BSD style license found at
5http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
6http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
7found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
8part of the polymer project is also subject to an additional IP rights grant
9found at http://polymer.github.io/PATENTS.txt
10*/
11// import polyfill for Symbol and Object.getOwnPropertySymbols
12import 'get-own-property-symbols/build/get-own-property-symbols.max';
13// Fix issue in toString patch when compiled into strict mode via closure
14// https://github.com/es-shims/get-own-property-symbols/issues/16
15const toString = Object.prototype.toString;
16Object.prototype.toString = function () {
17 if (this === undefined) {
18 return '[object Undefined]';
19 }
20 else if (this === null) {
21 return '[object Null]';
22 }
23 else {
24 return toString.call(this);
25 }
26};
27// overwrite Object.keys to filter out symbols
28Object.keys = function (obj) {
29 return Object.getOwnPropertyNames(obj).filter((name) => {
30 const prop = Object.getOwnPropertyDescriptor(obj, name);
31 return prop && prop.enumerable;
32 });
33};
34// implement iterators for IE 11
35if (!String.prototype[Symbol.iterator] || !String.prototype.codePointAt) {
36 String.prototype[Symbol.iterator] = function* () {
37 for (let i = 0; i < this.length; i++) {
38 yield this[i];
39 }
40 };
41}
42if (!Set.prototype[Symbol.iterator]) {
43 Set.prototype[Symbol.iterator] = function* () {
44 const temp = [];
45 this.forEach((value) => {
46 temp.push(value);
47 });
48 for (let i = 0; i < temp.length; i++) {
49 yield temp[i];
50 }
51 };
52}
53if (!Map.prototype[Symbol.iterator]) {
54 Map.prototype[Symbol.iterator] = function* () {
55 const entries = [];
56 this.forEach((value, key) => {
57 entries.push([key, value]);
58 });
59 for (let i = 0; i < entries.length; i++) {
60 yield entries[i];
61 }
62 };
63}
64//# sourceMappingURL=symbol.js.map
\No newline at end of file