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
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) |
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
/** 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.') |
NewerOlder