From 7ed679b63177efebe2e4f4d10517fc1728451083 Mon Sep 17 00:00:00 2001 From: Henri Bergius <henri.bergius@iki.fi> Date: Sat, 8 Jun 2024 17:15:01 +0100 Subject: [PATCH] Release 0.2.1 --- README.md | 2 ++ components/All.js | 26 ++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 components/All.js diff --git a/README.md b/README.md index 6c0c903..8341fa8 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ Status: early stages ## Changes +* 0.2.1 (2024-06-08) + - Added an `All` component for checking that all input values are truthy * 0.2.0 (2023-01-12) - Fixed main graph detection - Now using the community version of NoFlo UI diff --git a/components/All.js b/components/All.js new file mode 100644 index 0000000..a500d0a --- /dev/null +++ b/components/All.js @@ -0,0 +1,26 @@ +const noflo = require('noflo'); + +exports.getComponent = () => { + const c = new noflo.Component(); + c.description = 'Checks values of all connected inputs and sends whether they\'re all truthy or falsy'; + c.icon = 'search'; + c.inPorts.add('in', { + datatype: 'boolean', + addressable: true, + }); + c.outPorts.add('out', { + datatype: 'boolean', + }); + c.process((input, output) => { + const indexesWithData = input.attached('in').filter((idx) => input.hasData(['in', idx])); + if (indexesWithData.length !== input.attached('in').length) { + return; + } + const values = indexesWithData.map((idx) => input.getData(['in', idx])); + output.sendDone({ + // eslint-disable-next-line eqeqeq + out: values.every((v) => v != false), + }); + }); + return c; +}; diff --git a/package.json b/package.json index cf2c04c..cd99f4c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "noflo-signalk", - "version": "0.2.0", + "version": "0.2.1", "description": "Signal K automation with the NoFlo visual programming framework", "main": "index.js", "scripts": {