Skip to content

Commit

Permalink
feat: Add trim option to map/list transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaguiar committed May 23, 2024
1 parent 0ca5593 commit 1ad825a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ These options will change the parsed input data included any filters provided.
| searchkeys | String | Will return a map with only keys that match the provided string |
| searchvalues | String | Will return am map with only values that match the provided string |
| sortmapkeys | Boolean | If true the resulting map keys will be sorted |
| trim | Boolean | If true all the strings of the result map/list will be trimmed |

---

Expand Down
8 changes: 8 additions & 0 deletions src/include/transformFns.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,14 @@ var _transformFns = {
}
return _r
},
"trim": _r => {
if (toBoolean(params.trim)) {
traverse(_r, (aK, aV, aP, aO) => {
if (isString(aV)) aO[aK] = aV.trim()
})
}
return _r
},
"removedups": _r => {
if (toBoolean(params.removedups)) {
if (isArray(_r)) {
Expand Down

0 comments on commit 1ad825a

Please sign in to comment.