rangoo94/universal-lexer

View on GitHub
lib/compileLexer.js

Summary

Maintainability
A
0 mins
Test Coverage
const buildLexerCode = require('./buildLexerCode')

/**
 * Compiler lexer to use it dynamically
 *
 * @param {object[]} definitions
 * @returns {function(string)|function(string, function)}
 */
function compileLexer (definitions) {
  // eslint-disable-next-line
  return new Function(`return ${buildLexerCode(definitions)}`)()
}

module.exports = compileLexer