npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-red-contrib-boolean-logic

v0.0.3

Published

A set of Node-RED nodes for boolean logic

Downloads

1,392

Readme

node-red-contrib-boolean-logic

Node-RED nodes to easily perform boolean logic.

##The problem Node-RED does not support multiple inputs on nodes, and it has been discussed at length in this thread. The TL;DR - as I understand it - is that the developers of NR argue that multiple inputs makes it too complex for users without a background in electrical engineering and that it is preferred users of NR instead use other means to create the desired logic (i.e. write Javascript in function-nodes).

##A solution I really needed a simple and reusable way to perform boolean logic on multiple topics without the need to write the same code over and over.

Could this be solved using a subflow? No, function-node within a subflow cannot be configured on an instance basis which is required as the logic must know how many inputs it is expecting when performing operations such as A || B or A && (B || C). Yes, that could be hard coded, but then it would not be reusable. Also, a subflow cannot use the status indicator which is a great help to the user.

What I came up with are the following nodes.

  • BooleanLogic: Can perform AND, OR and XOR operations on msg.payload on any number of topics.
  • Invert: Inverts the msg.payload, e.g. true -> false.
  • Debug: A debug node that displays the status direcly in the editor, making it easier to see the boolean value at a specific point.

All nodes attempts to convert the incoming msg.payload to a boolean value according to these rules:

  • Boolean values are taken as-is.
  • For numbers, 0 evaluates to false, all other numbers evaluates to true.
  • Strings are converted to numbers if they match the format of a decimal value, then the same rule as for numbers are applied. If it does not match, it evaluates to false. Also, the string "true" evaluates to true.

####BooleanLogic This node must be configured with the expected number of topics. It will not output a value until it has received the configured number of topics. Also, if it receives more than the configured number of topics it will reset (but not output a value) and wait until it once again sees the configured number of topics.

##Example Example

##Version history

  • 0.0.1 First release
  • 0.0.2
    • Changed status indicators from dot to rings for false-values.
    • Reworked the conversion of input values to be consistent between numbers and strings with numeric meaning.