Socket
Socket
Sign inDemoInstall

when-conditional

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

when-conditional - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

2

package.json
{
"name": "when-conditional",
"version": "1.0.4",
"version": "1.1.0",
"description": "A simple little asyncronous if check and conditional method",

@@ -5,0 +5,0 @@ "main": "when.js",

# When-conditional
-----------------------
A utility library for asyncronous conditional checking, and then code running.
A utility library for asyncronous conditional checking, and then running a callback when the condition is true.

@@ -10,7 +10,20 @@ To get started, type the following:

## Syntax
------------------------
```when(logicStatement, callback)```
#### Parameters
###### logicStatement
A function which should `return` a `truthy` statement. The return is equivalent to what you would put in an `if` statement.
###### callback
A function which is called when the logicStatement function returns a truthy value.
## Example
------------------------
The example code shown below will print out someVar is false a number of times until it becomes true, then will tell you its true and exit.
```javascript
var when = require('when-conditional');

@@ -57,3 +70,5 @@ var someVar = false;

The when-method module is expected to be more efficient than an interval.
## See you when-ever!
Copyright Glen Keane - 2015 - MIT Licence

@@ -0,4 +1,9 @@

// the require('setImmediate') adds a setImmediate polyfill to the global
// scope. (this is for backwards and browser compatibility)
require('setImmediate');
function when(condition, code){
if(condition()){
return code();
setImmediate(code);
return;
} else {

@@ -8,2 +13,3 @@ setImmediate(function(){

});
return;
}

@@ -10,0 +16,0 @@ };

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc