<commit_before>'use strict';

var _ = require( 'lodash' );

// Pass in a function to return a caching version of that function
function caching( fn, isConstructor ){
	// An array of { input, output } references to store the result of each distinct function invocation
	var cache = [];

	if( arguments.length < 2 ){
		isConstructor = /function [A-Z]/.test( fn );
	}

	// This is the replacement interface for the function
	return function facade( input ){
		var isCached   = false;
		// Functions invoked with 'new' will never have the same context,
		// yet this is desirable for some singletons - but we need context
		// to correctly identify duplicate composite constructors. 
		// Isolate these cases by assigning them a void context.
		var context    = this instanceof facade ? void 0 : this;
		var signature  = [].concat.call( [ context ], arguments );
		var output     = _.findWhere( cache, function signaturesMatch( entry ){
			return ( isCached = _.every( signature, function argumentMatch( argument, index ){
				return signature[ index ] === entry.signature[ index ];
			} ) );
		} );
		var invocation = fn.bind.apply( fn, signature );

		// If we don't, execute the function and store the results
		if( !isCached ){
			if( isConstructor && !( this instanceof Object ) && !( this instanceof facade ) ){
				output = new invocation;
			}
			else {
				output = invocation();
			}

			cache.push( { signature : signature, output : output } );
		}

		return output;<commit_msg>Fixed call / apply typo in signature construction<commit_after>'use strict';

var _ = require( 'lodash' );

// Pass in a function to return a caching version of that function
function caching( fn, isConstructor ){
	// An array of { input, output } references to store the result of each distinct function invocation
	var cache = [];

	if( arguments.length < 2 ){
		isConstructor = /function [A-Z]/.test( fn );
	}

	// This is the replacement interface for the function
	return function facade( input ){
		var isCached   = false;
		// Functions invoked with 'new' will never have the same context,
		// yet this is desirable for some singletons - but we need context
		// to correctly identify duplicate composite constructors. 
		// Isolate these cases by assigning them a void context.
		var context    = this instanceof facade ? void 0 : this;
		var signature  = [].concat.apply( [ context ], arguments );
		var output     = _.findWhere( cache, function signaturesMatch( entry ){
			return ( isCached = _.every( signature, function argumentMatch( argument, index ){
				return signature[ index ] === entry.signature[ index ];
			} ) );
		} );
		var invocation = fn.bind.apply( fn, signature );

		// If we don't, execute the function and store the results
		if( !isCached ){
			if( isConstructor && !( this instanceof Object ) && !( this instanceof facade ) ){
				output = new invocation;
			}
			else {
				output = invocation();
			}

			cache.push( { signature : signature, output : output } );
		}

		return output;
{'fraction_non_alphanumeric': 0.10608579980046558, 'fraction_numerical': 0.0013302294645826404, 'mean_word_length': 3.242595204513399, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4960554', 'n_tokens_mistral': 911, 'n_tokens_neox': 795, 'n_words': 339}