Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

briskit

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

briskit

High-priority asynchronous task queue

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

briskit

a high-priority asynchronous task queue.

(adapted from kriskowal/asap)

usage

assuming we have access to a high-priority async method (like MutationObserver, MessageChannel, or setImmediate):

setTimeout(function() {
  console.log('this will print third');
});
briskit(function() {
  console.log('this will print second');
});
(function() {
  console.log('this will print first');
}());

briskit will use setTimeout as the async provider if nothing better is available.

instances

multiple briskit instances can be created with the fork method. each instance will independently execute its own stack.

var $briskit = briskit.fork();

execution

execution of a briskit instance's stack can be stopped and started with the defer and flush methods, respectively.

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:

briskit.use( 'name' );
NameNative Method
nextTicsetImmediate
observerMutationObserver
workerMessageChannel
timeoutsetTimeout

use will also accept a function that returns a custom provider. a custom, synchronous provider might look something like:

briskit.use(function() {
  return function( cb ) {
    cb();
  };
});

stack

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

ParameterTypeDefaultDescription
autoflushbooleanfalseWhen true, the stack will attempt to flush as soon as a callback is enqueued.
providerfunctionfunction( cb ){ cb() }The function used for flush calls. Synchronous by default.
preallocnumber1024The preallocated stack size.
// 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();

Keywords

FAQs

Package last updated on 22 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc