From 05d1bc3ae23c80a4362e8520b0b990cb6e2349b9 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Thu, 21 Mar 2019 15:02:05 -0400 Subject: [PATCH] Refactor delay into typescript --- app/lib/delay/index.js | 20 +++++++++++++------- app/lib/delay/index.js.map | 1 + cli/lib/delay/index.js | 15 +++++++++++++++ cli/lib/delay/index.js.map | 1 + cli/lib/delay/package.json | 11 +++++++++++ lib/delay/index.js | 15 +++++++++++++++ lib/delay/index.js.map | 1 + lib/delay/package.json | 11 +++++++++++ src/delay/index.ts | 17 +++++++++++++++++ 9 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 app/lib/delay/index.js.map create mode 100644 cli/lib/delay/index.js create mode 100644 cli/lib/delay/index.js.map create mode 100644 cli/lib/delay/package.json create mode 100644 lib/delay/index.js create mode 100644 lib/delay/index.js.map create mode 100644 lib/delay/package.json create mode 100644 src/delay/index.ts diff --git a/app/lib/delay/index.js b/app/lib/delay/index.js index 293a8ba..2b2d61d 100644 --- a/app/lib/delay/index.js +++ b/app/lib/delay/index.js @@ -1,9 +1,15 @@ 'use strict'; - -function delay (ms) { - return new Promise((resolve) => { - setTimeout(resolve, ms); - }); +/** + * Delay in an async/await function + * + * @param {integer} ms Milliseconds to delay for + * + * @returns {Promise} Promise to resolve after timeout + **/ +function delay(ms) { + return new Promise((resolve) => { + return setTimeout(resolve, ms); + }); } - -module.exports = delay; \ No newline at end of file +module.exports = delay; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/app/lib/delay/index.js.map b/app/lib/delay/index.js.map new file mode 100644 index 0000000..fbabfe4 --- /dev/null +++ b/app/lib/delay/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/delay/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;IAMI;AAEJ,SAAS,KAAK,CAAE,EAAW;IAC1B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAa,EAAE,EAAE;QACpC,OAAO,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC"} \ No newline at end of file diff --git a/cli/lib/delay/index.js b/cli/lib/delay/index.js new file mode 100644 index 0000000..2b2d61d --- /dev/null +++ b/cli/lib/delay/index.js @@ -0,0 +1,15 @@ +'use strict'; +/** + * Delay in an async/await function + * + * @param {integer} ms Milliseconds to delay for + * + * @returns {Promise} Promise to resolve after timeout + **/ +function delay(ms) { + return new Promise((resolve) => { + return setTimeout(resolve, ms); + }); +} +module.exports = delay; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/cli/lib/delay/index.js.map b/cli/lib/delay/index.js.map new file mode 100644 index 0000000..fbabfe4 --- /dev/null +++ b/cli/lib/delay/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/delay/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;IAMI;AAEJ,SAAS,KAAK,CAAE,EAAW;IAC1B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAa,EAAE,EAAE;QACpC,OAAO,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC"} \ No newline at end of file diff --git a/cli/lib/delay/package.json b/cli/lib/delay/package.json new file mode 100644 index 0000000..9a1fe44 --- /dev/null +++ b/cli/lib/delay/package.json @@ -0,0 +1,11 @@ +{ + "name": "delay", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +} diff --git a/lib/delay/index.js b/lib/delay/index.js new file mode 100644 index 0000000..2b2d61d --- /dev/null +++ b/lib/delay/index.js @@ -0,0 +1,15 @@ +'use strict'; +/** + * Delay in an async/await function + * + * @param {integer} ms Milliseconds to delay for + * + * @returns {Promise} Promise to resolve after timeout + **/ +function delay(ms) { + return new Promise((resolve) => { + return setTimeout(resolve, ms); + }); +} +module.exports = delay; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/delay/index.js.map b/lib/delay/index.js.map new file mode 100644 index 0000000..fbabfe4 --- /dev/null +++ b/lib/delay/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/delay/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;IAMI;AAEJ,SAAS,KAAK,CAAE,EAAW;IAC1B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAa,EAAE,EAAE;QACpC,OAAO,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC"} \ No newline at end of file diff --git a/lib/delay/package.json b/lib/delay/package.json new file mode 100644 index 0000000..9a1fe44 --- /dev/null +++ b/lib/delay/package.json @@ -0,0 +1,11 @@ +{ + "name": "delay", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +} diff --git a/src/delay/index.ts b/src/delay/index.ts new file mode 100644 index 0000000..01e23f8 --- /dev/null +++ b/src/delay/index.ts @@ -0,0 +1,17 @@ +'use strict'; + +/** + * Delay in an async/await function + * + * @param {integer} ms Milliseconds to delay for + * + * @returns {Promise} Promise to resolve after timeout + **/ + +function delay (ms : number) { + return new Promise((resolve : any) => { + return setTimeout(resolve, ms); + }); +} + +module.exports = delay; \ No newline at end of file