@private
(expected, actual)
| 115 | |
| 116 | /** @private */ |
| 117 | function compare (expected, actual) { |
| 118 | if (expected instanceof RegExp) { |
| 119 | if (typeof actual === 'object') return false |
| 120 | if (typeof actual === 'string') return expected.test(actual) |
| 121 | } |
| 122 | |
| 123 | if (typeof expected !== typeof actual) return false |
| 124 | if (typeof expected !== 'object' || expected === null) { |
| 125 | return expected === actual |
| 126 | } |
| 127 | |
| 128 | if (Array.isArray(expected)) { |
| 129 | return expected.every(exp => [].some.call(actual, act => compare(exp, act))) |
| 130 | } |
| 131 | |
| 132 | return Object.keys(expected).every(key => { |
| 133 | const ao = actual[key] |
| 134 | const eo = expected[key] |
| 135 | |
| 136 | if (typeof eo === 'object' && eo !== null && ao !== null) { |
| 137 | return compare(eo, ao) |
| 138 | } |
| 139 | if (typeof eo === 'boolean') { |
| 140 | return eo !== (ao == null) |
| 141 | } |
| 142 | |
| 143 | return ao === eo |
| 144 | }) |
| 145 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…