@yh-kit/utils 0.0.3 → 1.0.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 CHANGED
@@ -1,3 +1,18 @@
1
1
  # 实用程序合集
2
2
 
3
3
  实用程序合集
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm i @yh-kit/utils
9
+ ```
10
+
11
+ ## 使用
12
+
13
+ ```ts
14
+ import { queryURLParamsUtil } from "@yh-kit/utils";
15
+
16
+ const queryId = queryURLParamsUtil("id");
17
+ console.log(queryId);
18
+ ```
package/dist/utils.js CHANGED
@@ -1,15 +1,28 @@
1
- const r = (n) => {
2
- if (!n || !n.length) return {};
1
+ const r = (e) => {
2
+ if (!e || !e.length) return {};
3
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;
4
+ return e.forEach((n) => {
5
+ const t = Object.assign({ label: n.label, text: n.label }, n);
6
+ o[n == null ? void 0 : n.value] = t;
7
7
  }), o;
8
- }, s = (n) => {
9
- const e = new RegExp("[?&]" + n + "=([^&#]*)", "i").exec(window.location.href);
10
- return e ? decodeURIComponent(e[1]) : null;
8
+ }, s = {
9
+ toEnumObj: r
10
+ }, b = {
11
+ ...s
12
+ }, c = (e) => e.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), l = {
13
+ toMoney: c
14
+ }, g = {
15
+ ...l
16
+ }, u = (e) => {
17
+ const n = new RegExp("[?&]" + e + "=([^&#]*)", "i").exec(window.location.href);
18
+ return n ? decodeURIComponent(n[1]) : null;
19
+ }, a = {
20
+ getQueryInfoByName: u
21
+ }, y = {
22
+ ...a
11
23
  };
12
24
  export {
13
- r as handleArrTansferEnumObj,
14
- s as queryURLParamsUtil
25
+ b as arrayUtils,
26
+ g as numberUtils,
27
+ y as urlUtils
15
28
  };
@@ -1 +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"})});
1
+ (function(n,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(n=typeof globalThis<"u"?globalThis:n||self,o(n.yhkitUtils={}))})(this,function(n){"use strict";const s={...{toEnumObj:t=>{if(!t||!t.length)return{};const r={};return t.forEach(e=>{const c=Object.assign({label:e.label,text:e.label},e);r[e==null?void 0:e.value]=c}),r}}},l={...{toMoney:t=>t.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}},u={...{getQueryInfoByName:t=>{const e=new RegExp("[?&]"+t+"=([^&#]*)","i").exec(window.location.href);return e?decodeURIComponent(e[1]):null}}};n.arrayUtils=s,n.numberUtils=l,n.urlUtils=u,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yh-kit/utils",
3
3
  "private": false,
4
- "version": "0.0.3",
4
+ "version": "1.0.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -17,7 +17,11 @@
17
17
  },
18
18
  "scripts": {
19
19
  "dev": "vite",
20
- "build": "tsc && vite build"
20
+ "build": "tsc && vite build",
21
+ "clean": "rimraf node_modules",
22
+ "clean-build": "rimraf dist & rimraf types",
23
+ "clean-all": "rimraf node_modules & rimraf dist & rimraf types",
24
+ "prepublishOnly": "npm run clean-build && npm run build"
21
25
  },
22
26
  "devDependencies": {
23
27
  "typescript": "catalog:",
@@ -28,4 +32,4 @@
28
32
  "access": "public",
29
33
  "registry": "https://registry.npmjs.org/"
30
34
  }
31
- }
35
+ }
@@ -1,7 +1,5 @@
1
1
  import { IOptionItem, TValueEnum } from "../typings";
2
- /**
3
- * 数组转枚举对象
4
- * @param arr
5
- * @returns
6
- */
7
- export declare const handleArrTansferEnumObj: (arr: IOptionItem[]) => TValueEnum;
2
+ declare const _default: {
3
+ toEnumObj: (arr: IOptionItem[]) => TValueEnum;
4
+ };
5
+ export default _default;
@@ -1 +1,6 @@
1
- export * from "./array2obj";
1
+ /**
2
+ * 数组相关操作工具函数
3
+ */
4
+ export declare const arrayUtils: {
5
+ toEnumObj: (arr: import("../typings").IOptionItem[]) => import("../typings").TValueEnum;
6
+ };
package/types/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./array";
2
+ export * from "./number";
2
3
  export * from "./url";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 数字相关操作工具函数
3
+ */
4
+ export declare const numberUtils: {
5
+ toMoney: (x: number) => string;
6
+ };
@@ -0,0 +1,4 @@
1
+ declare const _default: {
2
+ toMoney: (x: number) => string;
3
+ };
4
+ export default _default;
@@ -12,7 +12,9 @@ export interface IOptionItem {
12
12
  /** 值 */
13
13
  value: number | string;
14
14
  /** 中文名 */
15
- text: string;
15
+ label: string;
16
+ /** 中文名 */
17
+ text?: string;
16
18
  /** 其他任意字段 */
17
19
  [key: string]: unknown;
18
20
  }
@@ -1 +1,6 @@
1
- export * from "./query";
1
+ /**
2
+ * url链接信息相关操作工具函数
3
+ */
4
+ export declare const urlUtils: {
5
+ getQueryInfoByName: (name: string) => string | null;
6
+ };
@@ -1,6 +1,4 @@
1
- /**
2
- * 获取url中的query中某字段的信息
3
- * @param name
4
- * @returns
5
- */
6
- export declare const queryURLParamsUtil: (name: string) => string | null;
1
+ declare const _default: {
2
+ getQueryInfoByName: (name: string) => string | null;
3
+ };
4
+ export default _default;