lib/filter.js
function _filterByObjectSchema(data, schema) {
    return Object
        .keys(data)
        .filter(function (key) {
            return schema.hasOwnProperty(key);
        })
        .reduce(function (memo, key) {
            var value = data[key];
            var schemaPart = schema[key];
            if (typeof schemaPart === 'object') {
                memo[key] = _filter(value, schemaPart);
            } else {
                memo[key] = value;
            }
            return memo;
        }, {});
}
function _filterByObjectSchema(data, schema) {
    return Object
        .keys(data)
        .filter(function (key) {
            return schema.hasOwnProperty(key);
        })
        .reduce(function (memo, key) {
            var value = data[key];
            var schemaPart = schema[key];
            if (typeof schemaPart === 'object') {
                memo[key] = _filter(value, schemaPart);
            } else {
                memo[key] = value;
            }
            return memo;
        }, {});
}
function _filterByObjectSchema ( data , schema ) { return Object . keys ( data ) . filter ( function ( key ) { return schema . hasOwnProperty ( key ) ; } ) . reduce ( function ( memo , key ) { var value = data [ key ] ; var schemaPart = schema [ key ] ; if ( typeof schemaPart === 'object' ) { memo [ key ] = _filter ( value , schemaPart ) ; } else { memo [ key ] = value ; } return memo ; } , { } ) ; }
Filters an object from an object schema
@param data Object to filter
@param schema Fields to keep
@returns {*}
@private
Filters an object from an object schema