Not Particularly Meaningful

    object-convert

    1.0.0 • Public • Published

    object-convert NPM version Build Status Dependency Status

    Convert an object from one schema to another.

    Installation

    $ npm install --save object-convert

    Usage

    var converter = require('object-convert'),
        type = converter.type;
     
    converter().define({
        user: {
            fullName: type(String, 'name'),
            bornOn: type(Date, 'birthDate'),
            likesCats: type(Boolean, 'interestingFacts.likesDogs'),
            hasPets: type(Boolean, 'interestingFacts.petNames', function(value) {
                return !!value.length;
            })
        }
    }).convert({
        name: 'Matthew Slipper',
        birthDate: new Date(),
        interestingFacts: {
            likesDogs: true,
            petNames: [ 'Speedy' ]
        }
    });
     
    /**
    Would return:
     
    {
        user: {
            fullName: 'Matthew Slipper',
            bornOn: Date,
            likesCats: false,
            hasPets: true
        }
    }
    **/
     

    License

    MIT © Matthew Slipper

    Install

    npm i object-convert

    DownloadsWeekly Downloads

    2

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • mslipper