@heyform-inc/utils 1.0.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/dist/index.d.mts +143 -0
- package/dist/index.d.ts +143 -0
- package/dist/index.js +791 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +704 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +70 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
export * from 'deep-object-diff';
|
|
2
|
+
import dayjs, { QUnitType, OpUnitType } from 'dayjs';
|
|
3
|
+
import validatorIsUUID from 'validator/lib/isUUID';
|
|
4
|
+
import * as m from 'mime-types';
|
|
5
|
+
export { v4 as uuidv4, v5 as uuidv5 } from 'uuid';
|
|
6
|
+
|
|
7
|
+
declare function parseBytes(value: string | number): number | undefined;
|
|
8
|
+
declare function bytes(size: string): number | undefined;
|
|
9
|
+
declare function formatBytes(value: string | number): string;
|
|
10
|
+
|
|
11
|
+
declare function clone<T>(obj: T): T;
|
|
12
|
+
|
|
13
|
+
declare function isHexColor(color: string): boolean;
|
|
14
|
+
declare function isRgba(color: string): boolean;
|
|
15
|
+
declare function isRgb(color: string): boolean;
|
|
16
|
+
declare function hexToRgb(hex: string): number[];
|
|
17
|
+
declare function isDarkColor(hex: string): boolean;
|
|
18
|
+
declare function isLightColor(hex: string): boolean;
|
|
19
|
+
declare function colorBrightness(hex: string): number;
|
|
20
|
+
declare function rgbToHex([r, g, b]: number[]): string;
|
|
21
|
+
declare function alpha(hex: string, alpha: number): string;
|
|
22
|
+
declare function lighten(hex: string, alpha: number): string;
|
|
23
|
+
declare function darken(hex: string, alpha: number): string;
|
|
24
|
+
declare function invert(hex: string): string;
|
|
25
|
+
declare function alphaHexToRgb(hex: string, alpha: number, backgroundHex: string): number[];
|
|
26
|
+
|
|
27
|
+
declare function toBool(value: unknown, defaults?: boolean): boolean;
|
|
28
|
+
|
|
29
|
+
type DayJS = dayjs.Dayjs;
|
|
30
|
+
declare function timestamp(): number;
|
|
31
|
+
declare function date(str?: string, format?: string): DayJS;
|
|
32
|
+
declare function unixDate(t: number): DayJS;
|
|
33
|
+
declare function isDateExpired(start: number, end: number, expire: string): boolean;
|
|
34
|
+
declare function unixDiff(start: number, end: number, unit?: QUnitType | OpUnitType): number;
|
|
35
|
+
declare function datePeriod(start: number, value?: number, unit?: OpUnitType): number;
|
|
36
|
+
|
|
37
|
+
declare function isBoolean(arg: any): boolean;
|
|
38
|
+
declare function isString(arg: any): boolean;
|
|
39
|
+
declare function isNumber(arg: any): boolean;
|
|
40
|
+
declare function isNumeric(arg: any): boolean;
|
|
41
|
+
declare function isValidArray(arg: any): boolean;
|
|
42
|
+
declare function isNan(arg: any): boolean;
|
|
43
|
+
declare function isSet(arg: any): boolean;
|
|
44
|
+
declare function isMap(arg: any): boolean;
|
|
45
|
+
declare function isSymbol(arg: any): boolean;
|
|
46
|
+
declare function isObject(arg: any): boolean;
|
|
47
|
+
declare function isDate(arg: any): boolean;
|
|
48
|
+
declare function isRegExp(arg: any): boolean;
|
|
49
|
+
declare function isError(arg: any): boolean;
|
|
50
|
+
declare function isFunction(arg: any): boolean;
|
|
51
|
+
declare function isNull(arg: any): boolean;
|
|
52
|
+
declare function isUndefined(arg: any): boolean;
|
|
53
|
+
declare function isNil(arg: any): boolean;
|
|
54
|
+
declare function isPlainObject(arg: any): boolean;
|
|
55
|
+
declare function isEmpty(arg: any): boolean;
|
|
56
|
+
declare function isValid(arg: any): boolean;
|
|
57
|
+
declare function isEqual(arg1: any, arg2: any): boolean;
|
|
58
|
+
declare function isTrue(arg1: any): boolean;
|
|
59
|
+
declare function isFalse(arg1: any): boolean;
|
|
60
|
+
declare function isBool(arg: any): boolean;
|
|
61
|
+
declare function isFormData(arg: any): boolean;
|
|
62
|
+
declare function uniqueArray(arg: any): any[];
|
|
63
|
+
declare function isURL(arg: any): boolean;
|
|
64
|
+
declare const _default$1: {
|
|
65
|
+
isUUID: typeof validatorIsUUID;
|
|
66
|
+
isBoolean: typeof isBoolean;
|
|
67
|
+
isString: typeof isString;
|
|
68
|
+
isNumber: typeof isNumber;
|
|
69
|
+
isNumeric: typeof isNumeric;
|
|
70
|
+
isArray: (arg: any) => arg is any[];
|
|
71
|
+
isValidArray: typeof isValidArray;
|
|
72
|
+
isNan: typeof isNan;
|
|
73
|
+
isSet: typeof isSet;
|
|
74
|
+
isMap: typeof isMap;
|
|
75
|
+
isSymbol: typeof isSymbol;
|
|
76
|
+
isObject: typeof isObject;
|
|
77
|
+
isDate: typeof isDate;
|
|
78
|
+
isRegExp: typeof isRegExp;
|
|
79
|
+
isError: typeof isError;
|
|
80
|
+
isFunction: typeof isFunction;
|
|
81
|
+
isNull: typeof isNull;
|
|
82
|
+
isUndefined: typeof isUndefined;
|
|
83
|
+
isNil: typeof isNil;
|
|
84
|
+
isPlainObject: typeof isPlainObject;
|
|
85
|
+
isEmpty: typeof isEmpty;
|
|
86
|
+
isValid: typeof isValid;
|
|
87
|
+
isEqual: typeof isEqual;
|
|
88
|
+
isTrue: typeof isTrue;
|
|
89
|
+
isFalse: typeof isFalse;
|
|
90
|
+
isBool: typeof isBool;
|
|
91
|
+
isURL: typeof isURL;
|
|
92
|
+
isFormData: typeof isFormData;
|
|
93
|
+
uniqueArray: typeof uniqueArray;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
declare function hs(arg: string): number | undefined;
|
|
97
|
+
declare function ms(arg: string): number | undefined;
|
|
98
|
+
|
|
99
|
+
declare const commonImageMimeTypes: string[];
|
|
100
|
+
declare const commonFileMimeTypes: string[];
|
|
101
|
+
declare const mime: typeof m.lookup;
|
|
102
|
+
|
|
103
|
+
declare function nanoid(len?: number): string;
|
|
104
|
+
declare function nanoidCustomAlphabet(alphabet: string, len?: number): string;
|
|
105
|
+
|
|
106
|
+
declare function pickObject(target: Record<string, any>, fields: Array<string | string[]>, excludes?: Array<string>): Record<string, any>;
|
|
107
|
+
declare function pickValidValues<T = string | number | boolean>(target: Record<string, T>, fields: Array<string | string[]>): Record<string, T>;
|
|
108
|
+
declare function removeObjectNil(target: Record<string, any>): Record<string, any>;
|
|
109
|
+
declare function copyObjectValues(target: Record<string, any>, dist: Record<string, any>, keyMaps: Array<string | string[]>): void;
|
|
110
|
+
|
|
111
|
+
declare function parseJson(str: string, defaultValue?: any): any;
|
|
112
|
+
declare function parseBool(arg: any, defaultValue?: boolean): boolean;
|
|
113
|
+
declare function parseNumber(arg: any, defaultValue?: number, maxValue?: number): number | undefined;
|
|
114
|
+
declare function htmlToText(html: string, limit?: number): string;
|
|
115
|
+
|
|
116
|
+
interface QsOptions {
|
|
117
|
+
encode?: boolean;
|
|
118
|
+
decode?: boolean;
|
|
119
|
+
separator?: string;
|
|
120
|
+
}
|
|
121
|
+
declare function stringify(arg: Record<string, any>, options?: QsOptions): string;
|
|
122
|
+
declare function parse(str: string, options?: QsOptions): Record<string, any>;
|
|
123
|
+
declare const _default: {
|
|
124
|
+
stringify: typeof stringify;
|
|
125
|
+
parse: typeof parse;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
declare enum RandomType {
|
|
129
|
+
LOWER = 0,
|
|
130
|
+
UPPER = 1,
|
|
131
|
+
NUMERIC = 2,
|
|
132
|
+
HEXIC = 3,
|
|
133
|
+
LOWER_NUMERIC = 4,
|
|
134
|
+
UPPER_NUMERIC = 5,
|
|
135
|
+
ALPHANUMERIC = 6
|
|
136
|
+
}
|
|
137
|
+
declare function random(len?: number, type?: RandomType): string;
|
|
138
|
+
|
|
139
|
+
declare function slugify(text: string): string;
|
|
140
|
+
|
|
141
|
+
declare function type(obj: any): string;
|
|
142
|
+
|
|
143
|
+
export { type DayJS, RandomType, alpha, alphaHexToRgb, bytes, clone, colorBrightness, commonFileMimeTypes, commonImageMimeTypes, copyObjectValues, darken, date, datePeriod, formatBytes, _default$1 as helper, hexToRgb, hs, htmlToText, invert, isDarkColor, isDateExpired, isHexColor, isLightColor, isRgb, isRgba, lighten, mime, ms, nanoid, nanoidCustomAlphabet, parseBool, parseBytes, parseJson, parseNumber, pickObject, pickValidValues, _default as qs, random, removeObjectNil, rgbToHex, slugify, timestamp, toBool, type, unixDate, unixDiff };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
export * from 'deep-object-diff';
|
|
2
|
+
import dayjs, { QUnitType, OpUnitType } from 'dayjs';
|
|
3
|
+
import validatorIsUUID from 'validator/lib/isUUID';
|
|
4
|
+
import * as m from 'mime-types';
|
|
5
|
+
export { v4 as uuidv4, v5 as uuidv5 } from 'uuid';
|
|
6
|
+
|
|
7
|
+
declare function parseBytes(value: string | number): number | undefined;
|
|
8
|
+
declare function bytes(size: string): number | undefined;
|
|
9
|
+
declare function formatBytes(value: string | number): string;
|
|
10
|
+
|
|
11
|
+
declare function clone<T>(obj: T): T;
|
|
12
|
+
|
|
13
|
+
declare function isHexColor(color: string): boolean;
|
|
14
|
+
declare function isRgba(color: string): boolean;
|
|
15
|
+
declare function isRgb(color: string): boolean;
|
|
16
|
+
declare function hexToRgb(hex: string): number[];
|
|
17
|
+
declare function isDarkColor(hex: string): boolean;
|
|
18
|
+
declare function isLightColor(hex: string): boolean;
|
|
19
|
+
declare function colorBrightness(hex: string): number;
|
|
20
|
+
declare function rgbToHex([r, g, b]: number[]): string;
|
|
21
|
+
declare function alpha(hex: string, alpha: number): string;
|
|
22
|
+
declare function lighten(hex: string, alpha: number): string;
|
|
23
|
+
declare function darken(hex: string, alpha: number): string;
|
|
24
|
+
declare function invert(hex: string): string;
|
|
25
|
+
declare function alphaHexToRgb(hex: string, alpha: number, backgroundHex: string): number[];
|
|
26
|
+
|
|
27
|
+
declare function toBool(value: unknown, defaults?: boolean): boolean;
|
|
28
|
+
|
|
29
|
+
type DayJS = dayjs.Dayjs;
|
|
30
|
+
declare function timestamp(): number;
|
|
31
|
+
declare function date(str?: string, format?: string): DayJS;
|
|
32
|
+
declare function unixDate(t: number): DayJS;
|
|
33
|
+
declare function isDateExpired(start: number, end: number, expire: string): boolean;
|
|
34
|
+
declare function unixDiff(start: number, end: number, unit?: QUnitType | OpUnitType): number;
|
|
35
|
+
declare function datePeriod(start: number, value?: number, unit?: OpUnitType): number;
|
|
36
|
+
|
|
37
|
+
declare function isBoolean(arg: any): boolean;
|
|
38
|
+
declare function isString(arg: any): boolean;
|
|
39
|
+
declare function isNumber(arg: any): boolean;
|
|
40
|
+
declare function isNumeric(arg: any): boolean;
|
|
41
|
+
declare function isValidArray(arg: any): boolean;
|
|
42
|
+
declare function isNan(arg: any): boolean;
|
|
43
|
+
declare function isSet(arg: any): boolean;
|
|
44
|
+
declare function isMap(arg: any): boolean;
|
|
45
|
+
declare function isSymbol(arg: any): boolean;
|
|
46
|
+
declare function isObject(arg: any): boolean;
|
|
47
|
+
declare function isDate(arg: any): boolean;
|
|
48
|
+
declare function isRegExp(arg: any): boolean;
|
|
49
|
+
declare function isError(arg: any): boolean;
|
|
50
|
+
declare function isFunction(arg: any): boolean;
|
|
51
|
+
declare function isNull(arg: any): boolean;
|
|
52
|
+
declare function isUndefined(arg: any): boolean;
|
|
53
|
+
declare function isNil(arg: any): boolean;
|
|
54
|
+
declare function isPlainObject(arg: any): boolean;
|
|
55
|
+
declare function isEmpty(arg: any): boolean;
|
|
56
|
+
declare function isValid(arg: any): boolean;
|
|
57
|
+
declare function isEqual(arg1: any, arg2: any): boolean;
|
|
58
|
+
declare function isTrue(arg1: any): boolean;
|
|
59
|
+
declare function isFalse(arg1: any): boolean;
|
|
60
|
+
declare function isBool(arg: any): boolean;
|
|
61
|
+
declare function isFormData(arg: any): boolean;
|
|
62
|
+
declare function uniqueArray(arg: any): any[];
|
|
63
|
+
declare function isURL(arg: any): boolean;
|
|
64
|
+
declare const _default$1: {
|
|
65
|
+
isUUID: typeof validatorIsUUID;
|
|
66
|
+
isBoolean: typeof isBoolean;
|
|
67
|
+
isString: typeof isString;
|
|
68
|
+
isNumber: typeof isNumber;
|
|
69
|
+
isNumeric: typeof isNumeric;
|
|
70
|
+
isArray: (arg: any) => arg is any[];
|
|
71
|
+
isValidArray: typeof isValidArray;
|
|
72
|
+
isNan: typeof isNan;
|
|
73
|
+
isSet: typeof isSet;
|
|
74
|
+
isMap: typeof isMap;
|
|
75
|
+
isSymbol: typeof isSymbol;
|
|
76
|
+
isObject: typeof isObject;
|
|
77
|
+
isDate: typeof isDate;
|
|
78
|
+
isRegExp: typeof isRegExp;
|
|
79
|
+
isError: typeof isError;
|
|
80
|
+
isFunction: typeof isFunction;
|
|
81
|
+
isNull: typeof isNull;
|
|
82
|
+
isUndefined: typeof isUndefined;
|
|
83
|
+
isNil: typeof isNil;
|
|
84
|
+
isPlainObject: typeof isPlainObject;
|
|
85
|
+
isEmpty: typeof isEmpty;
|
|
86
|
+
isValid: typeof isValid;
|
|
87
|
+
isEqual: typeof isEqual;
|
|
88
|
+
isTrue: typeof isTrue;
|
|
89
|
+
isFalse: typeof isFalse;
|
|
90
|
+
isBool: typeof isBool;
|
|
91
|
+
isURL: typeof isURL;
|
|
92
|
+
isFormData: typeof isFormData;
|
|
93
|
+
uniqueArray: typeof uniqueArray;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
declare function hs(arg: string): number | undefined;
|
|
97
|
+
declare function ms(arg: string): number | undefined;
|
|
98
|
+
|
|
99
|
+
declare const commonImageMimeTypes: string[];
|
|
100
|
+
declare const commonFileMimeTypes: string[];
|
|
101
|
+
declare const mime: typeof m.lookup;
|
|
102
|
+
|
|
103
|
+
declare function nanoid(len?: number): string;
|
|
104
|
+
declare function nanoidCustomAlphabet(alphabet: string, len?: number): string;
|
|
105
|
+
|
|
106
|
+
declare function pickObject(target: Record<string, any>, fields: Array<string | string[]>, excludes?: Array<string>): Record<string, any>;
|
|
107
|
+
declare function pickValidValues<T = string | number | boolean>(target: Record<string, T>, fields: Array<string | string[]>): Record<string, T>;
|
|
108
|
+
declare function removeObjectNil(target: Record<string, any>): Record<string, any>;
|
|
109
|
+
declare function copyObjectValues(target: Record<string, any>, dist: Record<string, any>, keyMaps: Array<string | string[]>): void;
|
|
110
|
+
|
|
111
|
+
declare function parseJson(str: string, defaultValue?: any): any;
|
|
112
|
+
declare function parseBool(arg: any, defaultValue?: boolean): boolean;
|
|
113
|
+
declare function parseNumber(arg: any, defaultValue?: number, maxValue?: number): number | undefined;
|
|
114
|
+
declare function htmlToText(html: string, limit?: number): string;
|
|
115
|
+
|
|
116
|
+
interface QsOptions {
|
|
117
|
+
encode?: boolean;
|
|
118
|
+
decode?: boolean;
|
|
119
|
+
separator?: string;
|
|
120
|
+
}
|
|
121
|
+
declare function stringify(arg: Record<string, any>, options?: QsOptions): string;
|
|
122
|
+
declare function parse(str: string, options?: QsOptions): Record<string, any>;
|
|
123
|
+
declare const _default: {
|
|
124
|
+
stringify: typeof stringify;
|
|
125
|
+
parse: typeof parse;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
declare enum RandomType {
|
|
129
|
+
LOWER = 0,
|
|
130
|
+
UPPER = 1,
|
|
131
|
+
NUMERIC = 2,
|
|
132
|
+
HEXIC = 3,
|
|
133
|
+
LOWER_NUMERIC = 4,
|
|
134
|
+
UPPER_NUMERIC = 5,
|
|
135
|
+
ALPHANUMERIC = 6
|
|
136
|
+
}
|
|
137
|
+
declare function random(len?: number, type?: RandomType): string;
|
|
138
|
+
|
|
139
|
+
declare function slugify(text: string): string;
|
|
140
|
+
|
|
141
|
+
declare function type(obj: any): string;
|
|
142
|
+
|
|
143
|
+
export { type DayJS, RandomType, alpha, alphaHexToRgb, bytes, clone, colorBrightness, commonFileMimeTypes, commonImageMimeTypes, copyObjectValues, darken, date, datePeriod, formatBytes, _default$1 as helper, hexToRgb, hs, htmlToText, invert, isDarkColor, isDateExpired, isHexColor, isLightColor, isRgb, isRgba, lighten, mime, ms, nanoid, nanoidCustomAlphabet, parseBool, parseBytes, parseJson, parseNumber, pickObject, pickValidValues, _default as qs, random, removeObjectNil, rgbToHex, slugify, timestamp, toBool, type, unixDate, unixDiff };
|