Skip to content

Instantly share code, notes, and snippets.

View yesvods's full-sized avatar
💭
Getting things done.

Jogis yesvods

💭
Getting things done.
View GitHub Profile
@yesvods
yesvods / async-parallel.js
Created July 21, 2015 09:11
ES6 async parallel execution
//mock a fs Object
let fs = {
readFile: function(filename, cb){
let randomTime = 100+Math.random()*1000>>0;
setTimeout(()=>{
cb(`hello ${filename}`)
}, randomTime)
}
}
@yesvods
yesvods / es6-inherit.js
Last active August 29, 2015 14:25
ES6 Class inherit
//ES6 Class inherit example
class Person{
sayName(){
console.log(this.name);
}
}
class Classmate extends Person {
constructor(name){
super()
this.name = name;
@yesvods
yesvods / promise-wrap.js
Last active November 19, 2018 23:25
wrap nodejs fs#readFile to be a promise.
let fs = {
readFile: function(filename, cb){
setTimeout(()=>{
cb('hello')
}, 100)
}
}
let readFilePro = function(filename){
return new Promise(function(resolve, reject) {
fs.readFile(filename, (data, err) => {