<commit_before>'use strict';

// MODULES

var isArray = require( 'validate.io-array' ),
	isObject = require( 'validate.io-object' ),
	isBoolean = require( 'validate.io-boolean-primitive' ),
	isFunction = require( 'validate.io-function' );


// SIGNUM //

/**
* FUNCTION: signum( x )
*	Determines the sign of a numeric value.
*
* @private
* @param {Number} x - input value
*/
function signum( x ) {
	// [0] NaN
	if ( x !== x ) {
		return NaN;
	}
	// [1] +-0
	if ( !x ) {
		return x;
	}
	// [2] x < 0
	if ( x < 0 ) {
		return -1;
	}
	// [3] x > 0
	return 1;
} // end FUNCTION signum()


// EXPORTS //

/**
* FUNCTION: signum( x[, options] )
*	Evaluates the signum function.
*
* @param {Number[]|Number} x - numeric array or single number
* @param {Object} [options] - function options
* @param {Function} [options.accessor] - accessor function for accessing array values
* @param {Boolean} [options.copy=true] - boolean indicating whether to return a new array
* @returns {Number[]|Number} signum values
*/
module.exports = function( x, opts ) {
	var copy = true,
		clbk,
		len,
		arr,
		v, i;

	if ( typeof x === 'number' ) {
		return signum( x );
	}
	if ( !isArray( x ) ) {
		throw new TypeError( 'signum()::invalid input argument. Must provide either a single number primitive or an array of number primitives. Value: `' + x + '`.' );
	}
	if ( arguments.length > 1 ) {
		if ( !isObject( opts ) ) {
			throw new TypeError( 'signum()::invalid input argument. Options argument must be an object. Value: `' + opts + '`.' );
		}
		if ( opts.hasOwnProperty( 'accessor' ) ) {
			clbk = opts.accessor;
			if ( !isFunction ( clbk ) ) {
				throw new TypeError( 'signum()::invalid option. Accessor must be a function. Option: `' + clbk + '`.' );
			}
		}
		if ( opts.hasOwnProperty( 'copy' ) ) {
			copy = opts.copy;
			if ( !isBoolean( copy ) ) {
				throw new TypeError( 'signum()::invalid option. Copy option must be a boolean primitive. Option: `' + copy + '`.' );
			}
		}
	}
	len = x.length;
	if ( copy === true ) {
		arr = new Array( len );
	} else {
		arr = x;
	}
	if ( clbk ) {
		for ( i = 0; i < len; i++ ) {
			v = clbk( x[ i ], i );
			if ( typeof v !== 'number' ) {
				throw new TypeError( 'signum()::invalid input argument. Must provide an array of number primitives. Value: `' + x + '`.' );
			}
			arr[ i ] = signum( v );
		}
	} else {
		for ( i = 0; i < len; i++ ) {
			v = x[ i ];
			if ( typeof v !== 'number' ) {
				throw new TypeError( 'signum()::invalid input argument. Must provide an array of number primitives. Value: `' + x + '`.' );
			}
			arr[ i ] = signum( v );
		}
	}
	return arr;
}; // end FUNCTION signum()<commit_msg>[FIX] err msg.<commit_after>'use strict';

// MODULES

var isArray = require( 'validate.io-array' ),
	isObject = require( 'validate.io-object' ),
	isBoolean = require( 'validate.io-boolean-primitive' ),
	isFunction = require( 'validate.io-function' );


// SIGNUM //

/**
* FUNCTION: signum( x )
*	Determines the sign of a numeric value.
*
* @private
* @param {Number} x - input value
*/
function signum( x ) {
	// [0] NaN
	if ( x !== x ) {
		return NaN;
	}
	// [1] +-0
	if ( !x ) {
		return x;
	}
	// [2] x < 0
	if ( x < 0 ) {
		return -1;
	}
	// [3] x > 0
	return 1;
} // end FUNCTION signum()


// EXPORTS //

/**
* FUNCTION: signum( x[, options] )
*	Evaluates the signum function.
*
* @param {Number[]|Number} x - numeric array or single number
* @param {Object} [options] - function options
* @param {Function} [options.accessor] - accessor function for accessing array values
* @param {Boolean} [options.copy=true] - boolean indicating whether to return a new array
* @returns {Number[]|Number} signum values
*/
module.exports = function( x, opts ) {
	var copy = true,
		clbk,
		len,
		arr,
		v, i;

	if ( typeof x === 'number' ) {
		return signum( x );
	}
	if ( !isArray( x ) ) {
		throw new TypeError( 'signum()::invalid input argument. Must provide either a single number primitive or an array of number primitives. Value: `' + x + '`.' );
	}
	if ( arguments.length > 1 ) {
		if ( !isObject( opts ) ) {
			throw new TypeError( 'signum()::invalid input argument. Options argument must be an object. Value: `' + opts + '`.' );
		}
		if ( opts.hasOwnProperty( 'accessor' ) ) {
			clbk = opts.accessor;
			if ( !isFunction ( clbk ) ) {
				throw new TypeError( 'signum()::invalid option. Accessor must be a function. Option: `' + clbk + '`.' );
			}
		}
		if ( opts.hasOwnProperty( 'copy' ) ) {
			copy = opts.copy;
			if ( !isBoolean( copy ) ) {
				throw new TypeError( 'signum()::invalid option. Copy option must be a boolean primitive. Option: `' + copy + '`.' );
			}
		}
	}
	len = x.length;
	if ( copy === true ) {
		arr = new Array( len );
	} else {
		arr = x;
	}
	if ( clbk ) {
		for ( i = 0; i < len; i++ ) {
			v = clbk( x[ i ], i );
			if ( typeof v !== 'number' ) {
				throw new TypeError( 'signum()::invalid input argument. Accessed array values must be number primitives. Value: `' + x + '`.' );
			}
			arr[ i ] = signum( v );
		}
	} else {
		for ( i = 0; i < len; i++ ) {
			v = x[ i ];
			if ( typeof v !== 'number' ) {
				throw new TypeError( 'signum()::invalid input argument. Must provide an array of number primitives. Value: `' + x + '`.' );
			}
			arr[ i ] = signum( v );
		}
	}
	return arr;
}; // end FUNCTION signum()
{'fraction_non_alphanumeric': 0.1747261050245561, 'fraction_numerical': 0.004911220249338874, 'mean_word_length': 2.75, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7095762', 'n_tokens_mistral': 2086, 'n_tokens_neox': 1914, 'n_words': 605}