Skip to content

Latest commit

 

History

History
62 lines (44 loc) · 1.05 KB

README.md

File metadata and controls

62 lines (44 loc) · 1.05 KB

yojs

Javascript library for declaring and calling functions and variables using namespaces.

Usage

Function definition:

yojs.define("yojs_test", function() {
  //your code goes here
});

yojs.define("yojs_test.comments.new", function() {
  //your code goes here
});

Function call:

yojs.call("yojs_test");

yojs.call("yojs_test.comments.new");

Store objects and values:

yojs.set("yojs_test.my_value", 42);
yojs.set("yojs_test.ns2.n3.my_json", { foo: "bar"} );

Retrieve stored object and values:

var value = yojs.get("yojs_test.my_value");
var json = yojs.get("yojs_test.ns2.n3.my_json");

Check if something is defined:

yojs.isDefined("yojs_test.ns1.ns2.var");
yojs.isDefined("yojs_test.ns1.ns2.function");

Namespace lookup:

yojs.define("my.deep.namespace.teste", function() {
  yojs.call("itworks");
});

yojs.define("my.deep.namespace.itworks", function() {
  console.log("yay");
});

yojs.call("my.deep.namespace.teste") // -> yay