MCPcopy Index your code
hub / github.com/caolan/nodeunit / objEquiv

Function objEquiv

lib/assert.js:230–272  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

228}
229
230function objEquiv (a, b) {
231 if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
232 return false;
233
234 // an identical "prototype" property.
235 if (a.prototype !== b.prototype) return false;
236 //~~~I've managed to break Object.keys through screwy arguments passing.
237 // Converting to array solves the problem.
238 if (isArguments(a)) {
239 if (!isArguments(b)) {
240 return false;
241 }
242 a = pSlice.call(a);
243 b = pSlice.call(b);
244 return _deepEqual(a, b);
245 }
246 try{
247 var ka = _keys(a),
248 kb = _keys(b),
249 key, i;
250 } catch (e) {//happens when one is a string literal and the other isn't
251 return false;
252 }
253 // having the same number of owned properties (keys incorporates hasOwnProperty)
254 if (ka.length != kb.length)
255 return false;
256 //the same set of keys (although not necessarily the same order),
257 ka.sort();
258 kb.sort();
259 //~~~cheap key test
260 for (i = ka.length - 1; i >= 0; i--) {
261 if (ka[i] != kb[i])
262 return false;
263 }
264 //equivalent values for every corresponding key, and
265 //~~~possibly expensive deep test
266 for (i = ka.length - 1; i >= 0; i--) {
267 key = ka[i];
268 if (!_deepEqual(a[key], b[key] ))
269 return false;
270 }
271 return true;
272}
273
274// 8. The non-equivalence assertion tests for any deep inequality.
275// assert.notDeepEqual(actual, expected, message_opt);

Callers 1

_deepEqualFunction · 0.70

Calls 4

isUndefinedOrNullFunction · 0.70
isArgumentsFunction · 0.70
_deepEqualFunction · 0.70
_keysFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…