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

node-powertools

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-powertools - npm Package Compare versions

Comparing version 0.0.21 to 0.0.22

52

dist/index.js

@@ -107,2 +107,6 @@ (function (root, factory) {

});
}
Powertools.queue = function (fn) {
return new FunctionQueue(fn);
}

@@ -296,1 +300,49 @@

}));
// FunctionQueue.js
function FunctionQueue() {
var self = this;
self.queue = [];
self.running = false;
}
FunctionQueue.prototype.enqueue = function (fn) {
var self = this;
return new Promise(function (resolve, reject) {
self.queue.push({
function: fn,
resolve: resolve,
reject: reject
});
self.process();
});
}
FunctionQueue.prototype.process = function () {
var self = this;
return new Promise(function (resolve, reject) {
if (self.running || !self.queue.length) {
return resolve();
}
self.running = true;
var current = self.queue.shift();
current
.function()
.then(function(result) {
current.resolve(result);
})
.catch(function(err) {
current.reject(err);
})
.finally(function() {
self.running = false;
self.process();
});
});
}

10

package.json
{
"name": "node-powertools",
"version": "0.0.21",
"version": "0.0.22",
"description": "Powerful assistive functions for Node and Browser environments.",

@@ -8,3 +8,3 @@ "main": "dist/index.js",

"test": "npm run prepare && ./node_modules/mocha/bin/mocha test/ --recursive --timeout=10000",
"prepare": "node -e 'require(`prepare-package`)'"
"prepare": "node -e 'require(`prepare-package`)()'"
},

@@ -31,5 +31,5 @@ "engines": {

"devDependencies": {
"mocha": "^8.0.1",
"prepare-package": "^0.0.13"
"mocha": "^8.4.0",
"prepare-package": "^0.0.16"
}
}
}

@@ -89,3 +89,3 @@ <p align="center">

// Call this function every 100 ms until it returns true or 30000 ms passes
await powertools.poll(function () {
await powertools.poll(function (index) {
return something === somethingElse;

@@ -92,0 +92,0 @@ }, {interval: 100, timeout: 30000});

@@ -107,2 +107,6 @@ (function (root, factory) {

});
}
Powertools.queue = function (fn) {
return new FunctionQueue(fn);
}

@@ -296,1 +300,49 @@

}));
// FunctionQueue.js
function FunctionQueue() {
var self = this;
self.queue = [];
self.running = false;
}
FunctionQueue.prototype.enqueue = function (fn) {
var self = this;
return new Promise(function (resolve, reject) {
self.queue.push({
function: fn,
resolve: resolve,
reject: reject
});
self.process();
});
}
FunctionQueue.prototype.process = function () {
var self = this;
return new Promise(function (resolve, reject) {
if (self.running || !self.queue.length) {
return resolve();
}
self.running = true;
var current = self.queue.shift();
current
.function()
.then(function(result) {
current.resolve(result);
})
.catch(function(err) {
current.reject(err);
})
.finally(function() {
self.running = false;
self.process();
});
});
}

@@ -21,2 +21,16 @@ const package = require('../package.json');

// describe('.queue()', () => {
// describe('queue', () => {
// // Normal
// it('object (one key) => array (one key)', () => {
// return assert.deepEqual(powertools.getKeys({name: 'ian'}), ['name']);
// });
// it('object (one key + nested) => array (one key, nested)', () => {
// return assert.deepEqual(powertools.getKeys({name: 'ian', favorites: {color: 'red'}}), ['name', 'favorites.color']);
// });
// });
// });
describe('.getKeys()', () => {

@@ -23,0 +37,0 @@

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