<commit_before>'use strict';

// MODULES //

var isObjectLike = require( '@stdlib/utils/is-object-like' );
var copy = require( '@stdlib/utils/copy' );
var defaults = require( './defaults.js' );
var validate = require( './validate.js' );
var flatten = require( './flatten.js' );


// MAIN //

/**
* Returns a function to flatten an object.
*
* @param {Options} options - function options
* @param {NonNegativeInteger} [options.depth] - maximum depth to flatten
* @param {boolean} [options.copy=false] - boolean indicating whether to deep copy
* @param {boolean} [options.flattenArrays=false] - boolean indicating whether to flatten arrays
* @param {string} [options.delimiter='.'] - key path delimiter
* @throws {TypeError} options argument must be an object
* @throws {TypeError} must provide valid options
* @returns {Function} flatten function
*
* @example
* var flatten = factory({
*     'copy': true,
*     'delimiter': '|'
* });
*
* var obj = {'a':{'b':{'c':'d'}}};
* var out = flatten( obj );
* // returns {'a|b|c':'d'}
*/
function factory( options ) {
	var opts;
	var err;

	opts = copy( defaults );
	err = validate( opts, options );
	if ( err ) {
		throw err;
	}
	/**
	* Flattens an object.
	*
	* @param {ObjectLike} obj - object to flatten
	* @throws {TypeError} first argument must be object-like
	* @returns {Object} flattened object
	*/
	return function flattenObject( obj ) {
		if ( !isObjectLike( obj ) ) {
			throw new TypeError( 'invalid input argument. Must provide an object-like value. Value: `' + obj + '`.' );
		}
		return flatten( obj, opts );
	}; // end FUNCTION flattenObject()
} // end FUNCTION factory()


// EXPORTS //

module.exports = factory;<commit_msg>Replace function expression<commit_after>'use strict';

// MODULES //

var isObjectLike = require( '@stdlib/utils/is-object-like' );
var copy = require( '@stdlib/utils/copy' );
var defaults = require( './defaults.js' );
var validate = require( './validate.js' );
var flatten = require( './flatten.js' );


// MAIN //

/**
* Returns a function to flatten an object.
*
* @param {Options} options - function options
* @param {NonNegativeInteger} [options.depth] - maximum depth to flatten
* @param {boolean} [options.copy=false] - boolean indicating whether to deep copy
* @param {boolean} [options.flattenArrays=false] - boolean indicating whether to flatten arrays
* @param {string} [options.delimiter='.'] - key path delimiter
* @throws {TypeError} options argument must be an object
* @throws {TypeError} must provide valid options
* @returns {Function} flatten function
*
* @example
* var flatten = factory({
*     'copy': true,
*     'delimiter': '|'
* });
*
* var obj = {'a':{'b':{'c':'d'}}};
* var out = flatten( obj );
* // returns {'a|b|c':'d'}
*/
function factory( options ) {
	var opts;
	var err;

	opts = copy( defaults );
	err = validate( opts, options );
	if ( err ) {
		throw err;
	}
	return flattenObject;

	/**
	* Flattens an object.
	*
	* @param {ObjectLike} obj - object to flatten
	* @throws {TypeError} first argument must be object-like
	* @returns {Object} flattened object
	*/
	function flattenObject( obj ) {
		if ( !isObjectLike( obj ) ) {
			throw new TypeError( 'invalid input argument. Must provide an object-like value. Value: `' + obj + '`.' );
		}
		return flatten( obj, opts );
	} // end FUNCTION flattenObject()
} // end FUNCTION factory()


// EXPORTS //

module.exports = factory;
{'fraction_non_alphanumeric': 0.1612713360800471, 'fraction_numerical': 0.0, 'mean_word_length': 3.733983286908078, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3870217', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1083, 'n_words': 346}