Conversation
| */ | ||
|
|
||
| var type = require('type-detect'); | ||
| var compareFn = require('default-compare-with-symbol').defaultCompareWithSymbol; |
There was a problem hiding this comment.
This new dependency also introduces some other transitive dependencies which themselves seem to do the stuff we already have (kind-of looks a lot like type-detect), so I'm a little hesitant to introduce this. If anything I'd like to work on reducing the type-detect dependency as I'm not totally convinced it's necessary with modern engines.
To fix #85 issue it seems as though we could use .toString() instead, or perhaps a try/catch.
There was a problem hiding this comment.
@keithamus I'm hitting the same issue but with actual symbols, not just urls
I don't see any dependencies to default-compare-with-symbol in fact the code is also quite small
https://www.npmjs.com/package/default-compare-with-symbol?activeTab=dependencies
Worst case we can just make the function in the lib, this is exactly what the dep does:
function defaultCompare(a, b) {
const typeA = a === null ? 'null' : typeof a;
const typeB = b === null ? 'null' : typeof b;
if (typeA === 'null' || typeA === 'undefined') {
switch (typeB) {
case typeA:
return 0;
case 'null':
return -1;
default:
return 1;
}
}
switch (true) {
case a < b:
return -1;
case a > b:
return 1;
}
return 0;
}
function extendedCompare(a, b) {
const typeB = typeof b;
if (typeof a === 'symbol') {
return typeB === 'symbol' ? defaultCompare(String(a), String(b)) : -1;
} else if (typeB === 'symbol') {
return 1;
}
return defaultCompare(a, b)
}
#85