A simple, no-nonsense procedure caller.
npm i @art-of-coding/procedure-caller
const ProcedureCaller = require('@art-of-coding/procedure-caller')
// Create a new ProcedureCaller
const pc = new ProcedureCaller()
// Define an 'add' procedure
pc.define('add', function (a, b) {
return a + b
})
// Call the 'add' procedure
const result = pc.call('add', 5, 6)
// And log the result
console.log(`The result is ${result}`)
Instantiates a new ProcedureCaller. Currently there are no arguments.
Defines a procedure by the given name
.
name
: The name of the procedurefn
: The procedure functionoverride
: Override if a procedure with this name already exists (defaultfalse
)
Calls the procedure with the given name
and returns the result.
name
: The name of the procedure...args
: Zero, one or more arguments for the procedure
Deletes the procedure with the given name
.
name
: The name of the procedurefailSilently
: Don't throw an error ifname
is not defined
Copyright 2017 Art of Coding.
This software is licensed under the MIT License.