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 [email protected] https://mail.mozilla.org/listinfo/es-discuss

