dregenor / jsonMapper

simple json mapper
MIT License
31 stars 8 forks source link

Add makeMapConverter function #8

Closed alexwhitman closed 10 years ago

alexwhitman commented 10 years ago

Fixes #7. Creates a converter which maps another converter on an array:

var input = [
    {
        a: '1',
        b: '2'
    },
    {
        a: '3',
        b: '4'
    }
];

var objConverter = jm.makeConverter({
    a: 'a'
});

var arrayConverter = jm.makeMapConverter(objConverter);

arrayConverter(input);

/*
Result:

[
    {
        a: '1'
    },
    {
        a: '3'
    }
]
*/