@yh-kit/utils 0.1.0 → 1.0.1

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
@@ -11,6 +11,8 @@
11
11
  ## 使用
12
12
 
13
13
  ```ts
14
- import httpRequest from '@yh-kit/utils';
14
+ import { queryURLParamsUtil } from "@yh-kit/utils";
15
15
 
16
+ const queryId = queryURLParamsUtil("id");
17
+ console.log(queryId);
16
18
  ```
package/dist/utils.js CHANGED
@@ -1,16 +1,33 @@
1
- const t = (n) => {
2
- if (!n || !n.length) return {};
3
- const o = {};
4
- return n.forEach((e) => {
5
- const r = Object.assign({ label: e.label, text: e.label }, e);
6
- o[e == null ? void 0 : e.value] = r;
7
- }), o;
8
- }, l = (n) => n.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), s = (n) => {
9
- const e = new RegExp("[?&]" + n + "=([^&#]*)", "i").exec(window.location.href);
10
- return e ? decodeURIComponent(e[1]) : null;
1
+ const r = {
2
+ /**
3
+ * 数组转枚举对象
4
+ * @param arr 数组
5
+ * @returns
6
+ */
7
+ toEnumObj: (e) => {
8
+ if (!e || !e.length) return {};
9
+ const o = {};
10
+ return e.forEach((n) => {
11
+ const t = Object.assign({ label: n.label, text: n.label }, n);
12
+ o[n == null ? void 0 : n.value] = t;
13
+ }), o;
14
+ }
15
+ }, a = {
16
+ ...r
17
+ }, s = (e) => e.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), c = {
18
+ toMoney: s
19
+ }, b = {
20
+ ...c
21
+ }, l = (e) => {
22
+ const n = new RegExp("[?&]" + e + "=([^&#]*)", "i").exec(window.location.href);
23
+ return n ? decodeURIComponent(n[1]) : null;
24
+ }, u = {
25
+ getQueryInfoByName: l
26
+ }, g = {
27
+ ...u
11
28
  };
12
29
  export {
13
- l as formatNumberWithCommasUtil,
14
- t as handleArrTansferEnumObj,
15
- s as queryURLParamsUtil
30
+ a as arrayUtils,
31
+ b as numberUtils,
32
+ g as urlUtils
16
33
  };
@@ -1 +1 @@
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 o=t=>{if(!t||!t.length)return{};const r={};return t.forEach(e=>{const u=Object.assign({label:e.label,text:e.label},e);r[e==null?void 0:e.value]=u}),r},l=t=>t.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),s=t=>{const e=new RegExp("[?&]"+t+"=([^&#]*)","i").exec(window.location.href);return e?decodeURIComponent(e[1]):null};n.formatNumberWithCommasUtil=l,n.handleArrTansferEnumObj=o,n.queryURLParamsUtil=s,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.1.0",
4
+ "version": "1.0.1",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -1,7 +1,11 @@
1
1
  import { IOptionItem, TValueEnum } from "../typings";
2
- /**
3
- * 数组转枚举对象
4
- * @param arr
5
- * @returns
6
- */
7
- export declare const handleArrTansferEnumObj: (arr: IOptionItem[]) => TValueEnum;
2
+ /** 数组转对象 */
3
+ declare const _default: {
4
+ /**
5
+ * 数组转枚举对象
6
+ * @param arr 数组
7
+ * @returns
8
+ */
9
+ toEnumObj: (arr: IOptionItem[]) => TValueEnum;
10
+ };
11
+ 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,3 +1,3 @@
1
1
  export * from "./array";
2
- export * from "./money";
2
+ export * from "./number";
3
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;
@@ -1,10 +0,0 @@
1
- /**
2
- * 格式化数字为标准金额格式(带千分位)
3
- * 例如:
4
- * 123456789 => 123,456,789.00
5
- * 0 => 0.00
6
- * 123.456789 => 123.46
7
- * @param x 数字
8
- * @returns
9
- */
10
- export declare const formatNumberWithCommasUtil: (x: number) => string;