https://github.com/featurist/invertism
A dependency inversion utility for JavaScript
https://github.com/featurist/invertism
Last synced: 16 days ago
JSON representation
A dependency inversion utility for JavaScript
- Host: GitHub
- URL: https://github.com/featurist/invertism
- Owner: featurist
- Created: 2013-07-05T09:16:19.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-07-05T23:08:46.000Z (over 12 years ago)
- Last Synced: 2025-01-20T11:21:44.750Z (12 months ago)
- Language: PogoScript
- Size: 105 KB
- Stars: 2
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Invertism
A dependency inversion utility for JavaScript.
Use invertism to inject arguments into constructors and other functions, from 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]'