danholibraryjs 1.5.0 → 1.8.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.
Files changed (112) hide show
  1. package/.gitattributes +2 -2
  2. package/README.md +12 -304
  3. package/Time.xlsx +0 -0
  4. package/dist/Classes/{Event.d.ts → Events/Event.d.ts} +9 -8
  5. package/dist/Classes/{Event.js → Events/Event.js} +17 -9
  6. package/dist/Classes/{EventCollection.d.ts → Events/EventCollection.d.ts} +10 -10
  7. package/dist/Classes/{EventCollection.js → Events/EventCollection.js} +28 -29
  8. package/dist/Classes/{EventEmitter.d.ts → Events/EventEmitter.d.ts} +33 -7
  9. package/dist/Classes/{EventEmitter.js → Events/EventEmitter.js} +33 -3
  10. package/dist/Classes/Events/index.d.ts +3 -0
  11. package/dist/Classes/Events/index.js +19 -0
  12. package/dist/Classes/Time/Date.d.ts +147 -0
  13. package/dist/Classes/Time/Date.js +238 -0
  14. package/dist/Classes/Time/Time.d.ts +65 -0
  15. package/dist/Classes/Time/Time.js +117 -0
  16. package/dist/Classes/Time/TimeProperties.d.ts +3 -0
  17. package/dist/{Interfaces/BaseEventInterface.js → Classes/Time/TimeProperties.js} +0 -0
  18. package/dist/Classes/Time/TimeSpan.d.ts +123 -0
  19. package/dist/Classes/Time/TimeSpan.js +179 -0
  20. package/dist/Classes/Time/index.d.ts +4 -0
  21. package/dist/Classes/Time/index.js +20 -0
  22. package/dist/Classes/index.d.ts +2 -3
  23. package/dist/Classes/index.js +7 -4
  24. package/dist/Classes/store.d.ts +79 -0
  25. package/dist/Classes/store.js +85 -0
  26. package/dist/Extensions/Array.d.ts +31 -0
  27. package/dist/Extensions/Array.js +26 -0
  28. package/dist/Extensions/Map.d.ts +38 -0
  29. package/dist/Extensions/Map.js +31 -0
  30. package/dist/Extensions/Object.d.ts +16 -0
  31. package/dist/Extensions/Object.js +8 -0
  32. package/dist/Extensions/String.d.ts +26 -0
  33. package/dist/Extensions/String.js +17 -0
  34. package/dist/Extensions/index.d.ts +29 -0
  35. package/dist/Extensions/index.js +71 -0
  36. package/dist/Functions/GetCSSProperty.d.ts +15 -0
  37. package/dist/Functions/GetCSSProperty.js +26 -0
  38. package/dist/Functions/HTMLEvent.d.ts +6 -0
  39. package/dist/Functions/HTMLEvent.js +6 -0
  40. package/dist/Functions/SetNavigationSelected.js +2 -0
  41. package/dist/Functions/index.d.ts +1 -0
  42. package/dist/Functions/index.js +6 -1
  43. package/dist/Interfaces/ElementOptions.d.ts +12 -15
  44. package/dist/Interfaces/IReplacement.d.ts +1 -1
  45. package/dist/Interfaces/index.d.ts +0 -1
  46. package/dist/Interfaces/index.js +5 -2
  47. package/dist/Types/BetterTypes.d.ts +9 -0
  48. package/dist/{Interfaces/IHTMLEvent.js → Types/BetterTypes.js} +0 -0
  49. package/dist/Types/Date.d.ts +6 -0
  50. package/dist/Types/{EventHandler.js → Date.js} +0 -0
  51. package/dist/Types/Events.d.ts +10 -0
  52. package/dist/Types/{IElement.js → Events.js} +0 -0
  53. package/dist/Types/PropertiesWith.d.ts +13 -0
  54. package/dist/Types/{StringRegex.js → PropertiesWith.js} +0 -0
  55. package/dist/Types/TransformTypes.d.ts +13 -0
  56. package/dist/Types/TransformTypes.js +2 -0
  57. package/dist/Types/index.d.ts +31 -3
  58. package/dist/Types/index.js +10 -4
  59. package/dist/index.d.ts +5 -5
  60. package/dist/index.js +19 -10
  61. package/docs/Classes.md +488 -0
  62. package/docs/Extensions.md +146 -0
  63. package/docs/Functions.md +53 -0
  64. package/docs/Interfaces.md +34 -0
  65. package/docs/Types.md +137 -0
  66. package/docs/index.md +29 -0
  67. package/package.json +22 -21
  68. package/src/Classes/{Event.ts → Events/Event.ts} +19 -14
  69. package/src/Classes/Events/EventCollection.ts +109 -0
  70. package/src/Classes/{EventEmitter.ts → Events/EventEmitter.ts} +37 -11
  71. package/src/Classes/Events/index.ts +3 -0
  72. package/src/Classes/Time/Date.ts +264 -0
  73. package/src/Classes/Time/Time.ts +134 -0
  74. package/src/Classes/Time/TimeProperties.ts +3 -0
  75. package/src/Classes/Time/TimeSpan.ts +195 -0
  76. package/src/Classes/Time/index.ts +4 -0
  77. package/src/Classes/index.ts +2 -3
  78. package/src/Classes/store.ts +95 -0
  79. package/src/Extensions/Array.ts +57 -0
  80. package/src/Extensions/Map.ts +73 -0
  81. package/src/Extensions/Object.ts +25 -0
  82. package/src/Extensions/String.ts +43 -0
  83. package/src/Extensions/index.ts +83 -0
  84. package/src/Functions/GetCSSProperty.ts +27 -0
  85. package/src/Functions/HTMLEvent.ts +6 -0
  86. package/src/Functions/SetNavigationSelected.ts +1 -0
  87. package/src/Functions/index.ts +2 -1
  88. package/src/Interfaces/ElementOptions.ts +18 -14
  89. package/src/Interfaces/IReplacement.ts +1 -1
  90. package/src/Interfaces/index.ts +1 -2
  91. package/src/Types/BetterTypes.ts +10 -0
  92. package/src/Types/Date.ts +7 -0
  93. package/src/Types/Events.ts +15 -0
  94. package/src/Types/PropertiesWith.ts +14 -0
  95. package/src/Types/TransformTypes.ts +18 -0
  96. package/src/Types/index.ts +36 -3
  97. package/src/index.ts +5 -6
  98. package/tsconfig.json +99 -7
  99. package/dist/Extensions.d.ts +0 -85
  100. package/dist/Extensions.js +0 -84
  101. package/dist/Interfaces/BaseEventInterface.d.ts +0 -4
  102. package/dist/Interfaces/IHTMLEvent.d.ts +0 -4
  103. package/dist/Types/EventHandler.d.ts +0 -7
  104. package/dist/Types/IElement.d.ts +0 -9
  105. package/dist/Types/StringRegex.d.ts +0 -2
  106. package/src/Classes/EventCollection.ts +0 -116
  107. package/src/Extensions.ts +0 -185
  108. package/src/Interfaces/BaseEventInterface.ts +0 -4
  109. package/src/Types/EventHandler.ts +0 -12
  110. package/src/Types/IElement.ts +0 -9
  111. package/src/Types/StringRegex.ts +0 -2
  112. package/test.js +0 -20
@@ -0,0 +1,488 @@
1
+ # [DanhoLibraryJS](../README.md)
2
+
3
+ ## Classes
4
+
5
+ ```ts
6
+ /**
7
+ * EventEmitter, but it stores state and handles state change with reducers
8
+ *
9
+ * @Initialization Actions & initial state must be defined in type parameters. InitialState must be provided in constructor, whereas reducer is optional.
10
+ * The ActionType must have properties as strings and values as arrays.
11
+ *
12
+ * @HandlingActions Reducers can be added through constructor or using Store.on('action', reducer) or Store.once('action', reducer).
13
+ * Every state change must return the next state, apart from 'stateChange', which returns void/any
14
+ * Emit/Dispatch an action using Store.dispatch('action', ...args), ...args being the parameters from the ActionType.
15
+ * Store.emit should NOT be used, as it doesn't update the Store's state.
16
+ *
17
+ * Reducer functions can be removed using Store.off('action', reducer);
18
+ *
19
+ * @borrows EventEmitter
20
+ * @borrows Arrayable
21
+ */
22
+ class Store<
23
+ State extends object,
24
+ ActionTypes extends Record<string, any[]>,
25
+ Actions extends
26
+ { [Action in keyof ActionTypes]: Array<Reducer<State, ActionTypes, Action>> } =
27
+ { [Action in keyof ActionTypes]: Array<Reducer<State, ActionTypes, Action>> }
28
+ > extends EventEmitter<Record<keyof Actions, ActionTypes[keyof ActionTypes]> & Record<'stateChange', [previous: State, current: State]>> {
29
+ constructor(state: State, actions: { [Action in keyof ActionTypes]?: Arrayable<Reducer<State, ActionTypes, Action>> } = {});
30
+
31
+ private _state: State;
32
+ public get state(): State;
33
+
34
+ public dispatch<Action extends keyof ActionTypes>(action: Action, ...args: ActionTypes[Action]): State;
35
+ }
36
+ ```
37
+
38
+ ### Events
39
+
40
+ ```ts
41
+ /**
42
+ * Base event for @see EventEmitter
43
+ * @borrows EventHandler
44
+ * @borrows BaseEvent
45
+ */
46
+ class Event<
47
+ Event extends BaseEvent<string, Array<any>>,
48
+ Name extends keyof Events = keyof Events
49
+ > {
50
+ /**
51
+ * Base event for @see EventEmitter, @borrows EventHandler
52
+ * @param name Name of event
53
+ * @param listeners Listeners/Handlers to execute when emitted
54
+ */
55
+ constructor(name: Name, ...listeners: Array<EventHandler<Events, Name>>);
56
+
57
+ /**Name of event*/
58
+ public name: Name;
59
+ /**Listener limit - default: 0 */
60
+ public limit = 0;
61
+ /**Number of times event was emitted - default: 0*/
62
+ public get runs: number;
63
+ /**Timestamp of last emit - default: null*/
64
+ public get lastEmitted: Date;
65
+
66
+ /**
67
+ * Emits event and returns array of responses
68
+ * @param args Arguments required for event listeners
69
+ * @returns Return values of listeners' returns
70
+ */
71
+ public emit(...args: Events[Name]): any[];
72
+ /**
73
+ * Adds listener to listeners array and returns self with new listener added
74
+ * @param listener Listener to add
75
+ * @param prepend Add first (true) or last (false) - default: false
76
+ * @returns this with listener added
77
+ *
78
+ * @throws Limit error, if limit was reached
79
+ */
80
+ public on(listener: EventHandler<Events, Name>, prepend = false): this
81
+ /**
82
+ * Like Event#on, adds listener to listeners array and returns self with new listener added, however removes listener once emitted
83
+ * @param listener Listener to add
84
+ * @param prepend Add first (true) or last (false) - default: false
85
+ * @returns this with listener added
86
+ *
87
+ * @throws Limit error, if limit was reached
88
+ */
89
+ public once(listener: EventHandler<Events, Name>, prepend = false): this;
90
+ /**
91
+ * Returns true or false, depending if event includes listener
92
+ * @param listener Listener to test
93
+ * @returns True of false, depending if event includes listener
94
+ */
95
+ public includes(listener: EventHandler<Events, Name>): boolean;
96
+ /**
97
+ * Removes listener from internal listeners array
98
+ * @param listener Listener to remove. If none specified, all will be removed
99
+ * @param throwNotFoundError Throw error if listener isn't in listeners array - default: false
100
+ * @returns this, without listener
101
+ *
102
+ * @throws NotFound, if throwNotFoundError is true, and internal listeners array doesn't include listener provided
103
+ */
104
+ public off(listener?: EventHandler<Events, Name>, throwNotFoundError = false): this;
105
+ }
106
+
107
+ /**
108
+ * Collection of Events from @see EventEmitter
109
+ * @borrows EventHandler
110
+ * @borrows Event
111
+ * @borrows BaseEvent
112
+ */
113
+ class EventCollection<Events extends BaseEvent<string, Array<any>>> {
114
+ /**Events to add in construction - Map<eventName, eventHandlers>*/
115
+ constructor(events?: Map<keyof Events, EventHandler<Events>>);
116
+
117
+ /**Amount of events stored*/
118
+ public get size: number
119
+
120
+ /**
121
+ * Returns true if event is in collection
122
+ * @param event Event name
123
+ * @returns true if event is in collection
124
+ */
125
+ public has<EventName extends keyof Events>(event: EventName): boolean
126
+ /**
127
+ * Returns all event handlers for event name. T is return type for event
128
+ * @param event Event name
129
+ * @returns Event object stored
130
+ */
131
+ public get<EventName extends keyof Events>(event: EventName): Event<Events, EventName>
132
+ /**
133
+ * Adds handler to event collection with name as key
134
+ * @param name Event name
135
+ * @param handler Handler for event
136
+ * @param once Whether or not handler only should run once or all times
137
+ * @returns this
138
+ */
139
+ public add<EventName extends keyof Events>(name: EventName, handler: EventHandler<Events, keyof Events>, once = false): this
140
+ /**
141
+ * @summary clear(): Clears all events
142
+ * @summary clear("all", myEventHandler): Removes myEventHandler from all events that have it
143
+ * @summary clear("myEvent"): Clears all handlers tied to "myEvent"
144
+ * @summary clear("myEvent", myEventHandler): Removes myEventHandler from "myEvent"
145
+ *
146
+ * @param name Event name | "all"
147
+ * @param handler Specific handler to remove. If left blank, all handlers in name will be removed
148
+ * @returns this
149
+ */
150
+ public clear<EventName extends keyof Events>(name: EventName | 'all' = 'all', handler?: EventHandler): this
151
+ /**
152
+ * Emits event matching name, and provides args param to saved handers. Returns result from all handlers
153
+ * @param name Event name
154
+ * @param args Arguments for event handlers
155
+ * @returns Result from all handlers
156
+ */
157
+ public emit<Event extends keyof Events>(name: Event, ...args: Events[Event]): any[];
158
+ /**
159
+ * Limits how many events to accept using EventEmitter#on or EventEmitter#once
160
+ * @param limit Limit of events to keep
161
+ * @returns this with the new limit
162
+ *
163
+ * @throws Unknown event, if event name isn't recognized
164
+ */
165
+ public limit<Event extends keyof Events>(eventName: 'all' | Event, limit: number): this
166
+ }
167
+
168
+ /**
169
+ * Traditional Node.js EventEmitter for vanilla JavaScript
170
+ * @borrows EventCollection
171
+ * @borrows BaseEvent
172
+ * @borrows EventHandler
173
+ */
174
+ class EventEmitter<Events extends BaseEvent<string, Array<any>>> {
175
+ /**@param events Map<name: string, handlers: EventHandler[]>*/
176
+ constructor(events?: Map<keyof Events, EventHandler<Events>>);
177
+
178
+ /**
179
+ * Adds listener to event collection, and runs listener when event is emitted
180
+ * @param event Event to handle
181
+ * @param listener Callback function to run, when event occurs
182
+ * @returns this
183
+ */
184
+ on<Return extends any, Event extends keyof Events>(event: Event, listener: EventHandler<Events, Event, Return>): this;
185
+ /**
186
+ * Adds listener to event collection, and runs listener once when event is emitted
187
+ * @param event Event to handle
188
+ * @param listener Callback function to run, when event occurs
189
+ * @returns this
190
+ */
191
+ once<Return extends any, Event extends keyof Events>(event: Event, listener: EventHandler<Events, Event, Return>): this;
192
+ /**
193
+ * Removes listener(s) from event
194
+ * @param event Event to get collection of listeners | "all"
195
+ * @param listener If left null, removes all listeners tied to event, else only removes listener from event
196
+ * @returns this
197
+ */
198
+ off<Return extends any, Event extends keyof Events>(event: Event | 'all' = 'all', listener?: EventHandler<Events, Event, Return>): this;
199
+ /**
200
+ * Emits event and runs all listeners tied to event
201
+ * @param event Event to emit
202
+ * @param args Arguments for the event
203
+ * @fires event
204
+ * @returns Array of listeners' reponses
205
+ */
206
+ emit<Return extends any, Event extends keyof Events>(event: Event, ...args: Events[Event]): Array<Return>;
207
+ /**
208
+ * Limits how many events to accept using EventEmitter#on or EventEmitter#once
209
+ * @param event: Specific event to limit, or by default, 'all'
210
+ * @param limit Limit of events to keep. If you want to limit amount of events saved, use 'all'.
211
+ * @returns this with the new limit
212
+ */
213
+ public limit<Event extends keyof Events>(event: 'all' | Event, limit: number): this;
214
+ }
215
+
216
+ ```
217
+
218
+ ### Time
219
+
220
+ ```ts
221
+ class DanhoDate {
222
+ constructor(data: Constructor)
223
+
224
+ protected _date: Date;
225
+
226
+ /**
227
+ * Year of the date
228
+ */
229
+ public year: number
230
+
231
+ /**
232
+ * Month of the date
233
+ */
234
+ public month: number
235
+
236
+ /**
237
+ * Days in the month of the date
238
+ */
239
+ public daysInMonth: number
240
+
241
+ /**
242
+ * Week of the year the day is in
243
+ */
244
+ public week: number
245
+
246
+ /**
247
+ * Week of the month the day is in
248
+ */
249
+ public weekOfMonth: number
250
+
251
+ /**
252
+ * Day of the date
253
+ */
254
+ public day: number
255
+
256
+ /**
257
+ * Hours of the date
258
+ */
259
+ public hours: number
260
+
261
+ /**
262
+ * Minutes of the date
263
+ */
264
+ public minutes: number
265
+
266
+ /**
267
+ * Seconds of the date
268
+ */
269
+ public seconds: number
270
+
271
+ /**
272
+ * Milliseconds of the date
273
+ */
274
+ public milliseconds: number
275
+
276
+ /**
277
+ * Week day i.e. Monday
278
+ */
279
+ public get weekDay: LongDay
280
+
281
+ /**
282
+ * Short week day i.e. Mon
283
+ */
284
+ public get weekDayShort: ShortDay
285
+
286
+ /**
287
+ * Month name i.e. February
288
+ */
289
+ public get monthName: LongMonth
290
+
291
+ /**
292
+ * Short month name i.e. Feb
293
+ */
294
+ public get monthNameShort: ShortMonth
295
+
296
+ /**
297
+ * Sets internal date property
298
+ * @param data Time properties to set - replacement of i.e. Date.setHours(value: number): number
299
+ * @returns This, with updated properties
300
+ */
301
+ public set(data: Partial<Data>): this
302
+
303
+ /**
304
+ * Calculates the time between this date and provided date
305
+ * @returns TimeSpan between dates
306
+ */
307
+ public between(date: DanhoDate | Constructor): TimeSpan
308
+
309
+ /**
310
+ * String representation of Date. Use internal comment for formatting
311
+ */
312
+ public toString(format = "$dd/$MM/$year", relativeFormat?: TimeSpanFormat): string
313
+ }
314
+
315
+ /**
316
+ * Time utility class
317
+ * @borrows TimeDelay
318
+ * @borrows ms
319
+ */
320
+ class Time {
321
+ /**
322
+ * Array of amount of days in the months. 0 indexed
323
+ */
324
+ public static get daysInMonth: Array<number>
325
+
326
+ /**
327
+ * Amount of weeks per year
328
+ */
329
+ public static get weeksInYear: number
330
+
331
+ /**
332
+ * Amount of days per year
333
+ */
334
+ public static get daysInYear: number
335
+
336
+ /**
337
+ * Returns function that converts value into double digit string
338
+ * @returns (value: number): string
339
+ */
340
+ public static get DoubleDigit(): string
341
+
342
+ /**
343
+ * Array of names of the months. 0 idnexed
344
+ */
345
+ public static get MonthNames: Array<LongMonth>
346
+
347
+ /**
348
+ * Array of names of the days of the week. 0 indexed
349
+ */
350
+ public static get DayNames: Array<LongDay>
351
+
352
+ /*
353
+ * Millisecond in milliseconds (I know that sounds silly but it makes sense later on?)
354
+ */
355
+ public static get millisecond: number;
356
+ /*
357
+ * Second in milliseconds
358
+ */
359
+ public static get second: number;
360
+ /*
361
+ * Minute in milliseconds
362
+ */
363
+ public static get minute: number;
364
+ /*
365
+ * Hour in milliseconds
366
+ */
367
+ public static get hour: number;
368
+ /*
369
+ * Day in milliseconds
370
+ */
371
+ public static get day: number;
372
+ /*
373
+ * Week in milliseconds
374
+ */
375
+ public static get week: number;
376
+ /*
377
+ * Month in milliseconds
378
+ */
379
+ public static get month: number;
380
+ /*
381
+ * Year in milliseconds
382
+ */
383
+ public static get year: number;
384
+ /*
385
+ * Average month in milliseconds
386
+ */
387
+ public static get avgMonth: number;
388
+
389
+ /*
390
+ * Converts TimeDelay input into milliseconds
391
+ */
392
+ public static ms(input: TimeDelay): number
393
+ }
394
+
395
+ /**
396
+ * Timespan between 2 dates.
397
+ * @borrows TimeSpanValue
398
+ * @borrows Time
399
+ * @borrows TimeProperties
400
+ */
401
+ class TimeSpan implements TimeProperties<true> {
402
+ constructor(from: TimeSpanValue, to: TimeSpanValue = Date.now());
403
+
404
+ /*
405
+ * Total x between dates
406
+ */
407
+ public years: number;
408
+ /*
409
+ * Total x between dates
410
+ */
411
+ public months: number;
412
+ /*
413
+ * Total x between dates
414
+ */
415
+ public weeks: number;
416
+ /*
417
+ * Total x between dates
418
+ */
419
+ public days: number;
420
+ /*
421
+ * Total x between dates
422
+ */
423
+ public hours: number;
424
+ /*
425
+ * Total x between dates
426
+ */
427
+ public minutes: number;
428
+ /*
429
+ * Total x between dates
430
+ */
431
+ public seconds: number;
432
+ /*
433
+ * Total x between dates
434
+ */
435
+ public milliseconds: number;
436
+
437
+ /**
438
+ * Get the maximum amount of months between the two dates
439
+ * @returns Number of max amount of months that are between the two dates
440
+ */
441
+ public getTotalMonths(): number;
442
+ /**
443
+ * Get the maximum amount of weeks between the two dates
444
+ * @returns Number of max amount of weeks that are between the two dates
445
+ */
446
+ public getTotalWeeks(): number;
447
+ /**
448
+ * Get the maximum amount of days between the two dates
449
+ * @returns Number of max amount of days that are between the two dates
450
+ */
451
+ public getTotalDays(): number;
452
+ /**
453
+ * Get the maximum amount of hours between the two dates
454
+ * @returns Number of max amount of hours that are between the two dates
455
+ */
456
+ public getTotalHours(): number;
457
+ /**
458
+ * Get the maximum amount of minutes between the two dates
459
+ * @returns Number of max amount of minutes that are between the two dates
460
+ */
461
+ public getTotalMinutes(): number;
462
+ /**
463
+ * Get the maximum amount of seconds between the two dates
464
+ * @returns Number of max amount of seconds that are between the two dates
465
+ */
466
+ public getTotalSeconds(): number;
467
+ /**
468
+ * Get the maximum amount of milliseconds between the two dates
469
+ * @returns Number of max amount of milliseconds that are between the two dates
470
+ */
471
+ public getTotalMilliseconds(): number;
472
+
473
+ /**
474
+ * Start date of timespan
475
+ */
476
+ public from: DanhoDate;
477
+ /**
478
+ * End date of timespan
479
+ */
480
+ public to: DanhoDate;
481
+ /**
482
+ * Timespan is in the past
483
+ */
484
+ public pastTense: boolean;
485
+
486
+ public toString(includeMs: boolean = false): string
487
+ }
488
+ ```
@@ -0,0 +1,146 @@
1
+ # [DanhoLibraryJS](../README.md)
2
+
3
+ ## Extensions
4
+
5
+ ### General
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
+ ```
31
+
32
+ ### Array
33
+
34
+ ```ts
35
+ interface Array<T> {
36
+ /**
37
+ * Pushes items to array and returns self with new items
38
+ * @param items Items to add to array
39
+ */
40
+ add(...items: Array<T>): this
41
+ /**
42
+ * Update an item in array
43
+ * @param old The old value or index to update
44
+ * @param updated Updated value
45
+ */
46
+ update(old: T | number, updated: T): T
47
+ /**
48
+ * Removes item from array and returns self without item
49
+ * @param item Item or index to remove
50
+ */
51
+ remove(item: T | number): this
52
+ /**
53
+ * Returns a random element from array
54
+ */
55
+ random(): T
56
+ /**
57
+ * Returns item matching index. If negative number, subtracts number from length
58
+ * @param i Index of item
59
+ */
60
+ index(i: number): T
61
+ }
62
+ ```
63
+
64
+ ### Map
65
+
66
+ ```ts
67
+ interface Map<K, V> {
68
+ /**
69
+ * Converts map into Array<[Key, Value]>
70
+ */
71
+ array(): Array<[K, V]>
72
+ /**
73
+ * Maps values into new types of generics
74
+ * @param callback Callbacking function to map values
75
+ */
76
+ map<EK, EV>(callback: (value: V, key: K, index: number, self: this) => [EK, EV]): Map<EK, EV>
77
+ /**
78
+ * Returns array of "accepted" values. Criteria defined in callback param
79
+ * @param callback Callbacking function to filter away unwanted values
80
+ */
81
+ filter(callback: (value: V, key: K, index: number, self: this) => boolean): Map<K, V>
82
+ /**
83
+ * Returns array of keys
84
+ */
85
+ keyArr(): Array<K>
86
+ /**
87
+ * Returns array of values
88
+ */
89
+ valueArr(): Array<V>
90
+ /**
91
+ * Returns first [key, value] match to callback param. Returns undefined if nothing found
92
+ * @param callback Callbacking function to find KeyValuePair
93
+ */
94
+ find(callback: (value: V, key: K, index: number, self: this) => boolean): [K, V] | undefined
95
+ /**
96
+ * Whether or not map includes a value (value version of Map#has)
97
+ * @param value Value that may be includded in map
98
+ * @param fromIndex Start looking for value from specific index+. Default: 0
99
+ */
100
+ includes(value: V, fromIndex?: number): boolean;
101
+ }
102
+ ```
103
+
104
+ ### Object
105
+
106
+ ```ts
107
+ interface ObjectConstructor {
108
+ /**
109
+ * Destructures object into array of [property, value]
110
+ * @param from Object to destruct
111
+ */
112
+ array<From = {}>(from: From): Array<keyof From, ValueOf<From>>
113
+ /**
114
+ * Destructures object into array of property keys
115
+ * @param from Object to destruct
116
+ */
117
+ keysOf<From = {}>(from: From): Array<keyof From>
118
+ }
119
+ ```
120
+
121
+ ### String
122
+
123
+ ```ts
124
+ interface String {
125
+ /**
126
+ * Uppercases first letter of string
127
+ */
128
+ toPascalCase(): string
129
+ /**
130
+ * Replaces "replacer" (default: ' ') with "replacement" (default: '_')
131
+ * @param replaceOptions This is practically your stereotypical String.replace, if you really want it to be
132
+ */
133
+ toSnakeCase(replaceOptions?: IReplacement): string
134
+ /**
135
+ * Replaces "replacer" (default: ' ') with "replacement" (default: '-')
136
+ * @param replaceOptions This is practically your stereotypical String.replace, if you really want it to be
137
+ */
138
+ toKebabCase(replaceOptions?: IReplacement): string
139
+ /**
140
+ * String.substring but accepting negative numbers to cut from length
141
+ * @param start Start of string. 0 indexed, if negative number, subtracts number from length
142
+ * @param end End of string. 0 indexed, if negative number, substracts number from length
143
+ */
144
+ clip(start: number, end?: number): string
145
+ }
146
+ ```
@@ -0,0 +1,53 @@
1
+ # [DanhoLibraryJS](../README.md)
2
+
3
+ ## Functions
4
+
5
+ ```ts
6
+ /**
7
+ * Copies value to clipboard and alerts a response, if response is defined
8
+ * @param value Value to clipboard
9
+ * @param response Alerts if response is given
10
+ */
11
+ async function CopyToClipboard(value: string, response?: string): Promise<void>;
12
+
13
+ /**
14
+ * Gets the value of "property" in type "type" from query "query"
15
+ * Basically, you can get your --color-primary from :root
16
+ *
17
+ * @param property Name of the property to get
18
+ * @param type Type of the property to parse
19
+ * @param query Query to get the element that has the property
20
+ * @returns Property value converted to type
21
+ */
22
+ function GetCSSProperty<Type extends keyof CSSReturnTypes>(property: string, type: Type, query = ":root"): CSSReturnTypes[Type];
23
+
24
+ /**
25
+ * Create HTMLEvent object from function
26
+ * @param name Name of the event
27
+ * @param handler Handler for the event
28
+ * @returns Parameters as object
29
+ */
30
+ function HTMLEvent<
31
+ Event extends keyof HTMLElementEventMap,
32
+ ReturnType extends any
33
+ >(name: Event, handler: (event: HTMLElementEventMap[Event]) => ReturnType): {
34
+ name: Event,
35
+ handler: (event: HTMLElementEventMap[Event]) => ReturnType
36
+ }
37
+
38
+ /**
39
+ * Appends classes to header's "a" elements, when navigation to "a"'s page is selected
40
+ * @param query The query selector for Document.querySelector
41
+ * @param currentPageClasses Class(es) to append header's "a" elements
42
+ *
43
+ * @borrows Document.querySelector
44
+ */
45
+ function SetNavigationSelected(query: string, ...currentPageClasses: Array<string>): void;
46
+
47
+ /**
48
+ * Converts input into milliseconds
49
+ * @param input Input to convert to ms. 1s | 2m | 3h | 1M | 60000
50
+ * @returns Millisecond value of input
51
+ */
52
+ function ms(input: TimeDelay): number
53
+ ```