# briskit

> High-priority asynchronous task queue

Latest version **1.1.1** (published 2015-10-22) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2015-10-22 |
| First published | 2015-02-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Bernard McManus |
| Maintainers | elnarddogg |
| Keywords | event, task, queue, async, asynchronous |

## Links

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

## 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.1.1 (latest) — 2015-10-22
- 1.0.1 — 2015-07-31
- 1.0.0 — 2015-07-23
- 0.2.2 — 2015-07-22
- 0.2.0 — 2015-04-26
- 0.1.4 — 2015-03-08
- 0.1.3 — 2015-03-08
- 0.1.2 — 2015-03-08
- 0.1.1 — 2015-02-05
- 0.1.0 — 2015-02-03

## README

# briskit

> a high-priority asynchronous task queue.

> _<sup>(adapted from [kriskowal/asap](https://github.com/kriskowal/asap))</sup>_

## usage
assuming we have access to a high-priority async method (like `MutationObserver`, `MessageChannel`, or `setImmediate`):
```javascript
setTimeout(function() {
  console.log('this will print third');
});
briskit(function() {
  console.log('this will print second');
});
(function() {
  console.log('this will print first');
}());
```
<sub>`briskit` will use `setTimeout` as the async provider if nothing better is available.</sub>

## instances
multiple `briskit` instances can be created with the `fork` method. each instance will independently execute its own stack.
```javascript
var $briskit = briskit.fork();
```

## execution
execution of a `briskit` instance's stack can be stopped and started with the `defer` and `flush` methods, respectively.
```javascript
var $briskit = briskit.fork();
$briskit.defer();
$briskit(function(){ console.log( "I'm deferred!" ) });
briskit(function(){ console.log( "I'm not!" ) }); // -> I'm not!
$briskit.flush(); // -> I'm deferred!
```

## providers
`briskit` will use the best possible async provider for its environment, but if for whatever reason you would like to override that choice:
```javascript
briskit.use( 'name' );
```
| Name | Native Method |
| ---- | ------------- |
| `nextTic` | `setImmediate` |
| `observer` | `MutationObserver` |
| `worker` | `MessageChannel` |
| `timeout` | `setTimeout` |

`use` will also accept a function that returns a custom provider. a custom, synchronous provider might look something like:
```javascript
briskit.use(function() {
  return function( cb ) {
    cb();
  };
});
```

## stack
the briskit stack can be used as a standalone class. all parameters are optional:

| Parameter | Type | Default | Description |
| --------- | ---- | ------- | ----------- |
| `autoflush` | `boolean` | `false` | When true, the stack will attempt to flush as soon as a callback is enqueued. |
| `provider` | `function` | `function( cb ){ cb() }` | The function used for flush calls. Synchronous by default. |
| `prealloc` | `number` | `1024` | The preallocated stack size. |

```javascript
// commonjs
var stack = briskit.stack( true );

// ES6 (requires compilation)
import Stack from 'briskit/src/stack';
var stack = new Stack( true );

// usage
stack.defer();
stack.enqueue(function() {
  // ...
});
stack.flush();
```

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