github node-opcua/node-opcua v2.7.0

latest releases: v2.124.0, v2.123.0, v2.122.0...
3 years ago

🐛 bug fixes

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

💔 breaking change

  • [4f5d15b] 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

Don't miss a new node-opcua release

NewReleases is sending notifications on new releases.