https://github.com/caiogondim/obstructed.js
:busstop: Checks if the main thread is busy, executing a callback whenever it happens
https://github.com/caiogondim/obstructed.js
Last synced: 2 months ago
JSON representation
:busstop: Checks if the main thread is busy, executing a callback whenever it happens
- Host: GitHub
- URL: https://github.com/caiogondim/obstructed.js
- Owner: caiogondim
- Created: 2016-06-16T16:44:24.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-04-03T15:54:27.000Z (about 7 years ago)
- Last Synced: 2025-03-29T08:03:18.924Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 134 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# obstructed
[](https://badge.fury.io/js/obstructed) [](https://codecov.io/gh/caiogondim/obstructed.js)obstructed.js checks if the main thread is busy, executing a callback whenever
it happens. It runs on the browser and on the server. The API is compatible with
[blocked](https://github.com/tj/node-blocked).## Installation
```shell
npm install --save obstructed
```## Usage
```js
const timer = obstructed(function(ms) {
console.log('Main thread was blocked for about ' + ms + 'ms')
})
```Use the returned timer and `clearInterval` on it to stop the lib on checking if
the main thread is blocked.```js
// Uses the previously defined `timer`
clearInterval(timer)
```## Credits
- Icon by Edward Boatman
- [blocked](https://github.com/tj/node-blocked)---
[caiogondim.com](https://caiogondim.com) ·
GitHub [@caiogondim](https://github.com/caiogondim) ·
Twitter [@caio_gondim](https://twitter.com/caio_gondim)