@yh-kit/utils 0.0.3 → 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 CHANGED
@@ -1,15 +1,16 @@
1
- const r = (n) => {
1
+ const t = (n) => {
2
2
  if (!n || !n.length) return {};
3
3
  const o = {};
4
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;
5
+ const r = Object.assign({ label: e.label, text: e.label }, e);
6
+ o[e == null ? void 0 : e.value] = r;
7
7
  }), o;
8
- }, s = (n) => {
8
+ }, l = (n) => n.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), s = (n) => {
9
9
  const e = new RegExp("[?&]" + n + "=([^&#]*)", "i").exec(window.location.href);
10
10
  return e ? decodeURIComponent(e[1]) : null;
11
11
  };
12
12
  export {
13
- r as handleArrTansferEnumObj,
13
+ l as formatNumberWithCommasUtil,
14
+ t as handleArrTansferEnumObj,
14
15
  s as queryURLParamsUtil
15
16
  };
@@ -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 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,7 +1,7 @@
1
1
  {
2
2
  "name": "@yh-kit/utils",
3
3
  "private": false,
4
- "version": "0.0.3",
4
+ "version": "0.1.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:",
package/types/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./array";
2
+ export * from "./money";
2
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;