We should probably run through type conversion no matter what during sorting
justinbmeyer opened this issue · comments
Currently, we don't use the .valueOf()
when doing sorting no matter what with a SetType like:
class StringIgnoreCaseSet {
constructor(value){
this.value = value;
}
// used to convert to a number
valueOf(){
return this.value.toLowerCase();
}
}
The problem here is that it will try to compare the new LessThan( new StringIgnoreCaseSet("word") )
to "WORD"
and not .toLowerCase()
"WORD". This is because in general, this is the right thing to do for MEMBERSHIP
, but the wrong thing to do when comparing two sets. Somehow we need to hydrate both sides ...
https://codepen.io/justinbmeyer/pen/Mzzgar?editors=0011
$lt: function(valueA, valueB) {
if(valueA == null || valueB == null) {
return helpers_1$1.typeCompare.$lt(valueA, valueB);
}
var $lt = hydrateAndValue({
$lt: valueB
}, key, schemaProp,
helpers_1$1.valueHydrator);
return $lt[isMemberSymbol$3](valueA);
}
Calls:
function isMemberThatUsesTest(value) {
var values = set_1$1.ownAndMemberValue(this.value, value);
return this.constructor.test(values.member, values.own);
}
ownAndMemberValue
will use .valueOf()
on this.value
's StringIgnoreCaseSet, but it will not convert the other side ....
ownValue.constructor !== memberValue.constructor
Sorting might need to use a bit different way of doing isMember