<commit_before>var Fetcher     = require("./fetcher");
var Resolver    = require("./resolver");
var logger      = require("./logger");
var dependency  = require("deps-bits");
var Bitloader   = require("bit-loader");
var utils       = require("belty");


/*
 * Default options for Bitimports instances
 *
 * @private
 * @memberof Bitimports
 */
var defaults = {
  baseUrl  : ".",
  packages : [],
  paths    : {}
};


/**
 * Bitimports is a module loader for the browser. It has flexible and powerful
 * processing pipelines that allow you to load your modules the way you want.
 * This module loader supports the System module loading interface for loading
 * modules as well as CJS dependency processing. This combination enables the
 * use of transpilers like [babel]{@link http://babeljs.io/} so that you can
 * write ES6 (and later), write in the browser. [bit-loader]{@link Bitloader}

 * @class
 * @private
 * @augments Bitloader
 */
function Bitimports(options) {
  var settings = utils.merge({}, defaults, options);
  var resolver = new Resolver(settings);
  var fetcher  = new Fetcher(this, settings);

  settings.resolve = settings.resolve || resolver.resolve.bind(resolver);
  settings.fetch   = settings.fetch   || fetcher.fetch.bind(fetcher);

  Bitloader.call(this, settings);

  this.plugin("js", {
    "dependency": dependency
  });

  // Make this option a bit obtuse - I wanna make it a lil difficult for people to
  // enable processing of node_modules since it can be rather difficult to tweak
  // configurations to properly excluce modules to be processed.
  if (settings.doNotIgnoreNodeModules !== true) {
    this.services.transform.ignore("path", /node_modules\//);
    this.services.dependency.ignore("path", /node_modules\//);
  }
}


// Setup inheritance.
Bitimports.prototype = Object.create(Bitloader.prototype);
Bitimports.prototype.constructor = Bitimports;

// Add these contructs to the prototype so that bit import instances can have
// access to them.

/**
 * Global logger instance.
 */
Bitimports.prototype.logger = logger;

/*
 * Module constructor
 */
Bitimports.prototype.Module = Bitloader.Module;

/*
 * Rule matching engine constructor
 */
Bitimports.prototype.Rule = Bitloader.Rule;


/**
 * Bitimports factory
 *
 * @returns {Bitimports} Instance of Bitimports
 */
Bitimports.prototype.create = function(options) {
  return new Bitimports(options);
};


/**
 * Method to configure an instance of Bitimports.
 *
 * config applies the configuration settings to `this` instance of Bitimports.
 * It will also create and return a new instance of Bitimports with the
 * configuration settings passed in. The config method is generally your
 * primary way of configuring and creating instances of Bitimports.
 *
 * @param {Object} options - Configuration settings for Bitimports instance.
 *  Please take a look over at [amd resolver]{@link https://github.com/MiguelCastillo/amd-resolver}
 *  for details on the options.
 * @param {string} options.baseUrl - Root URL for resolving modules names.
 * @param {Object} options.paths - A map of module names to module paths.
 *  The resolution pipeline will use the configured paths when loading modules
 *  for the matching names.
 * @param {string[]} options.extensions - List of known extensions. Files with
 *  extensions in this list will not get `.js` appended.
 * @param {string[]} options.packages - List of module names to be treated as packages.
 *  Module names matching items in this list will resolve to URLs `packagename/main.js`.
 *  That is to say that loading a module called `machine` will generate the URL `machine/main.js`.
 * @param {Object[]} options.packages - List of package configuration settings.
 *  Package objects allow you to granuarly configure what URLs are generated when
 *  resolving module names.
 * @param {string} options.packages[].location - Location of the module on disk
 * @param {string} options.packages[].main - File name. Defaults to `main.js`.
 * @param {string} options.packages[].name - Package name. This is what the resolution
 *  matches module names against.
 *
 * @returns {Bitimports} Instance of Bitimports
 */
Bitimports.prototype.config = function(options) {
  utils.merge(this.settings, options);
  return this.create(options);
};


/**
 * `bitimports` is the default Bitimports instance available in the environtment.
 * Generally speaking, you configure it with the [config]{@link Bitimports#config} method
 * to define how your application needs to be processed.
 *
 * When the bit-imports module is loaded via script tag, which is the more
 * common use case in the browser, `bitimports` is automatically added to the
 * global object.  But since bit-imports is a [UMD]{@link https://github.com/umdjs/umd}
 * module, feel free to load it as an [AMD]{@link https://github.com/amdjs/amdjs-api/wiki/AMD}
 * or [CJS]{@link http://wiki.commonjs.org/wiki/Modules/1.1.1} module.
 *
 * `bitimports` exposes methods such as [require]{@link Bitimports#require},
 * [import]{@link Bitimports#import}, and [register]{@link Bitimports#register} to provide
 * a comprehensive system for loading modules.
 *
 * @global
 * @name bitimports
 * @type Bitimports
 * @see {@link Bitimports}<commit_msg>Added example in bit-imports global instance<commit_after>var Fetcher     = require("./fetcher");
var Resolver    = require("./resolver");
var logger      = require("./logger");
var dependency  = require("deps-bits");
var Bitloader   = require("bit-loader");
var utils       = require("belty");


/*
 * Default options for Bitimports instances
 *
 * @private
 * @memberof Bitimports
 */
var defaults = {
  baseUrl  : ".",
  packages : [],
  paths    : {}
};


/**
 * Bitimports is a module loader for the browser. It has flexible and powerful
 * processing pipelines that allow you to load your modules the way you want.
 * This module loader supports the System module loading interface for loading
 * modules as well as CJS dependency processing. This combination enables the
 * use of transpilers like [babel]{@link http://babeljs.io/} so that you can
 * write ES6 (and later), write in the browser. [bit-loader]{@link Bitloader}
 *
 * @class
 * @private
 * @augments Bitloader
 */
function Bitimports(options) {
  var settings = utils.merge({}, defaults, options);
  var resolver = new Resolver(settings);
  var fetcher  = new Fetcher(this, settings);

  settings.resolve = settings.resolve || resolver.resolve.bind(resolver);
  settings.fetch   = settings.fetch   || fetcher.fetch.bind(fetcher);

  Bitloader.call(this, settings);

  this.plugin("js", {
    "dependency": dependency
  });

  // Make this option a bit obtuse - I wanna make it a lil difficult for people to
  // enable processing of node_modules since it can be rather difficult to tweak
  // configurations to properly excluce modules to be processed.
  if (settings.doNotIgnoreNodeModules !== true) {
    this.services.transform.ignore("path", /node_modules\//);
    this.services.dependency.ignore("path", /node_modules\//);
  }
}


// Setup inheritance.
Bitimports.prototype = Object.create(Bitloader.prototype);
Bitimports.prototype.constructor = Bitimports;

// Add these contructs to the prototype so that bit import instances can have
// access to them.

/**
 * Global logger instance.
 */
Bitimports.prototype.logger = logger;

/*
 * Module constructor
 */
Bitimports.prototype.Module = Bitloader.Module;

/*
 * Rule matching engine constructor
 */
Bitimports.prototype.Rule = Bitloader.Rule;


/**
 * Bitimports factory
 *
 * @returns {Bitimports} Instance of Bitimports
 */
Bitimports.prototype.create = function(options) {
  return new Bitimports(options);
};


/**
 * Method to configure an instance of Bitimports.
 *
 * config applies the configuration settings to `this` instance of Bitimports.
 * It will also create and return a new instance of Bitimports with the
 * configuration settings passed in. The config method is generally your
 * primary way of configuring and creating instances of Bitimports.
 *
 * @param {Object} options - Configuration settings for Bitimports instance.
 *  Please take a look over at [amd resolver]{@link https://github.com/MiguelCastillo/amd-resolver}
 *  for details on the options.
 * @param {string} options.baseUrl - Root URL for resolving modules names.
 * @param {Object} options.paths - A map of module names to module paths.
 *  The resolution pipeline will use the configured paths when loading modules
 *  for the matching names.
 * @param {string[]} options.extensions - List of known extensions. Files with
 *  extensions in this list will not get `.js` appended.
 * @param {string[]} options.packages - List of module names to be treated as packages.
 *  Module names matching items in this list will resolve to URLs `packagename/main.js`.
 *  That is to say that loading a module called `machine` will generate the URL `machine/main.js`.
 * @param {Object[]} options.packages - List of package configuration settings.
 *  Package objects allow you to granuarly configure what URLs are generated when
 *  resolving module names.
 * @param {string} options.packages[].location - Location of the module on disk
 * @param {string} options.packages[].main - File name. Defaults to `main.js`.
 * @param {string} options.packages[].name - Package name. This is what the resolution
 *  matches module names against.
 *
 * @returns {Bitimports} Instance of Bitimports
 */
Bitimports.prototype.config = function(options) {
  utils.merge(this.settings, options);
  return this.create(options);
};


/**
 * `bitimports` is the default Bitimports instance available in the environtment.
 * Generally speaking, you configure it with the [config]{@link Bitimports#config} method
 * to define how your application needs to be processed.
 *
 * When the bit-imports module is loaded via script tag, which is the more
 * common use case in the browser, `bitimports` is automatically added to the
 * global object.  But since bit-imports is a [UMD]{@link https://github.com/umdjs/umd}
 * module, feel free to load it as an [AMD]{@link https://github.com/amdjs/amdjs-api/wiki/AMD}
 * or [CJS]{@link http://wiki.commonjs.org/wiki/Modules/1.1.1} module.
 *
 *
 * @example
 * <!DOCTYPE html>
 * <html lang="en">
 *   <head>
 *     <script type="text/javascript" src="node_modules/bit-imports/dist/bit-imports.min.js" defer></script>
 *     <script type="text/javascript" src="config.js" defer></script>
 *   </head>
 * </html>
 *
 * @example
 * var System = bitimports
 *  // Configure bitimports
 *  .config({
 *    paths: {
 *      babel: "node_modules/babel-bits/dist/index.min"
 *    }
 *  })
 *  // Setup js pipeline with babel-bits
 *  .plugin("js", {
 *    match: { path: /\.(js)$/ },
 *    transform: {
 *      handler: "babel",
 *      options: {
 *        sourceMap: "inline",
 *        presets: ["es2015"]
 *      }
 *    }
 *  });
 *
 * // Import "main" module.
 * System.import("main");
 *
 * @global
 * @name bitimports
 * @type Bitimports
 * @see {@link Bitimports}
{'fraction_non_alphanumeric': 0.11347968069666182, 'fraction_numerical': 0.0010885341074020319, 'mean_word_length': 3.772727272727273, 'pattern_counts': {'":': 2, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 6, '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': '3348933', 'n_tokens_mistral': 3160, 'n_tokens_neox': 3110, 'n_words': 1143}