Actually I can envisage a simple node that does things like this... but of course the instant reaction is scope creep... I would want simple add, subtract, multiply, divide etc of the "payload" by a constant, (eg see Steve's buffer parser) or flow/global property... oh and then combinations like multiply and add etc (degC to degF etc). - oh then maybe AND, OR, XOR - etc etc... Not saying it can't be done (probably should be) - - but needs some design work first - and then indeed should it be part of the change node ? (see other recent discussions on change node) - or a new numeric only calculator node ?
This is something I've been thinking about - having a core set of nodes for common operations on standard JavaScript types.
There is already the node-red-contrib-string as a node that provides common string functions - not saying that's quite the model I had in mind, but it is along those lines.
A Maths node could provide operations for numeric types.
An Array node could do simple push/pop/splice etc type operations.
I think it would be worth putting together a concept for it.
And maybe a conversions node? I could see that would be REALLY useful.
These nodes would also help take Node-RED into improving some areas that it is weak on compared to some other visual tools as well which would be nice. One day, it would be wonderful to be able to use Node-RED to do ETL tasks that people currently switch to Python for.
If someone does a node-red-contrib-just-subtract-one node, can they also assemble an end to end illustrated tutorial to get from the idea n -=1 to a published node?
That is a can of worms you just opened. I'm with knolleary on this.
The only difference is that math is preferred in the U.S. and Canada, and maths is preferred in the U.K., Australia, and most other English-speaking areas of the world.
There was a recent conversation on slack about adding a local context to the change node, perfect for things like keeping a counter that can be modified by any expression syntax... perhaps it's time to rethink that as it's a general purpose solution?