<commit_before>Loadrunner is a JavaScript dependency manager.

Loadrunner started off as my science project script loader and module system but its turned into a generic dependency manager that you can build on to manage any type of asynchronous dependency from CSS templates to DOM events to cache loading.  It does however include build in support for loading regular JavaScript files, AMD modules and its own, more elegant (IMHO) flavour of modules.

Run the tests
-------------

Open test/test.html.  To run against the minified version open test/test.html?dist=true. Also, try reading the tests.  They illustrate how it works possibly better than the examples below.

Build a minified version
------------------------

Just run:

    make


The Basics
----------

In its basic form, loadrunner exposes two top level functions: `using` and `provide`.

__using(dependency[, dependency1, dependency2, ...][callback]) => Combination__

Takes any number of dependencies, which can be any type of dependency object or a string representing a dependency (a path to a javascript file or module identify works by default), and returns a dependency called a *Combination* which waits for all of the given dependencies to complete in any order.  If you specify a callback then it's attached to this dependency as a convenience.

    // use some javascript files
    using('javascripts/jquery.js', 'javascripts/underscore.js', function() {
      $(function() {
        _(['foo', bar', 'baz']).each(function(i) {
          $(document.body).append('<p>' + i + '</p>');
        });
      })
    });

Depending on the type of dependencies specified in the `using` block some arguments may be passed to the callback function.  For instance, in the case of using a module, the module's exports are passed as a function argument.

    // use some modules
    using('dom', 'events', function(dom, events) {
      var el = dom.get('#thing');

      events.on(el, function() {
        alert('kersplang');
      });
    });

    // get reference to a dependency
    var mods = using('dom', 'events');

    // use that dependency with others
    using(mods, 'javascripts/jquery.js', function(dom, events) {

    });

__provide([id,] factory) => Module__

`provide` defines a module with the given id.  If you don't provide an id then the module's id will be inferred from the location of the javascript file that contains it (dom/events.js => dom/events).  Provide returns a type of dependency, *Module*.  The second argument can be either a function that is run to define the module or any kind of other type.  In the case of this being a function, then when the module is a evaluated the function is called with a single argument, normally called *exports*, which is a function that you call to specify which public values the module exports.  Note that you can call this at any point after the module has been evaluated.  Exporting module values is asynchronous.  Among other things, this allows seamless operation with the `using` function to allow your modules to depend on other items.<commit_msg>added some small details to the readme<commit_after>Loadrunner is a JavaScript dependency manager.

Loadrunner started off as my science project script loader and module system but its turned into a generic dependency manager that you can build on to manage any type of asynchronous dependency from CSS templates to DOM events to cache loading.  It does however include build in support for loading regular JavaScript files, AMD modules and its own, more elegant (IMHO) flavour of modules.

Run the tests
-------------

Open test/test.html.  To run against the minified version open test/test.html?dist=true. Also, try reading the tests.  They illustrate how it works possibly better than the examples below.

Build a minified version
------------------------

Just run:

    make


The Basics
----------

In its basic form, loadrunner exposes two top level functions: `using` and `provide`.

__using(dependency[, dependency1, dependency2, ...][, callback][, collectResults]) => Combination__

Takes any number of dependencies, which can be any type of dependency object or a string representing a dependency (a path to a javascript file or module identify works by default), and returns a dependency called a *Combination* which waits for all of the given dependencies to complete in any order.  If you specify a callback then it's attached to this dependency as a convenience.

Dependencies are not loaded until a callback is attached.

    // use some javascript files
    using('javascripts/jquery.js', 'javascripts/underscore.js', function() {
      $(function() {
        _(['foo', bar', 'baz']).each(function(i) {
          $(document.body).append('<p>' + i + '</p>');
        });
      })
    });

Depending on the type of dependencies specified in the `using` block some arguments may be passed to the callback function.  For instance, in the case of using a module, the module's exports are passed as a function argument.

    // use some modules
    using('dom', 'events', function(dom, events) {
      var el = dom.get('#thing');

      events.on(el, function() {
        alert('kersplang');
      });
    });

    // get reference to a dependency
    var mods = using('dom', 'events');

    // use that dependency with others
    using(mods, 'javascripts/jquery.js', function(dom, events) {

    });

Using can provide all exports in a single object if required.  Just pass 'true' as the last parameter.

    // use some modules in one object
    using('dom', 'events', function(imports) {
      var el = imports.dom.get('#thing');
      imports.events.on(el, function() {
        alert('kersplang');
      });
    }, true);

Using can load script synchronously (in order) by being provided arguments in an array.

    // load 'dom' first, then load 'events', then execute the callback
    using(['dom', 'events'], function(imports) {

    }, true);


__provide([id,] factory) => Module__

`provide` defines a module with the given id.  If you don't provide an id then the module's id will be inferred from the location of the javascript file that contains it (dom/events.js => dom/events).  Provide returns a type of dependency, *Module*.  The second argument can be either a function that is run to define the module or any kind of other type.  In the case of this being a function, then when the module is a evaluated the function is called with a single argument, normally called *exports*, which is a function that you call to specify which public values the module exports.  Note that you can call this at any point after the module has been evaluated.  Exporting module values is asynchronous.  Among other things, this allows seamless operation with the `using` function to allow your modules to depend on other items.
{'fraction_non_alphanumeric': 0.09086911915579657, 'fraction_numerical': 0.0005862523816503004, 'mean_word_length': 3.4630477436232834, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5725806', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1631, 'n_words': 915}