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

but-wait

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

but-wait - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

27

index.js
var _stackOfMore = [];
var _noMore = false;
/**
* add function
* add a Promise or function that returns a Promise
*
* @param {function} more called without any parameters, expected to return Promise
* @param {function/Promise} more if function called without any parameters, expected to return Promise
*/
var thereIsMore = function(more) {
if (_noMore) throw new Error("but-wait: you must not add more after noMore was called");
if (!(more instanceof Function))
throw new Error("but-wait: 'thereIsMore' must be called with a function that return a Promise");
stackOfMore.push(more);
let toPush = more;
if (more instanceof Function) toPush = more();
if (!(toPush instanceof Promise))
throw new Error("but-wait: expected Promise as return, got " + prom.constructor.name);
_stackOfMore.push(more);
};
/**
* call when no more should be added
*
* @returns {Promise} Promise that is resolved when all asynchronous initializations finished
*/
var noMore = function() {
_noMore = true;
return Promise.all([
stackOfMore.map(function(more) {
var prom = more();
if (prom instanceof Promise) return prom;
else throw new Error("but-wait: expected Promise as return, got " + prom.constructor.name);
})
]);
return Promise.all(_stackOfMore);
};

@@ -25,0 +28,0 @@

{
"name": "but-wait",
"version": "0.1.1",
"description": "",
"version": "0.2.0",
"description": "but wait, there is more! run parallel tasks synchronously after initializing but before starting your application",
"main": "index.js",

@@ -6,0 +6,0 @@ "scripts": {

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