1.1.15 • Published 5 years ago

perfectobj v1.1.15

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
5 years ago

PerfectObj

Get your perfect model with one easy schema or with specific editions on the original object.

Build Status

Tech

PerfectObj uses open source projects to function properly such as:

  • Ramda - A practical functional library for JavaScript programmers.

Installation

Install the dependencies and devDependencies and start the server.

$ npm install perfectobj

Properties

For the creation of the model we need, perfectObj offers possibilities such as:

NameDescription
renameChange the name of a key
assocSet a new attribute in model
typeDefine a type for an attribute
omitGet undescribed items from a collection
picksGet the described items of a collection
enhacerFunction on one or more attributes of the original object

Examples

These are simple some examples

Original Object

const person = {
    name: 'Marcus Espinoza',
    identification: 964328461,
    telephone: 85886810,
    address: {
        apartment: 'Belén, Heredia',
        girl: 'San Rafael, Heredia',
        home: 'Golfito, Puntarenas'
    },
    interests: ['videogames', 'soccer', 'technology']
}

Perfect Object

const PerfectObj = require('perfectobj');

const personModel = new PerfectObj(person);

Model Object

personModel
    .rename('name', 'fullName')
    .assoc('birthday', '1995/08/01')
    .type('identification', 'string')
    .enhacer('telephone', v => `+506${v}`)
    .picks('address', ['apartment', 'home'])
    .omit('interests', ['technology', 'videogames']);

console.log(personModel);

OUTPUT

{
    props: { 
        identification: '964328461',
        telephone: '+50685886810',
        address: { apartment: 'Belén, Heredia', home: 'Golfito, Puntarenas' },
        interests: [ 'soccer' ],
        fullName: 'Marcus Espinoza',
        birthday: '1995/08/01'
    }
}

Todos

  • Write Tests
  • Add changelog

License

MIT

1.1.15

5 years ago

1.1.12

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago