UNPKG

safe-evaluate-expression

Version:

Small library to dynamically create and evaluate expression with multiple parameters (even undefined)

11 lines (8 loc) 214 B
"use strict"; module.exports = (obj, varType = "const") => { const scope = []; for (const [key, val] of Object.entries(obj)) { scope.push(`${varType} ${key} = ${val};`); } return scope.join("\n"); };