# blocked

> check if the event loop is blocked

Latest version **1.3.0** (published 2019-10-25) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2019-10-25 |
| First published | 2014-06-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/blocked) |
| Module format | CommonJS |
| Node | >= 0.9.1 |
| Dependencies | 0 |
| Unpacked size | 3.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 733 |
| Maintainers | ensonik, juliangruber, tjholowaychuk |
| Keywords | block, event, loop, performance |

## Links

- npm: https://www.npmjs.com/package/blocked
- Repository: https://github.com/visionmedia/node-blocked
- Homepage: https://github.com/visionmedia/node-blocked#readme
- Issues: https://github.com/visionmedia/node-blocked/issues
- npm.io page: https://npm.io/package/blocked

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.3.0 (latest) — 2019-10-25
- 1.2.1 — 2016-02-15
- 1.2.0 — 2016-02-11
- 1.1.0 — 2015-01-12
- 1.0.0 — 2014-06-10
- 0.0.1 — 2014-06-01

## README

# blocked

  Check if a node event loop is blocked.
  
  If You're running Node.js 8+ you can get a stacktrace pointing to the blocking function using very similar [blocked-at](https://github.com/naugtur/blocked-at) package.

## Installation

```
$ npm install blocked
```

## Description

  The `blocked()` function reports every value over the configured threshold (defaulted to 10ms).  You can then do whatever
  you want with that value, graph it, log it, alert, etc.

  The process won't be kept open through this.

## Params and return value

```js
var timer = blocked(fn, options);
```

* fn: The callback function to execute when the event loop is blocked. Will send in the amount of time in ms that the event loop was blocked.
* options: _Optional._ Options object to configure the behaviour.
  * `threshold` determines the amount of ms used to determine if the function callback should be executed; useful to speed up tests.
  * `interval` determines the frequency with which the event loop is checked in ms.


```js
blocked(function(ms) {
    console.log("Blocked");
}, {threshold:1, interval: 1000});
```
  
Returns: A reference to the timer. Useful for clearing the timer. 

```js
var timer = blocked(function(ms) {
                console.log("Blocked");
            });
clearInterval(timer);
```


# License

MIT

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