Skip to content

Commit ecd8250

Browse files
authored
Merge pull request #1368 from telefonicaid/task/add_hextostring_tranformation_function
add hextostring transformation jexl function
2 parents aaef13e + d5b2ae5 commit ecd8250

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

CHANGES_NEXT_RELEASE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- Add: add hextostring transformation jexl function (#1367)
12
- Add: JEXL support to bidirectinal plugin
23
- Remove: remove legacy expression support (removing IOTA_DEFAULT_EXPRESSION_LANGUAGE env var and associated defaultExpressionLanguage config.js setting) (#1340)
34
- Fix: avoid usage of newlines in logs (#1342)
@@ -6,4 +7,4 @@
67
- Fix: allow use static attributes from group in entityNameExp of group
78
- Fix: disable device attribute entity_name validation using pattern
89
- Fix: reenable invocation of custom plugins on update (#1348)
9-
- Fix: change level of log about not context available for apply expression from warn to info
10+
- Fix: change level of log about not context available for apply expression from warn to info

doc/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ Current common transformation set:
578578
| toisostring: (d) | `new Date(d).toISOString()` |
579579
| localestring: (d, timezone, options) | `new Date(d).toLocaleString(timezone, options)` |
580580
| now: () | `Date.now()` |
581+
| hextostring: (val) | `new TextDecoder().decode(new Uint8Array(val.match(/.{1,2}/g).map(byte => parseInt(byte, 16))))` |
581582

582583
You have available this [JEXL interactive playground][99] with all the transformations already loaded, in which you can
583584
test all the functions described above.

lib/jexlTranformsMap.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ const map = {
7878
toisostring: (d) => new Date(d).toISOString(),
7979
// https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString
8080
localestring: (d, timezone, options) => new Date(d).toLocaleString(timezone, options),
81-
now: () => Date.now()
81+
now: () => Date.now(),
82+
hextostring: (val) => new TextDecoder().decode(new Uint8Array(val.match(/.{1,2}/g).map(byte => parseInt(byte, 16))))
8283
};
8384

8485
exports.map = map;

0 commit comments

Comments
 (0)