UNPKG

genish.js

Version:
38 lines (25 loc) 633 B
'use strict' let gen = require('./gen.js') let proto = { basename:'tan', gen() { let out, inputs = gen.getInputs( this ) const isWorklet = gen.mode === 'worklet' const ref = isWorklet? '' : 'gen.' if( isNaN( inputs[0] ) ) { gen.closures.add({ 'tan': isWorklet ? 'Math.tan' : Math.tan }) out = `${ref}tan( ${inputs[0]} )` } else { out = Math.tan( parseFloat( inputs[0] ) ) } return out } } module.exports = x => { let tan = Object.create( proto ) tan.inputs = [ x ] tan.id = gen.getUID() tan.name = `${tan.basename}{tan.id}` return tan }