# domainit

> Wrap a function within the confines of a domain using the simple callback form you know and love.

Latest version **0.1.1** (published 2013-04-17) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2013-04-17 |
| First published | 2013-04-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.7 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mario Pareja |
| Maintainers | mpareja |
| Keywords | domains, exceptions, handling, error, callback |

## Links

- npm: https://www.npmjs.com/package/domainit
- Repository: https://github.com/mpareja/node-domainit
- npm.io page: https://npm.io/package/domainit

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 0.1.1 (latest) — 2013-04-17
- 0.1.0 — 2013-04-08
- 0.0.1 — 2013-04-03
- 0.0.0 — 2013-04-03

## README

# domainit - wrap a function with the safety of a domain

Wrap a function with the warm comfort of a node domain using standard callbacks.

[![Build Status](https://travis-ci.org/mpareja/node-domainit.png)](https://travis-ci.org/mpareja/node-domainit) [![Dependency Status](https://david-dm.org/mpareja/node-domainit/status.png)](https://david-dm.org/mpareja/node-domainit)

```javascript
var assert = require('assert');
var domainit = require('domainit');

function unsafe(cb) {
  process.nextTick(function () {
    throw new Error('Oops!');
  });
}

var safe = domainit(unsafe);
safe(function (err) {
  assert(err);
  assert(err.message === 'Oops!');
});
```

## warning for node < v0.9.5

Versions of Node before v0.9.5 raise `uncaughtException` events despite errors being handled within a domain. You shouldn't need to handle `uncaughtException` if you are working with domains.

Some testing frameworks, like `mocha`, bind to the `uncaughtException` event. This will wrongly cause tests to fail when errors occur within a domain on Node versions < 0.9.5.

Check out the relevant [issue on GitHub](https://github.com/joyent/node/issues/4375).

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