GPTScript / AiScript

A Minimal, Full-Stack, Tool-Assisted Language. Native to Browsers and Bun. Strictly & Strongly-Typed.
https://github.com/GPTScript/AiScript
Mozilla Public License 2.0
9 stars 1 forks source link

Promise._sleep(ms) #23

Open coolaj86 opened 2 years ago

coolaj86 commented 2 years ago

Another one of those things that just ought to be included.

As simple as it is, it's darn useful for:

/**
 * @param {Number} ms
 * @returns {Promise<void>}
 */
Promise._sleep = async function (ms) {
  return await new Promise(function (resolve) {
    setTimeout(resolve, ms);
  });
};