Skip to content

Instantly share code, notes, and snippets.

View caolan's full-sized avatar

Caolan McMahon caolan

View GitHub Profile
@caolan
caolan / example.js
Created October 17, 2018 15:27
async.eachLimit equivalent for Promises (via Highland)
var Highland = require('highland');
function addOne(x) {
return new Promise((resolve, reject) => resolve(x + 1));
}
var limit = 10;
Highland([1,2,3,4,5])
.map((x) => Highland(addOne(x)))
@caolan
caolan / gist:882892
Created March 23, 2011 10:05
List all files below a given path, recursing through subdirectories using node.js and the Async module
/**
* List all files below a given path, recursing through subdirectories.
*
* @param {String} p
* @param {Function} callback
* @api public
*/
exports.descendants = function (p, callback) {
fs.stat(p, function (err, stats) {
@caolan
caolan / gist:569883
Created September 8, 2010 09:27 — forked from siculars/gist:569874
8 Sep 05:08:38 - getfiltertags. submitted tags: one,two,test fail tag , 3
8 Sep 05:08:38 - checking : one
8 Sep 05:08:38 - getfiltertags. vetted tags: , length : 1
From 42cb3106c2b616d0357f3f89537ff751b3dbd570 Mon Sep 17 00:00:00 2001
From: Caolan McMahon <caolan@caolanmcmahon.com>
Date: Wed, 16 Jun 2010 19:08:39 +0100
Subject: [PATCH] Update path.exists to return relevant errors from fs.stat
The callback for path.exists now accepts two arguments, an error and
a boolean value which performs the same as before. The error is only
passed from fs.stat if it is something other than 'not found'.
This brings the callback in-line with the convention of returning an