Skip to content

Instantly share code, notes, and snippets.

View abstractmachines's full-sized avatar
🤸

Amanda Falke abstractmachines

🤸
View GitHub Profile
@abstractmachines
abstractmachines / promiseunderthehood.js
Created October 26, 2017 22:08
Dave's pwomise. Remember that the catch is not implemented correctly, recall the tree structure of Promise.
class Pwomise {
constructor (fn) {
fn(this._resolve.bind(this), this._reject.bind(this))
this._thens = []
this._catches = []
}
_resolve (value) {
while (this._thens.length > 0) {
this._thens.pop()(value)
@abstractmachines
abstractmachines / transducers.js
Created October 9, 2017 19:08
JS transducers
/** Implementing transformations (like map and filter) with reducers. **/
// https://www.webpackbin.com/bins/-Kvmn0gWkIMmtnFnkcu_
// https://medium.com/@roman01la/understanding-transducers-in-javascript-3500d3bd9624
// take all evens, multiply by 2, log that.
const arr = ['1', '2', '3', '4', '5', '6']
console.log('Chaining map and filter.')