<commit_before>(function ( global ) {

	'use strict';

	var reindex = function ( array, idField ) {
		var obj = {}, i, record;

		if ( Object.prototype.toString.call( array ) === '[object Array]' ) {
			throw new Error( 'Cannot reindex a non-array!' );
		}

		i = arrayOrObject.length;
		while ( i-- ) {
			record = arrayOrObject[i];
			if ( record.hasOwnProperty( idField ) ) {
				obj[ record[ idField ] ] = record;
			}
		}

		return obj;
	};

	// export as CommonJS module...
	if ( global.module && global.module.exports ) {
		global.module.exports = reindex;
	}

	// ... or as AMD module...
	else if ( global.define && global.define.amd ) {
		global.define( function () { return reindex; });
	}

	// ... or as browser global
	else {
		global.reindex = reindex;
	}


}( this ));<commit_msg>throw error if no id field specified<commit_after>// https://github.com/Rich-Harris/reindex
// --------------------------------------
//
// MIT licensed. Go nuts.

(function ( global ) {

	'use strict';

	var reindex = function ( array, idField ) {
		var obj = {}, i, record;

		if ( Object.prototype.toString.call( array ) === '[object Array]' ) {
			throw new Error( 'Cannot reindex a non-array!' );
		}

		if ( !idField ) {
			throw new Error( 'You must specify an ID field' );
		}

		i = arrayOrObject.length;
		while ( i-- ) {
			record = arrayOrObject[i];
			if ( record.hasOwnProperty( idField ) ) {
				obj[ record[ idField ] ] = record;
			}
		}

		return obj;
	};

	// export as CommonJS module...
	if ( global.module && global.module.exports ) {
		global.module.exports = reindex;
	}

	// ... or as AMD module...
	else if ( global.define && global.define.amd ) {
		global.define( function () { return reindex; });
	}

	// ... or as browser global
	else {
		global.reindex = reindex;
	}

}( this ));
{'fraction_non_alphanumeric': 0.1824736550194121, 'fraction_numerical': 0.0, 'mean_word_length': 2.4102079395085068, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '6360198', 'n_tokens_mistral': 657, 'n_tokens_neox': 590, 'n_words': 163}