I have noticed a regularity: if you try to return in the function the object which is an argument of that function, than each time a new object returns (although the argument hasn't changed regarding the library's work).
const aFunction = (state) => Math.random();
const memoFunc = memoize(aFunction);
const result1 = memoFunc({a: 1, b: 2});
const result2 = memoFunc({a: 1, b: 2});
console.log(Object.is(result1, result2)) // true
const aFunction = (state) => state;
const memoFunc = memoize(aFunction);
const result1 = memoFunc({a: 1, b: 2});
const result2 = memoFunc({a: 1, b: 2});
console.log(Object.is(result1, result2)) // false?..
Even if the object is inside another object:
const aFunction = (state) =>({n: Math.random()});
const memoFunc = memoize(aFunction);
const result1 = memoFunc({a: 1, b: 2});
const result2 = memoFunc({a: 1, b: 2});
console.log(Object.is(result1, result2) && Object.is(result1.n, result2.n)) // true
const aFunction = (state) =>({n: Math.random(), data: state});
const memoFunc = memoize(aFunction);
const result1 = memoFunc({a: 1, b: 2});
const result2 = memoFunc({a: 1, b: 2});
console.log(Object.is(result1, result2) && Object.is(result1.n, result2.n)) // false?..
Is it bug or a feature?
I have noticed a regularity: if you try to return in the function the object which is an argument of that function, than each time a new object returns (although the argument hasn't changed regarding the library's work).
Even if the object is inside another object:
Is it bug or a feature?