-
-
Notifications
You must be signed in to change notification settings - Fork 0
Transformer
Imani brown edited this page Aug 1, 2024
·
4 revisions
The Transformer
does exactly what it sounds like: it contains methods for parsing strings. This class is responsible for parsing variables efficiently and effectively.
const transformer = new Transformer({
collection: new RuleStore([]),
});
or...
const transformer = new Transformer({
collection: [new RuleStore([]), new RuleStore([])],
});
To parse a string:
transformer.parse("[string to parse]", "[The Event type]", eventObject);
For more complex parsing:
transformer.parse(text, "eventType", eventObject1, eventObject2, etc...);
Unlike in version 2, where the package was not fully stable or completed, the parser in the current version now uses regex to handle string parsing behind the scenes. This ensures it will always match an identifier, no matter how complex it is within the string.