@jrc03c/pause 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build.mjs CHANGED
@@ -9,7 +9,7 @@ function rebuild() {
9
9
 
10
10
  const commands = [
11
11
  `${baseCommand} --platform=node --outfile=dist/pause.require.cjs`,
12
- `${baseCommand} --outfile=dist/pause.standalone.cjs`,
12
+ `${baseCommand} --outfile=dist/pause.standalone.js`,
13
13
  `${baseCommand} --format=esm --outfile=dist/pause.import.mjs`,
14
14
  ]
15
15
 
@@ -0,0 +1,26 @@
1
+ (() => {
2
+ // src/index.mjs
3
+ function pauseAsync(ms) {
4
+ return new Promise((resolve, reject) => {
5
+ try {
6
+ const start = /* @__PURE__ */ new Date();
7
+ return setTimeout(() => resolve(/* @__PURE__ */ new Date() - start), ms);
8
+ } catch (e) {
9
+ return reject(e);
10
+ }
11
+ });
12
+ }
13
+ function pauseSync(ms) {
14
+ const start = /* @__PURE__ */ new Date();
15
+ let now = /* @__PURE__ */ new Date();
16
+ while (now - start < ms) {
17
+ now = /* @__PURE__ */ new Date();
18
+ }
19
+ return /* @__PURE__ */ new Date() - start;
20
+ }
21
+ if (typeof window !== "undefined") {
22
+ window.pause = pauseAsync;
23
+ window.pauseAsync = pauseAsync;
24
+ window.pauseSync = pauseSync;
25
+ }
26
+ })();
package/package.json CHANGED
@@ -22,5 +22,5 @@
22
22
  "module": "./dist/pause.import.mjs",
23
23
  "name": "@jrc03c/pause",
24
24
  "type": "module",
25
- "version": "0.0.7"
25
+ "version": "0.0.9"
26
26
  }