import { Util } from '../Util' ; import { Argument } from '.' ; category export class Function extends Argument { param name param args constructor ( name , ... args ) { super ( Function . #constructArgument ( name , ... args ) ) ; } static #constructArgument ( fn , ... args ) { if ( ! fn || ! fn . trim ( ) ) { throw new Error ( 'Function name cannot be empty.' ) ; } if ( args . filter ( arg => arg == null ) . length > 0 ) { throw new Error ( `Invalid function argument: ${ args }` ) ; } let str = `${ fn }(` ; args . forEach ( ( arg , i ) => { str += Util . argumentValueToString ( arg ) ; if ( i < args . length - 1 ) { str += ', ' ; } } ) ; str += ')' ; return str ; } } param name param args category export const fn = ( name , ... args ) : Function => new Function ( name , ... args ) ;