Echo JS 0.11.0

<~>
tracker1 2720 days ago. link 2 points
Not ES6, but with async/await, I tend to put this in the top of quite a few of my files, easier as a oneliner than pulling in from a library module a lot of the time.

    const sleep = ms => new Promise(res => setTimeout(res, ms));

Replies

olalonde 2705 days ago. link 1 point
Another one relatively simple:

    const promisify = fn => (...args) => new Promise(resolve, reject) {
      fn(...args, (err, result) => {
        if (err) return reject(err)
        resolve(result)
      }
    }