Skip to content

Instantly share code, notes, and snippets.

View keyvan-m-sadeghi's full-sized avatar
🏠
Working from home

Keyvan M. Sadeghi keyvan-m-sadeghi

🏠
Working from home
View GitHub Profile
// Ignore
let p = Nancy.reject(42)
.then(() => console.log('why')) // ignored
.then(() => console.log('you')) // ignored
.then(() => console.log('ignoring me?!')); // ignored!
// p is a Nancy
// p.state is states.rejected
// p.value is 42
const carry = output => input => {
class Nancy {
...
static resolve(value) {
return new Nancy(resolve => resolve(value));
}
static reject(value) {
return new Nancy((_, reject) => reject(value));
}
}
const getCallback = state => value => {
this.value = value;
this.state = state;
};
const resolve = getCallback(states.resolved);
const reject = getCallback(states.rejected);
class Nancy {
constructor(executor) {
const resolve = () => {
this.state = states.resolved;
};
const reject = () => {
this.state = states.rejected;
};
const states = {
pending: 'Pending',
resolved: 'Resolved',
rejected: 'Rejected'
};