@yrnd1/

FunnyGrizzledCleaninstall

Nodejs

No description

fork
loading
Files
  • index.js

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.6033810035622478","path":"index.js","file":{"path":"index.js","content":{"asEncoding":{"base64":"Y29uc3QgeyBtb3JwaGlzbSB9ID0gcmVxdWlyZSgnbW9ycGhpc20nKQoKLy8gZnJvbSB4CmNvbnN0IHggPSB7IF9hOiAnZm9vJywgX2I6ICdiYXInIH0gCi8vIHRvIHkKY29uc3QgeSA9IHsgYTogJ2Zvb2JhcicgfQoKLy8gc3RydWN0dXJlLXByZXNlcnZpbmcgbWFwCmNvbnN0IHNjaGVtYSA9IHsgYTogKHsgX2EsIF9iIH0pID0+IF9hICsgX2IgfQpjb25zdCBmbiA9IG1vcnBoaXNtKHNjaGVtYSkKCi8vIGZuKHgpID0geQpKU09OLnN0cmluZ2lmeShmbih4KSkgPT09IEpTT04uc3RyaW5naWZ5KHkpIAovLyA9PiB0cnVlCgo="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const { morphism } = require('morphism')

// from x
const x = { _a: 'foo', _b: 'bar' } 
// to y
const y = { a: 'foobar' }

// structure-preserving map
const schema = { a: ({ _a, _b }) => _a + _b }
const fn = morphism(schema)

// fn(x) = y
JSON.stringify(fn(x)) === JSON.stringify(y) 
// => true

node v10.16.0