Resolve promises one after another (i.e. in sequence)?

Update 2017: I would use an async function if the environment supports it: async function readFiles(files) { for(const file of files) { await readFile(file); } }; If you’d like, you can defer reading the files until you need them using an async generator (if your environment supports it): async function* readFiles(files) { for(const file of … Read more

How to check if an object is a Promise?

How a promise library decides If it has a .then function – that’s the only standard promise libraries use. The Promises/A+ specification has a notion called thenable which is basically “an object with a then method”. Promises will and should assimilate anything with a then method. All of the promise implementation you’ve mentioned do this. … Read more

What is the explicit promise construction antipattern and how do I avoid it?

The deferred antipattern (now explicit-construction anti-pattern) coined by Esailija is a common anti-pattern people who are new to promises make, I’ve made it myself when I first used promises. The problem with the above code is that is fails to utilize the fact that promises chain. Promises can chain with .then and you can return … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)