bin/typed.js
function Typed (config) {
    const typed = this;
    const hasDefault = config.hasOwnProperty('default');

    // enum
    if (config.hasOwnProperty('enum')) {
        if (!Array.isArray(config.enum) || config.enum.length === 0) {
            throw Error(util.propertyErrorMessage('enum', config.enum, 'Expected a non-empty array'));
        }
        const copy = [];
        config.enum.forEach(function(v) {
            if (copy.indexOf(v) === -1) copy.push(v);
        });
        config.enum = copy;
    }

    // transform
    if (config.transform && typeof config.transform !== 'function') {
        throw Error(util.propertyErrorMessage('transform', config.transform, 'Expected a function'));
    }

    // validate
    if (config.validator && typeof config.validator !== 'function') {
        throw Error(util.propertyErrorMessage('validator', config.validator, 'Expected a function'));
    }

    // define properties
    Object.defineProperties(typed, {

        default: {
            /**
             * @property
             * @name Typed#default
             * @type {function,*}
             */
            value: config.default,
            writable: false
        },

        enum: {
            /**
             * @property
             * @name Typed#enum
             * @readonly
             * @type {function,*}
             */
            value: config.enum,
            writable: false
        },

        hasDefault: {
            /**
             * @property
             * @name Typed#hasDefault
             * @type {boolean}
             */
            value: hasDefault,
            writable: false
        },

        transform: {
            /**
             * @property
             * @name Typed#transform
             * @readonly
             * @type {function}
             */
            value: config.transform,
            writable: false
        },

        type: {
            /**
             * @property
             * @name Typed#type
             * @readonly
             * @type {string,function}
             */
            value: config.type,
            writable: false
        },

        validator: {
            /**
             * @property
             * @name Typed#validator
             * @readonly
             * @type {function}
             */
            value: config.validator,
            writable: false
        }
    });

    return typed;
}
function Typed (config) {
    const typed = this;
    const hasDefault = config.hasOwnProperty('default');

    // enum
    if (config.hasOwnProperty('enum')) {
        if (!Array.isArray(config.enum) || config.enum.length === 0) {
            throw Error(util.propertyErrorMessage('enum', config.enum, 'Expected a non-empty array'));
        }
        const copy = [];
        config.enum.forEach(function(v) {
            if (copy.indexOf(v) === -1) copy.push(v);
        });
        config.enum = copy;
    }

    // transform
    if (config.transform && typeof config.transform !== 'function') {
        throw Error(util.propertyErrorMessage('transform', config.transform, 'Expected a function'));
    }

    // validate
    if (config.validator && typeof config.validator !== 'function') {
        throw Error(util.propertyErrorMessage('validator', config.validator, 'Expected a function'));
    }

    // define properties
    Object.defineProperties(typed, {

        default: {
            /**
             * @property
             * @name Typed#default
             * @type {function,*}
             */
            value: config.default,
            writable: false
        },

        enum: {
            /**
             * @property
             * @name Typed#enum
             * @readonly
             * @type {function,*}
             */
            value: config.enum,
            writable: false
        },

        hasDefault: {
            /**
             * @property
             * @name Typed#hasDefault
             * @type {boolean}
             */
            value: hasDefault,
            writable: false
        },

        transform: {
            /**
             * @property
             * @name Typed#transform
             * @readonly
             * @type {function}
             */
            value: config.transform,
            writable: false
        },

        type: {
            /**
             * @property
             * @name Typed#type
             * @readonly
             * @type {string,function}
             */
            value: config.type,
            writable: false
        },

        validator: {
            /**
             * @property
             * @name Typed#validator
             * @readonly
             * @type {function}
             */
            value: config.validator,
            writable: false
        }
    });

    return typed;
}
function Typed ( config ) { const typed = this ; const hasDefault = config . hasOwnProperty ( 'default' ) ; // enum if ( config . hasOwnProperty ( 'enum' ) ) { if ( ! Array . isArray ( config . enum ) || config . enum . length === 0 ) { throw Error ( util . propertyErrorMessage ( 'enum' , config . enum , 'Expected a non-empty array' ) ) ; } const copy = [ ] ; config . enum . forEach ( function ( v ) { if ( copy . indexOf ( v ) === - 1 ) copy . push ( v ) ; } ) ; config . enum = copy ; } // transform if ( config . transform && typeof config . transform !== 'function' ) { throw Error ( util . propertyErrorMessage ( 'transform' , config . transform , 'Expected a function' ) ) ; } // validate if ( config . validator && typeof config . validator !== 'function' ) { throw Error ( util . propertyErrorMessage ( 'validator' , config . validator , 'Expected a function' ) ) ; } // define properties Object . defineProperties ( typed , { default : { /**
             * @property
             * @name Typed#default
             * @type {function,*}
             */ value : config . default , writable : false } , enum : { /**
             * @property
             * @name Typed#enum
             * @readonly
             * @type {function,*}
             */ value : config . enum , writable : false } , hasDefault : { /**
             * @property
             * @name Typed#hasDefault
             * @type {boolean}
             */ value : hasDefault , writable : false } , transform : { /**
             * @property
             * @name Typed#transform
             * @readonly
             * @type {function}
             */ value : config . transform , writable : false } , type : { /**
             * @property
             * @name Typed#type
             * @readonly
             * @type {string,function}
             */ value : config . type , writable : false } , validator : { /**
             * @property
             * @name Typed#validator
             * @readonly
             * @type {function}
             */ value : config . validator , writable : false } } ) ; return typed ; }
Create a Typed instance.
@param {object} config
@returns {Typed}
@constructor
Create a Typed instance .