danholibraryjs 2.0.1 → 2.0.3

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.
Files changed (51) hide show
  1. package/README.md +1 -0
  2. package/dist/Extensions/Array/random.extension.d.ts +1 -2
  3. package/dist/Extensions/Array/random.extension.js +1 -22
  4. package/dist/Extensions/Array/string.extension.d.ts +3 -4
  5. package/dist/Extensions/Number.d.ts +2 -2
  6. package/dist/Extensions/Number.js +1 -1
  7. package/dist/Extensions/Object/arrays.extension.d.ts +14 -0
  8. package/dist/Extensions/Object/arrays.extension.js +7 -2
  9. package/dist/Extensions/Object/extracts.extension.d.ts +6 -6
  10. package/dist/Extensions/Object/extracts.extension.js +16 -9
  11. package/dist/Extensions/Object/properties.extension.js +1 -1
  12. package/dist/Extensions/String/case.extension.d.ts +1 -1
  13. package/dist/Extensions/String/case.extension.js +4 -1
  14. package/dist/Extensions/String/index.d.ts +1 -0
  15. package/dist/Extensions/String/index.js +1 -0
  16. package/dist/Extensions/String/string.extension.d.ts +6 -0
  17. package/dist/Extensions/String/string.extension.js +10 -0
  18. package/dist/Types/Able.d.ts +1 -1
  19. package/dist/Utils/NumberUtils.d.ts +5 -0
  20. package/dist/Utils/NumberUtils.js +25 -1
  21. package/dist/Utils/StringUtils.d.ts +5 -0
  22. package/dist/Utils/StringUtils.js +6 -1
  23. package/dist/Utils/TimeUtils/index.d.ts +3 -0
  24. package/dist/Utils/TimeUtils/index.js +2 -0
  25. package/dist/Utils/TimeUtils/string.util.d.ts +3 -0
  26. package/dist/Utils/TimeUtils/string.util.js +19 -0
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.js +1 -0
  29. package/docs/Classes.md +467 -467
  30. package/docs/Extensions.md +197 -164
  31. package/docs/Interfaces.md +12 -12
  32. package/docs/Types.md +24 -24
  33. package/docs/Utils.md +335 -0
  34. package/docs/index.md +1 -0
  35. package/package.json +1 -1
  36. package/src/Extensions/Array/random.extension.ts +2 -25
  37. package/src/Extensions/Array/string.extension.ts +3 -4
  38. package/src/Extensions/Number.ts +3 -3
  39. package/src/Extensions/Object/arrays.extension.ts +23 -2
  40. package/src/Extensions/Object/extracts.extension.ts +24 -15
  41. package/src/Extensions/Object/properties.extension.ts +1 -1
  42. package/src/Extensions/String/case.extension.ts +13 -9
  43. package/src/Extensions/String/index.ts +2 -1
  44. package/src/Extensions/String/string.extension.ts +11 -0
  45. package/src/Types/Able.ts +1 -1
  46. package/src/Utils/NumberUtils.ts +27 -0
  47. package/src/Utils/StringUtils.ts +7 -1
  48. package/src/Utils/TimeUtils/index.ts +2 -0
  49. package/src/Utils/TimeUtils/string.util.ts +13 -0
  50. package/src/index.ts +2 -1
  51. package/src/Extensions/Object/properties.ts +0 -51
package/docs/Classes.md CHANGED
@@ -9,68 +9,68 @@
9
9
  * Enhanced console logger with prefixes, colors, and grouping
10
10
  */
11
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;
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
74
  }
75
75
  ```
76
76
 
@@ -95,18 +95,18 @@ class DanhoLogger {
95
95
  * @borrows Arrayable
96
96
  */
97
97
  class Store<
98
- State extends object,
99
- ActionTypes extends Record<string, any[]>,
100
- Actions extends
101
- { [Action in keyof ActionTypes]: Array<Reducer<State, ActionTypes, Action>> } =
102
- { [Action in keyof ActionTypes]: Array<Reducer<State, ActionTypes, Action>> }
98
+ State extends object,
99
+ ActionTypes extends Record<string, any[]>,
100
+ Actions extends
101
+ { [Action in keyof ActionTypes]: Array<Reducer<State, ActionTypes, Action>> } =
102
+ { [Action in keyof ActionTypes]: Array<Reducer<State, ActionTypes, Action>> }
103
103
  > extends EventEmitter<Record<keyof Actions, ActionTypes[keyof ActionTypes]> & Record<'stateChange', [previous: State, current: State]>> {
104
- constructor(state: State, actions?: { [Action in keyof ActionTypes]?: Arrayable<Reducer<State, ActionTypes, Action>> });
104
+ constructor(state: State, actions?: { [Action in keyof ActionTypes]?: Arrayable<Reducer<State, ActionTypes, Action>> });
105
105
 
106
- private _state: State;
107
- public get state(): State;
106
+ private _state: State;
107
+ public get state(): State;
108
108
 
109
- public dispatch<Action extends keyof ActionTypes>(action: Action, ...args: ActionTypes[Action]): State;
109
+ public dispatch<Action extends keyof ActionTypes>(action: Action, ...args: ActionTypes[Action]): State;
110
110
  }
111
111
  ```
112
112
 
@@ -119,64 +119,64 @@ class Store<
119
119
  * @borrows BaseEvent
120
120
  */
121
121
  class Event<
122
- Event extends BaseEvent<string, Array<any>>,
123
- Name extends keyof Events = keyof Events
122
+ Event extends BaseEvent<string, Array<any>>,
123
+ Name extends keyof Events = keyof Events
124
124
  > {
125
- /**
126
- * Base event for @see EventEmitter, @borrows EventHandler
127
- * @param name Name of event
128
- * @param listeners Listeners/Handlers to execute when emitted
129
- */
130
- constructor(name: Name, ...listeners: Array<EventHandler<Events, Name>>);
131
-
132
- /**Name of event*/
133
- public name: Name;
134
- /**Listener limit - default: 0 */
135
- public limit = 0;
136
- /**Number of times event was emitted - default: 0*/
137
- public get runs: number;
138
- /**Timestamp of last emit - default: null*/
139
- public get lastEmitted: Date;
140
-
141
- /**
142
- * Emits event and returns array of responses
143
- * @param args Arguments required for event listeners
144
- * @returns Return values of listeners' returns
145
- */
146
- public emit(...args: Events[Name]): any[];
147
- /**
148
- * Adds listener to listeners array and returns self with new listener added
149
- * @param listener Listener to add
150
- * @param prepend Add first (true) or last (false) - default: false
151
- * @returns this with listener added
152
- *
153
- * @throws Limit error, if limit was reached
154
- */
155
- public on(listener: EventHandler<Events, Name>, prepend = false): this
156
- /**
157
- * Like Event#on, adds listener to listeners array and returns self with new listener added, however removes listener once emitted
158
- * @param listener Listener to add
159
- * @param prepend Add first (true) or last (false) - default: false
160
- * @returns this with listener added
161
- *
162
- * @throws Limit error, if limit was reached
163
- */
164
- public once(listener: EventHandler<Events, Name>, prepend = false): this;
165
- /**
166
- * Returns true or false, depending if event includes listener
167
- * @param listener Listener to test
168
- * @returns True of false, depending if event includes listener
169
- */
170
- public includes(listener: EventHandler<Events, Name>): boolean;
171
- /**
172
- * Removes listener from internal listeners array
173
- * @param listener Listener to remove. If none specified, all will be removed
174
- * @param throwNotFoundError Throw error if listener isn't in listeners array - default: false
175
- * @returns this, without listener
176
- *
177
- * @throws NotFound, if throwNotFoundError is true, and internal listeners array doesn't include listener provided
178
- */
179
- public off(listener?: EventHandler<Events, Name>, throwNotFoundError = false): this;
125
+ /**
126
+ * Base event for @see EventEmitter, @borrows EventHandler
127
+ * @param name Name of event
128
+ * @param listeners Listeners/Handlers to execute when emitted
129
+ */
130
+ constructor(name: Name, ...listeners: Array<EventHandler<Events, Name>>);
131
+
132
+ /**Name of event*/
133
+ public name: Name;
134
+ /**Listener limit - default: 0 */
135
+ public limit = 0;
136
+ /**Number of times event was emitted - default: 0*/
137
+ public get runs: number;
138
+ /**Timestamp of last emit - default: null*/
139
+ public get lastEmitted: Date;
140
+
141
+ /**
142
+ * Emits event and returns array of responses
143
+ * @param args Arguments required for event listeners
144
+ * @returns Return values of listeners' returns
145
+ */
146
+ public emit(...args: Events[Name]): any[];
147
+ /**
148
+ * Adds listener to listeners array and returns self with new listener added
149
+ * @param listener Listener to add
150
+ * @param prepend Add first (true) or last (false) - default: false
151
+ * @returns this with listener added
152
+ *
153
+ * @throws Limit error, if limit was reached
154
+ */
155
+ public on(listener: EventHandler<Events, Name>, prepend = false): this
156
+ /**
157
+ * Like Event#on, adds listener to listeners array and returns self with new listener added, however removes listener once emitted
158
+ * @param listener Listener to add
159
+ * @param prepend Add first (true) or last (false) - default: false
160
+ * @returns this with listener added
161
+ *
162
+ * @throws Limit error, if limit was reached
163
+ */
164
+ public once(listener: EventHandler<Events, Name>, prepend = false): this;
165
+ /**
166
+ * Returns true or false, depending if event includes listener
167
+ * @param listener Listener to test
168
+ * @returns True of false, depending if event includes listener
169
+ */
170
+ public includes(listener: EventHandler<Events, Name>): boolean;
171
+ /**
172
+ * Removes listener from internal listeners array
173
+ * @param listener Listener to remove. If none specified, all will be removed
174
+ * @param throwNotFoundError Throw error if listener isn't in listeners array - default: false
175
+ * @returns this, without listener
176
+ *
177
+ * @throws NotFound, if throwNotFoundError is true, and internal listeners array doesn't include listener provided
178
+ */
179
+ public off(listener?: EventHandler<Events, Name>, throwNotFoundError = false): this;
180
180
  }
181
181
 
182
182
  /**
@@ -186,58 +186,58 @@ class Event<
186
186
  * @borrows BaseEvent
187
187
  */
188
188
  class EventCollection<Events extends BaseEvent<string, Array<any>>> {
189
- /**Events to add in construction - Map<eventName, eventHandlers>*/
190
- constructor(events?: Map<keyof Events, EventHandler<Events>>);
191
-
192
- /**Amount of events stored*/
193
- public get size: number
194
-
195
- /**
196
- * Returns true if event is in collection
197
- * @param event Event name
198
- * @returns true if event is in collection
199
- */
200
- public has<EventName extends keyof Events>(event: EventName): boolean
201
- /**
202
- * Returns all event handlers for event name. T is return type for event
203
- * @param event Event name
204
- * @returns Event object stored
205
- */
206
- public get<EventName extends keyof Events>(event: EventName): Event<Events, EventName>
207
- /**
208
- * Adds handler to event collection with name as key
209
- * @param name Event name
210
- * @param handler Handler for event
211
- * @param once Whether or not handler only should run once or all times
212
- * @returns this
213
- */
214
- public add<EventName extends keyof Events>(name: EventName, handler: EventHandler<Events, keyof Events>, once = false): this
215
- /**
216
- * @summary clear(): Clears all events
217
- * @summary clear("all", myEventHandler): Removes myEventHandler from all events that have it
218
- * @summary clear("myEvent"): Clears all handlers tied to "myEvent"
219
- * @summary clear("myEvent", myEventHandler): Removes myEventHandler from "myEvent"
220
- *
221
- * @param name Event name | "all"
222
- * @param handler Specific handler to remove. If left blank, all handlers in name will be removed
223
- * @returns this
224
- */
225
- public clear<EventName extends keyof Events>(name: EventName | 'all' = 'all', handler?: EventHandler): this
226
- /**
227
- * Emits event matching name, and provides args param to saved handers. Returns result from all handlers
228
- * @param name Event name
229
- * @param args Arguments for event handlers
230
- * @returns Result from all handlers
231
- */
232
- public emit<Event extends keyof Events>(name: Event, ...args: Events[Event]): any[];
233
- /**
234
- * Limits how many events to accept using EventEmitter#on or EventEmitter#once
235
- * @param limit Limit of events to keep
236
- * @returns this with the new limit
237
- *
238
- * @throws Unknown event, if event name isn't recognized
239
- */
240
- public limit<Event extends keyof Events>(eventName: 'all' | Event, limit: number): this
189
+ /**Events to add in construction - Map<eventName, eventHandlers>*/
190
+ constructor(events?: Map<keyof Events, EventHandler<Events>>);
191
+
192
+ /**Amount of events stored*/
193
+ public get size: number
194
+
195
+ /**
196
+ * Returns true if event is in collection
197
+ * @param event Event name
198
+ * @returns true if event is in collection
199
+ */
200
+ public has<EventName extends keyof Events>(event: EventName): boolean
201
+ /**
202
+ * Returns all event handlers for event name. T is return type for event
203
+ * @param event Event name
204
+ * @returns Event object stored
205
+ */
206
+ public get<EventName extends keyof Events>(event: EventName): Event<Events, EventName>
207
+ /**
208
+ * Adds handler to event collection with name as key
209
+ * @param name Event name
210
+ * @param handler Handler for event
211
+ * @param once Whether or not handler only should run once or all times
212
+ * @returns this
213
+ */
214
+ public add<EventName extends keyof Events>(name: EventName, handler: EventHandler<Events, keyof Events>, once = false): this
215
+ /**
216
+ * @summary clear(): Clears all events
217
+ * @summary clear("all", myEventHandler): Removes myEventHandler from all events that have it
218
+ * @summary clear("myEvent"): Clears all handlers tied to "myEvent"
219
+ * @summary clear("myEvent", myEventHandler): Removes myEventHandler from "myEvent"
220
+ *
221
+ * @param name Event name | "all"
222
+ * @param handler Specific handler to remove. If left blank, all handlers in name will be removed
223
+ * @returns this
224
+ */
225
+ public clear<EventName extends keyof Events>(name: EventName | 'all' = 'all', handler?: EventHandler): this
226
+ /**
227
+ * Emits event matching name, and provides args param to saved handers. Returns result from all handlers
228
+ * @param name Event name
229
+ * @param args Arguments for event handlers
230
+ * @returns Result from all handlers
231
+ */
232
+ public emit<Event extends keyof Events>(name: Event, ...args: Events[Event]): any[];
233
+ /**
234
+ * Limits how many events to accept using EventEmitter#on or EventEmitter#once
235
+ * @param limit Limit of events to keep
236
+ * @returns this with the new limit
237
+ *
238
+ * @throws Unknown event, if event name isn't recognized
239
+ */
240
+ public limit<Event extends keyof Events>(eventName: 'all' | Event, limit: number): this
241
241
  }
242
242
 
243
243
  /**
@@ -247,45 +247,45 @@ class EventCollection<Events extends BaseEvent<string, Array<any>>> {
247
247
  * @borrows EventHandler
248
248
  */
249
249
  class EventEmitter<Events extends BaseEvent<string, Array<any>>> {
250
- /**@param events Map<name: string, handlers: EventHandler[]>*/
251
- constructor(events?: Map<keyof Events, EventHandler<Events>>);
252
-
253
- /**
254
- * Adds listener to event collection, and runs listener when event is emitted
255
- * @param event Event to handle
256
- * @param listener Callback function to run, when event occurs
257
- * @returns this
258
- */
259
- on<Return extends any, Event extends keyof Events>(event: Event, listener: EventHandler<Events, Event, Return>): this;
260
- /**
261
- * Adds listener to event collection, and runs listener once when event is emitted
262
- * @param event Event to handle
263
- * @param listener Callback function to run, when event occurs
264
- * @returns this
265
- */
266
- once<Return extends any, Event extends keyof Events>(event: Event, listener: EventHandler<Events, Event, Return>): this;
267
- /**
268
- * Removes listener(s) from event
269
- * @param event Event to get collection of listeners | "all"
270
- * @param listener If left null, removes all listeners tied to event, else only removes listener from event
271
- * @returns this
272
- */
273
- off<Return extends any, Event extends keyof Events>(event: Event | 'all' = 'all', listener?: EventHandler<Events, Event, Return>): this;
274
- /**
275
- * Emits event and runs all listeners tied to event
276
- * @param event Event to emit
277
- * @param args Arguments for the event
278
- * @fires event
279
- * @returns Array of listeners' reponses
280
- */
281
- emit<Return extends any, Event extends keyof Events>(event: Event, ...args: Events[Event]): Array<Return>;
282
- /**
283
- * Limits how many events to accept using EventEmitter#on or EventEmitter#once
284
- * @param event: Specific event to limit, or by default, 'all'
285
- * @param limit Limit of events to keep. If you want to limit amount of events saved, use 'all'.
286
- * @returns this with the new limit
287
- */
288
- public limit<Event extends keyof Events>(event: 'all' | Event, limit: number): this;
250
+ /**@param events Map<name: string, handlers: EventHandler[]>*/
251
+ constructor(events?: Map<keyof Events, EventHandler<Events>>);
252
+
253
+ /**
254
+ * Adds listener to event collection, and runs listener when event is emitted
255
+ * @param event Event to handle
256
+ * @param listener Callback function to run, when event occurs
257
+ * @returns this
258
+ */
259
+ on<Return extends any, Event extends keyof Events>(event: Event, listener: EventHandler<Events, Event, Return>): this;
260
+ /**
261
+ * Adds listener to event collection, and runs listener once when event is emitted
262
+ * @param event Event to handle
263
+ * @param listener Callback function to run, when event occurs
264
+ * @returns this
265
+ */
266
+ once<Return extends any, Event extends keyof Events>(event: Event, listener: EventHandler<Events, Event, Return>): this;
267
+ /**
268
+ * Removes listener(s) from event
269
+ * @param event Event to get collection of listeners | "all"
270
+ * @param listener If left null, removes all listeners tied to event, else only removes listener from event
271
+ * @returns this
272
+ */
273
+ off<Return extends any, Event extends keyof Events>(event: Event | 'all' = 'all', listener?: EventHandler<Events, Event, Return>): this;
274
+ /**
275
+ * Emits event and runs all listeners tied to event
276
+ * @param event Event to emit
277
+ * @param args Arguments for the event
278
+ * @fires event
279
+ * @returns Array of listeners' reponses
280
+ */
281
+ emit<Return extends any, Event extends keyof Events>(event: Event, ...args: Events[Event]): Array<Return>;
282
+ /**
283
+ * Limits how many events to accept using EventEmitter#on or EventEmitter#once
284
+ * @param event: Specific event to limit, or by default, 'all'
285
+ * @param limit Limit of events to keep. If you want to limit amount of events saved, use 'all'.
286
+ * @returns this with the new limit
287
+ */
288
+ public limit<Event extends keyof Events>(event: 'all' | Event, limit: number): this;
289
289
  }
290
290
 
291
291
  ```
@@ -294,97 +294,97 @@ class EventEmitter<Events extends BaseEvent<string, Array<any>>> {
294
294
 
295
295
  ```ts
296
296
  class DanhoDate {
297
- constructor(data: Constructor)
298
-
299
- protected _date: Date;
300
-
301
- /**
302
- * Year of the date
303
- */
304
- public year: number
305
-
306
- /**
307
- * Month of the date
308
- */
309
- public month: number
310
-
311
- /**
312
- * Days in the month of the date
313
- */
314
- public daysInMonth: number
315
-
316
- /**
317
- * Week of the year the day is in
318
- */
319
- public week: number
320
-
321
- /**
322
- * Week of the month the day is in
323
- */
324
- public weekOfMonth: number
325
-
326
- /**
327
- * Day of the date
328
- */
329
- public day: number
330
-
331
- /**
332
- * Hours of the date
333
- */
334
- public hours: number
335
-
336
- /**
337
- * Minutes of the date
338
- */
339
- public minutes: number
340
-
341
- /**
342
- * Seconds of the date
343
- */
344
- public seconds: number
345
-
346
- /**
347
- * Milliseconds of the date
348
- */
349
- public milliseconds: number
350
-
351
- /**
352
- * Week day i.e. Monday
353
- */
354
- public get weekDay: LongDay
355
-
356
- /**
357
- * Short week day i.e. Mon
358
- */
359
- public get weekDayShort: ShortDay
360
-
361
- /**
362
- * Month name i.e. February
363
- */
364
- public get monthName: LongMonth
365
-
366
- /**
367
- * Short month name i.e. Feb
368
- */
369
- public get monthNameShort: ShortMonth
370
-
371
- /**
372
- * Sets internal date property
373
- * @param data Time properties to set - replacement of i.e. Date.setHours(value: number): number
374
- * @returns This, with updated properties
375
- */
376
- public set(data: Partial<Data>): this
377
-
378
- /**
379
- * Calculates the time between this date and provided date
380
- * @returns TimeSpan between dates
381
- */
382
- public between(date: DanhoDate | Constructor): TimeSpan
383
-
384
- /**
385
- * String representation of Date. Use internal comment for formatting
386
- */
387
- public toString(format = "$dd/$MM/$year", relativeFormat?: TimeSpanFormat): string
297
+ constructor(data: Constructor)
298
+
299
+ protected _date: Date;
300
+
301
+ /**
302
+ * Year of the date
303
+ */
304
+ public year: number
305
+
306
+ /**
307
+ * Month of the date
308
+ */
309
+ public month: number
310
+
311
+ /**
312
+ * Days in the month of the date
313
+ */
314
+ public daysInMonth: number
315
+
316
+ /**
317
+ * Week of the year the day is in
318
+ */
319
+ public week: number
320
+
321
+ /**
322
+ * Week of the month the day is in
323
+ */
324
+ public weekOfMonth: number
325
+
326
+ /**
327
+ * Day of the date
328
+ */
329
+ public day: number
330
+
331
+ /**
332
+ * Hours of the date
333
+ */
334
+ public hours: number
335
+
336
+ /**
337
+ * Minutes of the date
338
+ */
339
+ public minutes: number
340
+
341
+ /**
342
+ * Seconds of the date
343
+ */
344
+ public seconds: number
345
+
346
+ /**
347
+ * Milliseconds of the date
348
+ */
349
+ public milliseconds: number
350
+
351
+ /**
352
+ * Week day i.e. Monday
353
+ */
354
+ public get weekDay: LongDay
355
+
356
+ /**
357
+ * Short week day i.e. Mon
358
+ */
359
+ public get weekDayShort: ShortDay
360
+
361
+ /**
362
+ * Month name i.e. February
363
+ */
364
+ public get monthName: LongMonth
365
+
366
+ /**
367
+ * Short month name i.e. Feb
368
+ */
369
+ public get monthNameShort: ShortMonth
370
+
371
+ /**
372
+ * Sets internal date property
373
+ * @param data Time properties to set - replacement of i.e. Date.setHours(value: number): number
374
+ * @returns This, with updated properties
375
+ */
376
+ public set(data: Partial<Data>): this
377
+
378
+ /**
379
+ * Calculates the time between this date and provided date
380
+ * @returns TimeSpan between dates
381
+ */
382
+ public between(date: DanhoDate | Constructor): TimeSpan
383
+
384
+ /**
385
+ * String representation of Date. Use internal comment for formatting
386
+ */
387
+ public toString(format = "$dd/$MM/$year", relativeFormat?: TimeSpanFormat): string
388
388
  }
389
389
 
390
390
  /**
@@ -393,78 +393,78 @@ class DanhoDate {
393
393
  * @borrows ms
394
394
  */
395
395
  class Time {
396
- /**
397
- * Array of amount of days in the months. 0 indexed
398
- */
399
- public static get daysInMonth: Array<number>
400
-
401
- /**
402
- * Amount of weeks per year
403
- */
404
- public static get weeksInYear: number
405
-
406
- /**
407
- * Amount of days per year
408
- */
409
- public static get daysInYear: number
410
-
411
- /**
412
- * Returns function that converts value into double digit string
413
- * @returns (value: number): string
414
- */
415
- public static get DoubleDigit(): string
416
-
417
- /**
418
- * Array of names of the months. 0 idnexed
419
- */
420
- public static get MonthNames: Array<LongMonth>
421
-
422
- /**
423
- * Array of names of the days of the week. 0 indexed
424
- */
425
- public static get DayNames: Array<LongDay>
426
-
427
- /*
428
- * Millisecond in milliseconds (I know that sounds silly but it makes sense later on?)
429
- */
430
- public static get millisecond: number;
431
- /*
432
- * Second in milliseconds
433
- */
434
- public static get second: number;
435
- /*
436
- * Minute in milliseconds
437
- */
438
- public static get minute: number;
439
- /*
440
- * Hour in milliseconds
441
- */
442
- public static get hour: number;
443
- /*
444
- * Day in milliseconds
445
- */
446
- public static get day: number;
447
- /*
448
- * Week in milliseconds
449
- */
450
- public static get week: number;
451
- /*
452
- * Month in milliseconds
453
- */
454
- public static get month: number;
455
- /*
456
- * Year in milliseconds
457
- */
458
- public static get year: number;
459
- /*
460
- * Average month in milliseconds
461
- */
462
- public static get avgMonth: number;
463
-
464
- /*
465
- * Converts TimeDelay input into milliseconds
466
- */
467
- public static ms(input: TimeDelay): number
396
+ /**
397
+ * Array of amount of days in the months. 0 indexed
398
+ */
399
+ public static get daysInMonth: Array<number>
400
+
401
+ /**
402
+ * Amount of weeks per year
403
+ */
404
+ public static get weeksInYear: number
405
+
406
+ /**
407
+ * Amount of days per year
408
+ */
409
+ public static get daysInYear: number
410
+
411
+ /**
412
+ * Returns function that converts value into double digit string
413
+ * @returns (value: number): string
414
+ */
415
+ public static get DoubleDigit(): string
416
+
417
+ /**
418
+ * Array of names of the months. 0 idnexed
419
+ */
420
+ public static get MonthNames: Array<LongMonth>
421
+
422
+ /**
423
+ * Array of names of the days of the week. 0 indexed
424
+ */
425
+ public static get DayNames: Array<LongDay>
426
+
427
+ /*
428
+ * Millisecond in milliseconds (I know that sounds silly but it makes sense later on?)
429
+ */
430
+ public static get millisecond: number;
431
+ /*
432
+ * Second in milliseconds
433
+ */
434
+ public static get second: number;
435
+ /*
436
+ * Minute in milliseconds
437
+ */
438
+ public static get minute: number;
439
+ /*
440
+ * Hour in milliseconds
441
+ */
442
+ public static get hour: number;
443
+ /*
444
+ * Day in milliseconds
445
+ */
446
+ public static get day: number;
447
+ /*
448
+ * Week in milliseconds
449
+ */
450
+ public static get week: number;
451
+ /*
452
+ * Month in milliseconds
453
+ */
454
+ public static get month: number;
455
+ /*
456
+ * Year in milliseconds
457
+ */
458
+ public static get year: number;
459
+ /*
460
+ * Average month in milliseconds
461
+ */
462
+ public static get avgMonth: number;
463
+
464
+ /*
465
+ * Converts TimeDelay input into milliseconds
466
+ */
467
+ public static ms(input: TimeDelay): number
468
468
  }
469
469
 
470
470
  /**
@@ -474,90 +474,90 @@ class Time {
474
474
  * @borrows TimeProperties
475
475
  */
476
476
  class TimeSpan implements TimeProperties<true> {
477
- constructor(from: TimeSpanValue, to: TimeSpanValue = Date.now());
478
-
479
- /*
480
- * Total x between dates
481
- */
482
- public years: number;
483
- /*
484
- * Total x between dates
485
- */
486
- public months: number;
487
- /*
488
- * Total x between dates
489
- */
490
- public weeks: number;
491
- /*
492
- * Total x between dates
493
- */
494
- public days: number;
495
- /*
496
- * Total x between dates
497
- */
498
- public hours: number;
499
- /*
500
- * Total x between dates
501
- */
502
- public minutes: number;
503
- /*
504
- * Total x between dates
505
- */
506
- public seconds: number;
507
- /*
508
- * Total x between dates
509
- */
510
- public milliseconds: number;
511
-
512
- /**
513
- * Get the maximum amount of months between the two dates
514
- * @returns Number of max amount of months that are between the two dates
515
- */
516
- public getTotalMonths(): number;
517
- /**
518
- * Get the maximum amount of weeks between the two dates
519
- * @returns Number of max amount of weeks that are between the two dates
520
- */
521
- public getTotalWeeks(): number;
522
- /**
523
- * Get the maximum amount of days between the two dates
524
- * @returns Number of max amount of days that are between the two dates
525
- */
526
- public getTotalDays(): number;
527
- /**
528
- * Get the maximum amount of hours between the two dates
529
- * @returns Number of max amount of hours that are between the two dates
530
- */
531
- public getTotalHours(): number;
532
- /**
533
- * Get the maximum amount of minutes between the two dates
534
- * @returns Number of max amount of minutes that are between the two dates
535
- */
536
- public getTotalMinutes(): number;
537
- /**
538
- * Get the maximum amount of seconds between the two dates
539
- * @returns Number of max amount of seconds that are between the two dates
540
- */
541
- public getTotalSeconds(): number;
542
- /**
543
- * Get the maximum amount of milliseconds between the two dates
544
- * @returns Number of max amount of milliseconds that are between the two dates
545
- */
546
- public getTotalMilliseconds(): number;
547
-
548
- /**
549
- * Start date of timespan
550
- */
551
- public from: DanhoDate;
552
- /**
553
- * End date of timespan
554
- */
555
- public to: DanhoDate;
556
- /**
557
- * Timespan is in the past
558
- */
559
- public pastTense: boolean;
560
-
561
- public toString(includeMs: boolean = false): string
477
+ constructor(from: TimeSpanValue, to: TimeSpanValue = Date.now());
478
+
479
+ /*
480
+ * Total x between dates
481
+ */
482
+ public years: number;
483
+ /*
484
+ * Total x between dates
485
+ */
486
+ public months: number;
487
+ /*
488
+ * Total x between dates
489
+ */
490
+ public weeks: number;
491
+ /*
492
+ * Total x between dates
493
+ */
494
+ public days: number;
495
+ /*
496
+ * Total x between dates
497
+ */
498
+ public hours: number;
499
+ /*
500
+ * Total x between dates
501
+ */
502
+ public minutes: number;
503
+ /*
504
+ * Total x between dates
505
+ */
506
+ public seconds: number;
507
+ /*
508
+ * Total x between dates
509
+ */
510
+ public milliseconds: number;
511
+
512
+ /**
513
+ * Get the maximum amount of months between the two dates
514
+ * @returns Number of max amount of months that are between the two dates
515
+ */
516
+ public getTotalMonths(): number;
517
+ /**
518
+ * Get the maximum amount of weeks between the two dates
519
+ * @returns Number of max amount of weeks that are between the two dates
520
+ */
521
+ public getTotalWeeks(): number;
522
+ /**
523
+ * Get the maximum amount of days between the two dates
524
+ * @returns Number of max amount of days that are between the two dates
525
+ */
526
+ public getTotalDays(): number;
527
+ /**
528
+ * Get the maximum amount of hours between the two dates
529
+ * @returns Number of max amount of hours that are between the two dates
530
+ */
531
+ public getTotalHours(): number;
532
+ /**
533
+ * Get the maximum amount of minutes between the two dates
534
+ * @returns Number of max amount of minutes that are between the two dates
535
+ */
536
+ public getTotalMinutes(): number;
537
+ /**
538
+ * Get the maximum amount of seconds between the two dates
539
+ * @returns Number of max amount of seconds that are between the two dates
540
+ */
541
+ public getTotalSeconds(): number;
542
+ /**
543
+ * Get the maximum amount of milliseconds between the two dates
544
+ * @returns Number of max amount of milliseconds that are between the two dates
545
+ */
546
+ public getTotalMilliseconds(): number;
547
+
548
+ /**
549
+ * Start date of timespan
550
+ */
551
+ public from: DanhoDate;
552
+ /**
553
+ * End date of timespan
554
+ */
555
+ public to: DanhoDate;
556
+ /**
557
+ * Timespan is in the past
558
+ */
559
+ public pastTense: boolean;
560
+
561
+ public toString(includeMs: boolean = false): string
562
562
  }
563
563
  ```