@yh-kit/utils 1.0.1 → 1.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/dist/utils.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const r = {
2
+ // toEnumObj: handleArrTansferEnumObj,
2
3
  /**
3
4
  * 数组转枚举对象
4
5
  * @param arr 数组
@@ -6,28 +7,31 @@ const r = {
6
7
  */
7
8
  toEnumObj: (e) => {
8
9
  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;
10
+ const n = {};
11
+ return e.forEach((t) => {
12
+ const o = Object.assign({ label: t.label, text: t.label }, t);
13
+ n[t == null ? void 0 : t.value] = o;
14
+ }), n;
14
15
  }
15
- }, a = {
16
+ }, g = {
16
17
  ...r
17
- }, s = (e) => e.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), c = {
18
- toMoney: s
19
- }, b = {
18
+ }, s = (e) => e > 25 || e < 0 ? "" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e], c = {
19
+ toLetter: s
20
+ }, l = (e) => e.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), u = {
21
+ toMoney: l
22
+ }, y = {
23
+ ...u,
20
24
  ...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
25
+ }, a = (e) => {
26
+ const t = new RegExp("[?&]" + e + "=([^&#]*)", "i").exec(window.location.href);
27
+ return t ? decodeURIComponent(t[1]) : null;
28
+ }, b = {
29
+ getQueryInfoByName: a
30
+ }, x = {
31
+ ...b
28
32
  };
29
33
  export {
30
- a as arrayUtils,
31
- b as numberUtils,
32
- g as urlUtils
34
+ g as arrayUtils,
35
+ y as numberUtils,
36
+ x as urlUtils
33
37
  };
@@ -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 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"})});
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:e=>{if(!e||!e.length)return{};const r={};return e.forEach(t=>{const c=Object.assign({label:t.label,text:t.label},t);r[t==null?void 0:t.value]=c}),r}}},l={...{toMoney:e=>e.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},...{toLetter:e=>e>25||e<0?"":"ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e]}},u={...{getQueryInfoByName:e=>{const t=new RegExp("[?&]"+e+"=([^&#]*)","i").exec(window.location.href);return t?decodeURIComponent(t[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": "1.0.1",
4
+ "version": "1.1.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -1,4 +1,9 @@
1
1
  import { IOptionItem, TValueEnum } from "../typings";
2
+ /**
3
+ * 数组转枚举对象
4
+ * @param arr
5
+ * @returns
6
+ */
2
7
  /** 数组转对象 */
3
8
  declare const _default: {
4
9
  /**
@@ -0,0 +1,11 @@
1
+ /**
2
+ * 数组相关操作工具函数
3
+ */
4
+ export declare const letterUtils: {
5
+ /**
6
+ * 将选中的字母数组从A-Z排序:用于试题选择答案的排序实例
7
+ * @param arr 字母数组
8
+ * @returns
9
+ */
10
+ sortFromA2Z: (arr: string[]) => string[] | undefined;
11
+ };
@@ -2,5 +2,6 @@
2
2
  * 数字相关操作工具函数
3
3
  */
4
4
  export declare const numberUtils: {
5
+ toLetter: (num: number) => string;
5
6
  toMoney: (x: number) => string;
6
7
  };
@@ -0,0 +1,4 @@
1
+ declare const _default: {
2
+ toLetter: (num: number) => string;
3
+ };
4
+ export default _default;