invertism

0.0.1 • Public • Published

Invertism

A dependency inversion utility for JavaScript.

Use invertism for partial appliction of constructors and other functions, where arguments are injected from on a set of named services.

Install

npm install invertism

Usage

invertism = require 'invertism'

services = {
    time () = '12:34'
    display (text) = "[#(text)]"
}

Clock (time, display) =
    this.time = time
    this.display = display

Clock.prototype.read () =
    this.display(this.time())
  
Bound Clock = invertism.bind(Clock, services)

clock = @new Bound Clock () // no arguments!
clock.read()                // '[12:34]'

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.1
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.1
    0

Package Sidebar

Install

npm i invertism

Weekly Downloads

0

Version

0.0.1

License

BSD

Last publish

Collaborators

  • joshski