hinoki

magical inversion of control for nodejs and the browser

hinoki

magical inversion of control for Node.js and the browser

Hinoki seems to be the least surprising IoC container available for Node.
I definitely do like its ascetic worldview.
Thanks a lot for this!
@andrey

var hinoki = require('hinoki');

hinoki is useful when your problem, application, problem or computation consists of multiple values that depend on each other.

a value can be anything: an integer, an object, a function, a class, ...

for example:
the value of a controller action might depend on
the value of a function to retrieve some data from a database which might depend on the value of a connection pool which might depend on
the value of an url to the database...

a name is - you guessed it - the name of a value.

let's use our knowledge to define the factories for that:

var factories = {
  sumFnfunction() {
    return function(xs) {
      return xs.reduce(function(accx) { return acc + x; }, 0);
    }
  },
  numbersSquaredfunction(numbers) {
    return numbers.map(function(x) { return x * x; });
  },
  numbersSortedfunction(numbers) {
    return numbers.slice().sort();
  }
  countfunction(numbers) {
    return numbers.length;
  },
  medianfunction(numbersSortedcount) {
    return numbersSorted[Math.round(count)];
  },
  meanfunction(numberscountsumFn) {
    return sumFn(numbers) / count;
  },
  meanOfSquaresfunction(numbersSquaredcountsumFn) {
    return sumFn(numbersSquared) / count;
  },
  variancefunction(meanmeanOfSquares) {
    return meanOfSquares - mean * mean;
  }
};
  • ok'ish readme
  • finish documentation
  • test the examples
  • replace resolvers by
    • sources
      • lifetime.factories can be array of sources
        • sources are tried in order
        • a source is either an object of factories
        • or a forge
          • function(name : string) -> factory or undefined
          • used for forge
    • proxies or wrappers or decorators
      • mapFactory(factory, name)
        • used for tracing
      • mapValue(value, name)
    • mappers
      • mapName(string) -> string
        • used for aliasing
  • implement factory arrays
  • implement factory objects
  • better debugging solution
  • port to js
    • use compiled js and go from there
  • performance
    • add benchmark
      • what ?
      • microbenchmark
    • record benchmark results
    • assert optimization status in unit test
    • use lodash
    • make sure that all but the outer function can be optimized
      • make inner functions monomorphic
    • pick low hanging fruits to improve performance
    • ensure that optimizations actually improved performance
  • logo
  • reddit
  • hackernews

license: MIT