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

@wordpress/priority-queue

Package Overview
Dependencies
Maintainers
9
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/priority-queue - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

23

build-module/index.js
var requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame;
/**
* Creates a context-aware queue that only executes
* the last task of a given context.
*
* @example
*```js
* import { createQueue } from '@wordpress/priority-queue';
*
* const queue = createQueue();
*
* // Context objects.
* const ctx1 = {};
* const ctx2 = {};
*
* // For a given context in the queue, only the last callback is executed.
* queue.add( ctx1, () => console.log( 'This will be printed first' ) );
* queue.add( ctx2, () => console.log( 'This won\'t be printed' ) );
* queue.add( ctx2, () => console.log( 'This will be printed second' ) );
*```
*
* @return {Object} Queue object with `add` and `flush` methods.
*/
export var createQueue = function createQueue() {

@@ -3,0 +26,0 @@ var waitingList = [];

@@ -8,2 +8,24 @@ "use strict";

var requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame;
/**
* Creates a context-aware queue that only executes
* the last task of a given context.
*
* @example
*```js
* import { createQueue } from '@wordpress/priority-queue';
*
* const queue = createQueue();
*
* // Context objects.
* const ctx1 = {};
* const ctx2 = {};
*
* // For a given context in the queue, only the last callback is executed.
* queue.add( ctx1, () => console.log( 'This will be printed first' ) );
* queue.add( ctx2, () => console.log( 'This won\'t be printed' ) );
* queue.add( ctx2, () => console.log( 'This will be printed second' ) );
*```
*
* @return {Object} Queue object with `add` and `flush` methods.
*/

@@ -10,0 +32,0 @@ var createQueue = function createQueue() {

2

CHANGELOG.md

@@ -1,3 +0,3 @@

### 1.0.0 (Unreleased)
### 1.0.0 (2019-03-06)
Initial release.
{
"name": "@wordpress/priority-queue",
"version": "1.0.0",
"version": "1.1.0",
"description": "Generic browser priority queue.",

@@ -30,3 +30,3 @@ "author": "The WordPress Contributors",

},
"gitHead": "80d228669adadb8dfcd24b8421517fed3be2d474"
"gitHead": "1e024a20a20369af7bc9720a676fdd3837a3a105"
}

@@ -13,6 +13,17 @@ # Priority Queue

_This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for ES2015+ such as lower versions of IE then using [core-js](https://github.com/zloirock/core-js) or [@babel/polyfill](https://babeljs.io/docs/en/next/babel-polyfill) will add support for these methods. Learn more about it in [Babel docs](https://babeljs.io/docs/en/next/caveats).
_This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for ES2015+ such as lower versions of IE then using [core-js](https://github.com/zloirock/core-js) or [@babel/polyfill](https://babeljs.io/docs/en/next/babel-polyfill) will add support for these methods. Learn more about it in [Babel docs](https://babeljs.io/docs/en/next/caveats)._
## Usage
## API
<!-- START TOKEN(Autogenerated API docs) -->
### createQueue
[src/index.js#L25-L72](src/index.js#L25-L72)
Creates a context-aware queue that only executes
the last task of a given context.
**Usage**
```js

@@ -25,3 +36,3 @@ import { createQueue } from '@wordpress/priority-queue';

const ctx1 = {};
const ctx2 = {};
const ctx2 = {};

@@ -34,2 +45,9 @@ // For a given context in the queue, only the last callback is executed.

**Returns**
`Object`: Queue object with `add` and `flush` methods.
<!-- END TOKEN(Autogenerated API docs) -->
<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
const requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame;
/**
* Creates a context-aware queue that only executes
* the last task of a given context.
*
* @example
*```js
* import { createQueue } from '@wordpress/priority-queue';
*
* const queue = createQueue();
*
* // Context objects.
* const ctx1 = {};
* const ctx2 = {};
*
* // For a given context in the queue, only the last callback is executed.
* queue.add( ctx1, () => console.log( 'This will be printed first' ) );
* queue.add( ctx2, () => console.log( 'This won\'t be printed' ) );
* queue.add( ctx2, () => console.log( 'This will be printed second' ) );
*```
*
* @return {Object} Queue object with `add` and `flush` methods.
*/
export const createQueue = () => {

@@ -4,0 +26,0 @@ const waitingList = [];

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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