<commit_before>/**
 * @license Copyright (c) 2010-2011 <NAME>
 * LICENSE: see the LICENSE.txt file. If file is missing, this file is subject
 * to the MIT License at: http://www.opensource.org/licenses/mit-license.php.
 */

/*
	File: wire.js
*/

//noinspection ThisExpressionReferencesGlobalObjectJS
(function(rootSpec, define){
	define(['require', 'when', 'wire/base'], function(require, when, basePlugin) {

	"use strict";

	var VERSION, tos, rootContext, delegate, emptyObject,
		defer, chain, whenAll, isPromise, undef;

	wire.version = VERSION = "0.6.5";
	tos = Object.prototype.toString;
	rootSpec = rootSpec || {};

	delegate = Object.create || createObject;

	emptyObject = {};

	// Local refs to when.js
	defer = when.defer;
	chain = when.chain;
	whenAll = when.all;
	isPromise = when.isPromise;

	// Helper to reject a deferred when another is rejected
	function chainReject(resolver) {
		return function(err) { resolver.reject(err); };
	}

	function indexOf(array, item) {
		for (var i = 0, len = array.length; i < len; i++) {
			if(array[i] === item) return i;
		}

		return -1;
	}

	//
	// AMD Module API
	//

	function wire(spec) {
		var d = defer();

		// If the root context is not yet wired, wire it first
		if (!rootContext) {
			rootContext = wireContext(rootSpec);
		}

		// Use the rootContext to wire all new contexts.
		when(rootContext).then(
			function(root) {
				chain(root.wire(spec), d);
			},
			chainReject(d)
		);

		return d.promise;
	}

	//
	// AMD loader plugin API
	//

	//noinspection JSUnusedLocalSymbols
	function amdLoad(name, require, callback, config) {
		var promise = callback.resolve
			? callback
			: {
				resolve: callback,
				reject: function(err) { throw err; }
			};

		chain(wire(name), promise);
	}

	wire.load = amdLoad;

	//
	// AMD Analyze/Build plugin API
	//
	// Separate builder plugin as per CommonJS LoaderPlugin spec:
	// http://wiki.commonjs.org/wiki/Modules/LoaderPlugin

	// plugin-builder: wire/cram/builder

	//
	// Private functions
	//

	function wireContext(specs, parent) {

		var deferred = defer();

		// Function to do the actual wiring.  Capture the
		// parent so it can be called after an async load
		// if spec is an AMD module Id string.
		function doWireContexts(specs) {
			var spec = mergeSpecs(specs);

			createScope(spec, parent).then(
				function(scope) {
					deferred.resolve(scope.objects);
				},
				chainReject(deferred)
			);
		}

    	// If spec is a module Id, or list of module Ids, load it/them, then wire.
    	// If it's a spec object or array of objects, wire it now.
    	if(isString(specs)) {
		    var specIds = specs.split(',');

    		require(specIds, function() { doWireContexts(arguments); });
		} else {
			doWireContexts(isArray(specs) ? specs : [specs]);
		}

		return deferred;
	}

	// Merge multiple specs together before wiring.
	function mergeSpecs(specs) {
		for (var i = 0, merged = {}, s; (s = specs[i++]);) {
			mixinSpec(merged, s);
		}

		return merged;
	}

	// Add components in from to those in to.  If duplicates are found, it
	// is an error.
	function mixinSpec(to, from) {
		for (var name in from) {
			if (from.hasOwnProperty(name) && !(name in emptyObject)) {
				if (to.hasOwnProperty(name)) {
					throw new Error("Duplicate component name in sibling specs: " + name);
				} else {
					to[name] = from[name];
				}
			}
		}
	}

	function createScope(scopeDef, parent, scopeName) {
		var scope, scopeParent, local, proxied, objects,
            pluginApi, resolvers, factories, facets, listeners, proxies,
			modulesToLoad, moduleLoadPromises,
			wireApi, modulesReady, scopeReady, scopeDestroyed,
			name, contextPromise, doDestroy;


		// Empty parent scope if none provided
		parent = parent || {};
        
        initFromParent(parent);
        initPluginApi();

        // TODO: Find a better way to load and scan the base plugin
		scanPlugin(basePlugin);<commit_msg>Removed unused var<commit_after>/**
 * @license Copyright (c) 2010-2011 <NAME>
 * LICENSE: see the LICENSE.txt file. If file is missing, this file is subject
 * to the MIT License at: http://www.opensource.org/licenses/mit-license.php.
 */

/*
	File: wire.js
*/

//noinspection ThisExpressionReferencesGlobalObjectJS
(function(rootSpec, define){
	define(['require', 'when', 'wire/base'], function(require, when, basePlugin) {

	"use strict";

	var VERSION, tos, rootContext, delegate, emptyObject,
		defer, chain, whenAll, isPromise, undef;

	wire.version = VERSION = "0.6.5";
	tos = Object.prototype.toString;
	rootSpec = rootSpec || {};

	delegate = Object.create || createObject;

	emptyObject = {};

	// Local refs to when.js
	defer = when.defer;
	chain = when.chain;
	whenAll = when.all;
	isPromise = when.isPromise;

	// Helper to reject a deferred when another is rejected
	function chainReject(resolver) {
		return function(err) { resolver.reject(err); };
	}

	function indexOf(array, item) {
		for (var i = 0, len = array.length; i < len; i++) {
			if(array[i] === item) return i;
		}

		return -1;
	}

	//
	// AMD Module API
	//

	function wire(spec) {
		var d = defer();

		// If the root context is not yet wired, wire it first
		if (!rootContext) {
			rootContext = wireContext(rootSpec);
		}

		// Use the rootContext to wire all new contexts.
		when(rootContext).then(
			function(root) {
				chain(root.wire(spec), d);
			},
			chainReject(d)
		);

		return d.promise;
	}

	//
	// AMD loader plugin API
	//

	//noinspection JSUnusedLocalSymbols
	function amdLoad(name, require, callback, config) {
		var promise = callback.resolve
			? callback
			: {
				resolve: callback,
				reject: function(err) { throw err; }
			};

		chain(wire(name), promise);
	}

	wire.load = amdLoad;

	//
	// AMD Analyze/Build plugin API
	//
	// Separate builder plugin as per CommonJS LoaderPlugin spec:
	// http://wiki.commonjs.org/wiki/Modules/LoaderPlugin

	// plugin-builder: wire/cram/builder

	//
	// Private functions
	//

	function wireContext(specs, parent) {

		var deferred = defer();

		// Function to do the actual wiring.  Capture the
		// parent so it can be called after an async load
		// if spec is an AMD module Id string.
		function doWireContexts(specs) {
			var spec = mergeSpecs(specs);

			createScope(spec, parent).then(
				function(scope) {
					deferred.resolve(scope.objects);
				},
				chainReject(deferred)
			);
		}

    	// If spec is a module Id, or list of module Ids, load it/them, then wire.
    	// If it's a spec object or array of objects, wire it now.
    	if(isString(specs)) {
		    var specIds = specs.split(',');

    		require(specIds, function() { doWireContexts(arguments); });
		} else {
			doWireContexts(isArray(specs) ? specs : [specs]);
		}

		return deferred;
	}

	// Merge multiple specs together before wiring.
	function mergeSpecs(specs) {
		for (var i = 0, merged = {}, s; (s = specs[i++]);) {
			mixinSpec(merged, s);
		}

		return merged;
	}

	// Add components in from to those in to.  If duplicates are found, it
	// is an error.
	function mixinSpec(to, from) {
		for (var name in from) {
			if (from.hasOwnProperty(name) && !(name in emptyObject)) {
				if (to.hasOwnProperty(name)) {
					throw new Error("Duplicate component name in sibling specs: " + name);
				} else {
					to[name] = from[name];
				}
			}
		}
	}

	function createScope(scopeDef, parent, scopeName) {
		var scope, scopeParent, local, proxied, objects,
            pluginApi, resolvers, factories, facets, listeners, proxies,
			modulesToLoad, moduleLoadPromises,
			wireApi, modulesReady, scopeReady, scopeDestroyed,
            contextPromise, doDestroy;
        
        // Empty parent scope if none provided
		parent = parent || {};
        
        initFromParent(parent);
        initPluginApi();

        // TODO: Find a better way to load and scan the base plugin
		scanPlugin(basePlugin);
{'fraction_non_alphanumeric': 0.12794999362163542, 'fraction_numerical': 0.0035718841688990944, 'mean_word_length': 3.0205128205128204, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3641434', 'n_tokens_mistral': 2879, 'n_tokens_neox': 2524, 'n_words': 756}