Skip to content

Instantly share code, notes, and snippets.

:octocat:
Working from home

Guilherme Kunigami kunigami

:octocat:
Working from home
Block or report user

Report or block kunigami

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View sample_url.txt
www.gstatic.com/og/_/js/k=og.og2.en_US.mOcfcqNpMkc.O/rt=j/m=drt,def/exm=in,fot/d=1/ed=1/rs=AA2YrTtfvY3V9vNuxwOxTw6H0xc0DK_I7A
View inline.js
/* code 1*/
/* async. yield execution to others */
/* .... */
/* return here */
/* code 2 */
View promise_code_carrier.js
p.then(() => {
/* code 1*/
}).then(() => {
/* code 2 */
});
View async_as_gen.js
function _asyncToGenerator(fn) {
return function () {
var self = this;
var args = arguments;
return new Promise(function (resolve, reject) {
// Instantiates the generator
var gen = fn.apply(self, args);
function _next(value) {
// Next step of the generator
var info = gen.next(value);
View async2.js
function f1() {
return Promise.resolve(21);
}
function f2(x) {
return Promise.resolve(x * 2);
}
async function g() {
r = await f1();
return await f2(r);
View error_async.js
function f() {
return Math.random() > 0.5 ?
Promise.resolve(10) :
Promise.reject(new Error('code x'));
}
async function g() {
try {
return await f();
} catch (e) {
View error_promise.js
function f() {
return Math.random() > 0.5 ?
Promise.resolve(10) :
Promise.reject(new Error('code x'));
}
function g() {
return f().then(r => {
return r + 1;
}).catch(e => {
View simple_async.js
function f() {
return Promise.resolve(10);
}
// Implicitly returns a Promise
async function g() {
r = await f();
return r + 1;
}
View simple_promise.js
function f() {
return Promise.resolve(10);
}
function g() {
return f().then(r => {
return r + 1;
});
}
View generator.js
function makeGenerator(n) {
return {
*[Symbol.iterator]() {
for(cnt = n - 1; cnt >= 0; cnt--) {
yield cnt;
}
},
};
}
You can’t perform that action at this time.