UNPKG

safe-evaluate-expression

Version:

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

9 lines (6 loc) 267 B
const test = require("ava"); const { safeLambda } = require("../"); const lambda = (a, b, c) => a + b + c; const protectedLambda = safeLambda(lambda, 0); test("lambda is NaN", (t) => t.is(lambda(), NaN)); test("safeLambda is 0", (t) => t.is(protectedLambda(), 0));