LocalMachinepacks.buildMachineCode()

Build a JavaScript code string which represents the provided machine metadata.

Usage

Hover over inputs/exits for more info.

var LocalMachinepacks = require('machinepack-localmachinepacks');


// Build a JavaScript code string which represents the provided machine metadata.

LocalMachinepacks.buildMachineCode({

friendlyName: 'Do something',

description: 'Do something useful given stuff; maybe return something else.',

extendedDescription: '...lots of words...',

moreInfoUrl: 'http://www.cis.upenn.edu/~treebank/tokenization.html',

fn: ' return exits.success();',

cacheable: false,

sync: false,

idempotent: false,

environment: [ 'req' ],

inputs: {},

exits: {},

}).execSync();

Inputs

friendlyName required

'Do something'
description

'Do something useful given stuff; maybe return something else.'
extendedDescription

The optional `extendedDescription` property for the generated machine definition.

'...lots of words...'
moreInfoUrl

The optional `moreInfoUrl` property for the generated machine definition.

'http://www.cis.upenn.edu/~treebank/tokenization.html'
fn

The stringified contents of the machine function (`fn`).

'  return exits.success();'
cacheable

Whether or not this machine should be marked as `cacheable`.

false
sync

Whether or not this machine can be run synchronously (with `.execSync()`).

false
idempotent

Whether or not running this machine multiple times achieves different results (ceteris paribus.)

false
environment

An optional array of environment objects. If specified, the machine will depend on these objects in order to work.

[ 'req' ]
inputs

The `inputs` definition object for this machine.

{}
exits

The `exits` definition object for this machine.

{}

Exits

error

An unexpected error occurred.

couldNotParseFnInsideInput
couldNotParseFnInsideExit
couldNotParseFn

The provided `fn` could not be parsed as a function.

success

OK.

'module.exports = { friendlyName: "Do something", inputs: {}, exits: { error: {}, success: {} }, fn: function (inputs, exits){} };'