youtube-maze/lib/util.mjs

18 lines
497 B
JavaScript
Raw Normal View History

2020-11-28 17:07:04 +00:00
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));