@vtj/utils 0.6.24 → 0.7.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/LICENSE +21 -21
- package/dist/index.cjs +59 -0
- package/dist/index.iife.js +59 -0
- package/dist/index.mjs +6510 -0
- package/dist/index.umd.js +59 -0
- package/package.json +24 -26
- package/types/base.d.ts +1 -0
- package/types/index.d.ts +6 -8
- package/types/jsonp.d.ts +5 -8
- package/types/loadScript.d.ts +9 -0
- package/types/request.d.ts +4 -3
- package/types/url.d.ts +0 -2
- package/types/util.d.ts +0 -63
- package/types/version.d.ts +8 -1
- package/cdn/index.js +0 -56
- package/lib/index.js +0 -6870
- package/types/crypto.d.ts +0 -2
- package/types/dayjs.d.ts +0 -3
- package/types/numeral.d.ts +0 -3
- package/types/regex.d.ts +0 -11
- /package/types/{Storage.d.ts → storage.d.ts} +0 -0
package/types/index.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './
|
|
1
|
+
export { version as VTJ_UTILS_VERSION } from './version';
|
|
2
|
+
export * from './base';
|
|
3
3
|
export * from './request';
|
|
4
4
|
export * from './raf';
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
5
|
+
export * from './storage';
|
|
6
|
+
export * from './jsonp';
|
|
7
|
+
export * from './loadScript';
|
|
8
|
+
export * from './util';
|
|
9
9
|
export * as cookie from './cookie';
|
|
10
|
-
export * as crypto from './crypto';
|
|
11
10
|
export * as url from './url';
|
|
12
|
-
export { jsonp } from './jsonp';
|
package/types/jsonp.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
prefix?: string;
|
|
5
|
-
param?: string;
|
|
6
|
-
name?: string;
|
|
7
|
-
script?: boolean;
|
|
1
|
+
import fetchJsonp from 'fetch-jsonp';
|
|
2
|
+
export interface FetchJsonpOptions extends fetchJsonp.Options {
|
|
3
|
+
query?: Record<string, any>;
|
|
8
4
|
}
|
|
9
|
-
export declare function jsonp<T>(url: string,
|
|
5
|
+
export declare function jsonp<T = any>(url: string, options?: FetchJsonpOptions): Promise<T>;
|
|
6
|
+
export type Jsonp = typeof jsonp;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface LoadScriptOptions {
|
|
2
|
+
async?: boolean;
|
|
3
|
+
attrs?: Record<string, string>;
|
|
4
|
+
charset?: string;
|
|
5
|
+
text?: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
library?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function loadScript<T = any>(src: string, options?: LoadScriptOptions): Promise<T | undefined>;
|
package/types/request.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import type { AxiosInstance, CreateAxiosDefaults, AxiosResponse, AxiosRequestConfig, RawAxiosRequestHeaders, InternalAxiosRequestConfig, CancelTokenSource } from 'axios';
|
|
2
3
|
declare const LOCAL_REQUEST_ID = "Local-Request-Id";
|
|
3
4
|
export interface IRequestSkipWarn {
|
|
4
5
|
executor: (resolve: (value: unknown) => void, reject: (reason?: any) => void) => void;
|
|
@@ -87,7 +88,7 @@ export declare class Request {
|
|
|
87
88
|
axios: AxiosInstance;
|
|
88
89
|
settings: IRequestSettings;
|
|
89
90
|
records: Record<string, IRequestRecord>;
|
|
90
|
-
|
|
91
|
+
isLoading: boolean;
|
|
91
92
|
private stopSkipWarn?;
|
|
92
93
|
private showLoading;
|
|
93
94
|
private showError;
|
|
@@ -120,4 +121,4 @@ export interface IApiMap {
|
|
|
120
121
|
[name: string]: string | IRequestConfig;
|
|
121
122
|
}
|
|
122
123
|
export declare function createApis(map: IApiMap): Record<string, (data?: unknown, opts?: IRequestConfig<any> | undefined) => Promise<unknown>>;
|
|
123
|
-
export { LOCAL_REQUEST_ID, type AxiosRequestConfig, type AxiosResponse, type RawAxiosRequestHeaders };
|
|
124
|
+
export { axios, LOCAL_REQUEST_ID, type AxiosRequestConfig, type AxiosResponse, type RawAxiosRequestHeaders };
|
package/types/url.d.ts
CHANGED
package/types/util.d.ts
CHANGED
|
@@ -1,67 +1,4 @@
|
|
|
1
|
-
import { upperFirst, camelCase } from 'lodash-es';
|
|
2
|
-
export { get, set, isPlainObject, cloneDeep, merge, debounce, throttle, isEqual, template, lowerFirst, kebabCase } from 'lodash-es';
|
|
3
|
-
export { upperFirst, camelCase };
|
|
4
1
|
/**
|
|
5
2
|
* 是否浏览器环境
|
|
6
3
|
*/
|
|
7
4
|
export declare const isClient: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* 已定义
|
|
10
|
-
* @param val
|
|
11
|
-
* @returns
|
|
12
|
-
*/
|
|
13
|
-
export declare const isDef: (val: unknown) => boolean;
|
|
14
|
-
/**
|
|
15
|
-
* 当前时间
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
export declare const now: () => number;
|
|
19
|
-
/**
|
|
20
|
-
* 时间戳
|
|
21
|
-
* @returns
|
|
22
|
-
*/
|
|
23
|
-
export declare const timestamp: () => number;
|
|
24
|
-
/**
|
|
25
|
-
* 随机数
|
|
26
|
-
* @param min
|
|
27
|
-
* @param max
|
|
28
|
-
* @returns
|
|
29
|
-
*/
|
|
30
|
-
export declare const rand: (min: number, max: number) => number;
|
|
31
|
-
export declare function uid(): string;
|
|
32
|
-
export declare function uuid(split?: boolean): string;
|
|
33
|
-
export declare function isFunction(val: any): val is (...args: any[]) => any;
|
|
34
|
-
export declare function isObject(value: any): value is Record<string, unknown>;
|
|
35
|
-
export declare function isString(value: any): value is string;
|
|
36
|
-
export declare function isUndefined(value: any): boolean;
|
|
37
|
-
export declare function upperFirstCamelCase(name: string): string;
|
|
38
|
-
/**
|
|
39
|
-
* 对象排除属性
|
|
40
|
-
* @param target 需要处理的对象
|
|
41
|
-
* @param keys 需要排除的属性名称
|
|
42
|
-
* @returns
|
|
43
|
-
*/
|
|
44
|
-
export declare function omit<T extends Record<string, any>, K extends Record<string, any>>(target: T, keys: string[] | ((k: string, v: any) => boolean)): K;
|
|
45
|
-
/**
|
|
46
|
-
* 对象提取属性
|
|
47
|
-
* @param target
|
|
48
|
-
* @param keys
|
|
49
|
-
* @returns
|
|
50
|
-
*/
|
|
51
|
-
export declare function pick<T extends Record<string, any>, K extends Record<string, any>>(target: T, keys: string[] | ((k: string, v: any) => boolean)): K;
|
|
52
|
-
/**
|
|
53
|
-
* 递归对象或数组清除文本类型值的两边空格
|
|
54
|
-
* @param {Object|Array} obj
|
|
55
|
-
* @return {Object|Array}
|
|
56
|
-
*/
|
|
57
|
-
export declare function trim(obj: any): any;
|
|
58
|
-
/**
|
|
59
|
-
* 截取几位小数
|
|
60
|
-
*/
|
|
61
|
-
export declare function toFixed(value: number, number: number | undefined, round: boolean): number;
|
|
62
|
-
export declare function delay(val?: number): Promise<unknown>;
|
|
63
|
-
export declare function arrayToMap<T>(data: T[], prop: keyof T): Map<any, T>;
|
|
64
|
-
export declare function mapToObject<V = any>(map: Map<any, V>): Record<any, V>;
|
|
65
|
-
export declare function dedupArray<T>(array: any[], prop?: keyof T): any[];
|
|
66
|
-
export declare function toArray<T = any>(maybeArray?: T | T[]): T[];
|
|
67
|
-
export declare function cleanObject(obj: Record<string, any>): Record<string, any>;
|
package/types/version.d.ts
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**!
|
|
2
|
+
* Copyright (c) 2024, VTJ.PRO All rights reserved.
|
|
3
|
+
* @name @vtj/utils
|
|
4
|
+
* @author CHC chenhuachun1549@dingtalk.com
|
|
5
|
+
* @version 0.7.0
|
|
6
|
+
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
|
+
*/
|
|
8
|
+
export declare const version = "0.7.0";
|