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
const PENDING_STATE = Symbol.for('MyPromise.PENDING'); | |
const foldPromiseImmedietely = (promise, { RESOLVED, PENDING, REJECTED }) => | |
Promise.race([ promise, Promise.resolve(PENDING_STATE) ]) | |
.then(x => x === PENDING_STATE ? PENDING() : RESOLVED(x)) | |
.catch(REJECTED); | |
const message = await foldPromiseImmedietely(teraPromise, { | |
RESOLVED: value => `Got ma ${value}`, | |
PENDING: () => 'Waitin for ma 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
const promiseState = status => ({ status }); | |
const PROMISE_STATE = { | |
PENDING: promiseState('PENDING'), | |
RESOLVED: promiseState('RESOLVED'), | |
REJECTED: promiseState('REJECTED'), | |
}; | |
const getPromiseStatus = promise => |
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
const path = require('path'); | |
const SOURCE = 'src'; | |
const SOURCE_PATH = path.resolve(SOURCE) + '/'; | |
const removeSourceDirName = path => | |
path.replace(new RegExp(`^${SOURCE}\/?`, 'gi'), ''); | |
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
_______ | |
/ \ | |
/ * \ | |
| ) \__________________ | |
|V| / /_ \ | |
| | / / |/| | | |
\ \__/ / \ / \_ | |
\____/ | |_____________| __/ | |
| | | | |
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
(() => { | |
const chuckFace = 'http://wallsdesk.com/wp-content/uploads/2016/11/Chuck-Norris-HD.jpg'; | |
const $body = document.body; | |
const $div = document.createElement('div'); | |
$body.innerHTML = ''; | |
$body.appendChild($div); | |
Object.assign($div.style, { width: '100%',fontSize: '1.5em', padding:'.5em', color: '#fff', textShadow: '1px 1px 1px #000', textAlign: 'center', backgroundColor: 'rgba(0,0,0,.4)' }); |