object-transform-stack

3.3.0 • Public • Published

object-transform-stack NPM version Downloads Build Status

Install

npm install object-transform-stack --save

Usage

import { transform } from 'object-transform-stack'

const transforms = {
  trim: {
    name: 'Trim',
    signature: [
      {
        name: 'Text',
        types: [ 'string' ],
        required: true
      }
    ],
    returns: 'string',
    execute: (v) => v.trim()
  }
}

const stack = {
  bday: { field: 'birth' },
  name: {
    transform: 'trim',
    arguments: [ { field: 'name.legal' } ]
  }
}

const input = {
  name: {
    legal: 'Don Adams',
    preferred: 'Donny'
  },
  birth: '11/12/27'
}

console.log(await transform(stack, input, { transforms }))
/*
Prints:

{
  "bday": "2027-11-12T05:00:00.000Z",
  "name": "Don Adams"
}
*/

Package Sidebar

Install

npm i object-transform-stack

Weekly Downloads

21

Version

3.3.0

License

MIT

Unpacked Size

27.5 kB

Total Files

10

Last publish

Collaborators

  • yocontra