disable sorting of arrays
adrian-gierakowski opened this issue · 6 comments
I'd like to be able to disable the sorting of arrays, so that hash([1,2] != hash([2,1])
, while keeping all other "object" types sorted. Is this currently possible?
Hi. Currently it's not supported. But I think it's easy to add such option.
For example object sorter could consume not only boolean
, but also an object
that will define granular sorting behaviour for needed types that are used in stringifier.*
methods.
It would be non-breaking change, and quiet easy to implement. If you would like to submit a PR, you're welcome. If not, I think I could find some time by the next weekend to add this.
thanks, I've added a sortArrays
option on my fork for now, which I set to false
to get my desired behaviour, cause that was the quickest way to get what I wanted. But I'll try to submit a PR with your what you've suggested if I find some time later this week.
@adrian-gierakowski good.
If you still interested I've implemented granular sorting control options. The changes aren't published yet, but you may preview them in https://github.com/SkeLLLa/node-object-hash/tree/next branch.
Now it will add possibility to control what kind of items you need to sort. Also it allows to disable type coercion(https://github.com/SkeLLLa/node-object-hash/blob/next/docs/interfaces/objectsorter.coerceoptions.md).
I think it will be released in near future (~ in a week I think). But that would be v2.0.0.
Version 2.0.0-rc.1 released to npm.You may install it via npm i node-object-hash@next
https://www.npmjs.com/package/node-object-hash/v/2.0.0-rc.1
It should contains all features you wanted:
https://github.com/SkeLLLa/node-object-hash/blob/master/docs/interfaces/hasher.hasheroptions.md#optional-sort
Released in v2.0.0. Feel free to test and reopen if it doesn't work as expected.