UNPKG

genish.js

Version:
46 lines (32 loc) 1.07 kB
a = cycle( 330 ) gain = ( in1, amt ) => { return in1 * amt } /* => */ gain( a, .5 ) // uid = 222, a gens to peek123_out let out_222 = peek123_out * .5 /* steps 1. */ expr = function( func, ...args ) { let entire = func.toString(), argNames = entire.substring( entire.indexOf('(') + 1, entire.indexOf(')') ).split(','), body = entire.substring(entire.indexOf("{") + 1, entire.lastIndexOf("}")), newArgNames = [], declaration = '' console.log( argNames ) // for form: v => v * 2 if( argNames[0] === '' ) argNames = entire.substring( 0, entire.indexOf( '=' ) ).split(',') if( body === '' ) body = entire.substring( entire.indexOf('>') + 1 ) console.log ('2', argNames ) newArgNames = argNames.map( v => v.trim() + gen.getUID() ) let inputs = gen.getInputs({ inputs: args }) argNames.forEach( (v,idx) => { let regex = new RegExp( '\ '+v+'\ ', 'gi' ) body = body.replace( regex, ' ' + newArgNames[ idx ] + ' ' ) }) console.log( 'args', argNames, newArgNames ) console.log( 'body', body ) return body }