Skip to content

Instantly share code, notes, and snippets.

View qetr1ck-op's full-sized avatar
💫

Orest Prystayko qetr1ck-op

💫
View GitHub Profile
@qetr1ck-op
qetr1ck-op / custom-promise.js
Last active July 16, 2018 20:08 — forked from ronkot/rastas-promise.js
Simple Promise implementation
const PENDING = 1;
const RESOLVED = 2;
const REJECTED = 3;
const callLater = fn => setTimeout(fn, 0);
class MyPromise {
constructor(fn) {
this._state = PENDING;
this._value = undefined;
@qetr1ck-op
qetr1ck-op / better-nodejs-require-paths.md
Created May 14, 2017 19:16 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@qetr1ck-op
qetr1ck-op / 1-sleep-es7.js
Created April 3, 2016 09:19 — forked from danharper/1-sleep-es7.js
ES7's async/await syntax.
// ES7, async/await
function sleep(ms = 0) {
return new Promise(r => setTimeout(r, ms));
}
(async () => {
console.log('a');
await sleep(1000);
console.log('b');
})()
@qetr1ck-op
qetr1ck-op / berlin-jsconf-2014.md
Created October 3, 2015 10:35 — forked from nikcorg/berlin-jsconf-2014.md
Slide decks of JSConf 2014