wjk-util 0.0.4 → 0.0.6

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/package.json CHANGED
@@ -1,42 +1,43 @@
1
- {
2
- "name": "wjk-util",
3
- "version": "0.0.4",
4
- "type": "module",
5
- "description": "一个包含常见 JavaScript 函数的实用库",
6
- "author": "wjk",
7
- "license": "MIT",
8
- "repository": {
9
- "type": "gitee",
10
- "url": "https://gitee.com/wjkfree/f-util.git"
11
- },
12
- "homepage": "https://gitee.com/wjkfree/f-util#readme",
13
- "keywords": [
14
- "utility",
15
- "functions",
16
- "typescript"
17
- ],
18
- "files": [
19
- "dist",
20
- "types"
21
- ],
22
- "main": "./dist/f-util.umd.js",
23
- "module": "./dist/f-util.es.js",
24
- "types": "./types/index.d.ts",
25
- "exports": {
26
- "types": "./types/index.d.ts",
27
- "import": "./dist/f-util.es.js",
28
- "require": "./dist/f-util.umd.js"
29
- },
30
- "sideEffects": false,
31
- "scripts": {
32
- "dev": "vite",
33
- "build": "vite build",
34
- "release": "npm version patch && npm publish"
35
- },
36
- "devDependencies": {
37
- "terser": "^5.46.0",
38
- "typescript": "~5.9.3",
39
- "vite": "^7.3.1",
40
- "vite-plugin-dts": "^4.5.4"
41
- }
42
- }
1
+ {
2
+ "name": "wjk-util",
3
+ "version": "0.0.6",
4
+ "type": "module",
5
+ "description": "一个包含常见 JavaScript 函数的实用库",
6
+ "author": "wjk",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "gitee",
10
+ "url": "https://gitee.com/wjkfree/wjk-util.git"
11
+ },
12
+ "homepage": "https://gitee.com/wjkfree/wjk-util#readme",
13
+ "keywords": [
14
+ "utility",
15
+ "functions",
16
+ "typescript"
17
+ ],
18
+ "files": [
19
+ "dist",
20
+ "types"
21
+ ],
22
+ "main": "./dist/wjk-util.umd.js",
23
+ "module": "./dist/wjk-util.es.js",
24
+ "types": "./types/index.d.ts",
25
+ "exports": {
26
+ "types": "./types/index.d.ts",
27
+ "import": "./dist/wjk-util.es.js",
28
+ "require": "./dist/wjk-util.umd.js"
29
+ },
30
+ "sideEffects": false,
31
+ "scripts": {
32
+ "dev": "vite",
33
+ "build": "vite build",
34
+ "patch": "npm version patch",
35
+ "publish": "npm publish"
36
+ },
37
+ "devDependencies": {
38
+ "terser": "^5.46.0",
39
+ "typescript": "~5.9.3",
40
+ "vite": "^7.3.1",
41
+ "vite-plugin-dts": "^4.5.4"
42
+ }
43
+ }
package/dist/f-util.es.js DELETED
@@ -1 +0,0 @@
1
- function r(r){return Object.prototype.toString.call(r).slice(8,-1).toLowerCase()}function t(r){return Array.isArray(r)}function n(t){return"object"===r(t)}function e(r){return"function"==typeof r}function o(r){return"string"==typeof r}function u(r){return"number"==typeof r&&!isNaN(r)}function c(r){return"boolean"==typeof r}function i(r){return null===r}function a(r){return void 0===r}function f(r){return!(!i(r)&&!a(r))||(o(r)||t(r)?0===r.length:!!n(r)&&0===Object.keys(r).length)}function s(r){if(!Array.isArray(r))throw new Error("参数必须是数组");return[...new Set(r)]}function l(r,t=1){if(!Array.isArray(r))throw new Error("参数必须是数组");return t<=0?r.slice():r.reduce((r,n)=>r.concat(Array.isArray(n)?l(n,t-1):[n]),[])}function y(r,t=1){if(!Array.isArray(r))throw new Error("参数必须是数组");if(t<=0)return[];const n=[];for(let e=0;e<r.length;e+=t)n.push(r.slice(e,e+t));return n}function h(r){if(Array.isArray(r)&&0!==r.length)return Math.max(...r)}function g(r){if(Array.isArray(r)&&0!==r.length)return Math.min(...r)}function A(r){if(!Array.isArray(r))throw new Error("参数必须是数组");return r.reduce((r,t)=>r+t,0)}function p(r){if(Array.isArray(r)&&0!==r.length)return A(r)/r.length}function b(r){if(null===r||"object"!=typeof r)return r;if(r instanceof Date)return new Date(r.getTime());if(r instanceof Array)return r.map(r=>b(r));if(r instanceof Object){const t={};for(let n in r)r.hasOwnProperty(n)&&(t[n]=b(r[n]));return t}return r}function m(...r){const t={};return r.forEach(r=>{r&&"object"==typeof r&&Object.keys(r).forEach(n=>{const e=n;void 0!==r[e]&&(t[e]=r[e])})}),t}function w(r){return"object"!=typeof r||null===r?[]:Object.keys(r)}function j(r){return"object"!=typeof r||null===r?[]:Object.values(r)}function S(r,t){return"object"==typeof r&&null!==r&&r.hasOwnProperty(t)}function M(r,t){return Math.floor(Math.random()*(t-r+1))+r}function O(r,t,n){return Math.min(Math.max(r,t),n)}function d(r){return r*(Math.PI/180)}function E(r){return r*(180/Math.PI)}function x(r,t){const n=t.x-r.x,e=t.y-r.y;return Math.sqrt(n*n+e*e)}function I(r,t){return Number(Math.round(parseFloat(r+"e"+t))+"e-"+t)}function N(r,t,n=!1){try{(n?sessionStorage:localStorage).setItem(r,JSON.stringify(t))}catch(e){console.error("存储失败:",e)}}function v(r,t=!1){try{const n=(t?sessionStorage:localStorage).getItem(r);return n?JSON.parse(n):null}catch(n){return console.error("获取存储失败:",n),null}}function P(r,t=!1){try{(t?sessionStorage:localStorage).removeItem(r)}catch(n){console.error("删除存储失败:",n)}}function k(r=!1){try{(r?sessionStorage:localStorage).clear()}catch(t){console.error("清空存储失败:",t)}}export{p as average,y as chunk,O as clamp,k as clearStorage,b as deepClone,d as degreesToRadians,x as distance,l as flatten,v as getStorage,r as getType,S as hasKey,t as isArray,c as isBoolean,f as isEmpty,e as isFunction,i as isNull,u as isNumber,n as isObject,o as isString,a as isUndefined,w as keys,h as max,m as merge,g as min,E as radiansToDegrees,M as randomInt,P as removeStorage,I as round,N as setStorage,A as sum,s as unique,j as values};
@@ -1 +0,0 @@
1
- !function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self).FUtil={})}(this,function(r){"use strict";function e(r){return Object.prototype.toString.call(r).slice(8,-1).toLowerCase()}function t(r){return Array.isArray(r)}function n(r){return"object"===e(r)}function o(r){return"string"==typeof r}function i(r){return null===r}function u(r){return void 0===r}function a(r){if(!Array.isArray(r))throw new Error("参数必须是数组");return r.reduce((r,e)=>r+e,0)}r.average=function(r){if(Array.isArray(r)&&0!==r.length)return a(r)/r.length},r.chunk=function(r,e=1){if(!Array.isArray(r))throw new Error("参数必须是数组");if(e<=0)return[];const t=[];for(let n=0;n<r.length;n+=e)t.push(r.slice(n,n+e));return t},r.clamp=function(r,e,t){return Math.min(Math.max(r,e),t)},r.clearStorage=function(r=!1){try{(r?sessionStorage:localStorage).clear()}catch(e){console.error("清空存储失败:",e)}},r.deepClone=function r(e){if(null===e||"object"!=typeof e)return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof Array)return e.map(e=>r(e));if(e instanceof Object){const t={};for(let n in e)e.hasOwnProperty(n)&&(t[n]=r(e[n]));return t}return e},r.degreesToRadians=function(r){return r*(Math.PI/180)},r.distance=function(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)},r.flatten=function r(e,t=1){if(!Array.isArray(e))throw new Error("参数必须是数组");return t<=0?e.slice():e.reduce((e,n)=>e.concat(Array.isArray(n)?r(n,t-1):[n]),[])},r.getStorage=function(r,e=!1){try{const t=(e?sessionStorage:localStorage).getItem(r);return t?JSON.parse(t):null}catch(t){return console.error("获取存储失败:",t),null}},r.getType=e,r.hasKey=function(r,e){return"object"==typeof r&&null!==r&&r.hasOwnProperty(e)},r.isArray=t,r.isBoolean=function(r){return"boolean"==typeof r},r.isEmpty=function(r){return!(!i(r)&&!u(r))||(o(r)||t(r)?0===r.length:!!n(r)&&0===Object.keys(r).length)},r.isFunction=function(r){return"function"==typeof r},r.isNull=i,r.isNumber=function(r){return"number"==typeof r&&!isNaN(r)},r.isObject=n,r.isString=o,r.isUndefined=u,r.keys=function(r){return"object"!=typeof r||null===r?[]:Object.keys(r)},r.max=function(r){if(Array.isArray(r)&&0!==r.length)return Math.max(...r)},r.merge=function(...r){const e={};return r.forEach(r=>{r&&"object"==typeof r&&Object.keys(r).forEach(t=>{const n=t;void 0!==r[n]&&(e[n]=r[n])})}),e},r.min=function(r){if(Array.isArray(r)&&0!==r.length)return Math.min(...r)},r.radiansToDegrees=function(r){return r*(180/Math.PI)},r.randomInt=function(r,e){return Math.floor(Math.random()*(e-r+1))+r},r.removeStorage=function(r,e=!1){try{(e?sessionStorage:localStorage).removeItem(r)}catch(t){console.error("删除存储失败:",t)}},r.round=function(r,e){return Number(Math.round(parseFloat(r+"e"+e))+"e-"+e)},r.setStorage=function(r,e,t=!1){try{(t?sessionStorage:localStorage).setItem(r,JSON.stringify(e))}catch(n){console.error("存储失败:",n)}},r.sum=a,r.unique=function(r){if(!Array.isArray(r))throw new Error("参数必须是数组");return[...new Set(r)]},r.values=function(r){return"object"!=typeof r||null===r?[]:Object.values(r)},Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
package/dist/vite.svg DELETED
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="77" height="47" fill="none" aria-labelledby="vite-logo-title" viewBox="0 0 77 47"><title id="vite-logo-title">Vite</title><style>.parenthesis{fill:#000}@media (prefers-color-scheme:dark){.parenthesis{fill:#fff}}</style><path fill="#9135ff" d="M40.151 45.71c-.663.844-2.02.374-2.02-.699V34.708a2.26 2.26 0 0 0-2.262-2.262H24.493c-.92 0-1.457-1.04-.92-1.788l7.479-10.471c1.07-1.498 0-3.578-1.842-3.578H15.443c-.92 0-1.456-1.04-.92-1.788l9.696-13.576c.213-.297.556-.474.92-.474h28.894c.92 0 1.456 1.04.92 1.788l-7.48 10.472c-1.07 1.497 0 3.578 1.842 3.578h11.376c.944 0 1.474 1.087.89 1.83L40.153 45.712z"/><mask id="a" width="48" height="47" x="14" y="0" maskUnits="userSpaceOnUse" style="mask-type:alpha"><path fill="#000" d="M40.047 45.71c-.663.843-2.02.374-2.02-.699V34.708a2.26 2.26 0 0 0-2.262-2.262H24.389c-.92 0-1.457-1.04-.92-1.788l7.479-10.472c1.07-1.497 0-3.578-1.842-3.578H15.34c-.92 0-1.456-1.04-.92-1.788l9.696-13.575c.213-.297.556-.474.92-.474H53.93c.92 0 1.456 1.04.92 1.788L47.37 13.03c-1.07 1.498 0 3.578 1.842 3.578h11.376c.944 0 1.474 1.088.89 1.831L40.049 45.712z"/></mask><g mask="url(#a)"><g filter="url(#b)"><ellipse cx="5.508" cy="14.704" fill="#eee6ff" rx="5.508" ry="14.704" transform="rotate(269.814 20.96 11.29)scale(-1 1)"/></g><g filter="url(#c)"><ellipse cx="10.399" cy="29.851" fill="#eee6ff" rx="10.399" ry="29.851" transform="rotate(89.814 -16.902 -8.275)scale(1 -1)"/></g><g filter="url(#d)"><ellipse cx="5.508" cy="30.487" fill="#8900ff" rx="5.508" ry="30.487" transform="rotate(89.814 -19.197 -7.127)scale(1 -1)"/></g><g filter="url(#e)"><ellipse cx="5.508" cy="30.599" fill="#8900ff" rx="5.508" ry="30.599" transform="rotate(89.814 -25.928 4.177)scale(1 -1)"/></g><g filter="url(#f)"><ellipse cx="5.508" cy="30.599" fill="#8900ff" rx="5.508" ry="30.599" transform="rotate(89.814 -25.738 5.52)scale(1 -1)"/></g><g filter="url(#g)"><ellipse cx="14.072" cy="22.078" fill="#eee6ff" rx="14.072" ry="22.078" transform="rotate(93.35 31.245 55.578)scale(-1 1)"/></g><g filter="url(#h)"><ellipse cx="3.47" cy="21.501" fill="#8900ff" rx="3.47" ry="21.501" transform="rotate(89.009 35.419 55.202)scale(-1 1)"/></g><g filter="url(#i)"><ellipse cx="3.47" cy="21.501" fill="#8900ff" rx="3.47" ry="21.501" transform="rotate(89.009 35.419 55.202)scale(-1 1)"/></g><g filter="url(#j)"><ellipse cx="14.592" cy="9.743" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(39.51 14.592 9.743)"/></g><g filter="url(#k)"><ellipse cx="61.728" cy="-5.321" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 61.728 -5.32)"/></g><g filter="url(#l)"><ellipse cx="55.618" cy="7.104" fill="#00c2ff" rx="5.971" ry="9.665" transform="rotate(37.892 55.618 7.104)"/></g><g filter="url(#m)"><ellipse cx="12.326" cy="39.103" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 12.326 39.103)"/></g><g filter="url(#n)"><ellipse cx="12.326" cy="39.103" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 12.326 39.103)"/></g><g filter="url(#o)"><ellipse cx="49.857" cy="30.678" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 49.857 30.678)"/></g><g filter="url(#p)"><ellipse cx="52.623" cy="33.171" fill="#00c2ff" rx="5.971" ry="15.297" transform="rotate(37.892 52.623 33.17)"/></g></g><path d="M6.919 0c-9.198 13.166-9.252 33.575 0 46.789h6.215c-9.25-13.214-9.196-33.623 0-46.789zm62.424 0h-6.215c9.198 13.166 9.252 33.575 0 46.789h6.215c9.25-13.214 9.196-33.623 0-46.789" class="parenthesis"/><defs><filter id="b" width="60.045" height="41.654" x="-5.564" y="16.92" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="c" width="90.34" height="51.437" x="-40.407" y="-6.762" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="d" width="79.355" height="29.4" x="-35.435" y="2.801" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="e" width="79.579" height="29.4" x="-30.84" y="20.8" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="f" width="79.579" height="29.4" x="-29.307" y="21.949" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="g" width="74.749" height="58.852" x="29.961" y="-17.13" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="h" width="61.377" height="25.362" x="37.754" y="3.055" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="i" width="61.377" height="25.362" x="37.754" y="3.055" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="j" width="56.045" height="63.649" x="-13.43" y="-22.082" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="k" width="54.814" height="64.646" x="34.321" y="-37.644" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="l" width="33.541" height="35.313" x="38.847" y="-10.552" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="m" width="54.814" height="64.646" x="-15.081" y="6.78" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="n" width="54.814" height="64.646" x="-15.081" y="6.78" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="o" width="54.814" height="64.646" x="22.45" y="-1.645" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="p" width="39.409" height="43.623" x="32.919" y="11.36" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter></defs></svg>
package/types/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from './module/type';
2
- export * from './module/array';
3
- export * from './module/object';
4
- export * from './module/math';
5
- export * from './module/storage';
@@ -1,48 +0,0 @@
1
- /**
2
- * 数组去重
3
- * @param array 待去重数组
4
- * @returns 去重后的数组
5
- * @example
6
- * unique([1, 2, 2, 3, 4, 4, 5]) // [1, 2, 3, 4, 5]
7
- */
8
- export declare function unique<T>(array: T[]): T[];
9
- /**
10
- * 数组扁平化
11
- * @param array 待扁平化数组
12
- * @param depth 扁平化深度,默认为1
13
- * @returns 扁平化后的数组
14
- * @example
15
- * flatten([1, [2, [3, [4, [5]]]]]) // [1, 2, [3, [4, [5]]]]
16
- */
17
- export declare function flatten<T>(array: (T | T[])[], depth?: number): T[];
18
- /**
19
- * 数组分块
20
- * @param array 待分块数组
21
- * @param size 每块大小
22
- * @returns 分块后的二维数组
23
- */
24
- export declare function chunk<T>(array: T[], size?: number): T[][];
25
- /**
26
- * 获取数组中的最大值
27
- * @param array 数字数组
28
- * @returns 最大值
29
- */
30
- export declare function max(array: number[]): number | undefined;
31
- /**
32
- * 获取数组中的最小值
33
- * @param array 数字数组
34
- * @returns 最小值
35
- */
36
- export declare function min(array: number[]): number | undefined;
37
- /**
38
- * 数组求和
39
- * @param array 数字数组
40
- * @returns 求和结果
41
- */
42
- export declare function sum(array: number[]): number;
43
- /**
44
- * 数组平均值
45
- * @param array 数字数组
46
- * @returns 平均值
47
- */
48
- export declare function average(array: number[]): number | undefined;
@@ -1,47 +0,0 @@
1
- /**
2
- * 生成范围内的随机整数
3
- * @param min 最小值
4
- * @param max 最大值
5
- * @returns 随机整数
6
- */
7
- export declare function randomInt(min: number, max: number): number;
8
- /**
9
- * 限制数值在指定范围内
10
- * @param value 数值
11
- * @param min 最小值
12
- * @param max 最大值
13
- * @returns 限制后的数值
14
- */
15
- export declare function clamp(value: number, min: number, max: number): number;
16
- /**
17
- * 将角度转换为弧度
18
- * @param degrees 角度
19
- * @returns 弧度
20
- */
21
- export declare function degreesToRadians(degrees: number): number;
22
- /**
23
- * 将弧度转换为角度
24
- * @param radians 弧度
25
- * @returns 角度
26
- */
27
- export declare function radiansToDegrees(radians: number): number;
28
- /**
29
- * 计算两点间距离
30
- * @param point1 点1 {x, y}
31
- * @param point2 点2 {x, y}
32
- * @returns 距离
33
- */
34
- export declare function distance(point1: {
35
- x: number;
36
- y: number;
37
- }, point2: {
38
- x: number;
39
- y: number;
40
- }): number;
41
- /**
42
- * 四舍五入到指定小数位
43
- * @param value 数值
44
- * @param decimals 小数位数
45
- * @returns 四舍五入后的数值
46
- */
47
- export declare function round(value: number, decimals: number): number;
@@ -1,31 +0,0 @@
1
- /**
2
- * 深拷贝对象
3
- * @param obj 待拷贝对象
4
- * @returns 拷贝后的对象
5
- */
6
- export declare function deepClone<T>(obj: T): T;
7
- /**
8
- * 合并对象
9
- * @param objects 待合并的对象
10
- * @returns 合并后的对象
11
- */
12
- export declare function merge<T extends Record<string, any>>(...objects: Partial<T>[]): T;
13
- /**
14
- * 获取对象的所有键
15
- * @param obj 对象
16
- * @returns 键数组
17
- */
18
- export declare function keys<T extends Record<string, any>>(obj: T): (keyof T)[];
19
- /**
20
- * 获取对象的所有值
21
- * @param obj 对象
22
- * @returns 值数组
23
- */
24
- export declare function values<T extends Record<string, any>>(obj: T): T[keyof T][];
25
- /**
26
- * 检查对象是否包含某个键
27
- * @param obj 对象
28
- * @param key 键名
29
- * @returns
30
- */
31
- export declare function hasKey<T extends Record<string, any>>(obj: T, key: PropertyKey): key is keyof T;
@@ -1,25 +0,0 @@
1
- /**
2
- * 设置本地存储
3
- * @param key 键
4
- * @param value 值
5
- * @param isSession 是否使用sessionStorage,默认false
6
- */
7
- export declare function setStorage<T>(key: string, value: T, isSession?: boolean): void;
8
- /**
9
- * 获取本地存储
10
- * @param key 键
11
- * @param isSession 是否使用sessionStorage,默认false
12
- * @returns 存储的值
13
- */
14
- export declare function getStorage<T>(key: string, isSession?: boolean): T | null;
15
- /**
16
- * 删除本地存储
17
- * @param key 键
18
- * @param isSession 是否使用sessionStorage,默认false
19
- */
20
- export declare function removeStorage(key: string, isSession?: boolean): void;
21
- /**
22
- * 清空本地存储
23
- * @param isSession 是否使用sessionStorage,默认false
24
- */
25
- export declare function clearStorage(isSession?: boolean): void;
@@ -1,60 +0,0 @@
1
- /**
2
- * 检测变量类型
3
- * @param value 待检测的值
4
- * @returns 类型字符串
5
- */
6
- export declare function getType(value: unknown): string;
7
- /**
8
- * 判断是否为数组
9
- * @param value 待检测的值
10
- * @returns
11
- */
12
- export declare function isArray(value: unknown): value is unknown[];
13
- /**
14
- * 判断是否为对象
15
- * @param value 待检测的值
16
- * @returns
17
- */
18
- export declare function isObject(value: unknown): value is Record<string, unknown>;
19
- /**
20
- * 判断是否为函数
21
- * @param value 待检测的值
22
- * @returns
23
- */
24
- export declare function isFunction(value: unknown): value is Function;
25
- /**
26
- * 判断是否为字符串
27
- * @param value 待检测的值
28
- * @returns
29
- */
30
- export declare function isString(value: unknown): value is string;
31
- /**
32
- * 判断是否为数字
33
- * @param value 待检测的值
34
- * @returns
35
- */
36
- export declare function isNumber(value: unknown): value is number;
37
- /**
38
- * 判断是否为布尔值
39
- * @param value 待检测的值
40
- * @returns
41
- */
42
- export declare function isBoolean(value: unknown): value is boolean;
43
- /**
44
- * 判断是否为null
45
- * @param value 待检测的值
46
- * @returns
47
- */
48
- export declare function isNull(value: unknown): value is null;
49
- /**
50
- * 判断是否为undefined
51
- * @param value 待检测的值
52
- * @returns
53
- */
54
- export declare function isUndefined(value: unknown): value is undefined;
55
- /**
56
- * 判断是否为空(null, undefined, 空字符串, 空数组, 空对象)
57
- * @param value 待检测的值
58
- * @returns
59
- */
60
- export declare function isEmpty(value: unknown): boolean;