Skip to content

Instantly share code, notes, and snippets.

@JeffreyMFarley
Last active June 29, 2018 15:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffreyMFarley/d8e10726aa645949f71d267db7843c1c to your computer and use it in GitHub Desktop.
Save JeffreyMFarley/d8e10726aa645949f71d267db7843c1c to your computer and use it in GitHub Desktop.
Who's changing my values?
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] );
}
}
} );
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