Skip to content

Instantly share code, notes, and snippets.

@bjouhier
bjouhier / rimraf.js
Created August 8, 2011 06:34 — forked from laverdet/rimraf.js
rimraf with futures
/*** Generated by streamline 0.1.35 - DO NOT EDIT ***/
var __global = typeof global !== 'undefined' ? global : window;
function __cb(_, fn){ var ctx = __global.__context; return function(err, result){ __global.__context = ctx; if (err) return _(err); try { return fn(null, result); } catch (ex) { return __propagate(_, ex); } } }
function __future(fn, args, i){ var done, err, result; var cb = function(e, r){ done = true; err = e, result = r; }; args = Array.prototype.slice.call(args); args[i] = function(e, r){ cb(e, r); }; fn.apply(this, args); return function(_){ if (done) _.call(this, err, result); else cb = _.bind(this); } .bind(this); }
function __nt(_, fn){ var i = 0; var cb = __cb(_, fn); var safeCb = function(){ try { cb(); } catch (ex) { __propagate(cb, ex); } }; if (typeof process != "undefined" && typeof process.nextTick == "function") return function(){ if (++i % 20 == 0) process.nextTick(safeCb); else cb(); }; else return function(){ if (++i % 20 == 0) setTimeout(safeCb); else cb(); }; }
function _
@bjouhier
bjouhier / fibers.js
Last active December 30, 2015 08:29 — forked from glennblock/fibers.js
//fibers
function markComplete(postedItems, completionCallback) {
var errors = [];
var getItemToUpdate = function(item) {
var fiber = Fiber.current;
process.nextTick(function() {
client.queryEntity('tasks', 'partition1', item, function(err, task) {
fiber.run(task);
});