@vtj/utils 0.6.25 → 0.7.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/types/index.d.ts CHANGED
@@ -1,12 +1,10 @@
1
- export * from './version';
2
- export * from './util';
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 './dayjs';
6
- export * from './numeral';
7
- export * from './Storage';
8
- export * from './regex';
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
- export interface JSONPOptions {
2
- cache?: boolean | string;
3
- timeout?: number;
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, params?: Record<string, any>, options?: JSONPOptions): Promise<T>;
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>;
@@ -1,4 +1,5 @@
1
- import { AxiosInstance, CreateAxiosDefaults, AxiosResponse, AxiosRequestConfig, RawAxiosRequestHeaders, InternalAxiosRequestConfig, CancelTokenSource } from 'axios';
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
- private isLoading;
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
@@ -1,5 +1,3 @@
1
- export declare const UrlRegex: RegExp;
2
- export declare function isUrl(txt: string): boolean;
3
1
  /**
4
2
  * 获取当前页面的 host
5
3
  */
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>;
@@ -1 +1,8 @@
1
- export declare const version = "0.6.25";
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";