Skip to content

Instantly share code, notes, and snippets.

Brian Cavalier briancavalier

Block or report user

Report or block briancavalier

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View most-logo-2.md
|====\____/====/============\=/===========|================|
|              |    ____    |/      ____//|                |
|              |   |    |   |      //_____|_____|    |_____|                    
|    |\==/|    |   |    |   |______       \\    |    |
|    | \/ |    |    \==/    |    \\/      //    |    |
|____|    |____|____________|___________//      |____|
View ambiguous-race.js
function logWinner (p1, p2) {
Promise.race([p1, p2]).then(console.log.bind(console));
}
var p1 = new Promise(function(resolve) {
setTimeout(function() { resolve('p1'); }, 20);
});
var p2 = new Promise(function(resolve) {
setTimeout(function() { resolve('p2'); }, 10);
View captureDefines-1.js
module.exports = captureDefines;
function captureDefines (amdEval) {
return function (load) {
var result, isAnon, _define;
result = { named: [] };
_define = function captureDefine () {
var args, def;
View curry.js
module.exports = curry;
function curry (f) {
var arity = f.length;
var params = [];
var end = createEnd(f, arity);
return createCurried(params, arity, end);
}
function createEnd (f, arity) {
View when-failure.js
var when1 = require('when1');
var when2 = require('when2');
when1.Promise.onPotentiallyUnhandledRejectionHandled = function(r) {
console.log('when1 Handled', r);
}
var rejectedPromise = when1.reject(new Error('Intentional failure'));
when2(rejectedPromise).done(undefined, function(error){
console.log('Rejection properly handled:', error);
View gist:becf2e7d7d6726730aa8
var deferred = {};
var keys = require('when/keys');
if (data.picture) {
deferred.picture = webservices.image(data['picture']);
}
if (data.screen) {
deferred.screen = webservices.image(data['screen']);
}
View perf.js
//var PerfTime = require('perf-time');
//var _ = require('underscore');
var Perf = module.exports = function() {
this.startTime = null;
// this.t = new PerfTime();
this.t = {
get: function() {
return Date.now();
}
View buildConfig.js
({
baseUrl: './src/',
dir: 'build',
include: ['main'],
logLevel: 0,
mainConfigFile: './src/main.js',
name: 'main',
wrap: false,
optimize: 'none',
preserveLicenseComments: false
View concat-promises.js
var when = require('when');
var fs = require('fs');
var concat = {};
concat.each = function(src, dest, options) {
if (!options) { options = {}; }
if (!options.separator) { options.separator = ''; }
return when.reduce(src, function(output, srcpath) {
var dfd = when.defer();
You can’t perform that action at this time.