0.0.9 • Published 8 years ago

transformer-js v0.0.9

Weekly downloads
11
License
MIT
Repository
-
Last release
8 years ago

transformer-js

npm version codecov CircleCI

transformer-js is a library for performing transformations on objects. There are many use cases. One example is log redaction:

import transformerFactory from './transformer-js'

const config = {
  transform: val => '[REDACTED]',
  matchers: [{
    key: /^token/
  }]
}

const transform = transformerFactory(config)

const logObj = {
  id: 1,
  token: 'dfadf2334hjlkjkxxnqqkkq4=='
}

console.log(transform.map(logObj))

// outputs
{
  id: 1,
  token: '[REDACTED]'
}

Examples directory coming soon...

API

Functions

Typedefs

transformerFactory(transformerConfig) ⇒ transformer

Kind: global function
Returns: transformer - a transformer instance

ParamTypeDescription
transformerConfigObject
transformerConfig.transformfunctionfunction to compute new value from any value matched by the matcher. If not defined the default transform will be used.
transformerConfig.matchersArray.<matcher>array of matcher objects

matcher : Object

Kind: global typedef
Properties

NameTypeDescription
transformfunctiondefault transform that is applied to any value matched unless
keyRejex | functionused to peform matching on keys.
valueRejex | functionused to perform matching on values.

transformer : Object

Kind: global typedef
Properties

NameTypeDescription
mapfunctionexecutes the transformer and returns a new transformed object
0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago