Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const collectTokens = string => {
const tokens = [];
let lastPos = 0;
try {
// eslint-disable-next-line no-restricted-syntax
for (const token of tokenizer(string, tokenizerOptions)) {
// Prepend empty space(s) as required.
if (token.start > lastPos) {
// eslint-disable-next-line fp/no-mutating-methods
tokens.push({
value: ' '.repeat(token.start - lastPos),
});
}
// Set custom types for missing types.
if (token.value === 'let') {
// eslint-disable-next-line no-underscore-dangle
token.type = tokenTypes._let;
}
if (token.value === 'from') {
// eslint-disable-next-line no-underscore-dangle
token.type = tokenTypes._from;