# domain-capture

> decorates a function in a domain

Latest version **0.0.1** (published 2013-12-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install domain-capture
pnpm add domain-capture
yarn add domain-capture
bun add domain-capture
```

## 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.0.1 |
| Published | 2013-12-01 |
| First published | 2013-12-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | stagas |
| Maintainers | stagas |
| Keywords | domain, error |

## Links

- npm: https://www.npmjs.com/package/domain-capture
- npm.io page: https://npm.io/package/domain-capture

## Dependencies (2)

- [once](https://npm.io/package/once.md) ~1.3.0
- [slice-arguments](https://npm.io/package/slice-arguments.md) ~0.0.1

## 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.0.1 (latest) — 2013-12-01

## README

# domain-capture

decorates a function in a domain

## Installing

`npm install domain-capture`

## Example

```js
var emitter = new (require('events').EventEmitter);
var capture = require('domain-capture');

function error(s, fn){
  setTimeout(function(){
    console.log('never shown');
  }, 100);

  // trigger a domain error, which will call fn(err)
  emitter.emit('error', new Error(s));

  console.log('never shown');

  fn(); // not called
}

// decorate `error` function
var fn = capture(error);

// invoke function where the error occurs
fn('oh', function(err){
  console.log(err.message); // => oh
});
```

## API

### capture(fn)

Decorates an async `fn` inside a domain
context, disposes the domain and callbacks
the error if any.

## License

MIT

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