Socket
Socket
Sign inDemoInstall

can-queues

Package Overview
Dependencies
3
Maintainers
6
Versions
37
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.4 to 1.2.0

doc/methods/lastTask.md

64

can-queues-test.js

@@ -206,4 +206,4 @@ var QUnit = require( 'steal-qunit' );

setFnName(derivedChild_queueUpdate, 'derivedChild_queueUpdate');
map = {

@@ -424,1 +424,63 @@ name: "map",

});
QUnit.test(".lastTask()", function(){
function notify () {
var lastTask = queues.lastTask();
QUnit.equal(lastTask.fn,notify);
}
queues.enqueueByQueue({
"notify": [notify],
});
});
QUnit.test(".stack(lastTask)", function(){
var lastTask;
var outerNotify, innerNotify;
queues.enqueueByQueue({
"notify": [outerNotify = function notify () {
queues.enqueueByQueue({
"notify": [innerNotify = function notify () {
lastTask = queues.lastTask();
}],
"domUI": [function domUI () {
var stack = queues.stack(lastTask);
QUnit.equal(stack[0].fn, outerNotify);
QUnit.equal(stack[1].fn, innerNotify);
}]
});
}]
});
});
QUnit.test(".runAsTask(fn)", function(){
var lastTask;
var outerNotify, innerNotify;
var obj = {};
var thing = function(){
queues.enqueueByQueue({
"notify": [innerNotify = function notify () {
lastTask = queues.lastTask();
}],
"domUI": [function domUI () {
var stack = queues.stack(lastTask);
QUnit.equal(stack[0].fn, outerNotify);
QUnit.equal(stack[1].fn, thing);
QUnit.deepEqual(stack[1].args[0], 1);
QUnit.equal(stack[1].context, obj);
QUnit.equal(stack[2].fn, innerNotify);
}]
});
};
var thingQueued = queues.runAsTask(thing);
queues.enqueueByQueue({
"notify": [outerNotify = function notify () {
thingQueued.call(obj, 1);
}]
});
});

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

},
runAsTask: function(fn, reasonLog){
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
return function(){
queueState.lastTask = {
fn: fn,
context: this,
args: arguments,
meta: {
reasonLog: typeof reasonLog === "function" ? reasonLog.apply(this, arguments): reasonLog,
parentTask: queueState.lastTask,
stack: {name: "RUN_AS"}
}
};
var ret = fn.apply(this, arguments);
queueState.lastTask = queueState.lastTask && queueState.lastTask.meta.parentTask;
return ret;
};
}
//!steal-remove-end
return fn;
},
enqueueByQueue: function enqueueByQueue ( fnByQueue, context, args, makeMeta, reasonLog ) {

@@ -128,6 +150,9 @@ if ( fnByQueue ) {

},
lastTask: function(){
return queueState.lastTask;
},
// Currently an internal method that provides the task stack.
// Returns an array with the first task as the first item.
stack: function () {
var current = queueState.lastTask;
stack: function (task) {
var current = task || queueState.lastTask;
var stack = [];

@@ -142,4 +167,4 @@ while ( current ) {

},
logStack: function () {
var stack = this.stack();
logStack: function (task) {
var stack = this.stack(task);
stack.forEach( function ( task, i ) {

@@ -146,0 +171,0 @@ var meta = task.meta;

2

doc/methods/logStack.md

@@ -7,3 +7,3 @@ @function can-queues.logStack logStack

@signature `queues.logStack( [type] )`
@signature `queues.logStack()`

@@ -10,0 +10,0 @@ `logStack()` is a very useful debugging tool for discovering why a particular piece of code

{
"name": "can-queues",
"version": "1.1.4",
"version": "1.2.0",
"description": "A light weight JavaScript task queue",

@@ -5,0 +5,0 @@ "homepage": "",

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