Last active
June 29, 2018 15:07
-
-
Save JeffreyMFarley/d8e10726aa645949f71d267db7843c1c to your computer and use it in GitHub Desktop.
Who's changing my values?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jasmine.addCustomEqualityTester( ( a, b ) => { | |
const ak = Object.keys( a ).concat( Object.keys( b ) ); | |
const unique = ak.filter( ( v, i, arr ) => arr.indexOf( v ) === i ); | |
unique.sort(); | |
for ( var i = 0; i < unique.length; i++ ) { | |
const k = unique[i]; | |
if ( b[k] ) { | |
console.log( k, '\t', a[k], '\t', b[k] ); | |
} | |
} | |
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const props = [ 'foo', 'bar', 'baz' ]; | |
const myObject = { | |
_innerSanctum: {} | |
}; | |
angular.forEach( props, p => { | |
myObject._innerSanctum[p] = false; | |
Object.defineProperty(myObject, p, { | |
get: () => { | |
console.log(`return ${p} ${myObject._innerSanctum[p]}`); | |
return myObject._innerSanctum[p]; | |
}, | |
set: (x) => { | |
console.log(`${p} = ${x}`); | |
myObject._innerSanctum[p] = x; | |
} | |
} ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment