<commit_before>import * as _ from "lodash";
import sinon from "sinon";
import jQueryObject from "./jQueryObject";

const arrayEach = ( a, c ) => {
	for ( let i = 0; i < a.length; i++ ) {
		c( i, a[ i ] );
	}
};

const objectEach = ( o, c ) => {
	for ( let k in o ) {
		if ( o.hasOwnProperty( k ) ) {
			c( k, o[ k ] );
		}
	}
};

const jQuery = sinon.stub();
jQuery.ajax = sinon.stub();
jQuery.each = ( o = {}, c ) => _.isArray( o ) ? arrayEach( o, c ) : objectEach( o, c );
jQuery.trim = ( a ) => a;

jQuery._restore = () => {
	jQuery.reset().resetBehavior();

	// TODO: On each call, return a fresh jQueryObject. Depends on something like sinon.stub().returnsCallbackResult()`.
	jQuery.returns( new jQueryObject() );
};
<commit_msg>Use Array.isArray() instead of lodash.<commit_after>import sinon from "sinon";
import jQueryObject from "./jQueryObject";

const arrayEach = ( a, c ) => {
	for ( let i = 0; i < a.length; i++ ) {
		c( i, a[ i ] );
	}
};

const objectEach = ( o, c ) => {
	for ( let k in o ) {
		if ( o.hasOwnProperty( k ) ) {
			c( k, o[ k ] );
		}
	}
};

const jQuery = sinon.stub();
jQuery.ajax = sinon.stub();
jQuery.each = ( o = {}, c ) => Array.isArray( o ) ? arrayEach( o, c ) : objectEach( o, c );
jQuery.trim = ( a ) => a;

jQuery._restore = () => {
	jQuery.reset().resetBehavior();

	// TODO: On each call, return a fresh jQueryObject. Depends on something like sinon.stub().returnsCallbackResult()`.
	jQuery.returns( new jQueryObject() );
};

{'fraction_non_alphanumeric': 0.19346049046321526, 'fraction_numerical': 0.0013623978201634877, 'mean_word_length': 3.11484593837535, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '2620656', 'n_tokens_mistral': 543, 'n_tokens_neox': 538, 'n_words': 160}