angelnikolov / ts-cacheable

Observable/Promise Cache Decorator
https://npmjs.com/package/ts-cacheable
ISC License
340 stars 42 forks source link

add hashcache option #15

Closed jmls closed 5 years ago

jmls commented 6 years ago

This PR allows for differing key positions in an object parameter to be considered the same. See issue #14

the default cache resolver simply does a JSON.stringify test against the old and new parameters. This does not take into account the position of the properties and can lead to false results (depending on your point of view).

Added a new boolean config option hashcache which uses a resolver that compares the parameters with object-hash

to use the new resolver, set the hashcache option to true

@Cacheable({hashcache:true})

2 extra tests were added: 1) to ensure the old cache resolver considers different key positions to be a different parameter, and 2) to test the new cache resolver considers different key positions to be the same parameter,