src/esquire.js
function inject() {
      var args = normalize(arguments);

      /* Sanity check, need a callback */
      if (!args.function) {
        throw new EsquireError("Callback for injection unspecified");
      }

      /* Create a fake "null" module and return its value */
      var module = new Module(null, args.arguments, args.function);
      try {
        return create(module, timeout, []);
      } catch (error) {
        return Promise.reject(error);
      }

    }
function inject() {
      var args = normalize(arguments);

      /* Sanity check, need a callback */
      if (!args.function) {
        throw new EsquireError("Callback for injection unspecified");
      }

      /* Create a fake "null" module and return its value */
      var module = new Module(null, args.arguments, args.function);
      try {
        return create(module, timeout, []);
      } catch (error) {
        return Promise.reject(error);
      }

    }
function inject ( ) { var args = normalize ( arguments ) ; /* Sanity check, need a callback */ if ( ! args . function ) { throw new EsquireError ( "Callback for injection unspecified" ) ; } /* Create a fake "null" module and return its value */ var module = new Module ( null , args . arguments , args . function ) ; try { return create ( module , timeout , [ ] ) ; } catch ( error ) { return Promise . reject ( error ) ; } }
Request injection for the specified modules.

@instance
@function inject
@memberof Esquire
@example -
var esq = new Esquire();

esq.inject(['modA', 'depB'], function(a, b) {
// 'a' will be an instance of 'modA'
// 'b' will be an instance of 'depB'
return "something";

}).then(function(result) {
// The function will be (eventually) injected with its required
// modules, and its return value will resolve the promis returned
// by the "inject(...) method!
});

@example Injection also works without arrays (only arguments)
esq.inject('modA', 'depB', function(a, b) {
// 'a' will be an instance of 'modA'
// 'b' will be an instance of 'depB'
});

@example Angular-JS style injection (one big array) is supported, too
esq.inject(['modA', 'depB', function(a, b) {
// 'a' will be an instance of 'modA'
// 'b' will be an instance of 'depB'
}]);

@param {string[]|string} [dependencies] - An array of required module
names whose instances will be
passed to the `callback(...)`
method.
@param {function} callback - A function that will be called once all
module dependencies have been instantiated,
with each instance as a parameter.
@return {@link Promise} Whatever value was returned by the `callback` function.
Request injection for the specified modules .