Skip to content

Instantly share code, notes, and snippets.

@bluejava
bluejava / Promise.eval
Created November 2, 2016 02:31
Adds the "eval" function to Promise (see http://www.bluejava.com/4PQ for details)
Promise.eval = function(ar)
{
// We accept either an array or items specified as individual arguments...
// ...but we convert the series into an array either way
if(!Array.isArray(ar))
ar = Array.prototype.slice.call(arguments)
var items = { } // map names to items
// This forEach is where it all happens - we evaluate each item within the eval array.
@bluejava
bluejava / PromiseTest.js
Created April 7, 2016 18:54
Runs some simple performance tests on Node for Native Promises, Zousan and Bluebird. (See Issue 5 : https://github.com/bluejava/zousan/issues/5)
var batchSize = 1000,
doBluebirdAll = true,
doZousanAll = true,
doNativeAll = true,
doBluebirdSeries = true,
doZousanSeries = true,
doNativeSeries = true
console.log(" - Batch Size: " + batchSize)
@bluejava
bluejava / setVisiTimeout.js
Last active March 22, 2016 22:41
A setTimeout replacement that pauses when browser window is not "visible"
/**
* This function uses the Page Visibility API to puase/restart the timeout such that
* the time you specify equates to "visibility time".
* Note: There is no clearTimeout capability - though it would not be hard to extend this to
* provide cancel-ability
*
* Usage:
* setVisiTimeout(function, ms, arg1, arg2, ... );
*
* LICENSE: Unlicense <http://unlicense.org/> / CC0