JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 36
  • Score
    100M100P100Q50499F
  • License MIT

Mapping, filtering, transforming, and morphing for your objects

Package Exports

  • morphmorph

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (morphmorph) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Morph Morph

Isomorphic transformations. Map, transform, filter, and morph your objects

Getting Started

$ npm i --save morphmorph

and then

const Mapper = require('morphmorph')

const mapper = new Mapper(/* [config] */)

const old = {
  here: {
    there: {
      anywhere: 'Earth'
    }
  }
}

const mappings = [ 'here.there.anywhere:location' ]

const transformation = mapper.map(mappings, old)
// -> { location: 'Earth' }

Config

You can pass in a config object to Mapper to create your own mapping system:

Options
Field Type Default
types Object {}
objDelimiter String "."
mapDelimiter String ":"
preFilters Array []
postFilters Array []
Example
const mapper = new Mapper({
  objDelimiter: '|',
  mapDelimiter: '->',
  types: { bool: Boolean },
  preFilters: [ FILTER_NULL ],
  postFilters: [ REMOVE_PASSWORD ]
  // add other field to your config here
})

Examples

See test/index.spec.js for more examples of how to use MorphMorph.