Handle undefineds
This commit is contained in:
parent
9b2e55f3b4
commit
fd12f398bb
2 changed files with 32 additions and 5 deletions
27
items_2.js
27
items_2.js
|
@ -233,6 +233,33 @@ class ExprField {
|
|||
function compareLexico(ia, keysA, ib, keysB) {
|
||||
for (let i = 0; i < keysA.length; i++) { // assuming keysA and keysB are the same length
|
||||
let aKey = keysA[i], bKey = keysB[i];
|
||||
if (typeof aKey === 'undefined') {
|
||||
switch (typeof bKey) {
|
||||
case 'string':
|
||||
aKey = "";
|
||||
break;
|
||||
case 'number':
|
||||
aKey = 0;
|
||||
break;
|
||||
case 'undefined':
|
||||
return 0;
|
||||
default:
|
||||
throw new Error(`Incomparable type ${typeof bKey}`);
|
||||
}
|
||||
}
|
||||
else if (typeof(bKey) === 'undefined') {
|
||||
switch (typeof aKey) {
|
||||
case 'string':
|
||||
bKey = "";
|
||||
break;
|
||||
case 'number':
|
||||
bKey = 0;
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Incomparable type ${typeof aKey}`);
|
||||
}
|
||||
|
||||
}
|
||||
if (typeof aKey !== typeof bKey) throw new Error(`Incomparable types ${typeof aKey} and ${typeof bKey}`); // can this even happen?
|
||||
switch (typeof aKey) {
|
||||
case 'string':
|
||||
|
|
|
@ -58,11 +58,11 @@
|
|||
"mr": 4,
|
||||
"xpb": 100,
|
||||
"lb": 100,
|
||||
"str": 21,
|
||||
"dex": 21,
|
||||
"int": 21,
|
||||
"agi": 21,
|
||||
"def": 21,
|
||||
"str": 15,
|
||||
"dex": 15,
|
||||
"int": 15,
|
||||
"agi": 15,
|
||||
"def": 15,
|
||||
"hpBonus": 6800,
|
||||
"spRaw1": -1,
|
||||
"spRaw2": -1,
|
||||
|
|
Loading…
Reference in a new issue