1.3.10 • Published 3 years ago

guinho-automapper-js v1.3.10

Weekly downloads
22
License
ISC
Repository
github
Last release
3 years ago

Guinho-Automapper-js

Guinho-Automapper-js makes easier working with object mapping.

Installation

Install the dependencies and start the server.

$ npm i guinho-automapper-js

Usage

import { map, mapReverse } from "guinho-automapper-js/index";

Example

import { map } from "guinho-automapper-js/index";

const mapping = [
  {
    from: 'name',
    to: 'forms[0].name',
  },
  {
    from: 'height',
    to: 'height',
  },
  {
    from: 'type',
    to: 'types[0].type.name',
  },
  {
    from: 'secondary_type',
    to: 'types[1].type.name',
  },
  {
    from: 'moves[0].name',
    to: 'moves[0].move.name',
  },
  {
    from: 'moves[1].name',
    to: 'moves[1].move.name',
  }
];


const pokemonOrigin = {
  name: 'bulbasaur',
  height: 7,
  type: 'grass',
  secondary_type: 'poison',
  moves: [
    {
      name: 'razor-wind'
    },
    {
      name: 'swords-dance'
    }
  ]
};

let pokemonDest = {};

map(pokemonOrigin, pokemonDest, mapping);

console.log(JSON.stringify(pokemonOrigin)); 
console.log(JSON.stringify(pokemonDest));  
1.3.7

3 years ago

1.3.10

3 years ago

1.3.9

3 years ago

1.3.8

3 years ago

1.3.6

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago