Suggest Object.compare(lert, right)
ljharb at gmail.com
Mon Sep 19 05:26:01 UTC 2016
This may have already been proposed as
https://github.com/sebmarkbage/ecmascript-shallow-equal - if so, you'll
want to post your comments there.
On Sun, Sep 18, 2016 at 10:10 PM, Park Hyeonu <nemo1275 at gmail.com> wrote:
> tl;dr - deterministic function that compares arbitrary objects
> I know now we have `Map` and `Set`, but sometimes we need more low level
> ones. Especially for library developers.
> For the case, say, I want to implement a map whose key can be a arbitrary
> number of objects. Currently this can only implemented as nested map whose
> structure is `keylen -> key1 -> key2 -> ... -> value`. Not really elegant.
> But if we have `Object.compare()`, `(key1, key2, ...) -> value` is possible.
> As its intended purpose is to be used with custom map/set, I don't think
> we should define how this function works in spec. Just guaranteed to be
> deterministic in each runtime is enough.
> For detail, this function follows `(left: any, right: any) => number`
> form. When `Object.is(left, right)` is true, `Object.compare(left, right)`
> must return `0`. Otherwise, the result must be deterministic, means
> whenever(in same runtime) we call this function with same arguments it
> should return same value(or at least, always greater than/lesser 0).
> Seems good?
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss