worklet-helpers.js (693B)
1 // This file contains helper methods that are appended to the start of bidder 2 // and seller worklets. 3 4 // Comparison function that checks if two arguments are the same. 5 // Not intended for use on anything other than built-in types 6 // (Arrays, objects, and primitive types). 7 function deepEquals(a, b) { 8 if (typeof a !== typeof b) 9 return false; 10 if (typeof a !== 'object' || a === null || b === null) 11 return a === b; 12 13 let aKeys = Object.keys(a); 14 if (aKeys.length !== Object.keys(b).length) 15 return false; 16 for (let key of aKeys) { 17 if (a.hasOwnProperty(key) !== b.hasOwnProperty(key) || 18 !deepEquals(a[key], b[key])) { 19 return false; 20 } 21 } 22 return true; 23 }