polyfill.js
3 years ago
scripts.js
1 year ago
scripts.js.map
3 years ago
scripts_admin copy.js
4 years ago
scripts_admin.js
1 year ago
scripts_admin_all_pages.js
2 years ago
scripts_es6.js
3 years ago
temp.js
4 years ago
polyfill.js
90 lines
| 1 | // endsWith polyfill |
| 2 | if (!String.prototype.endsWith) { |
| 3 | String.prototype.endsWith = function(search, thisLength) { |
| 4 | if (thisLength === undefined || thisLength > this.length) { |
| 5 | thisLength = this.length; |
| 6 | } |
| 7 | return this.substring(thisLength - search.length, thisLength) === search; |
| 8 | }; |
| 9 | } |
| 10 | |
| 11 | // Object.values polyfill |
| 12 | if (!Object.values) Object.values = o=>Object.keys(o).map(k=>o[k]); |
| 13 | |
| 14 | // Array.from polyfill |
| 15 | if (!Array.from) { |
| 16 | Array.from = (function () { |
| 17 | var toStr = Object.prototype.toString; |
| 18 | var isCallable = function (fn) { |
| 19 | return typeof fn === 'function' || toStr.call(fn) === '[object Function]'; |
| 20 | }; |
| 21 | var toInteger = function (value) { |
| 22 | var number = Number(value); |
| 23 | if (isNaN(number)) { return 0; } |
| 24 | if (number === 0 || !isFinite(number)) { return number; } |
| 25 | return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number)); |
| 26 | }; |
| 27 | var maxSafeInteger = Math.pow(2, 53) - 1; |
| 28 | var toLength = function (value) { |
| 29 | var len = toInteger(value); |
| 30 | return Math.min(Math.max(len, 0), maxSafeInteger); |
| 31 | }; |
| 32 | |
| 33 | // The length property of the from method is 1. |
| 34 | return function from(arrayLike/*, mapFn, thisArg */) { |
| 35 | // 1. Let C be the this value. |
| 36 | var C = this; |
| 37 | |
| 38 | // 2. Let items be ToObject(arrayLike). |
| 39 | var items = Object(arrayLike); |
| 40 | |
| 41 | // 3. ReturnIfAbrupt(items). |
| 42 | if (arrayLike == null) { |
| 43 | throw new TypeError("Array.from requires an array-like object - not null or undefined"); |
| 44 | } |
| 45 | |
| 46 | // 4. If mapfn is undefined, then let mapping be false. |
| 47 | var mapFn = arguments.length > 1 ? arguments[1] : void undefined; |
| 48 | var T; |
| 49 | if (typeof mapFn !== 'undefined') { |
| 50 | // 5. else |
| 51 | // 5. a If IsCallable(mapfn) is false, throw a TypeError exception. |
| 52 | if (!isCallable(mapFn)) { |
| 53 | throw new TypeError('Array.from: when provided, the second argument must be a function'); |
| 54 | } |
| 55 | |
| 56 | // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined. |
| 57 | if (arguments.length > 2) { |
| 58 | T = arguments[2]; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | // 10. Let lenValue be Get(items, "length"). |
| 63 | // 11. Let len be ToLength(lenValue). |
| 64 | var len = toLength(items.length); |
| 65 | |
| 66 | // 13. If IsConstructor(C) is true, then |
| 67 | // 13. a. Let A be the result of calling the [[Construct]] internal method of C with an argument list containing the single item len. |
| 68 | // 14. a. Else, Let A be ArrayCreate(len). |
| 69 | var A = isCallable(C) ? Object(new C(len)) : new Array(len); |
| 70 | |
| 71 | // 16. Let k be 0. |
| 72 | var k = 0; |
| 73 | // 17. Repeat, while k < len… (also steps a - h) |
| 74 | var kValue; |
| 75 | while (k < len) { |
| 76 | kValue = items[k]; |
| 77 | if (mapFn) { |
| 78 | A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k); |
| 79 | } else { |
| 80 | A[k] = kValue; |
| 81 | } |
| 82 | k += 1; |
| 83 | } |
| 84 | // 18. Let putStatus be Put(A, "length", len, true). |
| 85 | A.length = len; |
| 86 | // 20. Return A. |
| 87 | return A; |
| 88 | }; |
| 89 | }()); |
| 90 | } |