Skip to content

cronvel/appbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

appBox

It lets you store all your modules into one global. It supports lazy-loading or full-loading.

  • License: MIT
  • Current status: alpha / unstable
  • Platform: Node.js only

Full BDD spec generated by Mocha:

[appBox] Loading module: /home/cedric/inside/github/appbox/test/core/hello.js [appBox] Loading module: /home/cedric/inside/github/appbox/test/core/bonjour.js [appBox] Loading module: /home/cedric/inside/github/appbox/test/circular/one.js [appBox] Loading module: /home/cedric/inside/github/appbox/test/circular/two.js [appBox] Lazy-loading module: /home/cedric/inside/github/appbox/test/core/hello.js [appBox] Lazy-loading module: /home/cedric/inside/github/appbox/test/core/bonjour.js [appBox] Lazy-loading module: /home/cedric/inside/github/appbox/test/circular/one.js [appBox] Lazy-loading module: /home/cedric/inside/github/appbox/test/circular/two.js

TOC

Loading all module from the map file

with full-loading.

delete global.APP ;
appBox.loadMap( 'APP' , './map1.json' , { verbose: true , lazy: false } ) ;

// Ensure the module is already loaded
var descriptor = Object.getOwnPropertyDescriptor( APP.core , 'hello' ) ;
expect( descriptor.value ).to.be.an( Object ) ;
expect( descriptor.get ).to.be( undefined ) ;

expect( APP.core.hello.hello() ).to.be( 'Hello!' ) ;
expect( APP.core.hello.world() ).to.be( 'World!' ) ;
expect( APP.core.hello.helloWorld() ).to.be( 'Hello world!' ) ;
expect( APP.core.bonjour() ).to.be( 'Bonjour !' ) ;
expect( APP.circular.one() ).to.be( 'onetwo' ) ;

with lazy-loading.

delete global.APP ;
appBox.loadMap( 'APP' , './map1.json' , { verbose: true , lazy: true } ) ;

// Ensure the module is *NOT* loaded
var descriptor = Object.getOwnPropertyDescriptor( APP.core , 'hello' ) ;
expect( descriptor.value ).to.be( undefined ) ;
expect( descriptor.get ).to.be.an( Function ) ;

expect( APP.core.hello.hello() ).to.be( 'Hello!' ) ;
expect( APP.core.hello.world() ).to.be( 'World!' ) ;
expect( APP.core.hello.helloWorld() ).to.be( 'Hello world!' ) ;
expect( APP.core.bonjour() ).to.be( 'Bonjour !' ) ;
expect( APP.core.bonjour() ).to.be( 'Bonjour !' ) ;
expect( APP.circular.one() ).to.be( 'onetwo' ) ;
expect( APP.circular.one() ).to.be( 'onetwo' ) ;
expect( APP.circular.two() ).to.be( 'twoone' ) ;

// Ensure the module is now loaded
descriptor = Object.getOwnPropertyDescriptor( APP.core , 'hello' ) ;
expect( descriptor.value ).to.be.an( Object ) ;
expect( descriptor.get ).to.be( undefined ) ;

About

It lets you store all your modules into one global. It supports lazy-loading or full-loading.

Resources

License

Stars

Watchers

Forks

Packages

No packages published