Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryanve/cmon
CommonJS and ender-inspired require/provide with events
https://github.com/ryanve/cmon
Last synced: about 1 month ago
JSON representation
CommonJS and ender-inspired require/provide with events
- Host: GitHub
- URL: https://github.com/ryanve/cmon
- Owner: ryanve
- Created: 2013-05-08T07:17:24.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-11-09T06:49:37.000Z (about 11 years ago)
- Last Synced: 2024-09-14T23:21:00.126Z (2 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/cmon
- Size: 314 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# [cmon](../../)
#### [CommonJS](http://en.wikipedia.org/wiki/CommonJS) and [ender](https://github.com/ender-js/ender-js)-inspired require/provide with events
```sh
$ npm install cmon
```## API ([0.6](../../releases))
### cmon()
- `cmon(id)` Delegate to `cmon.require(id)`.
- `cmon(id, value)` Delegate to `cmon.provide(id, value)`.
- `cmon(id, value, guard)` Delegate to `cmon.require(id)`.
- `cmon(fn)` Call `fn` in the root scope and receive `(cmon)`.### .require / .provide
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 via `cmon.provide`.
- `cmon.require(deps, fn)` Async (fn applies with deps when available).
- `cmon.provide(id, value)` Provide a module.
- `cmon.provide.on(id, fn)` Attach a handler to run anytime id is provided.
- `cmon.provide.one(id, fn)` Attach a 1-time handler to run the next time id is provided.
- `cmon.provide.off(id, fn)` Remove a handler.
- `cmon.provide.off(id)` Remove all id handlers.
- `cmon.provide.emit(id)` Manually trigger active `id` handlers.
- `cmon.able(id, fn?, timeout?)` Attach a 1-time handler runs when `id` is available—async.### .claim / .unclaim
- `cmon.claim(id, value, target?)` Expose a module to the root or to target.
- `cmon.unclaim(id, value, target?)` Safely unexpose a module that was exposed via claim.### .noConflict
- `cmon.noConflict()` Unclaim `require`/`provide`
- `cmon.noConflict(true)` Unclaim `require`/`provide`/`cmon`
- `cmon.noConflict(callback)` Unclaim `require`/`provide`/`cmon`## Developers
Contribute by making edits in [`/src`](./src) or reporting [issues](../../issues).
```sh
$ npm install
$ grunt jshint:src
```## Fund
Fund development with [tips to @ryanve](https://www.gittip.com/ryanve/) =)
## License: [MIT](http://opensource.org/licenses/MIT)
Copyright (C) 2013 by [Ryan Van Etten](https://github.com/ryanve)