Advanced condition library for Node, Phantom, RequireJS, CommonJS and the Browser.
npm install condition
Getting an instance of
condition can be different depending on the kind of environment you're in.
condition supports many different environments and module systems - just try yours, chances are, it'll work. If not, file an issue and I'll work on it.
// Get an instance of conditionvar condition = ;// Wait for a condition to call a functioncondition;// Every time a condition is true, call a functioncondition;// Call a function until a condition becomes truecondition;
Sometimes your condition functions will be asynchronous,
condition supports that too. Simply ask for at least one argument in your condition function, and
condition will assume that it is an asynchronous condition. Call the first argument that the condition function is passed, with your "result", when you're done.
Here's an example: