New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

noflo

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

noflo - npm Package Compare versions

Comparing version 1.2.6 to 1.2.7

tsconfig.json

5

CHANGES.md
NoFlo ChangeLog
===============
## 1.2.7 (November 13th 2020)
* Added safeties against trying to load a falsy graph in `asCallback`
* Added safeties against trying to load unnamed components
## 1.2.6 (September 24th 2020)

@@ -5,0 +10,0 @@

17

components/Graph.js

@@ -66,3 +66,3 @@ "use strict";

_this.inPorts.graph.on('ip', function (packet) {
_this.inPorts.ports.graph.on('ip', function (packet) {
if (packet.type !== 'data') {

@@ -106,3 +106,3 @@ return;

inst.baseDir = _this2.baseDir;
inst.properties.baseDir = _this2.baseDir;

@@ -128,3 +128,3 @@ _this2.createNetwork(inst, callback);

inst.baseDir = _this2.baseDir;
inst.properties.baseDir = _this2.baseDir;

@@ -147,3 +147,3 @@ _this2.createNetwork(inst, callback);

graphObj.componentLoader = this.loader;
graphObj.properties.componentLoader = this.loader;
noflo.createNetwork(graphObj, {

@@ -187,12 +187,13 @@ delay: true,

key: "subscribeNetwork",
value: function subscribeNetwork() {
value: function subscribeNetwork(network) {
var _this4 = this;
var contexts = [];
this.network.on('start', function () {
network.on('start', function () {
var ctx = {};
contexts.push(ctx);
return _this4.activate(ctx);
_this4.activate(ctx);
});
return this.network.on('end', function () {
network.on('end', function () {
var ctx = contexts.pop();

@@ -199,0 +200,0 @@

// Flow-based example of counting lines of a file, roughly equivalent to
// "wc -l <filename>"
const noflo = require("noflo");
const noflo = require("../../lib/NoFlo");

@@ -14,6 +14,6 @@ if (!process.argv[2]) {

const graph = noflo.graph.createGraph("linecount");
graph.addNode("Read File", "ReadFile");
graph.addNode("Split by Lines", "SplitStr");
graph.addNode("Count Lines", "Counter");
graph.addNode("Display", "Output");
graph.addNode("Read File", "filesystem/ReadFile");
graph.addNode("Split by Lines", "strings/SplitStr");
graph.addNode("Count Lines", "packets/Counter");
graph.addNode("Display", "core/Output");

@@ -24,2 +24,4 @@ graph.addEdge("Read File", "out", "Split by Lines", "in");

graph.addEdge("Count Lines", "count", "Display", "in");
// Specify encoding
graph.addInitial("utf-8", "Read File", "encoding");

@@ -29,3 +31,5 @@ // Kick the process off by sending filename to fileReader

noflo.createNetwork(graph, (err) => {
noflo.createNetwork(graph, {
subscribeGraph: false,
}, (err) => {
if (err) {

@@ -32,0 +36,0 @@ console.error(err);

{
"properties": {
"name": "Count lines in a file"
"inports": {},
"outports": {},
"groups": [],
"processes": {
"Read": {
"component": "filesystem/ReadFile"
},
"processes": {
"ReadFile": {
"component": "ReadFile",
"metadata": {
"display": {
"x": 91,
"y": 154
}
}
},
"SplitbyLines": {
"component": "SplitStr",
"metadata": {
"display": {
"x": 209,
"y": 414
}
}
},
"CountLines": {
"component": "Counter",
"metadata": {
"display": {
"x": 206,
"y": 750
}
}
},
"Display": {
"component": "Output",
"metadata": {
"display": {
"x": 71,
"y": 1003
}
}
}
"Split": {
"component": "strings/SplitStr"
},
"connections": [
{
"src": {
"process": "ReadFile",
"port": "out"
},
"tgt": {
"process": "SplitbyLines",
"port": "in"
}
},
{
"src": {
"process": "ReadFile",
"port": "error"
},
"tgt": {
"process": "Display",
"port": "in"
}
},
{
"src": {
"process": "SplitbyLines",
"port": "out"
},
"tgt": {
"process": "CountLines",
"port": "in"
}
},
{
"src": {
"process": "CountLines",
"port": "count"
},
"tgt": {
"process": "Display",
"port": "in"
}
},
{
"data": "package.json",
"tgt": {
"process": "ReadFile",
"port": "in"
}
}
]
"Count": {
"component": "packets/Counter"
},
"Display": {
"component": "core/Output"
}
},
"connections": [
{
"data": "utf-8",
"tgt": {
"process": "Read",
"port": "encoding"
}
},
{
"data": "package.json",
"tgt": {
"process": "Read",
"port": "in"
}
},
{
"src": {
"process": "Read",
"port": "out"
},
"tgt": {
"process": "Split",
"port": "in"
}
},
{
"src": {
"process": "Split",
"port": "out"
},
"tgt": {
"process": "Count",
"port": "in"
}
},
{
"src": {
"process": "Count",
"port": "count"
},
"tgt": {
"process": "Display",
"port": "in"
}
},
{
"src": {
"process": "Read",
"port": "error"
},
"tgt": {
"process": "Display",
"port": "in"
}
}
],
"caseSensitive": false
}

@@ -85,3 +85,4 @@ "use strict";

if (_typeof(component) === 'object') {
component.componentLoader = options.loader;
// This is a graph object
component.properties.componentLoader = options.loader;
network = new Network(component, options); // Wire the network up

@@ -121,3 +122,3 @@

graph.componentLoader = options.loader;
graph.properties.componentLoader = options.loader;
network = new Network(graph, options); // Wire the network up and start execution

@@ -211,2 +212,7 @@

if (!portDef) {
callback(new Error("Port ".concat(port, " not available in the graph")));
return;
}
var _process = network.getNode(portDef.process);

@@ -238,3 +244,3 @@

// Scalar values are always simple inputs
if (_typeof(inputs) !== 'object') {
if (_typeof(inputs) !== 'object' || !inputs) {
return 'simple';

@@ -286,4 +292,9 @@ }

var inPort = Object.keys(network.graph.inports)[0]; // If we have a port named "IN", send to that
var inPort = Object.keys(network.graph.inports)[0];
if (!inPort) {
return {};
} // If we have a port named "IN", send to that
if (network.graph.inports["in"]) {

@@ -399,2 +410,6 @@ inPort = 'in';

exports.asCallback = function asCallback(component, options) {
if (!component) {
throw new Error('No component or graph provided');
}
options = normalizeOptions(options, component);

@@ -401,0 +416,0 @@ return function (inputs, callback) {

@@ -144,6 +144,6 @@ "use strict";

if (!platform.isBrowser()) {
_this.baseDir = graph.baseDir || process.cwd(); // On browser we default the baseDir to the Component loading
_this.baseDir = graph.properties.baseDir || process.cwd(); // On browser we default the baseDir to the Component loading
// root
} else {
_this.baseDir = graph.baseDir || '/';
_this.baseDir = graph.properties.baseDir || '/';
} // As most NoFlo networks are long-running processes, the

@@ -156,4 +156,4 @@ // network coordinator marks down the start-up time. This

if (graph.componentLoader) {
_this.loader = graph.componentLoader;
if (graph.properties.componentLoader) {
_this.loader = graph.properties.componentLoader;
} else {

@@ -175,3 +175,3 @@ _this.loader = new componentLoader.ComponentLoader(_this.baseDir, _this.options);

return new Date() - this.startupDate;
return Date.now() - this.startupDate.getTime();
}

@@ -399,3 +399,4 @@ }, {

return this.processes[id];
}
} // eslint-disable-next-line no-unused-vars
}, {

@@ -406,3 +407,3 @@ key: "connect",

var done = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
var done = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (err) {};
// Wrap the future which will be called when done in a function and return

@@ -884,3 +885,4 @@ // it

return this.getActiveProcesses().length > 0;
}
} // eslint-disable-next-line no-unused-vars
}, {

@@ -891,3 +893,3 @@ key: "startComponents",

var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (err) {};
// Emit start event when all processes are started

@@ -894,0 +896,0 @@ var count = 0;

@@ -36,5 +36,19 @@ "use strict";

var validTypes = ['all', 'string', 'number', 'int', 'object', 'array', 'boolean', 'color', 'date', 'bang', 'function', 'buffer', 'stream'];
/**
* @typedef {Object} BaseOptions - Options for configuring all types of ports
* @property {string} [description='']
* @property {string} [datatype='all']
* @property {string} [schema=null]
* @property {string} [type=null]
* @property {boolean} [required=false]
* @property {boolean} [scoped=true]
*/
function handleOptions() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
/**
* @template {BaseOptions} BaseportOptions
* @param {BaseportOptions} options
* @return {BaseportOptions}
*/
function handleOptions(options) {
// We default to the `all` type if no explicit datatype

@@ -60,10 +74,16 @@ // was provided

throw new Error("Invalid port schema '".concat(schema, "' specified. Should be URL or MIME type"));
}
} // Scoping
var scoped = typeof options.scoped === 'boolean' ? options.scoped : true; // Description
var description = options.description || '';
/* eslint-disable prefer-object-spread */
return Object.assign({}, options, {
description: description,
datatype: datatype,
required: required,
schema: schema
schema: schema,
scoped: scoped
});

@@ -138,8 +158,9 @@ }

this.emit('attach', socket);
}
/* eslint-disable class-methods-use-this */
} // eslint-disable-next-line class-methods-use-this,no-unused-vars
}, {
key: "attachSocket",
value: function attachSocket() {}
value: function attachSocket(socket) {
var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
}
}, {

@@ -146,0 +167,0 @@ key: "detach",

@@ -98,4 +98,4 @@ "use strict";

_this.icon = opts.icon ? opts.icon : _this.constructor.icon;
_this.description = opts.description ? opts.description : _this.constructor.description; // Initially the component is not started
_this.icon = opts.icon ? opts.icon : '';
_this.description = opts.description ? opts.description : ''; // Initially the component is not started

@@ -120,17 +120,19 @@ _this.started = false;

_this.forwardBrackets = {
"in": ['out', 'error']
};
if (!opts.forwardBrackets) {
opts.forwardBrackets = {
"in": ['out', 'error']
};
}
if ('forwardBrackets' in opts) {
_this.forwardBrackets = opts.forwardBrackets;
} // The component's process function can either be
_this.forwardBrackets = opts.forwardBrackets; // The component's process function can either be
// passed in opts, or given imperatively after
// instantation using the `component.process` method.
if (typeof opts.process === 'function') {
_this.process(opts.process);
}
} // Placeholder for the ID of the current node, populated
// by NoFlo network
_this.nodeId = null;
return _this;

@@ -137,0 +139,0 @@ }

@@ -166,2 +166,7 @@ "use strict";

if (!name) {
callback(new Error('No component name provided'));
return;
}
if (!this.ready) {

@@ -168,0 +173,0 @@ this.listComponents(function (err) {

@@ -69,2 +69,3 @@ "use strict";

_this = _super.call(this, opts);
_this.nodeInstance = null;

@@ -71,0 +72,0 @@ _this.prepareBuffer();

@@ -141,2 +141,4 @@ "use strict";

_this.emitEvent = _this.regularEmitEvent;
_this.from = null;
_this.to = null;
return _this;

@@ -414,3 +416,4 @@ } // ## Socket connections

exports.createSocket = function () {
return new InternalSocket();
var metadata = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return new InternalSocket(metadata);
};

@@ -66,4 +66,5 @@ "use strict";

return _super.call(this, graph, options);
}
} // eslint-disable-next-line no-unused-vars
_createClass(LegacyNetwork, [{

@@ -74,3 +75,3 @@ key: "connect",

var done = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
var done = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (err) {};

@@ -77,0 +78,0 @@ _get(_getPrototypeOf(LegacyNetwork.prototype), "connect", this).call(this, function (err) {

@@ -117,5 +117,6 @@ "use strict";

var modulePath = path.resolve(baseDir, "./components/".concat(name, ".js"));
var moduleImpl = new Module(modulePath, module);
var moduleImpl = new Module(modulePath, module); // @ts-ignore
moduleImpl.paths = Module._nodeModulePaths(path.dirname(modulePath));
moduleImpl.filename = modulePath;
moduleImpl.filename = modulePath; // @ts-ignore

@@ -122,0 +123,0 @@ moduleImpl._compile(source, modulePath);

@@ -235,3 +235,3 @@ "use strict";

if (options.baseDir) {
net.baseDir = options.baseDir;
net.properties.baseDir = options.baseDir;
}

@@ -238,0 +238,0 @@

@@ -39,3 +39,13 @@ "use strict";

/**
* @typedef {Object} OutportOptions - Options for configuring outports
* @property {string} [description='']
* @property {string} [datatype='all']
* @property {string} [schema=null]
* @property {boolean} [required=false]
* @property {boolean} [caching=false]
* @property {boolean} [scoped=true]
*/
module.exports = /*#__PURE__*/function (_BasePort) {

@@ -46,2 +56,5 @@ _inherits(OutPort, _BasePort);

/**
* @param {OutportOptions} options - Options for the outport
*/
function OutPort() {

@@ -60,2 +73,6 @@ var _this;

if (typeof opts.caching !== 'boolean') {
opts.caching = false;
}
_this = _super.call(this, opts);

@@ -62,0 +79,0 @@ _this.cache = {};

@@ -26,6 +26,2 @@ "use strict";

if (exports.isBrowser()) {
if (window.NOFLO_FATAL_DEPRECATED) {
throw new Error(message);
}
console.warn(message);

@@ -32,0 +28,0 @@ return;

@@ -130,3 +130,3 @@ "use strict";

this.ports[name].on(event, callback);
return this.ports[name].on(event, callback);
}

@@ -140,3 +140,3 @@ }, {

this.ports[name].once(event, callback);
return this.ports[name].once(event, callback);
}

@@ -143,0 +143,0 @@ }]);

@@ -120,3 +120,3 @@ "use strict";

function later() {
var last = Date.now - timestamp;
var last = Date.now() - timestamp;

@@ -142,3 +142,3 @@ if (last < wait && last >= 0) {

args = arguments;
timestamp = Date.now;
timestamp = Date.now();
var callNow = immediate && !timeout;

@@ -145,0 +145,0 @@

@@ -11,3 +11,3 @@ {

"author": "Henri Bergius <henri.bergius@iki.fi>",
"version": "1.2.6",
"version": "1.2.7",
"license": "MIT",

@@ -21,3 +21,3 @@ "engines": {

"fbp": "^1.5.0",
"fbp-graph": "^0.4.0",
"fbp-graph": "^0.6.1",
"fbp-manifest": "^0.2.5",

@@ -30,2 +30,3 @@ "get-function-params": "^2.0.6"

"@babel/preset-env": "^7.11.0",
"@types/node": "^14.14.2",
"chai": "^4.0.0",

@@ -36,2 +37,3 @@ "coveralls": "^3.0.0",

"eslint-plugin-import": "^2.22.0",
"events": "^3.2.0",
"karma": "^5.1.1",

@@ -45,5 +47,8 @@ "karma-chai": "^0.1.0",

"nyc": "^15.1.0",
"path-browserify": "^1.0.1",
"process": "^0.11.10",
"typescript": "^4.0.2",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12"
"util": "^0.12.3",
"webpack": "^5.0.0",
"webpack-cli": "^4.0.0"
},

@@ -61,3 +66,5 @@ "main": "./lib/NoFlo",

"scripts": {
"pretest": "eslint src",
"lint": "eslint src",
"typecheck": "tsc --noEmit",
"pretest": "npm run lint && npm run typecheck",
"test:node": "nyc mocha --require spec/utils/inject.js spec",

@@ -64,0 +71,0 @@ "test:browser": "karma start karma.config.js",

@@ -46,3 +46,3 @@ describe('NoFlo Legacy Network', () => {

g = new noflo.Graph();
g.baseDir = baseDir;
g.properties.baseDir = baseDir;
n = new noflo.Network(g);

@@ -70,3 +70,3 @@ n.connect(done);

it('should know its baseDir', () => {
chai.expect(n.baseDir).to.equal(g.baseDir);
chai.expect(n.baseDir).to.equal(g.properties.baseDir);
});

@@ -77,3 +77,3 @@ it('should have a ComponentLoader', () => {

it('should have transmitted the baseDir to the Component Loader', () => {
chai.expect(n.loader.baseDir).to.equal(g.baseDir);
chai.expect(n.loader.baseDir).to.equal(g.properties.baseDir);
});

@@ -194,3 +194,3 @@ it('should be able to list components', function (done) {

g = new noflo.Graph();
g.baseDir = baseDir;
g.properties.baseDir = baseDir;
g.addNode('Merge', 'Merge');

@@ -342,3 +342,3 @@ g.addNode('Callback', 'Callback');

// Pass the already-initialized component loader
graph.componentLoader = n.loader;
graph.properties.componentLoader = n.loader;
graph.addInitial((data) => {

@@ -389,3 +389,3 @@ chai.expect(data).to.equal('Foo');

g = new noflo.Graph();
g.baseDir = baseDir;
g.properties.baseDir = baseDir;
g.addNode('Def', 'Def');

@@ -488,3 +488,3 @@ g.addNode('Cb', 'Cb');

g = new noflo.Graph();
g.baseDir = baseDir;
g.properties.baseDir = baseDir;
g.addNode('Callback', 'Callback');

@@ -584,3 +584,3 @@ g.addNode('Repeat', 'Split');

const g = new noflo.Graph();
g.baseDir = baseDir;
g.properties.baseDir = baseDir;
let called = 0;

@@ -766,3 +766,3 @@ for (n = 0; n <= 10000; n++) {

const g = new noflo.Graph();
g.baseDir = baseDir;
g.properties.baseDir = baseDir;
const n = new noflo.Network(g);

@@ -782,3 +782,3 @@ chai.expect(n.baseDir).to.equal(baseDir);

const g = new noflo.Graph();
g.baseDir = baseDir;
g.properties.baseDir = baseDir;
const n = new noflo.Network(g);

@@ -794,3 +794,3 @@ chai.expect(n.baseDir).to.equal(baseDir);

g = new noflo.Graph();
g.baseDir = baseDir;
g.properties.baseDir = baseDir;
n = new noflo.Network(g);

@@ -797,0 +797,0 @@ n.loader.listComponents((err) => {

@@ -46,3 +46,3 @@ describe('NoFlo Network', () => {

g = new noflo.Graph();
g.baseDir = baseDir;
g.properties.baseDir = baseDir;
noflo.createNetwork(g, {

@@ -80,3 +80,3 @@ subscribeGraph: false,

it('should know its baseDir', () => {
chai.expect(n.baseDir).to.equal(g.baseDir);
chai.expect(n.baseDir).to.equal(g.properties.baseDir);
});

@@ -87,3 +87,3 @@ it('should have a ComponentLoader', () => {

it('should have transmitted the baseDir to the Component Loader', () => {
chai.expect(n.loader.baseDir).to.equal(g.baseDir);
chai.expect(n.loader.baseDir).to.equal(g.properties.baseDir);
});

@@ -266,3 +266,3 @@ it('should be able to list components', function (done) {

g = new noflo.Graph();
g.baseDir = baseDir;
g.properties.baseDir = baseDir;
g.addNode('Merge', 'Merge');

@@ -468,3 +468,3 @@ g.addNode('Callback', 'Callback');

// Pass the already-initialized component loader
graph.componentLoader = n.loader;
graph.properties.componentLoader = n.loader;
graph.addInitial((data) => {

@@ -519,3 +519,3 @@ chai.expect(data).to.equal('Foo');

g = new noflo.Graph();
g.baseDir = baseDir;
g.properties.baseDir = baseDir;
g.addNode('Def', 'Def');

@@ -627,3 +627,3 @@ g.addNode('Cb', 'Cb');

g = new noflo.Graph();
g.baseDir = baseDir;
g.properties.baseDir = baseDir;
g.addNode('Callback', 'Callback');

@@ -768,3 +768,3 @@ g.addNode('Repeat', 'Split');

const g = new noflo.Graph();
g.baseDir = baseDir;
g.properties.baseDir = baseDir;
let called = 0;

@@ -1014,3 +1014,3 @@ for (n = 0; n <= 10000; n++) {

const g = new noflo.Graph();
g.baseDir = baseDir;
g.properties.baseDir = baseDir;
noflo.createNetwork(g, {

@@ -1050,3 +1050,3 @@ delay: true,

const g = new noflo.Graph();
g.baseDir = baseDir;
g.properties.baseDir = baseDir;
noflo.createNetwork(g, {

@@ -1072,3 +1072,3 @@ delay: true,

g = new noflo.Graph();
g.baseDir = baseDir;
g.properties.baseDir = baseDir;
noflo.createNetwork(g, {

@@ -1075,0 +1075,0 @@ subscribeGraph: false,

@@ -36,3 +36,3 @@ // NoFlo - Flow-Based Programming for JavaScript

this.inPorts.graph.on('ip', (packet) => {
this.inPorts.ports.graph.on('ip', (packet) => {
if (packet.type !== 'data') { return; }

@@ -64,3 +64,3 @@ this.setGraph(packet.data, (err) => {

}
inst.baseDir = this.baseDir;
inst.properties.baseDir = this.baseDir;
this.createNetwork(inst, callback);

@@ -83,3 +83,3 @@ });

}
inst.baseDir = this.baseDir;
inst.properties.baseDir = this.baseDir;
this.createNetwork(inst, callback);

@@ -95,3 +95,3 @@ });

if (!graphObj.name) { graphObj.name = this.nodeId; }
graphObj.componentLoader = this.loader;
graphObj.properties.componentLoader = this.loader;

@@ -130,10 +130,10 @@ noflo.createNetwork(graphObj, {

subscribeNetwork() {
subscribeNetwork(network) {
const contexts = [];
this.network.on('start', () => {
network.on('start', () => {
const ctx = {};
contexts.push(ctx);
return this.activate(ctx);
this.activate(ctx);
});
return this.network.on('end', () => {
network.on('end', () => {
const ctx = contexts.pop();

@@ -140,0 +140,0 @@ if (!ctx) { return; }

@@ -68,3 +68,4 @@ // NoFlo - Flow-Based Programming for JavaScript

if (typeof component === 'object') {
component.componentLoader = options.loader;
// This is a graph object
component.properties.componentLoader = options.loader;

@@ -103,3 +104,3 @@ network = new Network(component, options);

// Prepare network
graph.componentLoader = options.loader;
graph.properties.componentLoader = options.loader;
network = new Network(graph, options);

@@ -185,2 +186,6 @@ // Wire the network up and start execution

const portDef = network.graph.inports[port];
if (!portDef) {
callback(new Error(`Port ${port} not available in the graph`));
return;
}
const process = network.getNode(portDef.process);

@@ -209,3 +214,3 @@ inSockets[port] = internalSocket.createSocket();

// Scalar values are always simple inputs
if (typeof inputs !== 'object') { return 'simple'; }
if (typeof inputs !== 'object' || !inputs) { return 'simple'; }

@@ -237,2 +242,5 @@ if (Array.isArray(inputs)) {

let inPort = Object.keys(network.graph.inports)[0];
if (!inPort) {
return {};
}
// If we have a port named "IN", send to that

@@ -324,2 +332,5 @@ if (network.graph.inports.in) { inPort = 'in'; }

exports.asCallback = function asCallback(component, options) {
if (!component) {
throw new Error('No component or graph provided');
}
options = normalizeOptions(options, component);

@@ -326,0 +337,0 @@ return (inputs, callback) => {

@@ -101,7 +101,7 @@ // NoFlo - Flow-Based Programming for JavaScript

if (!platform.isBrowser()) {
this.baseDir = graph.baseDir || process.cwd();
this.baseDir = graph.properties.baseDir || process.cwd();
// On browser we default the baseDir to the Component loading
// root
} else {
this.baseDir = graph.baseDir || '/';
this.baseDir = graph.properties.baseDir || '/';
}

@@ -115,4 +115,4 @@

// Initialize a Component Loader for the network
if (graph.componentLoader) {
this.loader = graph.componentLoader;
if (graph.properties.componentLoader) {
this.loader = graph.properties.componentLoader;
} else {

@@ -126,4 +126,6 @@ this.loader = new componentLoader.ComponentLoader(this.baseDir, this.options);

uptime() {
if (!this.startupDate) { return 0; }
return new Date() - this.startupDate;
if (!this.startupDate) {
return 0;
}
return Date.now() - this.startupDate.getTime();
}

@@ -315,3 +317,4 @@

connect(done = () => {}) {
// eslint-disable-next-line no-unused-vars
connect(done = (err) => {}) {
// Wrap the future which will be called when done in a function and return

@@ -695,3 +698,4 @@ // it

startComponents(callback = () => {}) {
// eslint-disable-next-line no-unused-vars
startComponents(callback = (err) => {}) {
// Emit start event when all processes are started

@@ -865,3 +869,5 @@ let count = 0;

// Starting the execution
if (!this.startupDate) { this.startupDate = new Date(); }
if (!this.startupDate) {
this.startupDate = new Date();
}
this.started = true;

@@ -868,0 +874,0 @@ this.stopped = false;

@@ -27,3 +27,18 @@ // NoFlo - Flow-Based Programming for JavaScript

function handleOptions(options = {}) {
/**
* @typedef {Object} BaseOptions - Options for configuring all types of ports
* @property {string} [description='']
* @property {string} [datatype='all']
* @property {string} [schema=null]
* @property {string} [type=null]
* @property {boolean} [required=false]
* @property {boolean} [scoped=true]
*/
/**
* @template {BaseOptions} BaseportOptions
* @param {BaseportOptions} options
* @return {BaseportOptions}
*/
function handleOptions(options) {
// We default to the `all` type if no explicit datatype

@@ -50,7 +65,15 @@ // was provided

// Scoping
const scoped = (typeof options.scoped === 'boolean') ? options.scoped : true;
// Description
const description = options.description || '';
/* eslint-disable prefer-object-spread */
return Object.assign({}, options, {
description,
datatype,
required,
schema,
scoped,
});

@@ -100,4 +123,4 @@ }

/* eslint-disable class-methods-use-this */
attachSocket() { }
// eslint-disable-next-line class-methods-use-this,no-unused-vars
attachSocket(socket, index = null) { }

@@ -104,0 +127,0 @@ detach(socket) {

@@ -51,4 +51,4 @@ // NoFlo - Flow-Based Programming for JavaScript

// Set the default component icon and description
this.icon = opts.icon ? opts.icon : this.constructor.icon;
this.description = opts.description ? opts.description : this.constructor.description;
this.icon = opts.icon ? opts.icon : '';
this.description = opts.description ? opts.description : '';

@@ -79,6 +79,6 @@ // Initially the component is not started

// brackets from `in` port to `out` and `error` ports.
this.forwardBrackets = { in: ['out', 'error'] };
if ('forwardBrackets' in opts) {
this.forwardBrackets = opts.forwardBrackets;
if (!opts.forwardBrackets) {
opts.forwardBrackets = { in: ['out', 'error'] };
}
this.forwardBrackets = opts.forwardBrackets;

@@ -91,2 +91,6 @@ // The component's process function can either be

}
// Placeholder for the ID of the current node, populated
// by NoFlo network
this.nodeId = null;
}

@@ -93,0 +97,0 @@

@@ -91,2 +91,6 @@ // NoFlo - Flow-Based Programming for JavaScript

load(name, callback, metadata) {
if (!name) {
callback(new Error('No component name provided'));
return;
}
if (!this.ready) {

@@ -93,0 +97,0 @@ this.listComponents((err) => {

@@ -27,2 +27,4 @@ // NoFlo - Flow-Based Programming for JavaScript

this.nodeInstance = null;
this.prepareBuffer();

@@ -29,0 +31,0 @@ }

@@ -88,2 +88,4 @@ // NoFlo - Flow-Based Programming for JavaScript

this.emitEvent = this.regularEmitEvent;
this.from = null;
this.to = null;
}

@@ -294,2 +296,2 @@

exports.createSocket = () => new InternalSocket();
exports.createSocket = (metadata = {}) => new InternalSocket(metadata);

@@ -30,3 +30,4 @@ // NoFlo - Flow-Based Programming for JavaScript

connect(done = () => {}) {
// eslint-disable-next-line no-unused-vars
connect(done = (err) => {}) {
super.connect((err) => {

@@ -33,0 +34,0 @@ if (err) {

@@ -89,4 +89,6 @@ /* eslint-disable

const moduleImpl = new Module(modulePath, module);
// @ts-ignore
moduleImpl.paths = Module._nodeModulePaths(path.dirname(modulePath));
moduleImpl.filename = modulePath;
// @ts-ignore
moduleImpl._compile(source, modulePath);

@@ -93,0 +95,0 @@ implementation = moduleImpl.exports;

@@ -220,3 +220,5 @@ // NoFlo - Flow-Based Programming for JavaScript

}
if (options.baseDir) { net.baseDir = options.baseDir; }
if (options.baseDir) {
net.properties.baseDir = options.baseDir;
}
exports.createNetwork(net, options, callback);

@@ -223,0 +225,0 @@ });

@@ -11,6 +11,22 @@ // NoFlo - Flow-Based Programming for JavaScript

// These ports are the way a component sends Information Packets.
/**
* @typedef {Object} OutportOptions - Options for configuring outports
* @property {string} [description='']
* @property {string} [datatype='all']
* @property {string} [schema=null]
* @property {boolean} [required=false]
* @property {boolean} [caching=false]
* @property {boolean} [scoped=true]
*/
module.exports = class OutPort extends BasePort {
/**
* @param {OutportOptions} options - Options for the outport
*/
constructor(options = {}) {
const opts = options;
if (opts.scoped == null) { opts.scoped = true; }
if (typeof opts.caching !== 'boolean') {
opts.caching = false;
}
super(opts);

@@ -144,5 +160,7 @@ this.cache = {};

isCaching() {
if (this.options.caching) { return true; }
if (this.options.caching) {
return true;
}
return false;
}
};

@@ -24,3 +24,2 @@ // NoFlo - Flow-Based Programming for JavaScript

if (exports.isBrowser()) {
if (window.NOFLO_FATAL_DEPRECATED) { throw new Error(message); }
console.warn(message);

@@ -27,0 +26,0 @@ return;

@@ -69,3 +69,3 @@ /* eslint-disable max-classes-per-file */

if (!this.ports[name]) { throw new Error(`Port ${name} not available`); }
this.ports[name].on(event, callback);
return this.ports[name].on(event, callback);
}

@@ -75,3 +75,3 @@

if (!this.ports[name]) { throw new Error(`Port ${name} not available`); }
this.ports[name].once(event, callback);
return this.ports[name].once(event, callback);
}

@@ -78,0 +78,0 @@ };

@@ -95,3 +95,3 @@ // NoFlo - Flow-Based Programming for JavaScript

function later() {
const last = Date.now - timestamp;
const last = Date.now() - timestamp;
if ((last < wait) && (last >= 0)) {

@@ -114,3 +114,3 @@ timeout = setTimeout(later, wait - last);

args = arguments;
timestamp = Date.now;
timestamp = Date.now();
const callNow = immediate && !timeout;

@@ -117,0 +117,0 @@ if (!timeout) {

const path = require('path');
const webpack = require('webpack');

@@ -39,8 +40,18 @@ module.exports = {

resolve: {
extensions: ['.js'],
fallback: {
child_process: false,
events: require.resolve('events/'),
fs: false,
os: false,
constants: false,
assert: false,
path: require.resolve('path-browserify'),
util: require.resolve('util'),
},
},
node: {
child_process: 'empty',
fs: 'empty',
},
plugins: [
new webpack.ProvidePlugin({
process: ['process'],
}),
],
};

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc