@jrc03c/pause 0.0.7 → 0.0.10

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
@@ -5,17 +5,15 @@ function rebuild() {
5
5
  console.log(`\nRebuilding... (${new Date().toLocaleString()})`)
6
6
 
7
7
  try {
8
- const baseCommand = "npx esbuild src/index.mjs --bundle"
8
+ execSync(
9
+ `npx esbuild src/iife.mjs --bundle --outfile=dist/pause.js`,
10
+ { encoding: "utf8" }
11
+ )
9
12
 
10
- const commands = [
11
- `${baseCommand} --platform=node --outfile=dist/pause.require.cjs`,
12
- `${baseCommand} --outfile=dist/pause.standalone.cjs`,
13
- `${baseCommand} --format=esm --outfile=dist/pause.import.mjs`,
14
- ]
15
-
16
- commands.forEach(command => {
17
- execSync(command, { encoding: "utf8" })
18
- })
13
+ execSync(
14
+ `npx esbuild src/iife.mjs --bundle --minify --outfile=dist/pause.min.js`,
15
+ { encoding: "utf8" }
16
+ )
19
17
 
20
18
  console.log("\nDone! 🎉\n")
21
19
  } catch (e) {
@@ -18,9 +18,11 @@
18
18
  }
19
19
  return /* @__PURE__ */ new Date() - start;
20
20
  }
21
- if (typeof window !== "undefined") {
22
- window.pause = pauseAsync;
23
- window.pauseAsync = pauseAsync;
24
- window.pauseSync = pauseSync;
21
+
22
+ // src/iife.mjs
23
+ if (typeof globalThis !== "undefined") {
24
+ globalThis.pause = pauseAsync;
25
+ globalThis.pauseAsync = pauseAsync;
26
+ globalThis.pauseSync = pauseSync;
25
27
  }
26
28
  })();
@@ -0,0 +1 @@
1
+ (()=>{function s(t){return new Promise((e,n)=>{try{let a=new Date;return setTimeout(()=>e(new Date-a),t)}catch(a){return n(a)}})}function u(t){let e=new Date,n=new Date;for(;n-e<t;)n=new Date;return new Date-e}typeof globalThis<"u"&&(globalThis.pause=s,globalThis.pauseAsync=s,globalThis.pauseSync=u);})();
package/package.json CHANGED
@@ -8,19 +8,15 @@
8
8
  "globals": "^15.11.0",
9
9
  "prettier": "^3.3.3"
10
10
  },
11
- "exports": {
12
- "import": "./dist/pause.import.mjs",
13
- "require": "./dist/pause.require.cjs"
14
- },
15
11
  "keywords": [
16
12
  "js",
17
13
  "pause",
18
14
  "settimeout"
19
15
  ],
20
16
  "license": "ISC",
21
- "main": "./dist/pause.require.cjs",
22
- "module": "./dist/pause.import.mjs",
17
+ "main": "./src/index.mjs",
18
+ "module": "./src/index.mjs",
23
19
  "name": "@jrc03c/pause",
24
20
  "type": "module",
25
- "version": "0.0.7"
21
+ "version": "0.0.10"
26
22
  }
package/src/iife.mjs ADDED
@@ -0,0 +1,7 @@
1
+ import { pause, pauseAsync, pauseSync } from "./index.mjs"
2
+
3
+ if (typeof globalThis !== "undefined") {
4
+ globalThis.pause = pauseAsync
5
+ globalThis.pauseAsync = pauseAsync
6
+ globalThis.pauseSync = pauseSync
7
+ }
package/src/index.mjs CHANGED
@@ -20,10 +20,4 @@ function pauseSync(ms) {
20
20
  return new Date() - start
21
21
  }
22
22
 
23
- if (typeof window !== "undefined") {
24
- window.pause = pauseAsync
25
- window.pauseAsync = pauseAsync
26
- window.pauseSync = pauseSync
27
- }
28
-
29
23
  export { pauseAsync as pause, pauseAsync, pauseSync }
@@ -1,29 +0,0 @@
1
- // src/index.mjs
2
- function pauseAsync(ms) {
3
- return new Promise((resolve, reject) => {
4
- try {
5
- const start = /* @__PURE__ */ new Date();
6
- return setTimeout(() => resolve(/* @__PURE__ */ new Date() - start), ms);
7
- } catch (e) {
8
- return reject(e);
9
- }
10
- });
11
- }
12
- function pauseSync(ms) {
13
- const start = /* @__PURE__ */ new Date();
14
- let now = /* @__PURE__ */ new Date();
15
- while (now - start < ms) {
16
- now = /* @__PURE__ */ new Date();
17
- }
18
- return /* @__PURE__ */ new Date() - start;
19
- }
20
- if (typeof window !== "undefined") {
21
- window.pause = pauseAsync;
22
- window.pauseAsync = pauseAsync;
23
- window.pauseSync = pauseSync;
24
- }
25
- export {
26
- pauseAsync as pause,
27
- pauseAsync,
28
- pauseSync
29
- };
@@ -1,55 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/index.mjs
20
- var src_exports = {};
21
- __export(src_exports, {
22
- pause: () => pauseAsync,
23
- pauseAsync: () => pauseAsync,
24
- pauseSync: () => pauseSync
25
- });
26
- module.exports = __toCommonJS(src_exports);
27
- function pauseAsync(ms) {
28
- return new Promise((resolve, reject) => {
29
- try {
30
- const start = /* @__PURE__ */ new Date();
31
- return setTimeout(() => resolve(/* @__PURE__ */ new Date() - start), ms);
32
- } catch (e) {
33
- return reject(e);
34
- }
35
- });
36
- }
37
- function pauseSync(ms) {
38
- const start = /* @__PURE__ */ new Date();
39
- let now = /* @__PURE__ */ new Date();
40
- while (now - start < ms) {
41
- now = /* @__PURE__ */ new Date();
42
- }
43
- return /* @__PURE__ */ new Date() - start;
44
- }
45
- if (typeof window !== "undefined") {
46
- window.pause = pauseAsync;
47
- window.pauseAsync = pauseAsync;
48
- window.pauseSync = pauseSync;
49
- }
50
- // Annotate the CommonJS export names for ESM import in node:
51
- 0 && (module.exports = {
52
- pause,
53
- pauseAsync,
54
- pauseSync
55
- });