morkai / h5.modbus

Implementation of the MODBUS IP/ASCII/RTU master and slave over TCP/UDP/Serial for Node.js.
https://miracle.systems/p/h5.modbus
MIT License
28 stars 21 forks source link

Update WriteSingleCoilRequest.js #3

Closed goranach closed 10 years ago

goranach commented 10 years ago
morkai commented 10 years ago

Sorry, I don't like that.

It would require changes to all code that acceps booleans to also accept "false" and "0" for consistency (then someone could also ask for accepting "123456" as numbers).

The state argument has a JSDoc type annotation specifiying that is should be a boolean and I think it's the developer's job to ensure that a correct type is passed (right now it's partly my fault for not having any real documentation).

The only scenario (that I can think of) that would require this change, is that you're calling the library functions with input data coming directly from the user (i.e. query string or forms). In that case you should sanitize and validate the data anyway (ensuring that the state parameter is converted to a correct type).

Thanks for the interest in the project anyway!

goranach commented 10 years ago

Ok.