The function generated by keywordTransform provides does not include switch defaults so a non-keyword that is of the same length as a keyword will be checked against all possible keyword values longer than it.
With the existing output a non keyword like 'x' is checked against both case "a" and case "bb":
//> console.log(moo.keywords({KW: ['a', 'bb'] }).toString())
function anonymous(value
) {
switch (value.length) {
case 1:
switch (value) {
case "a": return "KW"
}
case 2:
switch (value) {
case "bb": return "KW"
}
}
}
With the changes in this commit it is only checked against case "a".
//> console.log(moo.keywords({KW: ['a', 'bb'] }).toString())
function anonymous(value
) {
switch (value.length) {
case 1:
switch (value) {
case "a": return "KW"
default: return
}
case 2:
switch (value) {
case "bb": return "KW"
default: return
}
}
}
The function generated by keywordTransform provides does not include switch defaults so a non-keyword that is of the same length as a keyword will be checked against all possible keyword values longer than it.
With the existing output a non keyword like 'x' is checked against both
case "a"
andcase "bb"
:With the changes in this commit it is only checked against
case "a"
.