This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// if you convert to everything returning asynquence sequences | |
ASQ( get("/api/google/sheets/resources") ) | |
.val( JSON.parse ) | |
.seq( handlebar.bind(null,"#template", "#output") ) | |
.seq( pourover ) | |
.seq( linkify ) | |
.or(function(err) { | |
console.error(err); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//COMPILER: Scope, can you register an `Animal` and a `dog`? | |
//SCOPE: Sure. | |
var Animal, dog; | |
//ENGINE: Scope, do you have `Animal` available? | |
//SCOPE: Sure, here it is. | |
//ENGINE: I'm assigning a reference to the anonymous function to `Animal` | |
//COMPILER: I see a function expression with a parameter called `inLove` | |
//COMPILER: Scope, can you register `inLove` inside this function scope? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In asynquence-contrib | |
var emptyItems = [], | |
sq = ASQ(); | |
sq.map(emptyItems, function(item, done){ | |
// do some things to item | |
item.values = []; | |
done(item); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function segmentArray(arr,segmentSize) { | |
segmentSize = Math.max(1,Math.min(+segmentSize||0,arr.length)); | |
return Array.apply(null,{length:Math.ceil(arr.length / segmentSize)}).map(function(_,i){ | |
return arr.slice(i*segmentSize,(i+1)*segmentSize); | |
}); | |
} | |
// lift `serviceCall(..)` | |
function promiseServiceCall(v) { | |
return new Promise(function(resolve,reject){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
class Person { | |
constructor({ | |
firstName: this.firstName = '<FIRSTNAME_UNKNOWN>', | |
lastName: this.lastName = '<LASTNAME_UNKNOWN>' | |
} = {}) {} | |
printName() { | |
console.log(this.lastName, ',', this.firstName); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Doesn't throw an error, but doesn't return an object | |
const getObj = () => { a: 1 }; | |
console.log(getObj()); //=> val 'undefined' : void | |
// Reason: It looks like an arrow function returning an object, but it isn't. | |
// It's an arrow function with a function body (containing a labeled | |
// statement) that returns nothing. | |
const getObj = () => | |
{ // <- Start function body | |
a: // <- A label to use when break/continue; e.g. break a; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// FORKED FROM: https://gist.github.com/cowboyd/74c0fd9e7aa3cccaeda0b84604c0136a | |
// | |
// using CAF instead of Effection. | |
/** | |
* Implements an operation to fetch the data as described in https://twitter.com/BenLesh/status/1455597411385098242 | |
* The "winner" is unambiguous. It is the request corresponding to the latest click, guaranteed. | |
* Other important things to note: | |
* | |
* 1. The HTTP request is cancelled every time along with its containing task |
OlderNewer