Skip to content

Commit

Permalink
chore: internally document methods
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Nov 22, 2023
1 parent c3e1017 commit ee76791
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions lib/injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,38 @@ export default function Injector(modules, parent) {
};
}

function instantiate(Type) {
/**
* Instantiate the given type, injecting dependencies.
*
* @template T
*
* @param { Function | [...string[], Function ]} type
*
* @return T
*/
function instantiate(type) {
const {
fn,
dependencies
} = fnDef(Type);
} = fnDef(type);

// instantiate var args constructor
const Constructor = Function.prototype.bind.apply(fn, [ null ].concat(dependencies));

return new Constructor();
}

/**
* Invoke the given function, injecting dependencies. Return the result.
*
* @template T
*
* @param { Function | [...string[], Function ]} func
* @param { Object } [context]
* @param { Object } [locals]
*
* @return {T} invocation result
*/
function invoke(func, context, locals) {
const {
fn,
Expand Down

0 comments on commit ee76791

Please sign in to comment.