02 Jan 2018

ಠ_ಠ!!! Freelancer


AWS:

Currently we spent $80 on AWS

Node.js:

Bluebird revisit:

  • If you pass a promise object to the resolve function, the created promise will follow the state of that promise.
    const Promise = require('bluebird');
    const aPromise = new Promise(function(resolve, reject) {
      // vvv if you wanna resolve
      // resolve('hello');
      reject('world');
    });
    const bPromise = Promise.resolve(aPromise).catch(function(err){
      console.log('So its OOOOO ' + err + ' again?');
    });
      
    // Then bPromise should inherit aPromise's state (i.e. rejected)
    // 'So its OOOOO world again?' should be printed
    
  • Actually, we may make bPromise handle aPromise’s rejection in then like
    const bPromise = Promise.resolve(aPromise).then(function(resV){
      console.log('This cant happen', resV);
    }, function(rejV){ 
      console.log('Since its ' + rejV + ' ,you got rejected');
    }).catch(function(err){
      console.log('For any unexpected err lile', err);
    });
    
    // Should print 'Since its world ,you got rejected'
    
  • Filtered catch looks more reliable …
  • Perhaps the previous one’s rejection handling function in then is a long-term of catch(function(someErr){ .. })? We got supported here
  • This is how you chaining Promises’ val in if else branch

    If you are wondering why npm install -g SOMEPACKAGE doesnt work on OSX, this might work

    What is V8 and how does it work?

  • Javascript is a Prototype-inheritance lang
  • The most intiguing thing is what happens once the underlying instance has only, say 518 MB, to run javascript code in Node.js – GC by V8 engine just couldn’t help but rest!

    Go back to check event loop

    Why do let and var behave differently? This is exactly what has confused me for a while …