Socket
Socket
Sign inDemoInstall

immediate

Package Overview
Dependencies
0
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.0 to 3.2.0

44

lib/index.js

@@ -13,12 +13,13 @@ 'use strict';

var queue = [];
var scheduled = false;
function cleanUpNextTick() {
draining = false;
if (currentQueue && currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
nextTick();
}
draining = false;
if (currentQueue && currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
nextTick();
}
}

@@ -28,2 +29,3 @@

function nextTick() {
scheduled = false;
draining = true;

@@ -36,3 +38,3 @@ var len = queue.length;

while (++queueIndex < len) {
currentQueue[queueIndex]();
currentQueue[queueIndex].run();
}

@@ -49,3 +51,3 @@ queueIndex = -1;

var len = types.length;
while (++ i < len) {
while (++i < len) {
if (types[i] && types[i].test && types[i].test()) {

@@ -56,7 +58,23 @@ scheduleDrain = types[i].install(nextTick);

}
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
module.exports = immediate;
function immediate(task) {
if (queue.push(task) === 1 && !draining) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(task, args));
if (!scheduled && !draining) {
scheduled = true;
scheduleDrain();
}
}
}
{
"name": "immediate",
"version": "3.1.0",
"version": "3.2.0",
"description": "A cross browser microtask library",

@@ -5,0 +5,0 @@ "contributors": [

@@ -5,5 +5,23 @@ # immediate [![Build Status](https://travis-ci.org/calvinmetcalf/immediate.svg?branch=master)](https://travis-ci.org/calvinmetcalf/immediate)

```
npm install immediate --save
```
then
```js
var immediate = require("immediate");
immediate(function () {
// this will run soon
});
immediate(function (arg1, arg2) {
// get your args like in iojs
}, thing1, thing2);
```
## Introduction
**immediate.js** is a microtask library, decended from [NobleJS's setImmediate](https://github.com/NobleJS/setImmediate), but including ideas from [Cujo's When](https://github.com/cujojs/when) and [RSVP][RSVP].
**immediate** is a microtask library, decended from [NobleJS's setImmediate](https://github.com/NobleJS/setImmediate), but including ideas from [Cujo's When](https://github.com/cujojs/when) and [RSVP][RSVP].

@@ -14,2 +32,4 @@ immediate takes the tricks from setImmedate and RSVP and combines them with the schedualer inspired (vaugly) by whens.

## The Tricks

@@ -43,15 +63,2 @@

In Node.js, do
```
npm install immediate
```
then
```js
var immediate = require("immediate");
```
## Reference and Reading

@@ -75,2 +82,2 @@

[my-blog-1]:http://calvinmetcalf.com/post/61672207151/setimmediate-etc
[my-blog-2]:http://calvinmetcalf.com/post/61761231881/javascript-schedulers
[my-blog-2]:http://calvinmetcalf.com/post/61761231881/javascript-schedulers
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc