lib/parser.js
function (value) {

            if (!Array.isArray(value)) {

                // null/undefined or anything else must be safely convert to string

                value = value + '';
            }

            if (Array.isArray(value)) {

                // map all values again
                value = value.map(v => this.parseValue(v));

            } else if (validator.isNumeric(value)) {

                value = value * 1; // parse as a number

            } else if (validator.isBoolean(value)) {

                value = (value === 'true');

            } else {

                // convert to JS date
                const date = validator.toDate(value);

                // date is valid, assign
                if (date !== null) {

                    value = date;
                }

                if (value === 'null') {

                    value = null;
                }

                if (value === 'undefined') {

                    value = undefined;
                }
            }

            return value;
        }
function (value) {

            if (!Array.isArray(value)) {

                // null/undefined or anything else must be safely convert to string

                value = value + '';
            }

            if (Array.isArray(value)) {

                // map all values again
                value = value.map(v => this.parseValue(v));

            } else if (validator.isNumeric(value)) {

                value = value * 1; // parse as a number

            } else if (validator.isBoolean(value)) {

                value = (value === 'true');

            } else {

                // convert to JS date
                const date = validator.toDate(value);

                // date is valid, assign
                if (date !== null) {

                    value = date;
                }

                if (value === 'null') {

                    value = null;
                }

                if (value === 'undefined') {

                    value = undefined;
                }
            }

            return value;
        }
function ( value ) { if ( ! Array . isArray ( value ) ) { // null/undefined or anything else must be safely convert to string value = value + '' ; } if ( Array . isArray ( value ) ) { // map all values again value = value . map ( v => this . parseValue ( v ) ) ; } else if ( validator . isNumeric ( value ) ) { value = value * 1 ; // parse as a number } else if ( validator . isBoolean ( value ) ) { value = ( value === 'true' ) ; } else { // convert to JS date const date = validator . toDate ( value ) ; // date is valid, assign if ( date !== null ) { value = date ; } if ( value === 'null' ) { value = null ; } if ( value === 'undefined' ) { value = undefined ; } } return value ; }
Parse string to a parsable type
@param {string} value Value to parse
@returns {string|number|boolean|date} Parsed value
Parse string to a parsable type