MCPcopy Create free account
hub / github.com/easeway/js-plugins / wrapFactory

Function wrapFactory

lib/Plugins.js:10–23  ·  view source on GitHub ↗
(factory)

Source from the content-addressed store, hash-verified

8 flow = require('js-flow');
9
10function wrapFactory(factory) {
11 if (typeof(factory) == 'function') {
12 if (factory.length < 4) {
13 return function (data, host, info, callback) {
14 var instance = factory(data, host, info);
15 callback(null, instance);
16 };
17 } else {
18 return factory;
19 }
20 } else {
21 return function (data, host, info, callback) { callback(); return null; }
22 }
23}
24
25/** @class ModulePlugin
26 * Plugin loaded from a Node.js module

Callers 1

Plugins.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected