lib/map.js
function _getMappedFields(schema) {
    if (schema === undefined ||
        schema === null) {
        return;
    }
    if (schema instanceof Array) {
        return schema
            .reduce(function (memo, key) {
                var mappedField = _getMappedFields(key);
                if (mappedField !== undefined) {
                    memo = memo.concat(mappedField);
                }
                return memo;
            }, []);
    }
    if (typeof schema === 'object') {
        return Object
            .keys(schema)
            .reduce(function (memo, key) {
                var mappedField = _getMappedFields(schema[key]);
                if (mappedField !== undefined) {
                    memo = memo.concat(mappedField);
                }
                return memo;
            }, []);
    }
    if (typeof schema === 'string' ||
        typeof schema === 'number') {
        return schema;
    }
}
function _getMappedFields(schema) {
    if (schema === undefined ||
        schema === null) {
        return;
    }
    if (schema instanceof Array) {
        return schema
            .reduce(function (memo, key) {
                var mappedField = _getMappedFields(key);
                if (mappedField !== undefined) {
                    memo = memo.concat(mappedField);
                }
                return memo;
            }, []);
    }
    if (typeof schema === 'object') {
        return Object
            .keys(schema)
            .reduce(function (memo, key) {
                var mappedField = _getMappedFields(schema[key]);
                if (mappedField !== undefined) {
                    memo = memo.concat(mappedField);
                }
                return memo;
            }, []);
    }
    if (typeof schema === 'string' ||
        typeof schema === 'number') {
        return schema;
    }
}
function _getMappedFields ( schema ) { if ( schema === undefined || schema === null ) { return ; } if ( schema instanceof Array ) { return schema . reduce ( function ( memo , key ) { var mappedField = _getMappedFields ( key ) ; if ( mappedField !== undefined ) { memo = memo . concat ( mappedField ) ; } return memo ; } , [ ] ) ; } if ( typeof schema === 'object' ) { return Object . keys ( schema ) . reduce ( function ( memo , key ) { var mappedField = _getMappedFields ( schema [ key ] ) ; if ( mappedField !== undefined ) { memo = memo . concat ( mappedField ) ; } return memo ; } , [ ] ) ; } if ( typeof schema === 'string' || typeof schema === 'number' ) { return schema ; } }
Returns the fields which are used in the final object
@param schema Target schema
@returns {*}
@private
Returns the fields which are used in the final object