@yrnd1/

Morphism Flattening Projection

ES6

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.2105916015628191","path":"main.js","file":{"path":"main.js","content":{"asEncoding":{"base64":"aW1wb3J0IHsgbW9ycGhpc20gfSBmcm9tICdtb3JwaGlzbSc7Ci8vIFNvdXJjZSBkYXRhIGNvbWluZyBmcm9tIGFuIEFQSS4KY29uc3Qgc291cmNlID0gewogIGZvbzogJ2JheicsCiAgYmFyOiBbJ2JhcicsICdmb28nXSwKICBiYXo6IHsKICAgIHF1eDogJ2JhenF1eCcKICB9Cn07CmNvbnN0IHNjaGVtYSA9IHsKICBmb286ICdmb28nLCAvLyBTaW1wbGUgUHJvamVjdGlvbgogIGJhenF1eDogJ2Jhei5xdXgnIC8vIEdyYWIgYSB2YWx1ZSBmcm9tIGEgZGVlcCBwYXRoCn07Cgptb3JwaGlzbShzY2hlbWEsIHNvdXJjZSk7Ci8vPT4geyBmb286ICdiYXonLCBiYXpxdXg6ICdiYXpxdXgnIH0="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { morphism } from 'morphism';
// Source data coming from an API.
const source = {
  foo: 'baz',
  bar: ['bar', 'foo'],
  baz: {
    qux: 'bazqux'
  }
};
const schema = {
  foo: 'foo', // Simple Projection
  bazqux: 'baz.qux' // Grab a value from a deep path
};

morphism(schema, source);
//=> { foo: 'baz', bazqux: 'bazqux' }
Babel Compiler v6.4.4 Copyright (c) 2014-2015 Sebastian McKenzie