lib/polymorphic.js
function prepare(list, arg) {
		return list.map(function(config) {
			var item = {
					//  the function to call
					call: config.call,

					//  all configured arguments
					arguments: config.arguments,

					//  the calculated specificity
					specificity: config.arguments.map(function(argument, index) {
						var value = 'value' in argument,
							specificity = 0;

						//  if a argument not a variadic one and the value is specified
						if (argument.type !== '...' && index < arg.length) {
							++specificity;

							//  bonus points if the exact type matches (explicit by type)
							//  OR there is no default value (explicitly provided)
							if (Number(argument.type === type(arg[index], true) || isExtendOf(argument.type, arg[index]) || !value)) {
								++specificity;
							}

							//  extra bonus points if the type is explicity the same (in case of inheritance)
							if (new RegExp('^' + type(arg[index], true) + '!$').test(argument.type)){ 
								++specificity;
							}
						}

						return specificity;
					}).join(''),

					//  the parameters with which the `call` may be executed
					param: config.arguments.map(function(argument, index) {
						var result = {};

						result.name = argument.name;

						//  if a variadic type is encountered, the remainder of the given arguments becomes the value
						if (argument.type === '...') {
							result.value = arg.slice(index);
						}
						else if (index < arg.length && typeof arg[index] !== 'undefined' && arg[index] !== null) {
							result.value = arg[index];
						}
						else if ('value' in argument) {
							result.value = argument.value;
						}
						else if ('reference' in argument) {
							result.reference = argument.reference;
						}

						return result;
					})
				};

			return item;
		});
	}
function prepare(list, arg) {
		return list.map(function(config) {
			var item = {
					//  the function to call
					call: config.call,

					//  all configured arguments
					arguments: config.arguments,

					//  the calculated specificity
					specificity: config.arguments.map(function(argument, index) {
						var value = 'value' in argument,
							specificity = 0;

						//  if a argument not a variadic one and the value is specified
						if (argument.type !== '...' && index < arg.length) {
							++specificity;

							//  bonus points if the exact type matches (explicit by type)
							//  OR there is no default value (explicitly provided)
							if (Number(argument.type === type(arg[index], true) || isExtendOf(argument.type, arg[index]) || !value)) {
								++specificity;
							}

							//  extra bonus points if the type is explicity the same (in case of inheritance)
							if (new RegExp('^' + type(arg[index], true) + '!$').test(argument.type)){ 
								++specificity;
							}
						}

						return specificity;
					}).join(''),

					//  the parameters with which the `call` may be executed
					param: config.arguments.map(function(argument, index) {
						var result = {};

						result.name = argument.name;

						//  if a variadic type is encountered, the remainder of the given arguments becomes the value
						if (argument.type === '...') {
							result.value = arg.slice(index);
						}
						else if (index < arg.length && typeof arg[index] !== 'undefined' && arg[index] !== null) {
							result.value = arg[index];
						}
						else if ('value' in argument) {
							result.value = argument.value;
						}
						else if ('reference' in argument) {
							result.reference = argument.reference;
						}

						return result;
					})
				};

			return item;
		});
	}
function prepare ( list , arg ) { return list . map ( function ( config ) { var item = { //  the function to call call : config . call , //  all configured arguments arguments : config . arguments , //  the calculated specificity specificity : config . arguments . map ( function ( argument , index ) { var value = 'value' in argument , specificity = 0 ; //  if a argument not a variadic one and the value is specified if ( argument . type !== '...' && index < arg . length ) { ++ specificity ; //  bonus points if the exact type matches (explicit by type) //  OR there is no default value (explicitly provided) if ( Number ( argument . type === type ( arg [ index ] , true ) || isExtendOf ( argument . type , arg [ index ] ) || ! value ) ) { ++ specificity ; } //  extra bonus points if the type is explicity the same (in case of inheritance) if ( new RegExp ( '^' + type ( arg [ index ] , true ) + '!$' ) . test ( argument . type ) ) { ++ specificity ; } } return specificity ; } ) . join ( '' ) , //  the parameters with which the `call` may be executed param : config . arguments . map ( function ( argument , index ) { var result = { } ; result . name = argument . name ; //  if a variadic type is encountered, the remainder of the given arguments becomes the value if ( argument . type === '...' ) { result . value = arg . slice ( index ) ; } else if ( index < arg . length && typeof arg [ index ] !== 'undefined' && arg [ index ] !== null ) { result . value = arg [ index ] ; } else if ( 'value' in argument ) { result . value = argument . value ; } else if ( 'reference' in argument ) { result . reference = argument . reference ; } return result ; } ) } ; return item ; } ) ; }
Map the registered values to a new object containing the specifics we use to determine the best
@name    prepare
@access  internal
@param   array  candidates
@param   array  arguments
@return  array  mapped candidates
Map the registered values to a new object containing the specifics we use to determine the best