Error: unable to verify the certificate in NodeJS

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0


singleton design pattern example in javascript

const Singleton = (function () {
    let instance;
 
    function createInstance() {
        const object = new Object("I am the instance");
        return object;
    }
 
    return {
        getInstance: function () {
            if (!instance) {
                instance = createInstance();
            }
            return instance;
        }
    };
})();

const object1 = singleton.getInstance();
const object2 = singleton.getInstance();

console.log(object1 === object2); //true

Execute async functions in Series


const asyncTask = function(i) {
  return new Promise((resolve, reject) => {
    setTimeout(() => resolve(`Completing ${i}`), 100*i)
  });
}

const promises = [
  asyncTask(3),
  asyncTask(1),
  asyncTask(7),
  asyncTask(2),
  asyncTask(5),
];

asyncSeriesExecuter = async (promises)=> {
 
  for(let i=0; i<promises.length; i++) {
     await promises[i].then((data)=>{
       console.log(data)
     })
  }
 

 
}

asyncSeriesExecuter(promises);