| 171 | } |
| 172 | |
| 173 | function _deepEqual(actual, expected) { |
| 174 | // 7.1. All identical values are equivalent, as determined by ===. |
| 175 | if (actual === expected) |
| 176 | return true; |
| 177 | |
| 178 | // Convert to primitives, if supported |
| 179 | actual = actual.valueOf ? actual.valueOf() : actual; |
| 180 | expected = expected.valueOf ? expected.valueOf() : expected; |
| 181 | |
| 182 | // 7.2. If the expected value is a Date object, the actual value is |
| 183 | // equivalent if it is also a Date object that refers to the same time. |
| 184 | if (actual instanceof Date && expected instanceof Date) { |
| 185 | return actual.getTime() === expected.getTime(); |
| 186 | |
| 187 | // 7.2.1 If the expcted value is a RegExp object, the actual value is |
| 188 | // equivalent if it is also a RegExp object that refers to the same source and options |
| 189 | } else if (actual instanceof RegExp && expected instanceof RegExp) { |
| 190 | return actual.source === expected.source && |
| 191 | actual.global === expected.global && |
| 192 | actual.ignoreCase === expected.ignoreCase && |
| 193 | actual.multiline === expected.multiline; |
| 194 | |
| 195 | } else if (Buffer && actual instanceof Buffer && expected instanceof Buffer) { |
| 196 | return (function() { |
| 197 | var i, len; |
| 198 | |
| 199 | for (i = 0, len = expected.length; i < len; i++) { |
| 200 | if (actual[i] !== expected[i]) { |
| 201 | return false; |
| 202 | } |
| 203 | } |
| 204 | return actual.length === expected.length; |
| 205 | })(); |
| 206 | // 7.3. Other pairs that do not both pass typeof value == "object", |
| 207 | // equivalence is determined by ==. |
| 208 | } else if (typeof actual != 'object' && typeof expected != 'object') { |
| 209 | return actual == expected; |
| 210 | |
| 211 | // 7.4. For all other Object pairs, including Array objects, equivalence is |
| 212 | // determined by having the same number of owned properties (as verified |
| 213 | // with Object.prototype.hasOwnProperty.call), the same set of keys |
| 214 | // (although not necessarily the same order), equivalent values for every |
| 215 | // corresponding key, and an identical "prototype" property. Note: this |
| 216 | // accounts for both named and indexed properties on Arrays. |
| 217 | } else { |
| 218 | return objEquiv(actual, expected); |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | function isUndefinedOrNull (value) { |
| 223 | return value === null || value === undefined; |