MCPcopy Create free account
hub / github.com/codemix/contractual / createRequireStatement

Function createRequireStatement

lib/processor.js:72–97  ·  view source on GitHub ↗

* Create a require statement to be inserted at the top of the program. * * @param {Object} options [description] * @return {Object} [description]

(options)

Source from the content-addressed store, hash-verified

70 * @return {Object} [description]
71 */
72function createRequireStatement(options) {
73 OBLIGATIONS.precondition(options && typeof options === 'object');
74 return {
75 type: 'VariableDeclaration',
76 kind: 'var',
77 declarations: [{
78 type: 'VariableDeclarator',
79 id: {
80 type: 'Identifier',
81 name: options.libIdentifier
82 },
83 init: {
84 type: 'CallExpression',
85 callee: {
86 type: 'Identifier',
87 name: 'require'
88 },
89 arguments: [{
90 type: 'Literal',
91 value: options.require,
92 raw: JSON.stringify(options.require)
93 }]
94 }
95 }]
96 };
97}
98/**
99 * Processes `FunctionDeclaration` and `FunctionExpression` instances.
100 * These are the only structures which may contain contracts.

Callers 1

processProgramFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected