@yh-kit/utils 0.0.1 → 0.0.3

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 CHANGED
@@ -1,10 +1,3 @@
1
- <!--
2
- * @Description: file content
3
- * @Author: YH
4
- * @Date: 2025-04-29 17:19:04
5
- * @LastEditors: YH
6
- * @LastEditTime: 2025-04-29 17:19:04
7
- * @FilePath: \v3_vite\packages\utils\README.md
8
- -->
1
+ # 实用程序合集
9
2
 
10
- # README.md
3
+ 实用程序合集
package/dist/utils.js ADDED
@@ -0,0 +1,15 @@
1
+ const r = (n) => {
2
+ if (!n || !n.length) return {};
3
+ const o = {};
4
+ return n.forEach((e) => {
5
+ const l = Object.assign({ label: e.label, text: e.label }, e);
6
+ o[e == null ? void 0 : e.value] = l;
7
+ }), o;
8
+ }, s = (n) => {
9
+ const e = new RegExp("[?&]" + n + "=([^&#]*)", "i").exec(window.location.href);
10
+ return e ? decodeURIComponent(e[1]) : null;
11
+ };
12
+ export {
13
+ r as handleArrTansferEnumObj,
14
+ s as queryURLParamsUtil
15
+ };
@@ -0,0 +1 @@
1
+ (function(n,t){typeof exports=="object"&&typeof module<"u"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(n=typeof globalThis<"u"?globalThis:n||self,t(n.yhkitUtils={}))})(this,function(n){"use strict";const t=o=>{if(!o||!o.length)return{};const s={};return o.forEach(e=>{const r=Object.assign({label:e.label,text:e.label},e);s[e==null?void 0:e.value]=r}),s},l=o=>{const e=new RegExp("[?&]"+o+"=([^&#]*)","i").exec(window.location.href);return e?decodeURIComponent(e[1]):null};n.handleArrTansferEnumObj=t,n.queryURLParamsUtil=l,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@yh-kit/utils",
3
3
  "private": false,
4
- "version": "0.0.1",
4
+ "version": "0.0.3",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
8
- "index.d.ts"
8
+ "types"
9
9
  ],
10
- "main": "./dist/counter.umd.cjs",
11
- "module": "./dist/counter.js",
12
- "types": "./index.d.ts",
10
+ "main": "./dist/utils.umd.cjs",
11
+ "module": "./dist/utils.js",
12
+ "types": "./types/index.d.ts",
13
13
  "exports": {
14
- "types": "./index.d.ts",
15
- "import": "./dist/counter.js",
16
- "require": "./dist/counter.umd.cjs"
14
+ "types": "./types/index.d.ts",
15
+ "import": "./dist/utils.js",
16
+ "require": "./dist/utils.umd.cjs"
17
17
  },
18
18
  "scripts": {
19
19
  "dev": "vite",
@@ -24,8 +24,8 @@
24
24
  "vite": "catalog:"
25
25
  },
26
26
  "publishConfig": {
27
- "main": "dist/index.js",
27
+ "main": "dist/utils.js",
28
28
  "access": "public",
29
29
  "registry": "https://registry.npmjs.org/"
30
30
  }
31
- }
31
+ }
@@ -0,0 +1,7 @@
1
+ import { IOptionItem, TValueEnum } from "../typings";
2
+ /**
3
+ * 数组转枚举对象
4
+ * @param arr
5
+ * @returns
6
+ */
7
+ export declare const handleArrTansferEnumObj: (arr: IOptionItem[]) => TValueEnum;
@@ -0,0 +1 @@
1
+ export * from "./array2obj";
@@ -0,0 +1,2 @@
1
+ export * from "./array";
2
+ export * from "./url";
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 枚举对象类型
3
+ */
4
+ export type TValueEnum = Record<string | number | symbol, {
5
+ text: string;
6
+ [key: string]: unknown;
7
+ }>;
8
+ /**
9
+ * 枚举对象类型
10
+ */
11
+ export interface IOptionItem {
12
+ /** 值 */
13
+ value: number | string;
14
+ /** 中文名 */
15
+ text: string;
16
+ /** 其他任意字段 */
17
+ [key: string]: unknown;
18
+ }
@@ -0,0 +1 @@
1
+ export * from "./query";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 获取url中的query中某字段的信息
3
+ * @param name
4
+ * @returns
5
+ */
6
+ export declare const queryURLParamsUtil: (name: string) => string | null;
package/dist/counter.js DELETED
@@ -1,10 +0,0 @@
1
- function c(n) {
2
- let t = 0;
3
- const e = (o) => {
4
- t = o, n.innerHTML = `count is ${t}`;
5
- };
6
- n.addEventListener("click", () => e(++t)), e(0);
7
- }
8
- export {
9
- c as setupCounter
10
- };
@@ -1 +0,0 @@
1
- (function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.Counter={}))})(this,function(e){"use strict";function t(o){let n=0;const i=u=>{n=u,o.innerHTML=`count is ${n}`};o.addEventListener("click",()=>i(++n)),i(0)}e.setupCounter=t,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
package/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export function setupCounter(element: HTMLButtonElement): void;