Skip to content

Daeren/Lightject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codacy NodeSecurity

npm install lightject

require("lightject")

let ctx = {
        "payload": "!"
    };

let binds = {
        "myBind": "?"
    };

let data = {
        "myBind": "Replace!",

        "input":  "Simple start",
        "output": console.log
    };

let print;

//-------------]>

$injector
    .value("x", 0)
    .service("y", function(x) { this.v = 1 + x; })
    .factory("z", function(x, y) { return {"v": 3 + x + y.v}; });
    
print = $injector(fLog, binds);
print(data, ctx);

$injector.run(fLog, data, ctx);
$injector.run(["x", "y", (d1, d2) => d1 + d2.v]);

//-------------]>

function fLog(input, output, myBind) {
    output(input + this.payload + myBind);
}
  • Coverage: +
  • Benchmark: +
  • Browser: +
  • valueOf/toString: +

Module

Method Arguments Return
-
createInstance this
-
onCaller callback(name, data, ctx, func) this or exception
-
value name, value this
service name, func this
factory name, func this
-
table table[, binds] table or null
-
run f, data[, ctx] result of a function or null
runTable table, data[, ctx] table or null
execTable table, data[, ctx] overwritten table or null

System variables

Name Desc
$in

License

MIT


@ Daeren Torn

About

[JS] Lightweight module for Dependency Injection

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published