@spacego/turbo-utils 0.0.1-alpha → 0.0.1-alpha.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/lib/cjs/day/dayjs.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/is/is-empty.js +1 -1
- package/lib/cjs/is/is-equals.js +1 -1
- package/lib/cjs/utils/classnames.js +1 -0
- package/lib/cjs/utils/query2params.js +1 -1
- package/lib/cjs/utils/util.js +1 -1
- package/lib/es/day/dayjs.js +21 -22
- package/lib/es/index.js +75 -74
- package/lib/es/is/is-empty.js +1 -1
- package/lib/es/is/is-equals.js +18 -9
- package/lib/es/utils/classnames.js +15 -0
- package/lib/es/utils/query2params.js +38 -40
- package/lib/es/utils/util.js +15 -18
- package/lib/types/is/index.d.ts +2 -2
- package/lib/types/is/is-empty.d.ts +1 -2
- package/lib/types/is/is-equals.d.ts +10 -2
- package/lib/types/utils/classnames.d.ts +1 -2
- package/lib/types/utils/util.d.ts +2 -6
- package/package.json +2 -1
- package/lib/cjs/calc/index.js +0 -1
- package/lib/es/calc/index.js +0 -13
package/lib/cjs/day/dayjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../_virtual/dayjs.min.js")
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../_virtual/dayjs.min.js"),c=require("../utils/util.js");function m(r){return r.replace(/\-/g,"/")}function d(r,e){const t=l.default(r);e===void 0&&(e="yyyy-MM-dd HH:mm:ss");const a={"M+":t.month()+1,"d+":t.date(),"h+":t.hour()%12===0?12:t.hour()%12,"H+":t.hour(),"m+":t.minute(),"s+":t.second(),"q+":Math.floor((t.month()+3)/3),S:t.millisecond()},o={0:"日",1:"一",2:"二",3:"三",4:"四",5:"五",6:"六"};/(y+)/.test(e)&&(e=e.replace(RegExp.$1,(t.year()+"").substr(4-RegExp.$1.length))),/(E+)/.test(e)&&(e=e.replace(RegExp.$1,(RegExp.$1.length>1?RegExp.$1.length>2?"星期":"周":"")+o[t.day()+""]));for(const n in a)new RegExp("("+n+")").test(e)&&(e=e.replace(RegExp.$1,RegExp.$1.length===1?a[n]:("00"+a[n]).substr((""+a[n]).length)));return e}const i=["日","一","二","三","四","五","六"];function f(r){const e=l.default(r),t={y:e.year()+"",m:e.month()+1+"",d:e.date()+"",h:e.hour()+"",mm:e.minute()+"",ss:e.second()+"",w:i[e.day()]};for(const a in t)Object.hasOwnProperty.call(t,a)&&!["y","w"].includes(a)&&(t[a]=c.padZero(t[a]));return t}function g(r){const e=l.default(r).valueOf(),t=l.default().valueOf(),a=t-e;if(a<0)return"未来的时间";const o=[{label:"年",value:365*24*60*60*1e3},{label:"月",value:720*60*60*1e3},{label:"周",value:10080*60*1e3},{label:"天",value:1440*60*1e3},{label:"小时",value:3600*1e3},{label:"分钟",value:60*1e3},{label:"刚刚",value:10*1e3}];if(a<o[o.length-1].value)return"刚刚";for(const{label:n,value:u}of o.slice(0,-1)){const s=a/u;if(s>=1)return n==="天"&&s<2?s===1?"昨天":"今天":`${Math.floor(s)} ${n}前`}return"刚刚"}function D(r,e){if(!r)return"";const t=l.default(r),{m:a,d:o,w:n}=f(r);if(e){const u=l.default(e);return t.format("YYYY-MM-DD")===u.format("YYYY-MM-DD")?`${a}月${o}日 周${n} ${t.format("HH:mm")}-${u.format("HH:mm")}`:`${t.format("MM月DD日 HH:mm")} - ${u.format("MM月DD日 HH:mm")}`}else return`${a}月${o}日 周${n} ${t.format("HH:mm")}`}exports.WEEK_DAY=i;exports.formatActivityTime=D;exports.formatDate=d;exports.formatIosDate=m;exports.getDateDiff=g;exports.getDateParams=f;
|
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./calc/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./calc/calc.js"),u=require("./node_modules/.pnpm/decimal.js@10.6.0/node_modules/decimal.js/decimal.js"),c=require("./_virtual/dayjs.min.js"),a=require("./day/dayjs.js"),e=require("./is/is.js"),d=require("./is/is-empty.js"),t=require("./is/is-equals.js"),m=require("./utils/classnames.js"),p=require("./utils/deep-clone.js"),y=require("./utils/pick.js"),s=require("./utils/query2params.js"),r=require("./utils/util.js"),n=require("./utils/uuid.js"),o=require("./validator/validate.js"),i=require("./validator/validator.js");exports.calc=l.default;exports.Decimal=u.Decimal;exports.dayjs=c.default;exports.WEEK_DAY=a.WEEK_DAY;exports.formatActivityTime=a.formatActivityTime;exports.formatDate=a.formatDate;exports.formatIosDate=a.formatIosDate;exports.getDateDiff=a.getDateDiff;exports.getDateParams=a.getDateParams;exports.isArray=e.isArray;exports.isBoolean=e.isBoolean;exports.isDate=e.isDate;exports.isFile=e.isFile;exports.isFunction=e.isFunction;exports.isMap=e.isMap;exports.isNull=e.isNull;exports.isNumber=e.isNumber;exports.isObject=e.isObject;exports.isPromise=e.isPromise;exports.isRegExp=e.isRegExp;exports.isSet=e.isSet;exports.isString=e.isString;exports.isUndefined=e.isUndefined;exports.isEmpty=d.isEmpty;exports.depsAreSame=t.depsAreSame;exports.isEquals=t.isEquals;exports.classnames=m.classnames;exports.deepClone=p.deepClone;exports.pick=y.pick;exports.filterParams=s.filterParams;exports.filterQuery=s.filterQuery;exports.filtrationEmpty=s.filtrationEmpty;exports.getUrlParam=s.getUrlParam;exports.json2params=s.json2params;exports.padQuery=s.padQuery;exports.params2json=s.params2json;exports.ObjectAssign=r.ObjectAssign;exports.browser=r.browser;exports.calculateDistance=r.calculateDistance;exports.encryptString=r.encryptString;exports.isBrowser=r.isBrowser;exports.padZero=r.padZero;exports.thousands=r.thousands;exports.randomString=n.randomString;exports.uuid=n.uuid;exports.validate=o.validate;exports.validateRequire=o.validateRequire;exports.isCard=i.isCard;exports.isCurrency=i.isCurrency;exports.isEmail=i.isEmail;exports.isIdCard=i.isIdCard;exports.isMobile=i.isMobile;exports.isPassport=i.isPassport;exports.isUrl=i.isUrl;exports.maxLength=i.maxLength;exports.minLength=i.minLength;exports.regs=i.regs;exports.required=i.required;exports.validateType=i.validateType;exports.validation=i.validation;
|
package/lib/cjs/is/is-empty.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(t){return!!(t==null||typeof t=="string"&&t.trim()===""||Array.isArray(t)&&t.length===0||typeof t=="object"&&Object.keys(t).length===0||typeof t=="number"&&t===0||typeof t>"u"||t instanceof Map&&t.size===0||t instanceof Set&&t.size===0)}exports.isEmpty=r;
|
package/lib/cjs/is/is-equals.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function f(r,t){if(r===t)return!0;if(r===null||t===null)return!1;if(Array.isArray(r)&&Array.isArray(t)){if(r.length!==t.length)return!1;for(let n=0;n<r.length;n++)if(!f(r[n],t[n]))return!1;return!0}if(typeof r!="object"||typeof t!="object")return!1;const e=Object.getOwnPropertyNames(r),s=Object.getOwnPropertyNames(t);if(e.length!==s.length)return!1;for(let n=0;n<e.length;n++){const i=e[n];if(!f(r[i],t[i]))return!1}return!0}function o(r,t){if(r===t)return!0;for(let e=0;e<r.length;e++)if(!Object.is(r[e],t[e]))return!1;return!0}exports.depsAreSame=o;exports.isEquals=f;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../is/is.js");function r(...c){return c.filter(s=>!!s).map(s=>{if(i.isObject(s)){const e=[];Object.keys(s).forEach(t=>{s[t]&&e.push(t)}),s=e.join(" ")}return s}).join(" ")}exports.classnames=r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./util.js"),E=require("../is/is.js"),o=require("../is/is-empty.js");function u(t,e="&"){return o.isEmpty(t)?{}:decodeURIComponent(t).replace(/^\?/,"").split(e).reduce((r,m)=>{const[s,y]=m.split("=");if(s){const a=y??"";r[s]&&typeof r[s]=="string"?r[s]=[r[s],a]:r[s]?r[s].push(a):r[s]=a}return r},{})}function p(t,e="&"){return o.isEmpty(t)?"":Object.keys(t).map(n=>{const i=t[n];return Array.isArray(i)?i.map(r=>`${n}=${r}`).join(e):`${n}=${i}`}).join(e)}function g(t,e){const n=d.isBrowser?window:{location:{search:""}},i=new RegExp("(^|&)"+t+"=([^&]*)(&|$)"),r=(e||n.location.search).substr(1).match(i);return r!=null?unescape(r[2]):null}function f(t){return Object.keys(t).forEach(e=>{(o.isEmpty(t[e])||t[e]==="undefined")&&t[e]!==0&&delete t[e]}),t}function c(t,e=[]){const n=E.isString(t);if(o.isEmpty(t))return n?"":{};const i=n?u(t):t;return e.forEach(r=>{delete i[r]}),n?p(i):i}function l(t,e){if(o.isEmpty(t))return"";t=decodeURIComponent(t);const[n,i]=t.split("?"),r=f(Object.assign({},u(i),f(Object.assign({},e||{}))));return`${n}?${p(r)}`}function h(t,e=[]){if(o.isEmpty(t))return"";const[n,i=""]=t.split("?");return l(n,u(c(i,e)))}exports.filterParams=c;exports.filterQuery=h;exports.filtrationEmpty=f;exports.getUrlParam=g;exports.json2params=p;exports.padQuery=l;exports.params2json=u;
|
package/lib/cjs/utils/util.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../is/is-empty.js"),l=require("../is/is.js"),p=!!(typeof window<"u"&&window.document&&window.document.createElement);function M(t,n,i){return c.isEmpty(t)||c.isEmpty(n)||Object.keys(t).forEach(e=>{n[e]!==void 0&&!(i!=null&&i.includes(e))&&(t[e]=n[e])}),t}function S(){var i,e;const t=(e=(i=navigator==null?void 0:navigator.userAgent)==null?void 0:i.toLowerCase)==null?void 0:e.call(i),n={ios:!!t.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/i),android:t.indexOf("android")>-1||t.indexOf("linux")>-1,iPad:t.indexOf("ipad")>-1,wechat:t.indexOf("micromessenger")>-1,aliPay:t.indexOf("alipay")>-1};return{...n,isMobile:n.android||n.ios||n.iPad}}function w(t,n=2){return t.toString().padStart(n,"0")}function O(t,n=[3,7],i="*",e){if(c.isEmpty(t))return"";if(typeof n=="number")return t.slice(0,n)+i.repeat(e||t.length-n);const[r,s]=n;return t.slice(0,r)+i.repeat(t.length-s)+t.slice(s)}const y=function(t,n=2,i=!0,e=","){const r=Number(t);if(l.isNumber(r)){let s="";if(l.isNumber(n))if(i)s=r.toFixed(n).toString();else{let o=String(r).split(".")[1];o=o?o.length:0,o>n&&(o=n),s=r.toFixed(o).toString()}else s=r.toString();const a=s.split(".");return a[0]=a[0].toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+(e||",")),a.join(".")}return t};function E(t,n){const e=h=>h*(Math.PI/180),r=e(t.latitude),s=e(t.longitude),a=e(n.latitude),o=e(n.longitude),f=a-r,g=o-s,d=Math.pow(Math.sin(f/2),2)+Math.cos(r)*Math.cos(a)*Math.pow(Math.sin(g/2),2),u=6371*(2*Math.atan2(Math.sqrt(d),Math.sqrt(1-d))),m=u*1e3;return{km:Number(u.toFixed(2)),m:Math.round(m)}}exports.ObjectAssign=M;exports.browser=S;exports.calculateDistance=E;exports.encryptString=O;exports.isBrowser=p;exports.padZero=w;exports.thousands=y;
|
package/lib/es/day/dayjs.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import l from "../_virtual/dayjs.min.js";
|
|
2
|
-
import "../calc/index.js";
|
|
3
2
|
import { padZero as i } from "../utils/util.js";
|
|
4
|
-
function
|
|
5
|
-
return
|
|
3
|
+
function $(n) {
|
|
4
|
+
return n.replace(/\-/g, "/");
|
|
6
5
|
}
|
|
7
|
-
function h(
|
|
8
|
-
const t = l(
|
|
6
|
+
function h(n, e) {
|
|
7
|
+
const t = l(n);
|
|
9
8
|
e === void 0 && (e = "yyyy-MM-dd HH:mm:ss");
|
|
10
9
|
const r = {
|
|
11
10
|
"M+": t.month() + 1,
|
|
@@ -37,16 +36,16 @@ function h(o, e) {
|
|
|
37
36
|
RegExp.$1,
|
|
38
37
|
(RegExp.$1.length > 1 ? RegExp.$1.length > 2 ? "星期" : "周" : "") + a[t.day() + ""]
|
|
39
38
|
));
|
|
40
|
-
for (const
|
|
41
|
-
new RegExp("(" +
|
|
39
|
+
for (const o in r)
|
|
40
|
+
new RegExp("(" + o + ")").test(e) && (e = e.replace(
|
|
42
41
|
RegExp.$1,
|
|
43
|
-
RegExp.$1.length === 1 ? r[
|
|
42
|
+
RegExp.$1.length === 1 ? r[o] : ("00" + r[o]).substr(("" + r[o]).length)
|
|
44
43
|
));
|
|
45
44
|
return e;
|
|
46
45
|
}
|
|
47
46
|
const f = ["日", "一", "二", "三", "四", "五", "六"];
|
|
48
|
-
function c(
|
|
49
|
-
const e = l(
|
|
47
|
+
function c(n) {
|
|
48
|
+
const e = l(n), t = {
|
|
50
49
|
/* 年 */
|
|
51
50
|
y: e.year() + "",
|
|
52
51
|
/** 月 */
|
|
@@ -66,8 +65,8 @@ function c(o) {
|
|
|
66
65
|
Object.hasOwnProperty.call(t, r) && !["y", "w"].includes(r) && (t[r] = i(t[r]));
|
|
67
66
|
return t;
|
|
68
67
|
}
|
|
69
|
-
function
|
|
70
|
-
const e = l(
|
|
68
|
+
function p(n) {
|
|
69
|
+
const e = l(n).valueOf(), t = l().valueOf(), r = t - e;
|
|
71
70
|
if (r < 0) return "未来的时间";
|
|
72
71
|
const a = [
|
|
73
72
|
{ label: "年", value: 365 * 24 * 60 * 60 * 1e3 },
|
|
@@ -79,27 +78,27 @@ function g(o) {
|
|
|
79
78
|
{ label: "刚刚", value: 10 * 1e3 }
|
|
80
79
|
];
|
|
81
80
|
if (r < a[a.length - 1].value) return "刚刚";
|
|
82
|
-
for (const { label:
|
|
81
|
+
for (const { label: o, value: u } of a.slice(0, -1)) {
|
|
83
82
|
const s = r / u;
|
|
84
83
|
if (s >= 1)
|
|
85
|
-
return
|
|
84
|
+
return o === "天" && s < 2 ? s === 1 ? "昨天" : "今天" : `${Math.floor(s)} ${o}前`;
|
|
86
85
|
}
|
|
87
86
|
return "刚刚";
|
|
88
87
|
}
|
|
89
|
-
function
|
|
90
|
-
if (!
|
|
91
|
-
const t = l(
|
|
88
|
+
function g(n, e) {
|
|
89
|
+
if (!n) return "";
|
|
90
|
+
const t = l(n), { m: r, d: a, w: o } = c(n);
|
|
92
91
|
if (e) {
|
|
93
92
|
const u = l(e);
|
|
94
|
-
return t.format("YYYY-MM-DD") === u.format("YYYY-MM-DD") ? `${r}月${a}日 周${
|
|
93
|
+
return t.format("YYYY-MM-DD") === u.format("YYYY-MM-DD") ? `${r}月${a}日 周${o} ${t.format("HH:mm")}-${u.format("HH:mm")}` : `${t.format("MM月DD日 HH:mm")} - ${u.format("MM月DD日 HH:mm")}`;
|
|
95
94
|
} else
|
|
96
|
-
return `${r}月${a}日 周${
|
|
95
|
+
return `${r}月${a}日 周${o} ${t.format("HH:mm")}`;
|
|
97
96
|
}
|
|
98
97
|
export {
|
|
99
98
|
f as WEEK_DAY,
|
|
100
|
-
|
|
99
|
+
g as formatActivityTime,
|
|
101
100
|
h as formatDate,
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
$ as formatIosDate,
|
|
102
|
+
p as getDateDiff,
|
|
104
103
|
c as getDateParams
|
|
105
104
|
};
|
package/lib/es/index.js
CHANGED
|
@@ -1,76 +1,77 @@
|
|
|
1
|
-
import "./calc/
|
|
2
|
-
import {
|
|
3
|
-
import { default as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { deepClone as
|
|
10
|
-
import { pick as
|
|
11
|
-
import { filterParams as
|
|
12
|
-
import { ObjectAssign as
|
|
13
|
-
import { randomString as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
1
|
+
import { default as i } from "./calc/calc.js";
|
|
2
|
+
import { Decimal as a } from "./node_modules/.pnpm/decimal.js@10.6.0/node_modules/decimal.js/decimal.js";
|
|
3
|
+
import { default as s } from "./_virtual/dayjs.min.js";
|
|
4
|
+
import { WEEK_DAY as p, formatActivityTime as f, formatDate as l, formatIosDate as n, getDateDiff as d, getDateParams as x } from "./day/dayjs.js";
|
|
5
|
+
import { isArray as c, isBoolean as g, isDate as y, isFile as D, isFunction as E, isMap as b, isNull as j, isNumber as v, isObject as A, isPromise as P, isRegExp as S, isSet as C, isString as h, isUndefined as q } from "./is/is.js";
|
|
6
|
+
import { isEmpty as w } from "./is/is-empty.js";
|
|
7
|
+
import { depsAreSame as F, isEquals as I } from "./is/is-equals.js";
|
|
8
|
+
import { classnames as M } from "./utils/classnames.js";
|
|
9
|
+
import { deepClone as O } from "./utils/deep-clone.js";
|
|
10
|
+
import { pick as R } from "./utils/pick.js";
|
|
11
|
+
import { filterParams as k, filterQuery as K, filtrationEmpty as W, getUrlParam as Y, json2params as Z, padQuery as _, params2json as z } from "./utils/query2params.js";
|
|
12
|
+
import { ObjectAssign as H, browser as J, calculateDistance as V, encryptString as X, isBrowser as $, padZero as rr, thousands as er } from "./utils/util.js";
|
|
13
|
+
import { randomString as tr, uuid as ar } from "./utils/uuid.js";
|
|
14
|
+
import { validate as sr, validateRequire as mr } from "./validator/validate.js";
|
|
15
|
+
import { isCard as fr, isCurrency as lr, isEmail as nr, isIdCard as dr, isMobile as xr, isPassport as ur, isUrl as cr, maxLength as gr, minLength as yr, regs as Dr, required as Er, validateType as br, validation as jr } from "./validator/validator.js";
|
|
16
16
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
C as
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
17
|
+
a as Decimal,
|
|
18
|
+
H as ObjectAssign,
|
|
19
|
+
p as WEEK_DAY,
|
|
20
|
+
J as browser,
|
|
21
|
+
i as calc,
|
|
22
|
+
V as calculateDistance,
|
|
23
|
+
M as classnames,
|
|
24
|
+
s as dayjs,
|
|
25
|
+
O as deepClone,
|
|
26
|
+
F as depsAreSame,
|
|
27
|
+
X as encryptString,
|
|
28
|
+
k as filterParams,
|
|
29
|
+
K as filterQuery,
|
|
30
|
+
W as filtrationEmpty,
|
|
31
|
+
f as formatActivityTime,
|
|
32
|
+
l as formatDate,
|
|
33
|
+
n as formatIosDate,
|
|
34
|
+
d as getDateDiff,
|
|
35
|
+
x as getDateParams,
|
|
36
|
+
Y as getUrlParam,
|
|
37
|
+
c as isArray,
|
|
38
|
+
g as isBoolean,
|
|
39
|
+
$ as isBrowser,
|
|
40
|
+
fr as isCard,
|
|
41
|
+
lr as isCurrency,
|
|
42
|
+
y as isDate,
|
|
43
|
+
nr as isEmail,
|
|
44
|
+
w as isEmpty,
|
|
45
|
+
I as isEquals,
|
|
46
|
+
D as isFile,
|
|
47
|
+
E as isFunction,
|
|
48
|
+
dr as isIdCard,
|
|
49
|
+
b as isMap,
|
|
50
|
+
xr as isMobile,
|
|
51
|
+
j as isNull,
|
|
52
|
+
v as isNumber,
|
|
53
|
+
A as isObject,
|
|
54
|
+
ur as isPassport,
|
|
55
|
+
P as isPromise,
|
|
56
|
+
S as isRegExp,
|
|
57
|
+
C as isSet,
|
|
58
|
+
h as isString,
|
|
59
|
+
q as isUndefined,
|
|
60
|
+
cr as isUrl,
|
|
61
|
+
Z as json2params,
|
|
62
|
+
gr as maxLength,
|
|
63
|
+
yr as minLength,
|
|
64
|
+
_ as padQuery,
|
|
65
|
+
rr as padZero,
|
|
66
|
+
z as params2json,
|
|
67
|
+
R as pick,
|
|
68
|
+
tr as randomString,
|
|
69
|
+
Dr as regs,
|
|
70
|
+
Er as required,
|
|
71
|
+
er as thousands,
|
|
72
|
+
ar as uuid,
|
|
73
|
+
sr as validate,
|
|
74
|
+
mr as validateRequire,
|
|
75
|
+
br as validateType,
|
|
76
|
+
jr as validation
|
|
76
77
|
};
|
package/lib/es/is/is-empty.js
CHANGED
|
@@ -2,5 +2,5 @@ function t(r) {
|
|
|
2
2
|
return !!(r == null || typeof r == "string" && r.trim() === "" || Array.isArray(r) && r.length === 0 || typeof r == "object" && Object.keys(r).length === 0 || typeof r == "number" && r === 0 || typeof r > "u" || r instanceof Map && r.size === 0 || r instanceof Set && r.size === 0);
|
|
3
3
|
}
|
|
4
4
|
export {
|
|
5
|
-
t as
|
|
5
|
+
t as isEmpty
|
|
6
6
|
};
|
package/lib/es/is/is-equals.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function i(r, t) {
|
|
2
2
|
if (r === t)
|
|
3
3
|
return !0;
|
|
4
4
|
if (r === null || t === null)
|
|
@@ -6,23 +6,32 @@ function s(r, t) {
|
|
|
6
6
|
if (Array.isArray(r) && Array.isArray(t)) {
|
|
7
7
|
if (r.length !== t.length)
|
|
8
8
|
return !1;
|
|
9
|
-
for (let
|
|
10
|
-
if (!
|
|
9
|
+
for (let n = 0; n < r.length; n++)
|
|
10
|
+
if (!i(r[n], t[n]))
|
|
11
11
|
return !1;
|
|
12
12
|
return !0;
|
|
13
13
|
}
|
|
14
14
|
if (typeof r != "object" || typeof t != "object")
|
|
15
15
|
return !1;
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
16
|
+
const e = Object.getOwnPropertyNames(r), s = Object.getOwnPropertyNames(t);
|
|
17
|
+
if (e.length !== s.length)
|
|
18
18
|
return !1;
|
|
19
|
-
for (let
|
|
20
|
-
const f = n
|
|
21
|
-
if (!
|
|
19
|
+
for (let n = 0; n < e.length; n++) {
|
|
20
|
+
const f = e[n];
|
|
21
|
+
if (!i(r[f], t[f]))
|
|
22
22
|
return !1;
|
|
23
23
|
}
|
|
24
24
|
return !0;
|
|
25
25
|
}
|
|
26
|
+
function o(r, t) {
|
|
27
|
+
if (r === t)
|
|
28
|
+
return !0;
|
|
29
|
+
for (let e = 0; e < r.length; e++)
|
|
30
|
+
if (!Object.is(r[e], t[e]))
|
|
31
|
+
return !1;
|
|
32
|
+
return !0;
|
|
33
|
+
}
|
|
26
34
|
export {
|
|
27
|
-
|
|
35
|
+
o as depsAreSame,
|
|
36
|
+
i as isEquals
|
|
28
37
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { isObject as r } from "../is/is.js";
|
|
2
|
+
function n(...o) {
|
|
3
|
+
return o.filter((s) => !!s).map((s) => {
|
|
4
|
+
if (r(s)) {
|
|
5
|
+
const t = [];
|
|
6
|
+
Object.keys(s).forEach((c) => {
|
|
7
|
+
s[c] && t.push(c);
|
|
8
|
+
}), s = t.join(" ");
|
|
9
|
+
}
|
|
10
|
+
return s;
|
|
11
|
+
}).join(" ");
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
n as classnames
|
|
15
|
+
};
|
|
@@ -1,57 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../calc/index.js";
|
|
3
|
-
import "../_virtual/dayjs.min.js";
|
|
1
|
+
import { isBrowser as l } from "./util.js";
|
|
4
2
|
import { isString as d } from "../is/is.js";
|
|
5
|
-
import
|
|
6
|
-
function f(
|
|
7
|
-
return
|
|
8
|
-
const [
|
|
9
|
-
if (
|
|
10
|
-
const u =
|
|
11
|
-
|
|
3
|
+
import { isEmpty as o } from "../is/is-empty.js";
|
|
4
|
+
function f(n, r = "&") {
|
|
5
|
+
return o(n) ? {} : decodeURIComponent(n).replace(/^\?/, "").split(r).reduce((t, c) => {
|
|
6
|
+
const [s, m] = c.split("=");
|
|
7
|
+
if (s) {
|
|
8
|
+
const u = m ?? "";
|
|
9
|
+
t[s] && typeof t[s] == "string" ? t[s] = [t[s], u] : t[s] ? t[s].push(u) : t[s] = u;
|
|
12
10
|
}
|
|
13
|
-
return
|
|
11
|
+
return t;
|
|
14
12
|
}, {});
|
|
15
13
|
}
|
|
16
|
-
function p(
|
|
17
|
-
return
|
|
18
|
-
const i =
|
|
19
|
-
return Array.isArray(i) ? i.map((
|
|
20
|
-
}).join(
|
|
14
|
+
function p(n, r = "&") {
|
|
15
|
+
return o(n) ? "" : Object.keys(n).map((e) => {
|
|
16
|
+
const i = n[e];
|
|
17
|
+
return Array.isArray(i) ? i.map((t) => `${e}=${t}`).join(r) : `${e}=${i}`;
|
|
18
|
+
}).join(r);
|
|
21
19
|
}
|
|
22
|
-
function
|
|
23
|
-
const e = l ? window : { location: { search: "" } }, i = new RegExp("(^|&)" +
|
|
24
|
-
return
|
|
20
|
+
function E(n, r) {
|
|
21
|
+
const e = l ? window : { location: { search: "" } }, i = new RegExp("(^|&)" + n + "=([^&]*)(&|$)"), t = (r || e.location.search).substr(1).match(i);
|
|
22
|
+
return t != null ? unescape(t[2]) : null;
|
|
25
23
|
}
|
|
26
|
-
function a(
|
|
27
|
-
return Object.keys(
|
|
28
|
-
(
|
|
29
|
-
}),
|
|
24
|
+
function a(n) {
|
|
25
|
+
return Object.keys(n).forEach((r) => {
|
|
26
|
+
(o(n[r]) || n[r] === "undefined") && n[r] !== 0 && delete n[r];
|
|
27
|
+
}), n;
|
|
30
28
|
}
|
|
31
|
-
function h(
|
|
32
|
-
const e = d(
|
|
33
|
-
if (
|
|
34
|
-
const i = e ? f(
|
|
35
|
-
return
|
|
36
|
-
delete i[
|
|
29
|
+
function h(n, r = []) {
|
|
30
|
+
const e = d(n);
|
|
31
|
+
if (o(n)) return e ? "" : {};
|
|
32
|
+
const i = e ? f(n) : n;
|
|
33
|
+
return r.forEach((t) => {
|
|
34
|
+
delete i[t];
|
|
37
35
|
}), e ? p(i) : i;
|
|
38
36
|
}
|
|
39
|
-
function y(
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
const [e, i] =
|
|
43
|
-
return `${e}?${p(
|
|
37
|
+
function y(n, r) {
|
|
38
|
+
if (o(n)) return "";
|
|
39
|
+
n = decodeURIComponent(n);
|
|
40
|
+
const [e, i] = n.split("?"), t = a(Object.assign({}, f(i), a(Object.assign({}, r || {}))));
|
|
41
|
+
return `${e}?${p(t)}`;
|
|
44
42
|
}
|
|
45
|
-
function
|
|
46
|
-
if (
|
|
47
|
-
const [e, i = ""] =
|
|
48
|
-
return y(e, f(h(i,
|
|
43
|
+
function P(n, r = []) {
|
|
44
|
+
if (o(n)) return "";
|
|
45
|
+
const [e, i = ""] = n.split("?");
|
|
46
|
+
return y(e, f(h(i, r)));
|
|
49
47
|
}
|
|
50
48
|
export {
|
|
51
49
|
h as filterParams,
|
|
52
|
-
|
|
50
|
+
P as filterQuery,
|
|
53
51
|
a as filtrationEmpty,
|
|
54
|
-
|
|
52
|
+
E as getUrlParam,
|
|
55
53
|
p as json2params,
|
|
56
54
|
y as padQuery,
|
|
57
55
|
f as params2json
|
package/lib/es/utils/util.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../_virtual/dayjs.min.js";
|
|
1
|
+
import { isEmpty as c } from "../is/is-empty.js";
|
|
3
2
|
import { isNumber as f } from "../is/is.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function R(t, n, e) {
|
|
3
|
+
const S = !!(typeof window < "u" && window.document && window.document.createElement);
|
|
4
|
+
function O(t, n, e) {
|
|
7
5
|
return c(t) || c(n) || Object.keys(t).forEach((i) => {
|
|
8
6
|
n[i] !== void 0 && !(e != null && e.includes(i)) && (t[i] = n[i]);
|
|
9
7
|
}), t;
|
|
10
8
|
}
|
|
11
|
-
function
|
|
9
|
+
function x() {
|
|
12
10
|
var e, i;
|
|
13
11
|
const t = (i = (e = navigator == null ? void 0 : navigator.userAgent) == null ? void 0 : e.toLowerCase) == null ? void 0 : i.call(e), n = {
|
|
14
12
|
ios: !!t.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/i),
|
|
@@ -22,7 +20,7 @@ function P() {
|
|
|
22
20
|
isMobile: n.android || n.ios || n.iPad
|
|
23
21
|
};
|
|
24
22
|
}
|
|
25
|
-
function
|
|
23
|
+
function A(t, n = 2) {
|
|
26
24
|
return t.toString().padStart(n, "0");
|
|
27
25
|
}
|
|
28
26
|
function E(t, n = [3, 7], e = "*", i) {
|
|
@@ -32,7 +30,7 @@ function E(t, n = [3, 7], e = "*", i) {
|
|
|
32
30
|
const [o, r] = n;
|
|
33
31
|
return t.slice(0, o) + e.repeat(t.length - r) + t.slice(r);
|
|
34
32
|
}
|
|
35
|
-
const
|
|
33
|
+
const P = function(t, n = 2, e = !0, i = ",") {
|
|
36
34
|
const o = Number(t);
|
|
37
35
|
if (f(o)) {
|
|
38
36
|
let r = "";
|
|
@@ -50,22 +48,21 @@ const U = function(t, n = 2, e = !0, i = ",") {
|
|
|
50
48
|
}
|
|
51
49
|
return t;
|
|
52
50
|
};
|
|
53
|
-
function
|
|
54
|
-
const i = (
|
|
51
|
+
function R(t, n) {
|
|
52
|
+
const i = (h) => h * (Math.PI / 180), o = i(t.latitude), r = i(t.longitude), s = i(n.latitude), a = i(n.longitude), l = s - o, m = a - r, d = Math.pow(Math.sin(l / 2), 2) + Math.cos(o) * Math.cos(s) * Math.pow(Math.sin(m / 2), 2), u = 6371 * (2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d))), g = u * 1e3;
|
|
55
53
|
return {
|
|
56
54
|
km: Number(u.toFixed(2)),
|
|
57
55
|
// 保留两位小数
|
|
58
|
-
m: Math.round(
|
|
56
|
+
m: Math.round(g)
|
|
59
57
|
// 四舍五入到整数
|
|
60
58
|
};
|
|
61
59
|
}
|
|
62
60
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
O as ObjectAssign,
|
|
62
|
+
x as browser,
|
|
63
|
+
R as calculateDistance,
|
|
66
64
|
E as encryptString,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
U as thousands
|
|
65
|
+
S as isBrowser,
|
|
66
|
+
A as padZero,
|
|
67
|
+
P as thousands
|
|
71
68
|
};
|
package/lib/types/is/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './is';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export * from './is-empty';
|
|
3
|
+
export * from './is-equals';
|
|
@@ -7,5 +7,13 @@
|
|
|
7
7
|
* const a = { a: 1 }; const b = { a: 1 };
|
|
8
8
|
* isEquals(a) => true
|
|
9
9
|
*/
|
|
10
|
-
declare function isEquals(value1: any, value2: any): boolean;
|
|
11
|
-
|
|
10
|
+
export declare function isEquals(value1: any, value2: any): boolean;
|
|
11
|
+
type DependencyList = readonly unknown[];
|
|
12
|
+
/**
|
|
13
|
+
* 判断依赖项是否相同-浅比较
|
|
14
|
+
* @param oldDeps 旧的依赖项
|
|
15
|
+
* @param newDeps 新的依赖项
|
|
16
|
+
* @returns 是否相同
|
|
17
|
+
*/
|
|
18
|
+
export declare function depsAreSame(oldDeps: DependencyList, newDeps: DependencyList): boolean;
|
|
19
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spacego/turbo-utils",
|
|
3
|
-
"version": "0.0.1-alpha",
|
|
3
|
+
"version": "0.0.1-alpha.1",
|
|
4
4
|
"description": "🚀 A universal tool library. It basically covers all the commonly used practical functions. ",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/cjs/index.js",
|
|
7
7
|
"module": "lib/es/index.js",
|
|
8
8
|
"typings": "lib/types/index.d.ts",
|
|
9
|
+
"sideEffects": false,
|
|
9
10
|
"exports": {
|
|
10
11
|
".": {
|
|
11
12
|
"types": "./lib/types/index.d.ts",
|
package/lib/cjs/calc/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./calc.js"),i=require("../node_modules/.pnpm/decimal.js@10.6.0/node_modules/decimal.js/decimal.js");Number.prototype.toFixedNew=function(t){let e=this;return e<0?(e=e*-1,(Math.round(o.default.multiply(e,Math.pow(10,t)))/Math.pow(10,t)*-1).toFixed(t)):(Math.round(o.default.multiply(e,Math.pow(10,t)))/Math.pow(10,t)).toFixed(t)};Number.prototype.countDecimals=function(){return Math.floor(this.valueOf())===this.valueOf()?0:this.toString().split(".")[1].length||0};exports.calc=o.default;exports.Decimal=i.Decimal;
|
package/lib/es/calc/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import r from "./calc.js";
|
|
2
|
-
import { Decimal as p } from "../node_modules/.pnpm/decimal.js@10.6.0/node_modules/decimal.js/decimal.js";
|
|
3
|
-
Number.prototype.toFixedNew = function(t) {
|
|
4
|
-
let o = this;
|
|
5
|
-
return o < 0 ? (o = o * -1, (Math.round(r.multiply(o, Math.pow(10, t))) / Math.pow(10, t) * -1).toFixed(t)) : (Math.round(r.multiply(o, Math.pow(10, t))) / Math.pow(10, t)).toFixed(t);
|
|
6
|
-
};
|
|
7
|
-
Number.prototype.countDecimals = function() {
|
|
8
|
-
return Math.floor(this.valueOf()) === this.valueOf() ? 0 : this.toString().split(".")[1].length || 0;
|
|
9
|
-
};
|
|
10
|
-
export {
|
|
11
|
-
p as Decimal,
|
|
12
|
-
r as calc
|
|
13
|
-
};
|