From c3ad5f0f6d4250ac0c712862584a8daf62e2124e Mon Sep 17 00:00:00 2001 From: Garth Braithwaite Date: Mon, 4 Apr 2022 15:52:56 -0600 Subject: [PATCH] feat: add attribute/sets transform --- attribute-sets-transform.js | 12 ++++++++++++ index.js | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 attribute-sets-transform.js diff --git a/attribute-sets-transform.js b/attribute-sets-transform.js new file mode 100644 index 0000000..dca8f1c --- /dev/null +++ b/attribute-sets-transform.js @@ -0,0 +1,12 @@ +module.exports = { + type: "attribute", + name: "attribute/sets", + matcher: (token) => token.path.includes("sets"), + transformer: (token) => { + return { + sets: token.path.filter( + (part, index, array) => array[index - 1] == "sets" + ), + }; + }, +}; diff --git a/index.js b/index.js index 2cd86be..eb41417 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ -const JsonSetsFormatter = require('./json-sets-formatter'); +const JsonSetsFormatter = require("./json-sets-formatter"); +const AttributeSetsTransform = require("./attribute-sets-transform"); -module.exports = {JsonSetsFormatter}; +module.exports = { JsonSetsFormatter, AttributeSetsTransform };