youtube-maze/lib/util.mjs

18 lines
497 B
JavaScript

import util from 'util';
export const YOUTUBE_BASE = 'https://www.youtube.com/%s';
export const WATCH_BASE = util.format(YOUTUBE_BASE, 'watch?v=%s');
/**
* Escape double quotes in a string.
*/
export const escapeQuotes = str => str.replace(/"/g, '\\"');
/**
* Make a promise that is resolved in a point in the future.
*
* @param number time Time to wait before resolving the promise (ms).
* @return null
*/
export const sleep = time => new Promise(resolve => setTimeout(resolve, time));