genish.js
Version:
29 lines (20 loc) • 399 B
JavaScript
let gen = require('./gen.js')
let proto = {
name:'not',
gen() {
let out,
inputs = gen.getInputs( this )
if( isNaN( this.inputs[0] ) ) {
out = `( ${inputs[0]} === 0 ? 1 : 0 )`
} else {
out = !inputs[0] === 0 ? 1 : 0
}
return out
}
}
module.exports = x => {
let not = Object.create( proto )
not.inputs = [ x ]
return not
}