<commit_before>'use strict';

var plainReplaceAll = require('es5-ext/string/#/plain-replace-all')

  , slice = Array.prototype.slice
  , caller = function (name, args) { $[name].apply($, args); };

module.exports = function (domjs/*, options*/) {
	var script = domjs.ns.script, fn = caller, options = arguments[1];
	if (options && (options.globalName != null) &&
			(String(options.globalName) !== '$')) {
		fn = eval('(' + plainReplaceAll.call(fn, '$', options.globalName) + ')');
	}
	domjs.ns[(options && options.name) || 'legacy'] = function (name) {
		return script(fn, name, slice.call(arguments, 1));
	};
};<commit_msg>Improve error handling in legacy extension<commit_after>'use strict';

var plainReplaceAll = require('es5-ext/string/#/plain-replace-all')

  , slice = Array.prototype.slice
  , caller;

caller = function (name, args) {
	if (typeof $[name] !== 'function') {
		throw new TypeError(name + " not accessible on $" +
			" Make sure utility is imported");
	}
	$[name].apply($, args);
};

module.exports = function (domjs/*, options*/) {
	var script = domjs.ns.script, fn = caller, options = arguments[1];
	if (options && (options.globalName != null) &&
			(String(options.globalName) !== '$')) {
		fn = eval('(' + plainReplaceAll.call(fn, '$', options.globalName) + ')');
	}
	domjs.ns[(options && options.name) || 'legacy'] = function (name) {
		return script(fn, name, slice.call(arguments, 1));
	};
};
{'fraction_non_alphanumeric': 0.20323488045007032, 'fraction_numerical': 0.004219409282700422, 'mean_word_length': 4.4106463878327, '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': '697767', 'n_tokens_mistral': 487, 'n_tokens_neox': 470, 'n_words': 107}