danholibraryjs 2.0.0 → 2.0.2
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/README.md +1 -1
- package/_package.github-release.json +6 -0
- package/_package.npm-release.json +6 -0
- package/dist/Extensions/Array/index.d.ts +6 -20
- package/dist/Extensions/Array/index.js +8 -26
- package/dist/Extensions/Array/random.extension.d.ts +1 -2
- package/dist/Extensions/Array/random.extension.js +1 -22
- package/dist/Extensions/Array/string.extension.d.ts +3 -4
- package/dist/Extensions/Number.d.ts +2 -2
- package/dist/Extensions/Number.js +1 -1
- package/dist/Extensions/Object/arrays.extension.d.ts +14 -0
- package/dist/Extensions/Object/arrays.extension.js +7 -2
- package/dist/Extensions/Object/extracts.extension.d.ts +6 -6
- package/dist/Extensions/Object/extracts.extension.js +10 -7
- package/dist/Extensions/Object/index.d.ts +4 -10
- package/dist/Extensions/Object/index.js +6 -22
- package/dist/Extensions/Object/properties.extension.d.ts +28 -1
- package/dist/Extensions/Object/properties.extension.js +19 -2
- package/dist/Extensions/Object/properties.js +2 -1
- package/dist/Extensions/String/index.d.ts +2 -4
- package/dist/Extensions/String/index.js +4 -16
- package/dist/Extensions/String/string.extension.d.ts +6 -0
- package/dist/Extensions/String/string.extension.js +10 -0
- package/dist/Extensions/index.d.ts +2 -2
- package/dist/Extensions/index.js +2 -2
- package/dist/Types/Able.d.ts +1 -1
- package/dist/Utils/NumberUtils.d.ts +5 -0
- package/dist/Utils/NumberUtils.js +25 -1
- package/dist/Utils/StringUtils.d.ts +5 -0
- package/dist/Utils/StringUtils.js +6 -1
- package/dist/Utils/TimeUtils/index.d.ts +3 -0
- package/dist/Utils/TimeUtils/index.js +2 -0
- package/dist/Utils/TimeUtils/string.util.d.ts +3 -0
- package/dist/Utils/TimeUtils/string.util.js +19 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/docs/Classes.md +78 -3
- package/docs/Extensions.md +247 -73
- package/docs/Types.md +202 -58
- package/docs/Utils.md +335 -0
- package/docs/index.md +1 -1
- package/package.json +1 -1
- package/src/Extensions/Array/index.ts +6 -15
- package/src/Extensions/Array/random.extension.ts +2 -25
- package/src/Extensions/Array/string.extension.ts +3 -4
- package/src/Extensions/Number.ts +3 -3
- package/src/Extensions/Object/arrays.extension.ts +23 -2
- package/src/Extensions/Object/extracts.extension.ts +18 -13
- package/src/Extensions/Object/index.ts +4 -11
- package/src/Extensions/Object/properties.extension.ts +50 -2
- package/src/Extensions/String/index.ts +2 -5
- package/src/Extensions/String/string.extension.ts +11 -0
- package/src/Extensions/index.ts +2 -2
- package/src/Types/Able.ts +1 -1
- package/src/Utils/NumberUtils.ts +27 -0
- package/src/Utils/StringUtils.ts +7 -1
- package/src/Utils/TimeUtils/index.ts +2 -0
- package/src/Utils/TimeUtils/string.util.ts +13 -0
- package/src/index.ts +2 -2
- package/dist/Extensions/Array.d.ts +0 -52
- package/dist/Extensions/Array.js +0 -51
- package/dist/Extensions/Document.d.ts +0 -27
- package/dist/Extensions/Document.js +0 -32
- package/dist/Extensions/String.d.ts +0 -36
- package/dist/Extensions/String.js +0 -25
- package/dist/Functions/CopyToClipboard.d.ts +0 -7
- package/dist/Functions/CopyToClipboard.js +0 -15
- package/dist/Functions/GetCSSProperty.d.ts +0 -15
- package/dist/Functions/GetCSSProperty.js +0 -26
- package/dist/Functions/GetNestedProperty.d.ts +0 -9
- package/dist/Functions/GetNestedProperty.js +0 -23
- package/dist/Functions/HTMLEvent.d.ts +0 -11
- package/dist/Functions/HTMLEvent.js +0 -14
- package/dist/Functions/SetNavigationSelected.d.ts +0 -9
- package/dist/Functions/SetNavigationSelected.js +0 -25
- package/dist/Functions/index.d.ts +0 -5
- package/dist/Functions/index.js +0 -21
- package/dist/Utils/ApiUtil/ApiTypes.d.ts +0 -15
- package/dist/Utils/ApiUtil/ApiTypes.js +0 -15
- package/dist/Utils/ApiUtil/RequestUtil.d.ts +0 -19
- package/dist/Utils/ApiUtil/RequestUtil.js +0 -73
- package/dist/Utils/ApiUtil/index.d.ts +0 -20
- package/dist/Utils/ApiUtil/index.js +0 -33
- package/dist/Utils/FormUtil.d.ts +0 -6
- package/dist/Utils/FormUtil.js +0 -35
- package/docs/Functions.md +0 -61
- package/src/Extensions/Document.ts +0 -58
- package/src/Extensions/Object/properties.ts +0 -50
- package/src/Functions/CopyToClipboard.ts +0 -10
- package/src/Functions/GetCSSProperty.ts +0 -27
- package/src/Functions/GetNestedProperty.ts +0 -29
- package/src/Functions/HTMLEvent.ts +0 -13
- package/src/Functions/SetNavigationSelected.ts +0 -19
- package/src/Functions/index.ts +0 -5
package/dist/index.js
CHANGED
|
@@ -16,6 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./Classes"), exports);
|
|
18
18
|
__exportStar(require("./Extensions"), exports);
|
|
19
|
-
__exportStar(require("./Functions"), exports);
|
|
20
19
|
__exportStar(require("./Interfaces"), exports);
|
|
21
20
|
__exportStar(require("./Types"), exports);
|
|
21
|
+
__exportStar(require("./Utils"), exports);
|
package/docs/Classes.md
CHANGED
|
@@ -2,11 +2,86 @@
|
|
|
2
2
|
|
|
3
3
|
## Classes
|
|
4
4
|
|
|
5
|
+
### DanhoLogger
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
/**
|
|
9
|
+
* Enhanced console logger with prefixes, colors, and grouping
|
|
10
|
+
*/
|
|
11
|
+
class DanhoLogger {
|
|
12
|
+
/**
|
|
13
|
+
* @param options Logger configuration
|
|
14
|
+
* @param options.name Name to display in log prefix (default: 'DanhoLogger')
|
|
15
|
+
* @param options.color Color for the prefix (default: 'inherit')
|
|
16
|
+
* @param options.preferCollapsed Whether to use collapsed groups by default (default: false)
|
|
17
|
+
*/
|
|
18
|
+
constructor(options?: { name?: string; color?: string; preferCollapsed?: boolean });
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Name displayed in log prefix
|
|
22
|
+
*/
|
|
23
|
+
public name: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Color for the prefix
|
|
27
|
+
*/
|
|
28
|
+
public color?: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Logs a message
|
|
32
|
+
*/
|
|
33
|
+
public log(...args: any[]): this;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Logs a warning message
|
|
37
|
+
*/
|
|
38
|
+
public warn(...args: any[]): this;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Logs an error message
|
|
42
|
+
*/
|
|
43
|
+
public error(...args: any[]): this;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Creates a log group
|
|
47
|
+
*/
|
|
48
|
+
public group(...args: any[]): this;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Creates a collapsed log group
|
|
52
|
+
*/
|
|
53
|
+
public groupCollapsed(...args: any[]): this;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Ends the current log group
|
|
57
|
+
*/
|
|
58
|
+
public groupEnd(...args: any[]): this;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Starts a timer with a label
|
|
62
|
+
*/
|
|
63
|
+
public time(label: string): this;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Ends a timer and logs the elapsed time
|
|
67
|
+
*/
|
|
68
|
+
public timeEnd(label: string): this;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Logs data in a table format
|
|
72
|
+
*/
|
|
73
|
+
public table(data: any, columns?: string[]): this;
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Store
|
|
78
|
+
|
|
5
79
|
```ts
|
|
6
80
|
/**
|
|
7
|
-
* EventEmitter
|
|
81
|
+
* EventEmitter that stores state and handles state changes with reducers
|
|
8
82
|
*
|
|
9
|
-
* @Initialization Actions & initial state must be defined in type parameters.
|
|
83
|
+
* @Initialization Actions & initial state must be defined in type parameters.
|
|
84
|
+
* InitialState must be provided in constructor, whereas reducer is optional.
|
|
10
85
|
* The ActionType must have properties as strings and values as arrays.
|
|
11
86
|
*
|
|
12
87
|
* @HandlingActions Reducers can be added through constructor or using Store.on('action', reducer) or Store.once('action', reducer).
|
|
@@ -26,7 +101,7 @@ class Store<
|
|
|
26
101
|
{ [Action in keyof ActionTypes]: Array<Reducer<State, ActionTypes, Action>> } =
|
|
27
102
|
{ [Action in keyof ActionTypes]: Array<Reducer<State, ActionTypes, Action>> }
|
|
28
103
|
> extends EventEmitter<Record<keyof Actions, ActionTypes[keyof ActionTypes]> & Record<'stateChange', [previous: State, current: State]>> {
|
|
29
|
-
constructor(state: State, actions
|
|
104
|
+
constructor(state: State, actions?: { [Action in keyof ActionTypes]?: Arrayable<Reducer<State, ActionTypes, Action>> });
|
|
30
105
|
|
|
31
106
|
private _state: State;
|
|
32
107
|
public get state(): State;
|
package/docs/Extensions.md
CHANGED
|
@@ -2,72 +2,134 @@
|
|
|
2
2
|
|
|
3
3
|
## Extensions
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```ts
|
|
8
|
-
interface BooleanConstructor {
|
|
9
|
-
/**
|
|
10
|
-
* Parses string to boolean. Will only return true if value === "true" otherwise false
|
|
11
|
-
*/
|
|
12
|
-
parseBoolean(value: string): boolean
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface Document {
|
|
16
|
-
/**
|
|
17
|
-
* Creates an element like Document#createElement, however with construction options to assign values in construction instead of after construction.
|
|
18
|
-
* @param tagName HTMLElement tag name
|
|
19
|
-
* @param options Construction options, instead of assigning values after construction
|
|
20
|
-
*/
|
|
21
|
-
createProperElement<K extends keyof HTMLElementTagNameMap>(tagName: K, options?: ElementOptions): HTMLElementTagNameMap[K];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface HTMLCollection {
|
|
25
|
-
/**
|
|
26
|
-
* Converts HTMLCollection to Element[]
|
|
27
|
-
*/
|
|
28
|
-
array(): Element[];
|
|
29
|
-
}
|
|
30
|
-
```
|
|
5
|
+
Extensions add new methods to native JavaScript types and interfaces.
|
|
31
6
|
|
|
32
7
|
### Array
|
|
33
8
|
|
|
9
|
+
#### Instance Methods
|
|
10
|
+
|
|
34
11
|
```ts
|
|
35
12
|
interface Array<T> {
|
|
36
13
|
/**
|
|
37
14
|
* Pushes items to array and returns self with new items
|
|
38
15
|
* @param items Items to add to array
|
|
39
16
|
*/
|
|
40
|
-
add(...items: Array<T>): this
|
|
17
|
+
add(...items: Array<T>): this;
|
|
18
|
+
|
|
41
19
|
/**
|
|
42
20
|
* Update an item in array
|
|
43
|
-
* @param old The old value or
|
|
21
|
+
* @param old The old value, index, or finder function to locate item to update
|
|
44
22
|
* @param updated Updated value
|
|
45
23
|
*/
|
|
46
|
-
update(old: T | number, updated: T): T
|
|
24
|
+
update(old: T | number | ((item: T, index: number, self: Array<T>) => boolean), updated: T): T;
|
|
25
|
+
|
|
47
26
|
/**
|
|
48
27
|
* Removes item from array and returns self without item
|
|
49
28
|
* @param item Item or index to remove
|
|
50
29
|
*/
|
|
51
|
-
remove(item: T | number):
|
|
30
|
+
remove(item: T | number): Array<T>;
|
|
31
|
+
|
|
52
32
|
/**
|
|
53
33
|
* Returns a random element from array
|
|
54
34
|
*/
|
|
55
|
-
random(): T
|
|
35
|
+
random(): T;
|
|
36
|
+
|
|
56
37
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @param i Index of item
|
|
38
|
+
* Shuffles array in random order
|
|
59
39
|
*/
|
|
60
|
-
|
|
40
|
+
shuffle(): Array<T>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Returns the first `count` elements from the array
|
|
44
|
+
* @param count Number of elements to take
|
|
45
|
+
*/
|
|
46
|
+
take(count: number): Array<T>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Returns a new array with only unique elements
|
|
50
|
+
*/
|
|
51
|
+
unique(): Array<T>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Splits the array into chunks of a specified size or by a splitter function
|
|
55
|
+
* @param chunkSizeOrSplitter The size of each chunk or a function that determines where to split
|
|
56
|
+
*/
|
|
57
|
+
splitBy(chunkSizeOrSplitter: number | ((value: T, index: number, array: Array<T>) => boolean)): Array<Array<T>>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Groups elements based on a key selector function
|
|
61
|
+
* @param keySelector A function that selects a key for each element
|
|
62
|
+
*/
|
|
63
|
+
groupBy<K>(keySelector: (value: T, index: number, array: Array<T>) => K): Map<K, Array<T>>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* For every nth element in array, execute callback
|
|
67
|
+
* @param every Execute callback every nth element
|
|
68
|
+
* @param callback Function to execute
|
|
69
|
+
*/
|
|
70
|
+
nth<U>(every: number, callback: (collection: Array<T>, index: number, self: this) => U): Array<U>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Joins array elements with a separator, and a different separator before the last element
|
|
74
|
+
* @param separator Separator between elements (default: ',')
|
|
75
|
+
* @param endSeparator Separator before last element (default: '&')
|
|
76
|
+
*/
|
|
77
|
+
join(separator?: string, endSeparator?: string): string;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Orders array by comparators in ascending order
|
|
81
|
+
* @param comparators Comparison functions
|
|
82
|
+
*/
|
|
83
|
+
orderBy(...comparators: Array<(a: T, b: T) => number>): Array<T>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Orders array by comparators in descending order
|
|
87
|
+
* @param comparators Comparison functions
|
|
88
|
+
*/
|
|
89
|
+
orderByDescending(...comparators: Array<(a: T, b: T) => number>): Array<T>;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Sorts array by object properties
|
|
93
|
+
* @param properties Properties to sort by
|
|
94
|
+
*/
|
|
95
|
+
sortByProperty(...properties: Array<keyof T>): Array<T>;
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### Static Methods
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
interface ArrayConstructor {
|
|
61
103
|
/**
|
|
62
|
-
*
|
|
63
|
-
* @param
|
|
64
|
-
* @param callback Do this for every x in array
|
|
65
|
-
* @returns Mapped array
|
|
104
|
+
* Forces an arrayable object into an array
|
|
105
|
+
* @param arrayable The value or array to normalize
|
|
66
106
|
*/
|
|
67
|
-
|
|
107
|
+
forceArray<T>(arrayable: T | Array<T>): Array<T>;
|
|
68
108
|
}
|
|
69
109
|
```
|
|
70
110
|
|
|
111
|
+
### Function
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
/**
|
|
115
|
+
* Checks if a value is a function
|
|
116
|
+
*/
|
|
117
|
+
function is(obj: any): obj is Function;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Resolves a functionable value (value or function that returns value)
|
|
121
|
+
* @param functionable Value or function
|
|
122
|
+
* @param args Arguments to pass if functionable is a function
|
|
123
|
+
*/
|
|
124
|
+
function resolveFunctionable<T, TArgs extends any[] = any[]>(functionable: T | ((...args: TArgs) => T), ...args: TArgs): T;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Converts a functionable value into a function
|
|
128
|
+
* @param functionable Value or function
|
|
129
|
+
*/
|
|
130
|
+
function forceFunction<T, TArgs extends any[] = any[]>(functionable: T | ((...args: TArgs) => T)): (...args: TArgs) => T;
|
|
131
|
+
```
|
|
132
|
+
|
|
71
133
|
### Map
|
|
72
134
|
|
|
73
135
|
```ts
|
|
@@ -75,79 +137,191 @@ interface Map<K, V> {
|
|
|
75
137
|
/**
|
|
76
138
|
* Converts map into Array<[Key, Value]>
|
|
77
139
|
*/
|
|
78
|
-
array(): Array<[K, V]
|
|
140
|
+
array(): Array<[K, V]>;
|
|
141
|
+
|
|
79
142
|
/**
|
|
80
|
-
* Maps values into new types
|
|
81
|
-
* @param callback
|
|
143
|
+
* Maps values into new types
|
|
144
|
+
* @param callback Mapping function
|
|
82
145
|
*/
|
|
83
|
-
map<EK, EV>(callback: (value: V, key: K, index: number, self: this) => [EK, EV]): Map<EK, EV
|
|
146
|
+
map<EK, EV>(callback: (value: V, key: K, index: number, self: this) => [EK, EV]): Map<EK, EV>;
|
|
147
|
+
|
|
84
148
|
/**
|
|
85
|
-
*
|
|
86
|
-
* @param callback
|
|
149
|
+
* Filters map entries
|
|
150
|
+
* @param callback Filter function
|
|
87
151
|
*/
|
|
88
|
-
filter(callback: (value: V, key: K, index: number, self: this) => boolean): Map<K, V
|
|
152
|
+
filter(callback: (value: V, key: K, index: number, self: this) => boolean): Map<K, V>;
|
|
153
|
+
|
|
89
154
|
/**
|
|
90
155
|
* Returns array of keys
|
|
91
156
|
*/
|
|
92
|
-
keyArr(): Array<K
|
|
157
|
+
keyArr(): Array<K>;
|
|
158
|
+
|
|
93
159
|
/**
|
|
94
160
|
* Returns array of values
|
|
95
161
|
*/
|
|
96
|
-
valueArr(): Array<V
|
|
162
|
+
valueArr(): Array<V>;
|
|
163
|
+
|
|
97
164
|
/**
|
|
98
|
-
*
|
|
99
|
-
* @param callback
|
|
165
|
+
* Finds first entry matching callback
|
|
166
|
+
* @param callback Find function
|
|
100
167
|
*/
|
|
101
|
-
find(callback: (value: V, key: K, index: number, self: this) => boolean): [K, V] | undefined
|
|
168
|
+
find(callback: (value: V, key: K, index: number, self: this) => boolean): [K, V] | undefined;
|
|
169
|
+
|
|
102
170
|
/**
|
|
103
|
-
*
|
|
104
|
-
* @param value Value
|
|
105
|
-
* @param fromIndex Start looking
|
|
171
|
+
* Checks if map includes a value
|
|
172
|
+
* @param value Value to search for
|
|
173
|
+
* @param fromIndex Start looking from specific index
|
|
106
174
|
*/
|
|
107
175
|
includes(value: V, fromIndex?: number): boolean;
|
|
108
176
|
}
|
|
109
177
|
```
|
|
110
178
|
|
|
179
|
+
### Number
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
interface Number {
|
|
183
|
+
/**
|
|
184
|
+
* Formats number with thousand and decimal separators
|
|
185
|
+
* @param separators Custom separators for thousand and decimal (optional)
|
|
186
|
+
*/
|
|
187
|
+
toSeparationString(separators?: Partial<{ thousand: string; decimal: string }>): string;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Converts number to Roman numeral (1-3999)
|
|
191
|
+
*/
|
|
192
|
+
toRomanNumeral(): string;
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
111
196
|
### Object
|
|
112
197
|
|
|
198
|
+
#### Static Methods
|
|
199
|
+
|
|
113
200
|
```ts
|
|
114
201
|
interface ObjectConstructor {
|
|
115
202
|
/**
|
|
116
203
|
* Destructures object into array of [property, value]
|
|
117
204
|
* @param from Object to destruct
|
|
118
205
|
*/
|
|
119
|
-
array<From = {}>(from: From): Array<keyof From, ValueOf<From
|
|
206
|
+
array<From extends {} = {}>(from: From): Array<[keyof From, ValueOf<From>]>;
|
|
207
|
+
/**
|
|
208
|
+
* Destructures object into array of property keys or values depending on selector
|
|
209
|
+
* @param from Object to destruct
|
|
210
|
+
* @param selector Selects whether to return keys or values
|
|
211
|
+
*/
|
|
212
|
+
array<From extends {} = {}>(from: From, selector: 'keys'): Array<keyof From>;
|
|
120
213
|
/**
|
|
121
|
-
* Destructures object into array of property keys
|
|
214
|
+
* Destructures object into array of property keys or values depending on selector
|
|
122
215
|
* @param from Object to destruct
|
|
216
|
+
* @param selector Selects whether to return keys or values
|
|
217
|
+
*/
|
|
218
|
+
array<From extends {} = {}>(from: From, selector: 'values'): Array<ValueOf<From>>;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Returns array of object keys with proper typing
|
|
222
|
+
* @param from Object to get keys from
|
|
223
|
+
*/
|
|
224
|
+
keysOf<From = {}>(from: From): Array<keyof From>;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Object with property filter methods by type
|
|
228
|
+
* Methods: getStrings, getNumbers, getBooleans, getUndefineds, getNulls,
|
|
229
|
+
* getObjects, getFunctions, getAnys, getDates, getRegExps,
|
|
230
|
+
* getPromises, getArrays, getMaps, getSets
|
|
231
|
+
* @example Object.properties.getStrings(obj) // Returns object with only string properties
|
|
123
232
|
*/
|
|
124
|
-
|
|
233
|
+
properties: {
|
|
234
|
+
getStrings<Source extends {}, AllowFunctions extends boolean = false>(source: Source, withFunctions?: AllowFunctions): Partial<Source>;
|
|
235
|
+
getNumbers<Source extends {}, AllowFunctions extends boolean = false>(source: Source, withFunctions?: AllowFunctions): Partial<Source>;
|
|
236
|
+
getBooleans<Source extends {}, AllowFunctions extends boolean = false>(source: Source, withFunctions?: AllowFunctions): Partial<Source>;
|
|
237
|
+
getUndefineds<Source extends {}, AllowFunctions extends boolean = false>(source: Source, withFunctions?: AllowFunctions): Partial<Source>;
|
|
238
|
+
getNulls<Source extends {}, AllowFunctions extends boolean = false>(source: Source, withFunctions?: AllowFunctions): Partial<Source>;
|
|
239
|
+
getObjects<Source extends {}, AllowFunctions extends boolean = false>(source: Source, withFunctions?: AllowFunctions): Partial<Source>;
|
|
240
|
+
getFunctions<Source extends {}, AllowFunctions extends boolean = false>(source: Source, withFunctions?: AllowFunctions): Partial<Source>;
|
|
241
|
+
getAnys<Source extends {}, AllowFunctions extends boolean = false>(source: Source, withFunctions?: AllowFunctions): Partial<Source>;
|
|
242
|
+
getDates<Source extends {}, AllowFunctions extends boolean = false>(source: Source, withFunctions?: AllowFunctions): Partial<Source>;
|
|
243
|
+
getRegExps<Source extends {}, AllowFunctions extends boolean = false>(source: Source, withFunctions?: AllowFunctions): Partial<Source>;
|
|
244
|
+
getPromises<Source extends {}, AllowFunctions extends boolean = false>(source: Source, withFunctions?: AllowFunctions): Partial<Source>;
|
|
245
|
+
getArrays<Source extends {}, AllowFunctions extends boolean = false>(source: Source, withFunctions?: AllowFunctions): Partial<Source>;
|
|
246
|
+
getMaps<Source extends {}, AllowFunctions extends boolean = false>(source: Source, withFunctions?: AllowFunctions): Partial<Source>;
|
|
247
|
+
getSets<Source extends {}, AllowFunctions extends boolean = false>(source: Source, withFunctions?: AllowFunctions): Partial<Source>;
|
|
248
|
+
};
|
|
125
249
|
}
|
|
126
250
|
```
|
|
127
251
|
|
|
252
|
+
#### Standalone Functions
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
/**
|
|
256
|
+
* Creates new object omitting specified properties
|
|
257
|
+
* @param from Source object
|
|
258
|
+
* @param props Properties to omit
|
|
259
|
+
*/
|
|
260
|
+
function omit<From extends {}, Props extends keyof From>(from: From, ...props: Array<Props | Partial<From>>): Omit<From, Props>;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Creates new object with only specified properties
|
|
264
|
+
* @param from Source object
|
|
265
|
+
* @param props Properties to pick
|
|
266
|
+
*/
|
|
267
|
+
function pick<From extends {}, Props extends keyof From>(from: From, ...props: Array<Props | Partial<From>>): Pick<From, Props>;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Returns the difference between two objects
|
|
271
|
+
* @param source Source object
|
|
272
|
+
* @param target Target object
|
|
273
|
+
* @param exclude Properties to exclude from comparison
|
|
274
|
+
*/
|
|
275
|
+
function difference<T extends object>(source: T, target: T, ...exclude: Array<keyof T>): Partial<T>;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Deeply combines multiple objects
|
|
279
|
+
* @param objects Objects to combine
|
|
280
|
+
*/
|
|
281
|
+
function combine<T extends Record<string, any | undefined>>(...objects: Array<T | undefined>): T;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Deep equality check for objects
|
|
285
|
+
* @param a First object
|
|
286
|
+
* @param b Second object
|
|
287
|
+
*/
|
|
288
|
+
function areEqual<T extends object | null>(a?: T, b?: T): boolean;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Type guard for null or undefined
|
|
292
|
+
* @param obj Value to check
|
|
293
|
+
*/
|
|
294
|
+
function isNullOrUndefined(obj: any): obj is null | undefined;
|
|
295
|
+
```
|
|
296
|
+
|
|
128
297
|
### String
|
|
129
298
|
|
|
130
299
|
```ts
|
|
131
300
|
interface String {
|
|
132
301
|
/**
|
|
133
|
-
*
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Replaces "replacer" (default: ' ') with "replacement" (default: '_')
|
|
138
|
-
* @param replaceOptions This is practically your stereotypical String.replace, if you really want it to be
|
|
139
|
-
*/
|
|
140
|
-
toSnakeCase(replaceOptions?: IReplacement): string
|
|
141
|
-
/**
|
|
142
|
-
* Replaces "replacer" (default: ' ') with "replacement" (default: '-')
|
|
143
|
-
* @param replaceOptions This is practically your stereotypical String.replace, if you really want it to be
|
|
302
|
+
* Converts string from one case to another
|
|
303
|
+
* @param from Case to convert from ('camel' | 'pascal' | 'snake' | 'kebab' | 'lower' | 'upper')
|
|
304
|
+
* @param to Cases to convert to, can chain multiple conversions
|
|
144
305
|
*/
|
|
145
|
-
|
|
306
|
+
convertCase(from: Case, ...to: Array<Case>): string;
|
|
307
|
+
|
|
146
308
|
/**
|
|
147
|
-
*
|
|
148
|
-
* @param
|
|
149
|
-
* @param
|
|
309
|
+
* Truncates string to specified length with optional ellipsis
|
|
310
|
+
* @param length Maximum length of string
|
|
311
|
+
* @param ellipsis String to append if truncated (default: '...')
|
|
150
312
|
*/
|
|
151
|
-
|
|
313
|
+
truncate(length: number, ellipsis?: string): string;
|
|
152
314
|
}
|
|
153
315
|
```
|
|
316
|
+
|
|
317
|
+
#### Standalone Function
|
|
318
|
+
|
|
319
|
+
```ts
|
|
320
|
+
/**
|
|
321
|
+
* Converts a string's case
|
|
322
|
+
* @param value String to convert
|
|
323
|
+
* @param from Source case format
|
|
324
|
+
* @param to Target case format(s)
|
|
325
|
+
*/
|
|
326
|
+
function convertCase(value: string, from: Case, ...to: Array<Case>): string;
|
|
327
|
+
```
|