@yh-kit/utils 0.0.2 → 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 CHANGED
@@ -1,3 +1,16 @@
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 httpRequest from '@yh-kit/utils';
15
+
16
+ ```
package/dist/utils.js ADDED
@@ -0,0 +1,16 @@
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;
11
+ };
12
+ export {
13
+ l as formatNumberWithCommasUtil,
14
+ t as handleArrTansferEnumObj,
15
+ s as queryURLParamsUtil
16
+ };
@@ -0,0 +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"})});
package/package.json CHANGED
@@ -1,30 +1,34 @@
1
1
  {
2
2
  "name": "@yh-kit/utils",
3
3
  "private": false,
4
- "version": "0.0.2",
4
+ "version": "0.1.0",
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",
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:",
24
28
  "vite": "catalog:"
25
29
  },
26
30
  "publishConfig": {
27
- "main": "dist/index.js",
31
+ "main": "dist/utils.js",
28
32
  "access": "public",
29
33
  "registry": "https://registry.npmjs.org/"
30
34
  }
@@ -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,3 @@
1
+ export * from "./array";
2
+ export * from "./money";
3
+ export * from "./url";
@@ -0,0 +1,10 @@
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;
@@ -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;