Skip to content

Commit 156f5b9

Browse files
Nuno Miguel AguiarNuno Miguel Aguiar
authored andcommitted
Update val2icon option to accept string values for emoticon transformation and document new transformation functions
1 parent b1e5198 commit 156f5b9

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

data/completion.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,4 +616,4 @@ complete:
616616
- name: xrfn=
617617
desc: A javascript code, receiving each input array record as 'args' and return it's code evaluation
618618
- name: val2icon=
619-
desc: If true will transform undefined, null and boolean values to emoticons
619+
desc: If defined will transform undefined, null and boolean values to emoticons -values can be 'default' or 'simple'-

data/usage.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,21 @@
295295
"Type": "String",
296296
"Description": "A JSON/SLON map with a 'a' path and a 'b' path to compare and provide diff data"
297297
},
298+
{
299+
"Option": "field2byte",
300+
"Type": "String",
301+
"Description": "A comma delimited list of fields whose value should be converted to a byte abbreviation"
302+
},
303+
{
304+
"Option": "field2date",
305+
"Type": "String",
306+
"Description": "A comma delimited list of fields whose value should be converted to date values"
307+
},
308+
{
309+
"Option": "field2si",
310+
"Type": "String",
311+
"Description": "A comma delimited list of fields whose value should be converted to a SI abbreviation"
312+
},
298313
{
299314
"Option": "flatmap",
300315
"Type": "Boolean",
@@ -415,6 +430,11 @@
415430
"Type": "Boolean",
416431
"Description": "If true all the strings of the result map/list will be trimmed"
417432
},
433+
{
434+
"Option": "val2icon",
435+
"Type": "Boolean",
436+
"Description": "If true will transform undefined, null and boolean values to emoticons"
437+
},
418438
{
419439
"Option": "xjs",
420440
"Type": "String",

src/docs/USAGE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ These options will change the parsed input data included any filters provided.
139139
| sortmapkeys | Boolean | If true the resulting map keys will be sorted |
140140
| spacekeys | String | Replaces spaces in keys with the provided string (for example, helpful to xml output) |
141141
| trim | Boolean | If true all the strings of the result map/list will be trimmed |
142-
| val2icon | Boolean | If true will transform undefined, null and boolean values to emoticons |
142+
| val2icon | String | If defined will transform undefined, null and boolean values to emoticons (values can be 'default' or 'simple') |
143143
| xjs | String | A .js file with function code manipulating an input 'args'. Returns the transformed 'args' variable. |
144144
| xpy | String | A .py file with Python function code manipulating an input 'args'. Returns the transformed 'args' variable. |
145145
| xfn | String | A javascript code, receiving input as 'args' and return it's code evaluation. |

src/include/transformFns.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,24 @@ var _transformFns = {
529529
return _r
530530
},
531531
"val2icon": _r => {
532-
if (toBoolean(params.val2icon)) {
532+
let _t = {
533+
d: [ "🕳️", "✅", "❌" ],
534+
s: [ "╍", "✓", "✕" ]
535+
}
536+
if (isDef(params.val2icon)) {
537+
var th
538+
switch(params.val2icon) {
539+
case "simple": th = _t.s; break
540+
default :
541+
case "default": th = _t.d; break
542+
}
533543
ow.loadFormat()
534544
traverse(_r, (aK, aV, aP, aO) => {
535545
if (isUnDef(aV) || isNull(aV)) {
536-
aO[aK] = "🕳️"
546+
aO[aK] = th[0]
537547
} else {
538548
if (isBoolean(aV)) {
539-
aO[aK] = aV ? "✅" : "❌"
549+
aO[aK] = aV ? th[1] : th[2]
540550
}
541551
}
542552
})

0 commit comments

Comments
 (0)