CommonJS and ender-inspired require/provide with events
$ npm install cmon
cmon(id)- delegates tocmon.require(id)cmon(id, value)- delegates tocmon.provide(id, value)cmon(id, value, guard)- delegates tocmon.require(id)cmon(callback)- runs in the root scope and receives(cmon)
At runtime in a browser cmon claims the global require/provide if unclaimed. Otherwise access them as methods:
cmon.require(id)- get a module that was provided viacmon.providecmon.provide(id, value)- provide a modulecmon.provide.on(id, handler)- attach a handler to run anytimeidis providedcmon.provide.one(id, handler)- attach a 1-time handler to run the next timeidis providedcmon.provide.able(id, handler)- attach a 1-time handler to run whenidis available—now or later.cmon.provide.off(id, handler)- remove a handlercmon.provide.off(id)- remove allidhandlerscmon.provide.trigger(id)- manually trigger activeidhandlers
cmon.claim(id, value, opt_scope)- expose a module to the root oropt_scopecmon.unclaim(id, value, opt_scope)- safely unexpose a module that was exposed via claim
cmon.noConflict()- unclaimrequire/providecmon.noConflict(true)- unclaimrequire/provide/cmoncmon.noConflict(callback)- unclaimrequire/provide/cmon
cmon is available under the MIT license
Copyright (C) 2013 by Ryan Van Etten