array_to_if

0.0.2 • Public • Published

Build Status

Array to If

Node.js module that takes an array and generates a string with a function containing conditional constructs.

Install

npm i array_to_if

Examples

const F = require('array_to_if')

let one = eval(F([1,2,3,4,5], 'if (argv[0] == %%) { return argv[0]*%% } else', 0))
let two = eval(F([1,2,3,4,5], (a, b) => b == a, (a, b) => b * a, 0)) // so slow
let three = eval(F([1,2,3,4,5], F.t`${0} == ${'item'}`, F.t`${0} * ${'item'}`, 0))

console.log(one(3))
console.log(two(4))
console.log(three(5))

Package Sidebar

Install

npm i array_to_if

Weekly Downloads

2

Version

0.0.2

License

GPL-3.0

Last publish

Collaborators

  • kekdude