# cmon

> CommonJS and ender-inspired require/provide with events

Latest version **0.6.0** (published 2013-11-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install cmon
pnpm add cmon
yarn add cmon
bun add cmon
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.0 |
| Published | 2013-11-09 |
| First published | 2013-05-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Ryan Van Etten |
| Maintainers | ryanve |
| Keywords | require, common, commonjs, module, browser, ender, async |

## Links

- npm: https://www.npmjs.com/package/cmon
- Repository: https://github.com/ryanve/cmon
- Issues: https://github.com/ryanve/cmon/issues
- npm.io page: https://npm.io/package/cmon

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.6.0 (latest) — 2013-11-09
- 0.5.3 — 2013-10-06
- 0.5.2 — 2013-09-03
- 0.5.1 — 2013-09-03
- 0.5.0 — 2013-09-03
- 0.4.1 — 2013-08-29
- 0.4.0 — 2013-07-31
- 0.3.1 — 2013-05-16
- 0.2.0 — 2013-05-16
- 0.1.4 — 2013-05-14
- 0.1.2 — 2013-05-14
- 0.1.1 — 2013-05-08
- 0.1.0 — 2013-05-08

## 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 (<var>fn</var> applies with <var>deps</var> when available).
- `cmon.provide(id, value)` Provide a module.
- `cmon.provide.on(id, fn)` Attach a handler to run anytime <var>id</var> is provided.
- `cmon.provide.one(id, fn)` Attach a 1-time handler to run the next time <var>id</var> is provided.
- `cmon.provide.off(id, fn)` Remove a handler.
- `cmon.provide.off(id)` Remove all <var>id</var> 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&mdash;async.

### .claim / .unclaim

- `cmon.claim(id, value, target?)` Expose a module to the <b>root</b> or to <var>target</var>.
- `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

<b>Contribute</b> 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)

---
_Source: https://npm.io/package/cmon · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
