transformer-js
transformer-js is a library for performing transformations on objects. There are many use cases. One example is log redaction:
const config = '[REDACTED]' matchers: key: /^token/ const transform = const logObj = id: 1 token: 'dfadf2334hjlkjkxxnqqkkq4==' console // outputs id: 1 token: '[REDACTED]'
Examples directory coming soon...
API
Functions
Typedefs
- matcher :
Object
- transformer :
Object
transformer
transformerFactory(transformerConfig) ⇒ Kind: global function
Returns: transformer
- a transformer instance
Param | Type | Description |
---|---|---|
transformerConfig | Object |
|
transformerConfig.transform | function |
function to compute new value from any value matched by the matcher. If not defined the default transform will be used. |
transformerConfig.matchers | Array.<matcher> |
array of matcher objects |
Object
matcher : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
transform | function |
default transform that is applied to any value matched unless |
key | Rejex | function |
used to peform matching on keys. |
value | Rejex | function |
used to perform matching on values. |
Object
transformer : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
map | function |
executes the transformer and returns a new transformed object |