github node-opcua/node-opcua v2.7.0

🐛 bug fixes

  • #320 [ExtensionObjects] fix parsing bsd file with non-encodable extension objects (@@DavoodCH)
  • [fd8a753b48fc79ba10158e5c83e46ed5c803f0c8] improve toJSON on ExtensionObject

💔 breaking change

  • [4f5d15bc7cbd02dfa51800d83f11c1a7f5c1d743] improve lowerFirstLetter (BreakingChange)

for instance
| example | <= @2.6.7 | >= @2.7.0 | comment |
| HelloWorld | helloWorld | helloWorld | unchanged |
| ALM_FlowOutOfTolerance | alM_FlowOutOfTolerance | ALM_FlowOutOfTolerance | |
| AB_CD_EF | AB_CD_EF | AB_CD_EF | unchanged |

OPCUA and Javascript use two different rules to build identifiers.

OPCUA Identifier usually starts with an upper case letter and word are joined together, this is known as the Pascal case, or CapitalizedWords convention. (for instance HelloWorld)
But sometimes, OPCUA identifiers do not follow this convention strictly and we can find various other conventions being applied such as underscore between word, or addition of ACRONYMED prefixes.
On its own, this causes great confusion and inconsistency in programming style.
Javascript uses a slightly different convention called camelCase where word are joined together
and inner words start with a capital letter whereas the first word starts with a lower case letter.
(for instance helloWorld)

In node-opcua we have taken the opinionated decision to consistently use camelCase convention for object properties so that all the code looks nice and consistent.

the lowerFirstLetter method can be used to easily convert from the OPCUA naming convention to the javascript naming convention by applying the following rules.

  • each ASCII sequence in an identifier will be converted to a lower camel case.
  • when an identifier only contains an upper case letter then it will be untouched. ( i.e CQDF => CQFD)
    (this rule helps to preserve acronyms)
  • when an identifier starts with more than one UpperCase letter but still contain a lowercase letter
    then the first Uppercase letter excluding the last one will be converted to lower case
    ( ie: EURange = > euRange)
  • (new rule) when an identifier contains several sequences delimited with underscores (_) the above rules will be applied to each of the element of the sequence ( ie: ALM_FlowOutOfTolerance => ALM_flowOutOfTolerance ( ALM=>ALM , FlowOutOfTolerance =>flowOutOfTolerance)

👬 Contributors

  • @DavoodCH
latest releases: v2.16.0, v2.15.0, v2.14.0...
3 months ago