@1771technologies/lytenyte-pro
Version:
Blazingly fast headless React data grid with 100s of features.
21 lines (20 loc) • 754 B
JavaScript
import { isAlphaNumeric } from "../predicates/is-alpha-numeric.js";
const KEYWORDS = new Map([
["true", { type: "Boolean", value: "true" }],
["false", { type: "Boolean", value: "false" }],
["null", { type: "Null", value: "null" }],
["undefined", { type: "Undefined", value: "undefined" }],
["in", { type: "Operator", value: "in" }],
["not", { type: "Operator", value: "not" }],
]);
export function scanIdentifier(source, start) {
let i = start;
while (i < source.length && isAlphaNumeric(source[i]))
i++;
const value = source.slice(start, i);
const kw = KEYWORDS.get(value);
if (kw) {
return { type: kw.type, value: kw.value, end: i };
}
return { type: "Identifier", value, end: i };
}