UNPKG

@jbrowse/core

Version:

JBrowse 2 core libraries used by plugins

24 lines (23 loc) 881 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.stringToJexlExpression = stringToJexlExpression; const jexl_1 = __importDefault(require("./jexl")); const compilationCache = {}; function stringToJexlExpression(str, jexl) { const cacheKey = `nosig|${str}`; if (!compilationCache[cacheKey]) { const match = str.startsWith('jexl:'); if (!match) { throw new Error('string does not appear to be in jexl format'); } const code = str.split('jexl:')[1]; const compiled = jexl ? jexl.compile(code) : (0, jexl_1.default)().compile(code); compilationCache[cacheKey] = compiled; } return compilationCache[cacheKey]; }