| 1 | module js |
| 2 | |
| 3 | // TODO: Fix msvc bug that's preventing $embed_file('fast_deep_equal.js') |
| 4 | const fast_deep_eq_fn = "// https://www.npmjs.com/package/fast-deep-equal - 3/3/2021 |
| 5 | const envHasBigInt64Array = typeof BigInt64Array !== 'undefined'; |
| 6 | function vEq(a, b) { |
| 7 | if (a === b) return true; |
| 8 | |
| 9 | if (a && b && typeof a == 'object' && typeof b == 'object') { |
| 10 | if (a.constructor !== b.constructor) return false; |
| 11 | // we want to convert all V types to JS for comparison. |
| 12 | if ('\$toJS' in a) |
| 13 | a = a.\$toJS(); |
| 14 | |
| 15 | if ('\$toJS' in b) |
| 16 | b = b.\$toJS(); |
| 17 | |
| 18 | var length, i, keys; |
| 19 | if (Array.isArray(a)) { |
| 20 | length = a.length; |
| 21 | if (length != b.length) return false; |
| 22 | for (i = length; i-- !== 0;) |
| 23 | if (!vEq(a[i], b[i])) return false; |
| 24 | return true; |
| 25 | } |
| 26 | |
| 27 | if (typeof Map != 'undefined') { |
| 28 | if ((a instanceof Map) && (b instanceof Map)) { |
| 29 | if (a.size !== b.size) return false; |
| 30 | for (i of a.entries()) |
| 31 | if (!b.has(i[0])) return false; |
| 32 | for (i of a.entries()) |
| 33 | if (!vEq(i[1], b.get(i[0]))) return false; |
| 34 | return true; |
| 35 | } |
| 36 | |
| 37 | if ((a instanceof Set) && (b instanceof Set)) { |
| 38 | if (a.size !== b.size) return false; |
| 39 | for (i of a.entries()) |
| 40 | if (!b.has(i[0])) return false; |
| 41 | return true; |
| 42 | } |
| 43 | } |
| 44 | if (typeof ArrayBuffer != 'undefined') { |
| 45 | if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) { |
| 46 | length = a.length; |
| 47 | if (length != b.length) return false; |
| 48 | for (i = length; i-- !== 0;) |
| 49 | if (a[i] !== b[i]) return false; |
| 50 | return true; |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | if (typeof RegExp != 'undefined') { |
| 55 | if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags; |
| 56 | } |
| 57 | if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf(); |
| 58 | if (a.toString !== Object.prototype.toString) return a.toString() === b.toString(); |
| 59 | |
| 60 | keys = Object.keys(a); |
| 61 | length = keys.length; |
| 62 | if (length !== Object.keys(b).length) return false; |
| 63 | |
| 64 | for (i = length; i-- !== 0;) |
| 65 | if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; |
| 66 | |
| 67 | for (i = length; i-- !== 0;) { |
| 68 | var key = keys[i]; |
| 69 | |
| 70 | if (!vEq(a[key], b[key])) return false; |
| 71 | } |
| 72 | |
| 73 | return true; |
| 74 | } |
| 75 | |
| 76 | // true if both NaN, false otherwise |
| 77 | return a!==a && b!==b; |
| 78 | }; |
| 79 | |
| 80 | function \$sortComparator(a, b) |
| 81 | { |
| 82 | a = a.\$toJS(); |
| 83 | b = b.\$toJS(); |
| 84 | if (a > b) return 1; |
| 85 | if (a < b) return -1; |
| 86 | return 0; |
| 87 | |
| 88 | |
| 89 | } |
| 90 | " |
| 91 | |