(b: any, a: any)
| 58 | // cloned from https://github.com/epoberezkin/fast-deep-equal with small changes |
| 59 | export |
| 60 | function objectIncludes (b: any, a: any): boolean { |
| 61 | if (a === b) return true; |
| 62 | |
| 63 | const arrA = Array.isArray(a), arrB = Array.isArray(b); |
| 64 | let i; |
| 65 | |
| 66 | if (arrA && arrB) { |
| 67 | if (a.length != b.length) return false; |
| 68 | for (i = 0; i < a.length; i++) |
| 69 | if (!objectIncludes(a[i], b[i])) return false; |
| 70 | return true; |
| 71 | } |
| 72 | |
| 73 | if (arrA != arrB) return false; |
| 74 | |
| 75 | if (a && b && typeof a === 'object' && typeof b === 'object') { |
| 76 | const dateA = a instanceof Date, dateB = b instanceof Date; |
| 77 | if (dateA && dateB) return a.getTime() == b.getTime(); |
| 78 | if (dateA != dateB) return false; |
| 79 | |
| 80 | const regexpA = a instanceof RegExp, regexpB = b instanceof RegExp; |
| 81 | if (regexpA && regexpB) return a.toString() == b.toString(); |
| 82 | if (regexpA != regexpB) return false; |
| 83 | |
| 84 | const keys = Object.keys(a); |
| 85 | // if (keys.length !== Object.keys(b).length) return false; |
| 86 | |
| 87 | for (i = 0; i < keys.length; i++) |
| 88 | if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; |
| 89 | |
| 90 | for (i = 0; i < keys.length; i++) |
| 91 | if(!objectIncludes(b[keys[i]], a[keys[i]])) return false; |
| 92 | |
| 93 | return true; |
| 94 | } else if (a && b && typeof a === 'function' && typeof b === 'function') { |
| 95 | return a.toString() === b.toString() |
| 96 | } |
| 97 | |
| 98 | return false; |
| 99 | } |
| 100 | |
| 101 | /** Selection range */ |
| 102 | export |
no test coverage detected