@unicom-cloud/utils 0.1.5 → 0.1.11
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/caseName.js +11 -0
- package/className.js +5 -0
- package/clipboardCopy.js +6 -0
- package/constant.js +4 -0
- package/content-disposition/index.js +56 -0
- package/contentDisposition.js +7 -0
- package/convert-time/index.js +61 -0
- package/convertTime.js +4 -0
- package/cookie.js +7 -0
- package/dayjs.js +5 -0
- package/decimal.js +5 -0
- package/eventEmitter.js +4 -0
- package/file.js +6 -0
- package/filesize.js +8 -0
- package/index.js +44 -31
- package/invariant.js +4 -0
- package/is.js +92 -0
- package/lunar-converter/index.js +641 -0
- package/lunarConverter.js +4 -0
- package/math.js +9 -0
- package/md5.js +4 -0
- package/mock.js +8 -0
- package/normalizeWheel.js +6 -0
- package/number-to-chinese/index.js +72 -0
- package/numberToChinese.js +4 -0
- package/nzh.js +4 -0
- package/object-keys-sort/index.js +7 -0
- package/objectKeysSort.js +2 -5
- package/package.json +1 -1
- package/random.js +15 -0
- package/screenfull.js +4 -0
- package/search-tree/index.js +54 -0
- package/searchTree.js +4 -0
- package/snapdom/src/api/preCache.js +31 -27
- package/snapdom/src/core/capture.js +55 -44
- package/snapdom/src/core/clone.js +11 -11
- package/snapdom/src/core/prepare.js +38 -31
- package/snapdom/src/modules/background.js +18 -43
- package/snapdom/src/modules/pseudo.js +66 -67
- package/snapdom/src/utils/helpers.js +105 -56
- package/snapdom.js +6 -0
- package/tree.js +11 -0
- package/turboStream.js +6 -0
- package/types/case-name/index.d.ts +11 -0
- package/types/class-name/index.d.ts +2 -0
- package/types/clipboard-copy/index.d.ts +2 -0
- package/types/constant/address.d.ts +14 -0
- package/types/constant/chineseCharacters.d.ts +2 -0
- package/types/constant/constellations.d.ts +2 -0
- package/types/constant/domain.d.ts +2 -0
- package/types/constant/identity.d.ts +2 -0
- package/types/constant/index.d.ts +1 -0
- package/types/constant/keyboardCode.d.ts +158 -0
- package/types/constant/licensePlate.d.ts +2 -0
- package/types/constant/name.d.ts +4 -0
- package/types/constant/platform.d.ts +11 -0
- package/types/constant/protocol.d.ts +2 -0
- package/types/constant/ui.d.ts +14 -0
- package/types/content-disposition/index.d.ts +10 -0
- package/types/convert-time/index.d.ts +32 -0
- package/types/cookie/index.d.ts +4 -0
- package/types/cookie/src/index.d.ts +114 -0
- package/types/dayjs/index.d.ts +1 -0
- package/types/decimal/decimal.d.ts +4 -0
- package/types/decimal/index.d.ts +1 -0
- package/types/event-emitter/index.d.ts +17 -0
- package/types/file/fileToURL.d.ts +2 -0
- package/types/file/index.d.ts +3 -0
- package/types/file/saveAs.d.ts +2 -0
- package/types/filesize/index.d.ts +2 -0
- package/types/filesize/src/constants.d.ts +42 -0
- package/types/filesize/src/filesize.d.ts +47 -0
- package/types/index.d.ts +24 -0
- package/types/invariant/index.d.ts +2 -0
- package/types/is/index.d.ts +53 -0
- package/types/lunar-converter/index.d.ts +113 -0
- package/types/math/index.d.ts +11 -0
- package/types/md5/index.d.ts +2 -0
- package/types/mock/MockWebSocket.d.ts +17 -0
- package/types/mock/MockXMLHttpRequest.d.ts +17 -0
- package/types/mock/index.d.ts +2 -0
- package/types/normalize-wheel/ExecutionEnvironment.d.ts +9 -0
- package/types/normalize-wheel/UserAgent_DEPRECATED.d.ts +86 -0
- package/types/normalize-wheel/index.d.ts +115 -0
- package/types/normalize-wheel/isEventSupported.d.ts +16 -0
- package/types/number-to-chinese/index.d.ts +11 -0
- package/types/nzh/cn.d.ts +8 -0
- package/types/nzh/hk.d.ts +8 -0
- package/types/nzh/index.d.ts +1 -0
- package/types/nzh/nzh.d.ts +36 -0
- package/types/nzh/src/autoGet.d.ts +8 -0
- package/types/nzh/src/index.d.ts +34 -0
- package/types/nzh/src/langs/cn_b.d.ts +10 -0
- package/types/nzh/src/langs/cn_s.d.ts +7 -0
- package/types/nzh/src/langs/hk_b.d.ts +10 -0
- package/types/nzh/src/langs/hk_s.d.ts +7 -0
- package/types/nzh/src/utils.d.ts +65 -0
- package/types/object-keys-sort/index.d.ts +4 -0
- package/types/random/address.d.ts +8 -0
- package/types/random/constellation.d.ts +2 -0
- package/types/random/image.d.ts +5 -0
- package/types/random/index.d.ts +40 -0
- package/types/random/licensePlate.d.ts +2 -0
- package/types/random/name.d.ts +9 -0
- package/types/random/number.d.ts +6 -0
- package/types/random/text.d.ts +13 -0
- package/types/random/time.d.ts +2 -0
- package/types/random/web.d.ts +11 -0
- package/types/screenfull/index.d.ts +10 -0
- package/types/search-tree/index.d.ts +20 -0
- package/types/snapdom/index.d.ts +1 -0
- package/types/snapdom/src/api/preCache.d.ts +8 -0
- package/types/snapdom/src/api/snapdom.d.ts +26 -0
- package/types/snapdom/src/core/cache.d.ts +11 -0
- package/types/snapdom/src/core/capture.d.ts +17 -0
- package/types/snapdom/src/core/clone.d.ts +11 -0
- package/types/snapdom/src/core/prepare.d.ts +8 -0
- package/types/snapdom/src/index.browser.d.ts +1 -0
- package/types/snapdom/src/index.d.ts +2 -0
- package/types/snapdom/src/modules/background.d.ts +10 -0
- package/types/snapdom/src/modules/fonts.d.ts +25 -0
- package/types/snapdom/src/modules/images.d.ts +8 -0
- package/types/snapdom/src/modules/pseudo.d.ts +12 -0
- package/types/snapdom/src/modules/styles.d.ts +10 -0
- package/types/snapdom/src/utils/cssTools.d.ts +38 -0
- package/types/snapdom/src/utils/helpers.d.ts +71 -0
- package/types/tree/index.d.ts +8 -0
- package/types/turbo-stream/index.d.ts +1 -0
- package/types/turbo-stream/src/decode.d.ts +7 -0
- package/types/turbo-stream/src/encode.d.ts +27 -0
- package/types/turbo-stream/src/shared.d.ts +107 -0
- package/types/turbo-stream/src/turbo-stream.d.ts +4 -0
- package/types/url-toolkit/index.d.ts +2 -0
- package/types/url-toolkit/src/url-toolkit.d.ts +18 -0
- package/urlToolkit.js +8 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 时间单位定义
|
|
3
|
+
* @property name - 单位名称(如 "秒"、"分钟")
|
|
4
|
+
* @property seconds - 该单位对应的秒数
|
|
5
|
+
* @property max - 该单位的最大值(例如月份最大为12,小时最大为24),可选
|
|
6
|
+
*/
|
|
7
|
+
interface TimeUnit {
|
|
8
|
+
name: string;
|
|
9
|
+
seconds: number;
|
|
10
|
+
max?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 支持的输入单位类型
|
|
14
|
+
*/
|
|
15
|
+
type InputTimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week';
|
|
16
|
+
/**
|
|
17
|
+
* 时间单位转换函数
|
|
18
|
+
* @param inputValue 输入的时间值
|
|
19
|
+
* @param options 配置选项
|
|
20
|
+
* @param options.inputUnit 输入单位(默认为 'second')
|
|
21
|
+
* @param options.units 自定义输出单位(默认为 DEFAULT_TIME_UNITS)
|
|
22
|
+
* @param options.maxUnitCount 最多显示几个单位(默认为全部)
|
|
23
|
+
* @param options.keepZero 是否保留0值单位(如 "0小时1分钟")
|
|
24
|
+
* @returns 格式化后的时间字符串(如 "2小时30分钟")
|
|
25
|
+
*/
|
|
26
|
+
declare function convertTime(inputValue: number, options?: {
|
|
27
|
+
inputUnit?: InputTimeUnit;
|
|
28
|
+
units?: TimeUnit[];
|
|
29
|
+
maxUnitCount?: number;
|
|
30
|
+
keepZero?: boolean;
|
|
31
|
+
}): string;
|
|
32
|
+
export default convertTime;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse options.
|
|
3
|
+
*/
|
|
4
|
+
export interface ParseOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Specifies a function that will be used to decode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1).
|
|
7
|
+
* Since the value of a cookie has a limited character set (and must be a simple string), this function can be used to decode
|
|
8
|
+
* a previously-encoded cookie value into a JavaScript string.
|
|
9
|
+
*
|
|
10
|
+
* The default function is the global `decodeURIComponent`, wrapped in a `try..catch`. If an error
|
|
11
|
+
* is thrown it will return the cookie's original value. If you provide your own encode/decode
|
|
12
|
+
* scheme you must ensure errors are appropriately handled.
|
|
13
|
+
*
|
|
14
|
+
* @default decode
|
|
15
|
+
*/
|
|
16
|
+
decode?: (str: string) => string | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Parse a cookie header.
|
|
20
|
+
*
|
|
21
|
+
* Parse the given cookie header string into an object
|
|
22
|
+
* The object has the various cookies as keys(names) => values
|
|
23
|
+
*/
|
|
24
|
+
export declare function parse(str: string, options?: ParseOptions): Record<string, string | undefined>;
|
|
25
|
+
/**
|
|
26
|
+
* Serialize options.
|
|
27
|
+
*/
|
|
28
|
+
export interface SerializeOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Specifies a function that will be used to encode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1).
|
|
31
|
+
* Since value of a cookie has a limited character set (and must be a simple string), this function can be used to encode
|
|
32
|
+
* a value into a string suited for a cookie's value, and should mirror `decode` when parsing.
|
|
33
|
+
*
|
|
34
|
+
* @default encodeURIComponent
|
|
35
|
+
*/
|
|
36
|
+
encode?: (str: string) => string;
|
|
37
|
+
/**
|
|
38
|
+
* Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.2).
|
|
39
|
+
*
|
|
40
|
+
* The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and
|
|
41
|
+
* `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
|
|
42
|
+
* so if both are set, they should point to the same date and time.
|
|
43
|
+
*/
|
|
44
|
+
maxAge?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.1).
|
|
47
|
+
* When no expiration is set clients consider this a "non-persistent cookie" and delete it the current session is over.
|
|
48
|
+
*
|
|
49
|
+
* The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and
|
|
50
|
+
* `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
|
|
51
|
+
* so if both are set, they should point to the same date and time.
|
|
52
|
+
*/
|
|
53
|
+
expires?: Date;
|
|
54
|
+
/**
|
|
55
|
+
* Specifies the value for the [`Domain` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.3).
|
|
56
|
+
* When no domain is set clients consider the cookie to apply to the current domain only.
|
|
57
|
+
*/
|
|
58
|
+
domain?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4).
|
|
61
|
+
* When no path is set, the path is considered the ["default path"](https://tools.ietf.org/html/rfc6265#section-5.1.4).
|
|
62
|
+
*/
|
|
63
|
+
path?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Enables the [`HttpOnly` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.6).
|
|
66
|
+
* When enabled, clients will not allow client-side JavaScript to see the cookie in `document.cookie`.
|
|
67
|
+
*/
|
|
68
|
+
httpOnly?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Enables the [`Secure` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.5).
|
|
71
|
+
* When enabled, clients will only send the cookie back if the browser has a HTTPS connection.
|
|
72
|
+
*/
|
|
73
|
+
secure?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Enables the [`Partitioned` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-cutler-httpbis-partitioned-cookies/).
|
|
76
|
+
* When enabled, clients will only send the cookie back when the current domain _and_ top-level domain matches.
|
|
77
|
+
*
|
|
78
|
+
* This is an attribute that has not yet been fully standardized, and may change in the future.
|
|
79
|
+
* This also means clients may ignore this attribute until they understand it. More information
|
|
80
|
+
* about can be found in [the proposal](https://github.com/privacycg/CHIPS).
|
|
81
|
+
*/
|
|
82
|
+
partitioned?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Specifies the value for the [`Priority` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).
|
|
85
|
+
*
|
|
86
|
+
* - `'low'` will set the `Priority` attribute to `Low`.
|
|
87
|
+
* - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.
|
|
88
|
+
* - `'high'` will set the `Priority` attribute to `High`.
|
|
89
|
+
*
|
|
90
|
+
* More information about priority levels can be found in [the specification](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).
|
|
91
|
+
*/
|
|
92
|
+
priority?: 'low' | 'medium' | 'high';
|
|
93
|
+
/**
|
|
94
|
+
* Specifies the value for the [`SameSite` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).
|
|
95
|
+
*
|
|
96
|
+
* - `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
|
97
|
+
* - `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement.
|
|
98
|
+
* - `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie.
|
|
99
|
+
* - `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
|
100
|
+
*
|
|
101
|
+
* More information about enforcement levels can be found in [the specification](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).
|
|
102
|
+
*/
|
|
103
|
+
sameSite?: boolean | 'lax' | 'strict' | 'none';
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Serialize data into a cookie header.
|
|
107
|
+
*
|
|
108
|
+
* Serialize a name value pair into a cookie string suitable for
|
|
109
|
+
* http headers. An optional options object specifies cookie parameters.
|
|
110
|
+
*
|
|
111
|
+
* serialize('foo', 'bar', { httpOnly: true })
|
|
112
|
+
* => "foo=bar; httpOnly"
|
|
113
|
+
*/
|
|
114
|
+
export declare function serialize(name: string, val: string, options?: SerializeOptions): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function convertToDurationBasedOnTimeUnits(duration: any, unit: any): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Decimal, default } from "./decimal";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default EventEmitter;
|
|
2
|
+
declare class EventEmitter {
|
|
3
|
+
addListener: (k: any, cb: any) => void;
|
|
4
|
+
addEventListener: (k: any, cb: any) => void;
|
|
5
|
+
removeListener: (k: any, cb: any) => void;
|
|
6
|
+
removeEventListener: (k: any, cb: any) => void;
|
|
7
|
+
removeAllListeners: (k: any) => void;
|
|
8
|
+
removeAllEventListeners: (k: any) => void;
|
|
9
|
+
dispatch: (k: any, ...a: any[]) => void;
|
|
10
|
+
dispatchEvent: (k: any, ...a: any[]) => void;
|
|
11
|
+
once(k: any, cb: any): void;
|
|
12
|
+
on(k: any, cb: any): void;
|
|
13
|
+
off(k: any, cb: any): void;
|
|
14
|
+
offAll(k: any): void;
|
|
15
|
+
emit(k: any, ...a: any[]): void;
|
|
16
|
+
#private;
|
|
17
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const ARRAY: "array";
|
|
2
|
+
export const BIT: "bit";
|
|
3
|
+
export const BITS: "bits";
|
|
4
|
+
export const BYTE: "byte";
|
|
5
|
+
export const BYTES: "bytes";
|
|
6
|
+
export const EMPTY: "";
|
|
7
|
+
export const EXPONENT: "exponent";
|
|
8
|
+
export const FUNCTION: "function";
|
|
9
|
+
export const IEC: "iec";
|
|
10
|
+
export const INVALID_NUMBER: "Invalid number";
|
|
11
|
+
export const INVALID_ROUND: "Invalid rounding method";
|
|
12
|
+
export const JEDEC: "jedec";
|
|
13
|
+
export const OBJECT: "object";
|
|
14
|
+
export const PERIOD: ".";
|
|
15
|
+
export const ROUND: "round";
|
|
16
|
+
export const S: "s";
|
|
17
|
+
export const SI: "si";
|
|
18
|
+
export const SI_KBIT: "kbit";
|
|
19
|
+
export const SI_KBYTE: "kB";
|
|
20
|
+
export const SPACE: " ";
|
|
21
|
+
export const STRING: "string";
|
|
22
|
+
export const ZERO: "0";
|
|
23
|
+
export namespace STRINGS {
|
|
24
|
+
namespace symbol {
|
|
25
|
+
namespace iec {
|
|
26
|
+
let bits: string[];
|
|
27
|
+
let bytes: string[];
|
|
28
|
+
}
|
|
29
|
+
namespace jedec {
|
|
30
|
+
let bits_1: string[];
|
|
31
|
+
export { bits_1 as bits };
|
|
32
|
+
let bytes_1: string[];
|
|
33
|
+
export { bytes_1 as bytes };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
namespace fullform {
|
|
37
|
+
let iec_1: string[];
|
|
38
|
+
export { iec_1 as iec };
|
|
39
|
+
let jedec_1: string[];
|
|
40
|
+
export { jedec_1 as jedec };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function filesize(arg: any, { bits, pad, base, round, locale, localeOptions, separator, spacer, symbols, standard, output, fullform, fullforms, exponent, roundingMethod, precision, }?: {
|
|
2
|
+
bits?: boolean | undefined;
|
|
3
|
+
pad?: boolean | undefined;
|
|
4
|
+
base?: number | undefined;
|
|
5
|
+
round?: number | undefined;
|
|
6
|
+
locale?: string | undefined;
|
|
7
|
+
localeOptions?: {} | undefined;
|
|
8
|
+
separator?: string | undefined;
|
|
9
|
+
spacer?: string | undefined;
|
|
10
|
+
symbols?: {} | undefined;
|
|
11
|
+
standard?: string | undefined;
|
|
12
|
+
output?: string | undefined;
|
|
13
|
+
fullform?: boolean | undefined;
|
|
14
|
+
fullforms?: never[] | undefined;
|
|
15
|
+
exponent?: number | undefined;
|
|
16
|
+
roundingMethod?: string | undefined;
|
|
17
|
+
precision?: number | undefined;
|
|
18
|
+
}): string | number | any[] | {
|
|
19
|
+
value: any;
|
|
20
|
+
symbol: any;
|
|
21
|
+
exponent: number;
|
|
22
|
+
unit: string;
|
|
23
|
+
};
|
|
24
|
+
export function partial({ bits, pad, base, round, locale, localeOptions, separator, spacer, symbols, standard, output, fullform, fullforms, exponent, roundingMethod, precision, }?: {
|
|
25
|
+
bits?: boolean | undefined;
|
|
26
|
+
pad?: boolean | undefined;
|
|
27
|
+
base?: number | undefined;
|
|
28
|
+
round?: number | undefined;
|
|
29
|
+
locale?: string | undefined;
|
|
30
|
+
localeOptions?: {} | undefined;
|
|
31
|
+
separator?: string | undefined;
|
|
32
|
+
spacer?: string | undefined;
|
|
33
|
+
symbols?: {} | undefined;
|
|
34
|
+
standard?: string | undefined;
|
|
35
|
+
output?: string | undefined;
|
|
36
|
+
fullform?: boolean | undefined;
|
|
37
|
+
fullforms?: never[] | undefined;
|
|
38
|
+
exponent?: number | undefined;
|
|
39
|
+
roundingMethod?: string | undefined;
|
|
40
|
+
precision?: number | undefined;
|
|
41
|
+
}): (arg: any) => string | number | any[] | {
|
|
42
|
+
value: any;
|
|
43
|
+
symbol: any;
|
|
44
|
+
exponent: number;
|
|
45
|
+
unit: string;
|
|
46
|
+
};
|
|
47
|
+
export default filesize;
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * as is from "./is";
|
|
2
|
+
export * as math from "./math";
|
|
3
|
+
export * as tree from "./tree";
|
|
4
|
+
export * as turboStream from "./turbo-stream";
|
|
5
|
+
export * as urlToolkit from "./url-toolkit";
|
|
6
|
+
export { default as caseName } from "./case-name";
|
|
7
|
+
export { default as className } from "./class-name";
|
|
8
|
+
export { default as clipboardCopy } from "./clipboard-copy";
|
|
9
|
+
export { default as convertTime } from "./convert-time";
|
|
10
|
+
export { default as decimal } from "./decimal";
|
|
11
|
+
export { default as eventEmitter } from "./event-emitter";
|
|
12
|
+
export { default as invariant } from "./invariant";
|
|
13
|
+
export { default as LunarConverter } from "./lunar-converter";
|
|
14
|
+
export { default as md5 } from "./md5";
|
|
15
|
+
export { default as normalizeWheel } from "./normalize-wheel";
|
|
16
|
+
export { default as numberToChinese } from "./number-to-chinese";
|
|
17
|
+
export { default as nzh } from "./nzh";
|
|
18
|
+
export { default as objectKeysSort } from "./object-keys-sort";
|
|
19
|
+
export { default as screenfull } from "./screenfull";
|
|
20
|
+
export { default as searchTree } from "./search-tree";
|
|
21
|
+
export { default as contentDisposition, getContentDispositionFromHeader, getContentDispositionParametersFilenameFromHeader, getContentDispositionParametersFromHeader } from "./content-disposition";
|
|
22
|
+
export { default as cookie, splitCookiesString } from "./cookie";
|
|
23
|
+
export { fileToURL, saveAs } from "./file";
|
|
24
|
+
export { default as filesize, filesizeConstants, partial } from "./filesize";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import isArguments from 'lodash/isArguments';
|
|
2
|
+
import isArray from 'lodash/isArray';
|
|
3
|
+
import isArrayBuffer from 'lodash/isArrayBuffer';
|
|
4
|
+
import isArrayLike from 'lodash/isArrayLike';
|
|
5
|
+
import isArrayLikeObject from 'lodash/isArrayLikeObject';
|
|
6
|
+
export function isBlob(o: any): boolean;
|
|
7
|
+
import isBoolean from 'lodash/isBoolean';
|
|
8
|
+
import isBuffer from 'lodash/isBuffer';
|
|
9
|
+
export function isColor(color: any): boolean;
|
|
10
|
+
export function isColor2(color: any): boolean;
|
|
11
|
+
import isDate from 'lodash/isDate';
|
|
12
|
+
import isElement from 'lodash/isElement';
|
|
13
|
+
import isEmpty from 'lodash/isEmpty';
|
|
14
|
+
export function isEmptyArray(o: any): boolean;
|
|
15
|
+
export function isEmptyObject(o: any): boolean;
|
|
16
|
+
export function isEmptyValue(o: any): boolean;
|
|
17
|
+
import isEqual from 'lodash/isEqual';
|
|
18
|
+
import isEqualWith from 'lodash/isEqualWith';
|
|
19
|
+
import isError from 'lodash/isError';
|
|
20
|
+
export function isFile(o: any): boolean;
|
|
21
|
+
import isFinite from 'lodash/isFinite';
|
|
22
|
+
import isFunction from 'lodash/isFunction';
|
|
23
|
+
import isInteger from 'lodash/isInteger';
|
|
24
|
+
export function isJSON(text: any): boolean;
|
|
25
|
+
import isLength from 'lodash/isLength';
|
|
26
|
+
import isMap from 'lodash/isMap';
|
|
27
|
+
import isMatch from 'lodash/isMatch';
|
|
28
|
+
import isMatchWith from 'lodash/isMatchWith';
|
|
29
|
+
import isNaN from 'lodash/isNaN';
|
|
30
|
+
import isNative from 'lodash/isNative';
|
|
31
|
+
import isNil from 'lodash/isNil';
|
|
32
|
+
import isNull from 'lodash/isNull';
|
|
33
|
+
import isNumber from 'lodash/isNumber';
|
|
34
|
+
import isObject from 'lodash/isObject';
|
|
35
|
+
import isObjectLike from 'lodash/isObjectLike';
|
|
36
|
+
import isPlainObject from 'lodash/isPlainObject';
|
|
37
|
+
export function isPromise(p: any): p is Promise<any>;
|
|
38
|
+
export const isReadableByteStreamControllerSupported: boolean;
|
|
39
|
+
export function isReadableStream(params: any): boolean;
|
|
40
|
+
export const isReadableStreamDefaultControllerSupported: boolean;
|
|
41
|
+
export const isReadableStreamSupported: boolean;
|
|
42
|
+
export const isReadableStreamSymbolAsyncIteratorSupported: any;
|
|
43
|
+
import isRegExp from 'lodash/isRegExp';
|
|
44
|
+
import isSafeInteger from 'lodash/isSafeInteger';
|
|
45
|
+
import isSet from 'lodash/isSet';
|
|
46
|
+
import isString from 'lodash/isString';
|
|
47
|
+
import isSymbol from 'lodash/isSymbol';
|
|
48
|
+
import isTypedArray from 'lodash/isTypedArray';
|
|
49
|
+
import isUndefined from 'lodash/isUndefined';
|
|
50
|
+
export function isValidColor(value: any): boolean;
|
|
51
|
+
import isWeakMap from 'lodash/isWeakMap';
|
|
52
|
+
import isWeakSet from 'lodash/isWeakSet';
|
|
53
|
+
export { isArguments, isArray, isArrayBuffer, isArrayLike, isArrayLikeObject, isBoolean, isBuffer, isDate, isElement, isEmpty, isEqual, isEqualWith, isError, isFinite, isFunction, isInteger, isLength, isMap, isMatch, isMatchWith, isNaN, isNative, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
interface LunarDate {
|
|
2
|
+
year: number;
|
|
3
|
+
month: number;
|
|
4
|
+
day: number;
|
|
5
|
+
chineseMonth: string;
|
|
6
|
+
chineseDay: string;
|
|
7
|
+
isLeapMonth: boolean;
|
|
8
|
+
zodiac: string;
|
|
9
|
+
ganZhiYear: string;
|
|
10
|
+
solarTerm: string | null;
|
|
11
|
+
festivals: string[];
|
|
12
|
+
}
|
|
13
|
+
declare class LunarConverter {
|
|
14
|
+
private static readonly MIN;
|
|
15
|
+
private static readonly MAX;
|
|
16
|
+
private static readonly LUNAR_INFO;
|
|
17
|
+
private static readonly SOLAR_TERMS;
|
|
18
|
+
private static readonly LUNAR_HOLIDAYS;
|
|
19
|
+
private static readonly SOLAR_HOLIDAYS;
|
|
20
|
+
private static readonly SPECIAL_HOLIDAYS;
|
|
21
|
+
/**
|
|
22
|
+
* 查找某月中第N个星期X的日期
|
|
23
|
+
* @param year 年份
|
|
24
|
+
* @param month 月份(1-12)
|
|
25
|
+
* @param weekday 星期几(0-6,0表示周日)
|
|
26
|
+
* @param nth 第几个(1-5)
|
|
27
|
+
* @returns 日期
|
|
28
|
+
*/
|
|
29
|
+
private static findNthWeekdayInMonth;
|
|
30
|
+
private static readonly GAN;
|
|
31
|
+
private static readonly ZHI;
|
|
32
|
+
private static readonly ZODIAC;
|
|
33
|
+
private static readonly CHINESE_NUMBERS;
|
|
34
|
+
private static readonly CHINESE_DAY_NAMES;
|
|
35
|
+
private static readonly CHINESE_MONTH_NAMES;
|
|
36
|
+
private static customSolarHolidays;
|
|
37
|
+
private static customLunarHolidays;
|
|
38
|
+
/**
|
|
39
|
+
* 添加自定义公历节日
|
|
40
|
+
* @param month 月份(1-12)
|
|
41
|
+
* @param day 日期
|
|
42
|
+
* @param name 节日名称
|
|
43
|
+
*/
|
|
44
|
+
static addCustomSolarHoliday(month: number, day: number, name: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* 添加自定义农历节日
|
|
47
|
+
* @param month 月份(1-12)
|
|
48
|
+
* @param day 日期
|
|
49
|
+
* @param name 节日名称
|
|
50
|
+
*/
|
|
51
|
+
static addCustomLunarHoliday(month: number, day: number, name: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* 移除自定义公历节日
|
|
54
|
+
* @param month 月份(1-12)
|
|
55
|
+
* @param day 日期
|
|
56
|
+
*/
|
|
57
|
+
static removeCustomSolarHoliday(month: number, day: number): void;
|
|
58
|
+
/**
|
|
59
|
+
* 移除自定义农历节日
|
|
60
|
+
* @param month 月份(1-12)
|
|
61
|
+
* @param day 日期
|
|
62
|
+
*/
|
|
63
|
+
static removeCustomLunarHoliday(month: number, day: number): void;
|
|
64
|
+
/**
|
|
65
|
+
* 公历转农历(主方法)
|
|
66
|
+
* @param year 公历年份
|
|
67
|
+
* @param month 公历月份(1-12)
|
|
68
|
+
* @param day 公历日期(1-31)
|
|
69
|
+
* @returns 农历日期对象
|
|
70
|
+
*/
|
|
71
|
+
static solarToLunar(year: number, month: number, day: number): LunarDate;
|
|
72
|
+
/**
|
|
73
|
+
* 获取所有节日(农历、公历和自定义节日)
|
|
74
|
+
*/
|
|
75
|
+
private static getFestivals;
|
|
76
|
+
/**
|
|
77
|
+
* 获取农历年的总天数
|
|
78
|
+
*/
|
|
79
|
+
private static getLunarYearDays;
|
|
80
|
+
/**
|
|
81
|
+
* 获取农历每月的天数信息
|
|
82
|
+
*/
|
|
83
|
+
private static getLunarMonthInfo;
|
|
84
|
+
/**
|
|
85
|
+
* 获取闰月月份(没有闰月返回0)
|
|
86
|
+
*/
|
|
87
|
+
private static getLeapMonth;
|
|
88
|
+
/**
|
|
89
|
+
* 获取节气
|
|
90
|
+
*/
|
|
91
|
+
private static getSolarTerm;
|
|
92
|
+
/**
|
|
93
|
+
* 获取农历月份的天数
|
|
94
|
+
*/
|
|
95
|
+
private static getLunarMonthDays;
|
|
96
|
+
/**
|
|
97
|
+
* 数字日期转中文
|
|
98
|
+
*/
|
|
99
|
+
private static dayToChinese;
|
|
100
|
+
/**
|
|
101
|
+
* 数字月份转中文(处理闰月)
|
|
102
|
+
*/
|
|
103
|
+
private static monthToChinese;
|
|
104
|
+
/**
|
|
105
|
+
* 获取生肖
|
|
106
|
+
*/
|
|
107
|
+
private static getZodiac;
|
|
108
|
+
/**
|
|
109
|
+
* 获取天干地支
|
|
110
|
+
*/
|
|
111
|
+
private static getGanZhi;
|
|
112
|
+
}
|
|
113
|
+
export default LunarConverter;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function plus(a: any, b: any): any;
|
|
2
|
+
export function minus(a: any, b: any): any;
|
|
3
|
+
export function times(a: any, b: any): any;
|
|
4
|
+
export function div(a: any, b: any): any;
|
|
5
|
+
declare namespace _default {
|
|
6
|
+
export { plus };
|
|
7
|
+
export { minus };
|
|
8
|
+
export { times };
|
|
9
|
+
export { div };
|
|
10
|
+
}
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const WebSocketNative: {
|
|
2
|
+
new (url: string | URL, protocols?: string | string[]): WebSocket;
|
|
3
|
+
prototype: WebSocket;
|
|
4
|
+
readonly CONNECTING: 0;
|
|
5
|
+
readonly OPEN: 1;
|
|
6
|
+
readonly CLOSING: 2;
|
|
7
|
+
readonly CLOSED: 3;
|
|
8
|
+
};
|
|
9
|
+
export class MockWebSocket extends EventTarget {
|
|
10
|
+
static add(url: any, template: any, other: any): void;
|
|
11
|
+
constructor(url: any, protocols: any);
|
|
12
|
+
get readyState(): any;
|
|
13
|
+
close(code: any, reason: any): void;
|
|
14
|
+
send(data: any): void;
|
|
15
|
+
#private;
|
|
16
|
+
}
|
|
17
|
+
export default MockWebSocket;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const XMLHttpRequestNative: {
|
|
2
|
+
new (): XMLHttpRequest;
|
|
3
|
+
prototype: XMLHttpRequest;
|
|
4
|
+
readonly UNSENT: 0;
|
|
5
|
+
readonly OPENED: 1;
|
|
6
|
+
readonly HEADERS_RECEIVED: 2;
|
|
7
|
+
readonly LOADING: 3;
|
|
8
|
+
readonly DONE: 4;
|
|
9
|
+
};
|
|
10
|
+
export class MockXMLHttpRequest extends XMLHttpRequest {
|
|
11
|
+
static add(url: any, method: string | undefined, template: any, other: any): void;
|
|
12
|
+
constructor(v: any);
|
|
13
|
+
open(method: any, url: any, async?: boolean, username?: null, password?: null): void;
|
|
14
|
+
send(body: any): void;
|
|
15
|
+
#private;
|
|
16
|
+
}
|
|
17
|
+
export default MockXMLHttpRequest;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default ExecutionEnvironment;
|
|
2
|
+
declare namespace ExecutionEnvironment {
|
|
3
|
+
export { canUseDOM };
|
|
4
|
+
export let canUseWorkers: boolean;
|
|
5
|
+
export let canUseEventListeners: boolean;
|
|
6
|
+
export let canUseViewport: boolean;
|
|
7
|
+
export let isInWorker: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const canUseDOM: boolean;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export default UserAgent_DEPRECATED;
|
|
2
|
+
declare namespace UserAgent_DEPRECATED {
|
|
3
|
+
/**
|
|
4
|
+
* Check if the UA is Internet Explorer.
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* @return float|NaN Version number (if match) or NaN.
|
|
8
|
+
*/
|
|
9
|
+
function ie(): any;
|
|
10
|
+
/**
|
|
11
|
+
* Check if we're in Internet Explorer compatibility mode.
|
|
12
|
+
*
|
|
13
|
+
* @return bool true if in compatibility mode, false if
|
|
14
|
+
* not compatibility mode or not ie
|
|
15
|
+
*/
|
|
16
|
+
function ieCompatibilityMode(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the browser is 64-bit IE. Really, this is kind of weak sauce; we
|
|
19
|
+
* only need this because Skype can't handle 64-bit IE yet. We need to remove
|
|
20
|
+
* this when we don't need it -- tracked by #601957.
|
|
21
|
+
*/
|
|
22
|
+
function ie64(): any;
|
|
23
|
+
/**
|
|
24
|
+
* Check if the UA is Firefox.
|
|
25
|
+
*
|
|
26
|
+
*
|
|
27
|
+
* @return float|NaN Version number (if match) or NaN.
|
|
28
|
+
*/
|
|
29
|
+
function firefox(): any;
|
|
30
|
+
/**
|
|
31
|
+
* Check if the UA is Opera.
|
|
32
|
+
*
|
|
33
|
+
*
|
|
34
|
+
* @return float|NaN Version number (if match) or NaN.
|
|
35
|
+
*/
|
|
36
|
+
function opera(): any;
|
|
37
|
+
/**
|
|
38
|
+
* Check if the UA is WebKit.
|
|
39
|
+
*
|
|
40
|
+
*
|
|
41
|
+
* @return float|NaN Version number (if match) or NaN.
|
|
42
|
+
*/
|
|
43
|
+
function webkit(): any;
|
|
44
|
+
/**
|
|
45
|
+
* For Push
|
|
46
|
+
* WILL BE REMOVED VERY SOON. Use UserAgent_DEPRECATED.webkit
|
|
47
|
+
*/
|
|
48
|
+
function safari(): any;
|
|
49
|
+
/**
|
|
50
|
+
* Check if the UA is a Chrome browser.
|
|
51
|
+
*
|
|
52
|
+
*
|
|
53
|
+
* @return float|NaN Version number (if match) or NaN.
|
|
54
|
+
*/
|
|
55
|
+
function chrome(): any;
|
|
56
|
+
/**
|
|
57
|
+
* Check if the user is running Windows.
|
|
58
|
+
*
|
|
59
|
+
* @return bool `true' if the user's OS is Windows.
|
|
60
|
+
*/
|
|
61
|
+
function windows(): any;
|
|
62
|
+
/**
|
|
63
|
+
* Check if the user is running Mac OS X.
|
|
64
|
+
*
|
|
65
|
+
* @return float|bool Returns a float if a version number is detected,
|
|
66
|
+
* otherwise true/false.
|
|
67
|
+
*/
|
|
68
|
+
function osx(): any;
|
|
69
|
+
/**
|
|
70
|
+
* Check if the user is running Linux.
|
|
71
|
+
*
|
|
72
|
+
* @return bool `true' if the user's OS is some flavor of Linux.
|
|
73
|
+
*/
|
|
74
|
+
function linux(): any;
|
|
75
|
+
/**
|
|
76
|
+
* Check if the user is running on an iPhone or iPod platform.
|
|
77
|
+
*
|
|
78
|
+
* @return bool `true' if the user is running some flavor of the
|
|
79
|
+
* iPhone OS.
|
|
80
|
+
*/
|
|
81
|
+
function iphone(): any;
|
|
82
|
+
function mobile(): any;
|
|
83
|
+
function nativeApp(): any;
|
|
84
|
+
function android(): any;
|
|
85
|
+
function ipad(): any;
|
|
86
|
+
}
|