orange funny define
- ns is a plugin without any cmd or amd grammar rules,it is a proxy model
- it is easier to organize variables
- it is easy to use
- for nodejs or browser
- download
nsand import it
require('./ns')or
<scripttype="text/javascript"src="script/ns.js">- use ns("key")
// if it is exist in global or window// it will be throw an error //namespace should not be cover//we want namespace match file-name or plugin-name as much as possiblens('namespace');//use namespacenamespace(...)//define ns whit demons('demo');//use demo//whit basic valuedemo("name","value");demo("name")//--> get "value"//cover name value//if false or not //it will be throw an exist key errordemo("name","name",true);demo("name")//--> get "name"//with function operation//if params is null //it could not be operationdemo("operation",function(a,b,c){returna+b+c;},1,2,3);//it just store after function operationdemo("operation");//--> get "6";cover variables see
1. define basic variables
//define ns with fnns('fn');fn("dosomething",function(param){returnparam;});fn("dosomething")("todo");//-- get "todo"fn("next",function(next){//if params is not null//must return function//here is an closurereturnfunction(param){returnnext+param;}},1);fn("next")(1);//get 2cover variables see
1. define basic variables
ns('obj')obj("map",{key:"value"});obj("map");// -->get {key:"value"}Copyright 2017 @arefn.cn