@noah-libjs/utils 0.0.3 → 0.0.5
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/constant.d.ts +17 -0
- package/dist/dic-helper.d.ts +37 -0
- package/dist/{index.js → es.js} +429 -28
- package/dist/helper.d.ts +3 -0
- package/dist/index.d.ts +5 -1
- package/dist/lib.js +2665 -0
- package/dist/moment-help.d.ts +13 -8
- package/dist/option-help.d.ts +24 -0
- package/dist/small-fn.d.ts +7 -5
- package/dist/types.d.ts +14 -823
- package/dist/typing.d.ts +919 -0
- package/package.json +5 -4
package/dist/moment-help.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import dayjs from "dayjs";
|
|
1
|
+
import dayjs, { ConfigType, OpUnitType, QUnitType } from "dayjs";
|
|
2
2
|
export type Dayjs = dayjs.Dayjs;
|
|
3
3
|
export type DayjsConfigType = dayjs.ConfigType;
|
|
4
4
|
export declare function getMomentObj(s: DayjsConfigType): Dayjs;
|
|
5
|
-
export declare const formatDate: ((s?: any) =>
|
|
5
|
+
export declare const formatDate: ((s?: any) => string | null) & {
|
|
6
6
|
format: "YYYY-MM-DD";
|
|
7
7
|
};
|
|
8
|
-
export declare const formatDateTime: ((s?: any) =>
|
|
8
|
+
export declare const formatDateTime: ((s?: any) => string | null) & {
|
|
9
9
|
format: "YYYY-MM-DD HH:mm:ss";
|
|
10
10
|
};
|
|
11
|
-
export declare const formatDateTimeNoSecond: ((s?: any) =>
|
|
11
|
+
export declare const formatDateTimeNoSecond: ((s?: any) => string | null) & {
|
|
12
12
|
format: "YYYY-MM-DD HH:mm";
|
|
13
13
|
};
|
|
14
|
-
export declare const formatTime: ((s?: any) =>
|
|
14
|
+
export declare const formatTime: ((s?: any) => string | null) & {
|
|
15
15
|
format: "HH:mm:ss";
|
|
16
16
|
};
|
|
17
17
|
export declare function getMomentRange(m?: any): {
|
|
@@ -19,17 +19,22 @@ export declare function getMomentRange(m?: any): {
|
|
|
19
19
|
今天: [dayjs.Dayjs, dayjs.Dayjs];
|
|
20
20
|
明天: [dayjs.Dayjs, dayjs.Dayjs];
|
|
21
21
|
上周: [dayjs.Dayjs, dayjs.Dayjs];
|
|
22
|
-
|
|
22
|
+
近一周: [dayjs.Dayjs, dayjs.Dayjs];
|
|
23
23
|
下周: [dayjs.Dayjs, dayjs.Dayjs];
|
|
24
24
|
上月: [dayjs.Dayjs, dayjs.Dayjs];
|
|
25
|
-
|
|
25
|
+
近一月: [dayjs.Dayjs, dayjs.Dayjs];
|
|
26
26
|
下月: [dayjs.Dayjs, dayjs.Dayjs];
|
|
27
|
-
|
|
27
|
+
近一年: [dayjs.Dayjs, dayjs.Dayjs];
|
|
28
28
|
};
|
|
29
|
+
export declare function presets_date(): {
|
|
30
|
+
label: string;
|
|
31
|
+
value: any;
|
|
32
|
+
}[];
|
|
29
33
|
export declare function isMoment(m: any): boolean;
|
|
30
34
|
/**
|
|
31
35
|
* 获取若干天后的日期
|
|
32
36
|
*/
|
|
33
37
|
export declare function getFutureDate(num: number): any;
|
|
34
38
|
export declare function dayjs_quarter(input: Dayjs, which_quarter?: number): [Dayjs, number];
|
|
39
|
+
export declare function diff_between(a: ConfigType, b: ConfigType, unit: QUnitType | OpUnitType, float?: boolean): any;
|
|
35
40
|
export { dayjs };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AnyObject } from './type-utils';
|
|
2
|
+
import { ICommonOption } from './types';
|
|
3
|
+
interface ISpectialOption {
|
|
4
|
+
sp?: ICommonOption[];
|
|
5
|
+
start?: number;
|
|
6
|
+
useString?: boolean;
|
|
7
|
+
useDefault?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const optionKey其他 = 99;
|
|
10
|
+
export declare const optionKey不详 = 100;
|
|
11
|
+
export declare const optionKey否 = 0;
|
|
12
|
+
type TOptionKey = string[] | string;
|
|
13
|
+
type TGetOptionKey = () => TOptionKey;
|
|
14
|
+
type TOptions<T extends TOptionKey | TGetOptionKey> = T extends TOptionKey ? ICommonOption[] : () => ICommonOption[];
|
|
15
|
+
export declare function getSimpleOptions<T extends TOptionKey | TGetOptionKey>(_arr: T, options?: ISpectialOption): TOptions<T>;
|
|
16
|
+
export declare function getSameOptions<T extends TOptionKey | TGetOptionKey>(_arr: T): TOptions<T>;
|
|
17
|
+
export declare function getDualModeOptions<T extends TOptionKey | TGetOptionKey>(arr: T, options?: ISpectialOption): readonly [TOptions<T>, TOptions<T>];
|
|
18
|
+
export type T_FETCH_OPTIONS = () => (Promise<ICommonOption[]> | ICommonOption[]);
|
|
19
|
+
export declare function safe_fetch_options(cb: T_FETCH_OPTIONS): Promise<ICommonOption[]>;
|
|
20
|
+
export declare function getPresetOptions(key: string, pure?: boolean): ICommonOption[];
|
|
21
|
+
export declare function getOptionLabel(k: string, value: any, defaultLabel?: string): string;
|
|
22
|
+
export declare function getOptionValue(k: string, label: any): any;
|
|
23
|
+
export declare function merge_preset_options(ops: AnyObject<() => ICommonOption[]>): void;
|
|
24
|
+
export {};
|
package/dist/small-fn.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AnyObject } from "./type-utils";
|
|
2
2
|
export type TCommonFileType = 'application/vnd.ms-excel' | 'text/csv;charset=utf-8' | 'application/msword';
|
|
3
3
|
export declare function getSearchParamsValue(key: string): string | null;
|
|
4
|
-
export declare function getSearchParamsAll(url?: URL):
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export declare function getSearchParamsAll(url?: URL): AnyObject<string>;
|
|
5
|
+
export declare function setSearchParamsValue(key: string, value: string | number): URL;
|
|
6
|
+
export declare function setSearchParamsAll(data: AnyObject<string | number>): URL;
|
|
7
7
|
export declare function scrollIntoView(symbol: string, finder?: (selectors: string) => Element | null): void;
|
|
8
8
|
export declare function base64ToBinary(data: string, type: TCommonFileType): Blob;
|
|
9
9
|
export declare function downloadFile(content: string | Blob, filename?: string, type?: TCommonFileType, isBase64?: boolean): void;
|
|
@@ -15,12 +15,12 @@ export declare function unicodeToChar(u: number): string | null;
|
|
|
15
15
|
export declare function unicode_to_UTF8(u: number): number[] | null;
|
|
16
16
|
export declare function getFilledArray(n: number): any[];
|
|
17
17
|
export declare function copyText(text: string): boolean;
|
|
18
|
-
export declare function safeExec<T extends (...args: any) => any>(fn?: T, ...args: Parameters<T>
|
|
18
|
+
export declare function safeExec<T extends (...args: any) => any>(fn?: T, ...args: Parameters<T>): any;
|
|
19
19
|
export declare function safeGetFromFuncOrData(fn: any): any;
|
|
20
20
|
export declare function numberLikeCompare(a: number | string | boolean, b: number | string | boolean): boolean;
|
|
21
21
|
export declare function warpBase64Type(str: string, type: 'img' | 'pdf'): string;
|
|
22
22
|
export declare function safe_number_parse(value: any, defaultValue?: number): number;
|
|
23
|
-
export declare function expect_array<T>(value?: T[] | null): T[];
|
|
23
|
+
export declare function expect_array<T>(value?: T[] | null, default_v?: T[]): T[];
|
|
24
24
|
export declare function gen_encoded_char_svg(props: {
|
|
25
25
|
char: string;
|
|
26
26
|
size?: number;
|
|
@@ -37,3 +37,5 @@ export declare function random_word(): string[];
|
|
|
37
37
|
export declare function confirm_operation(): boolean;
|
|
38
38
|
export declare function simple_encrypt(data: AnyObject | any[]): number[] | null;
|
|
39
39
|
export declare function simple_decrypt(code: number[]): AnyObject | null;
|
|
40
|
+
export declare function simple_encrypt_str(data: string): string | null;
|
|
41
|
+
export declare function simple_decrypt_str(code: string): string | null;
|