x-essential-lib 0.1.0
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/README.md +1 -0
- package/dist/index.es.js +36 -0
- package/package.json +45 -0
- package/types/index.d.ts +2 -0
- package/types/utils/core.d.ts +3 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# x-essential-lib
|
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
function o(i) {
|
|
2
|
+
return { all: i = i || /* @__PURE__ */ new Map(), on: function(t, n) {
|
|
3
|
+
var e = i.get(t);
|
|
4
|
+
e ? e.push(n) : i.set(t, [n]);
|
|
5
|
+
}, off: function(t, n) {
|
|
6
|
+
var e = i.get(t);
|
|
7
|
+
e && (n ? e.splice(e.indexOf(n) >>> 0, 1) : i.set(t, []));
|
|
8
|
+
}, emit: function(t, n) {
|
|
9
|
+
var e = i.get(t);
|
|
10
|
+
e && e.slice().map(function(s) {
|
|
11
|
+
s(n);
|
|
12
|
+
}), (e = i.get("*")) && e.slice().map(function(s) {
|
|
13
|
+
s(t, n);
|
|
14
|
+
});
|
|
15
|
+
} };
|
|
16
|
+
}
|
|
17
|
+
const a = o();
|
|
18
|
+
async function u(i) {
|
|
19
|
+
return new Promise((t) => {
|
|
20
|
+
setTimeout(t, i);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async function f(i, t, n) {
|
|
24
|
+
const e = Date.now();
|
|
25
|
+
return new Promise((s) => {
|
|
26
|
+
const c = async () => {
|
|
27
|
+
i() ? s(!0) : t && Date.now() - e > t ? s(!1) : setTimeout(c, n ?? 30);
|
|
28
|
+
};
|
|
29
|
+
c();
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
a as eventBus,
|
|
34
|
+
u as waitMs,
|
|
35
|
+
f as waitUtil
|
|
36
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "x-essential-lib",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "dist/index.es.js",
|
|
7
|
+
"types": "types/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"types/**/*.d.ts"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "vite",
|
|
14
|
+
"build": "vue-tsc && vite build",
|
|
15
|
+
"preview": "vite preview",
|
|
16
|
+
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix",
|
|
17
|
+
"format": "prettier --write .",
|
|
18
|
+
"lint-staged": "lint-staged",
|
|
19
|
+
"prepare": "husky"
|
|
20
|
+
},
|
|
21
|
+
"lint-staged": {
|
|
22
|
+
"*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
|
|
23
|
+
"*": "prettier --write ."
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@rushstack/eslint-patch": "^1.8.0",
|
|
27
|
+
"@types/node": "^20.12.2",
|
|
28
|
+
"@vitejs/plugin-vue": "^5.0.4",
|
|
29
|
+
"@vue/eslint-config-prettier": "^9.0.0",
|
|
30
|
+
"@vue/eslint-config-typescript": "^13.0.0",
|
|
31
|
+
"eslint": "^8.57.0",
|
|
32
|
+
"eslint-plugin-vue": "^9.24.1",
|
|
33
|
+
"husky": "^9.0.11",
|
|
34
|
+
"lint-staged": "^15.2.2",
|
|
35
|
+
"mitt": "^3.0.1",
|
|
36
|
+
"prettier": "3.2.5",
|
|
37
|
+
"sass": "^1.74.1",
|
|
38
|
+
"typescript": "^5.2.2",
|
|
39
|
+
"vite": "^5.2.0",
|
|
40
|
+
"vite-plugin-css-injected-by-js": "^3.5.0",
|
|
41
|
+
"vite-plugin-vuetify": "^2.0.3",
|
|
42
|
+
"vue": "^3.4.23",
|
|
43
|
+
"vue-tsc": "^2.0.6"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const eventBus: import("mitt").Emitter<Record<import("mitt").EventType, unknown>>;
|
|
2
|
+
export declare function waitMs(ms: number): Promise<void>;
|
|
3
|
+
export declare function waitUtil(conditionFunc: () => boolean, timeout?: number, interval?: number): Promise<boolean>;
|