@unicom-cloud/utils 0.1.10 → 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/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 +38 -30
- 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.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,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
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export default normalizeWheel;
|
|
2
|
+
/**
|
|
3
|
+
* Mouse wheel (and 2-finger trackpad) support on the web sucks. It is
|
|
4
|
+
* complicated, thus this doc is long and (hopefully) detailed enough to answer
|
|
5
|
+
* your questions.
|
|
6
|
+
*
|
|
7
|
+
* If you need to react to the mouse wheel in a predictable way, this code is
|
|
8
|
+
* like your bestest friend. * hugs *
|
|
9
|
+
*
|
|
10
|
+
* As of today, there are 4 DOM event types you can listen to:
|
|
11
|
+
*
|
|
12
|
+
* 'wheel' -- Chrome(31+), FF(17+), IE(9+)
|
|
13
|
+
* 'mousewheel' -- Chrome, IE(6+), Opera, Safari
|
|
14
|
+
* 'MozMousePixelScroll' -- FF(3.5 only!) (2010-2013) -- don't bother!
|
|
15
|
+
* 'DOMMouseScroll' -- FF(0.9.7+) since 2003
|
|
16
|
+
*
|
|
17
|
+
* So what to do? The is the best:
|
|
18
|
+
*
|
|
19
|
+
* normalizeWheel.getEventType();
|
|
20
|
+
*
|
|
21
|
+
* In your event callback, use this code to get sane interpretation of the
|
|
22
|
+
* deltas. This code will return an object with properties:
|
|
23
|
+
*
|
|
24
|
+
* spinX -- normalized spin speed (use for zoom) - x plane
|
|
25
|
+
* spinY -- " - y plane
|
|
26
|
+
* pixelX -- normalized distance (to pixels) - x plane
|
|
27
|
+
* pixelY -- " - y plane
|
|
28
|
+
*
|
|
29
|
+
* Wheel values are provided by the browser assuming you are using the wheel to
|
|
30
|
+
* scroll a web page by a number of lines or pixels (or pages). Values can vary
|
|
31
|
+
* significantly on different platforms and browsers, forgetting that you can
|
|
32
|
+
* scroll at different speeds. Some devices (like trackpads) emit more events
|
|
33
|
+
* at smaller increments with fine granularity, and some emit massive jumps with
|
|
34
|
+
* linear speed or acceleration.
|
|
35
|
+
*
|
|
36
|
+
* This code does its best to normalize the deltas for you:
|
|
37
|
+
*
|
|
38
|
+
* - spin is trying to normalize how far the wheel was spun (or trackpad
|
|
39
|
+
* dragged). This is super useful for zoom support where you want to
|
|
40
|
+
* throw away the chunky scroll steps on the PC and make those equal to
|
|
41
|
+
* the slow and smooth tiny steps on the Mac. Key data: This code tries to
|
|
42
|
+
* resolve a single slow step on a wheel to 1.
|
|
43
|
+
*
|
|
44
|
+
* - pixel is normalizing the desired scroll delta in pixel units. You'll
|
|
45
|
+
* get the crazy differences between browsers, but at least it'll be in
|
|
46
|
+
* pixels!
|
|
47
|
+
*
|
|
48
|
+
* - positive value indicates scrolling DOWN/RIGHT, negative UP/LEFT. This
|
|
49
|
+
* should translate to positive value zooming IN, negative zooming OUT.
|
|
50
|
+
* This matches the newer 'wheel' event.
|
|
51
|
+
*
|
|
52
|
+
* Why are there spinX, spinY (or pixels)?
|
|
53
|
+
*
|
|
54
|
+
* - spinX is a 2-finger side drag on the trackpad, and a shift + wheel turn
|
|
55
|
+
* with a mouse. It results in side-scrolling in the browser by default.
|
|
56
|
+
*
|
|
57
|
+
* - spinY is what you expect -- it's the classic axis of a mouse wheel.
|
|
58
|
+
*
|
|
59
|
+
* - I dropped spinZ/pixelZ. It is supported by the DOM 3 'wheel' event and
|
|
60
|
+
* probably is by browsers in conjunction with fancy 3D controllers .. but
|
|
61
|
+
* you know.
|
|
62
|
+
*
|
|
63
|
+
* Implementation info:
|
|
64
|
+
*
|
|
65
|
+
* Examples of 'wheel' event if you scroll slowly (down) by one step with an
|
|
66
|
+
* average mouse:
|
|
67
|
+
*
|
|
68
|
+
* OS X + Chrome (mouse) - 4 pixel delta (wheelDelta -120)
|
|
69
|
+
* OS X + Safari (mouse) - N/A pixel delta (wheelDelta -12)
|
|
70
|
+
* OS X + Firefox (mouse) - 0.1 line delta (wheelDelta N/A)
|
|
71
|
+
* Win8 + Chrome (mouse) - 100 pixel delta (wheelDelta -120)
|
|
72
|
+
* Win8 + Firefox (mouse) - 3 line delta (wheelDelta -120)
|
|
73
|
+
*
|
|
74
|
+
* On the trackpad:
|
|
75
|
+
*
|
|
76
|
+
* OS X + Chrome (trackpad) - 2 pixel delta (wheelDelta -6)
|
|
77
|
+
* OS X + Firefox (trackpad) - 1 pixel delta (wheelDelta N/A)
|
|
78
|
+
*
|
|
79
|
+
* On other/older browsers.. it's more complicated as there can be multiple and
|
|
80
|
+
* also missing delta values.
|
|
81
|
+
*
|
|
82
|
+
* The 'wheel' event is more standard:
|
|
83
|
+
*
|
|
84
|
+
* http://www.w3.org/TR/DOM-Level-3-Events/#events-wheelevents
|
|
85
|
+
*
|
|
86
|
+
* The basics is that it includes a unit, deltaMode (pixels, lines, pages), and
|
|
87
|
+
* deltaX, deltaY and deltaZ. Some browsers provide other values to maintain
|
|
88
|
+
* backward compatibility with older events. Those other values help us
|
|
89
|
+
* better normalize spin speed. Example of what the browsers provide:
|
|
90
|
+
*
|
|
91
|
+
* | event.wheelDelta | event.detail
|
|
92
|
+
* ------------------+------------------+--------------
|
|
93
|
+
* Safari v5/OS X | -120 | 0
|
|
94
|
+
* Safari v5/Win7 | -120 | 0
|
|
95
|
+
* Chrome v17/OS X | -120 | 0
|
|
96
|
+
* Chrome v17/Win7 | -120 | 0
|
|
97
|
+
* IE9/Win7 | -120 | undefined
|
|
98
|
+
* Firefox v4/OS X | undefined | 1
|
|
99
|
+
* Firefox v4/Win7 | undefined | 3
|
|
100
|
+
*
|
|
101
|
+
*/
|
|
102
|
+
declare function normalizeWheel(event: any): {
|
|
103
|
+
spinX: number;
|
|
104
|
+
spinY: number;
|
|
105
|
+
pixelX: number;
|
|
106
|
+
pixelY: number;
|
|
107
|
+
};
|
|
108
|
+
declare namespace normalizeWheel {
|
|
109
|
+
/**
|
|
110
|
+
* The best combination if you prefer spinX + spinY normalization. It favors
|
|
111
|
+
* the older DOMMouseScroll for Firefox, as FF does not include wheelDelta with
|
|
112
|
+
* 'wheel' event, making spin speed determination impossible.
|
|
113
|
+
*/
|
|
114
|
+
function getEventType(): "wheel" | "DOMMouseScroll" | "mousewheel";
|
|
115
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default isEventSupported;
|
|
2
|
+
/**
|
|
3
|
+
* Checks if an event is supported in the current execution environment.
|
|
4
|
+
*
|
|
5
|
+
* NOTE: This will not work correctly for non-generic events such as `change`,
|
|
6
|
+
* `reset`, `load`, `error`, and `select`.
|
|
7
|
+
*
|
|
8
|
+
* Borrows from Modernizr.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} eventNameSuffix Event name, e.g. "click".
|
|
11
|
+
* @param {?boolean} capture Check if the capture phase is supported.
|
|
12
|
+
* @return {boolean} True if the event is supported.
|
|
13
|
+
* @internal
|
|
14
|
+
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
15
|
+
*/
|
|
16
|
+
declare function isEventSupported(eventNameSuffix: string, capture: boolean | null): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface NumberToChineseOptions {
|
|
2
|
+
mode?: 'normal' | 'money';
|
|
3
|
+
negativeSymbol?: string;
|
|
4
|
+
decimalDigits?: number;
|
|
5
|
+
trailingZeros?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* 数字转中文主函数
|
|
9
|
+
*/
|
|
10
|
+
declare function numberToChinese(num: number, options?: NumberToChineseOptions): string;
|
|
11
|
+
export default numberToChinese;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
encodeS: (num: any, options: any) => string;
|
|
3
|
+
encodeB: (num: any, options: any) => string;
|
|
4
|
+
decodeS: (...args: any[]) => string | number;
|
|
5
|
+
decodeB: (...args: any[]) => string | number;
|
|
6
|
+
toMoney: (num: any, options: any) => string;
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
encodeS: (num: any, options: any) => string;
|
|
3
|
+
encodeB: (num: any, options: any) => string;
|
|
4
|
+
decodeS: (...args: any[]) => string | number;
|
|
5
|
+
decodeB: (...args: any[]) => string | number;
|
|
6
|
+
toMoney: (num: any, options: any) => string;
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|