Skip to content

Instantly share code, notes, and snippets.

View oxcarga's full-sized avatar

Oscar Garita oxcarga

View GitHub Profile

Keybase proof

I hereby claim:

  • I am oxcarga on github.
  • I am oxcar (https://keybase.io/oxcar) on keybase.
  • I have a public key ASD6UXY8dmNADTIA_5AAtJ-3e6vck2DlHc5Z9nhqPCYMSQo

To claim this, I am signing this object:

@oxcarga
oxcarga / run-promise-right-away.js
Last active September 13, 2019 07:02
Promises in serie. One promise does not start until previous one is resolved/rejected
//
// This will run the promises right away
//
var arr = [
new Promise((res, rej) => {
console.log(" -UNO- ");
const timeout = 7;
setTimeout(() => {
res(`|FIRST | -> ${timeout} seconds`);
}, timeout * 1000)
@oxcarga
oxcarga / promises-in-serie-using-generator.js
Last active September 13, 2019 06:27
Just playing around with generators to make promises work in serie. One promise will not start until the previous one is finised
function* makeIterator(_arr) {
for (let i = 0; i < _arr.length; i++) {
yield _arr[i](i);
}
}
var arr = [
() => new Promise((res, rej) => {
const timeout = 15;
setTimeout(() => {
res(`|FIRST | -> ${timeout} seconds`);