danholibraryjs 1.3.0 → 1.7.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 (103) 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} +14 -11
  5. package/dist/Classes/{Event.js → Events/Event.js} +16 -6
  6. package/dist/Classes/{EventCollection.d.ts → Events/EventCollection.d.ts} +10 -9
  7. package/dist/Classes/{EventCollection.js → Events/EventCollection.js} +27 -28
  8. package/dist/Classes/{EventEmitter.d.ts → Events/EventEmitter.d.ts} +11 -8
  9. package/dist/Classes/{EventEmitter.js → Events/EventEmitter.js} +7 -1
  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/{Types/EventHandler.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 -2
  23. package/dist/Classes/index.js +7 -3
  24. package/dist/Extensions/Array.d.ts +31 -0
  25. package/dist/Extensions/Array.js +26 -0
  26. package/dist/Extensions/Map.d.ts +38 -0
  27. package/dist/Extensions/Map.js +31 -0
  28. package/dist/Extensions/Object.d.ts +16 -0
  29. package/dist/Extensions/Object.js +8 -0
  30. package/dist/Extensions/String.d.ts +26 -0
  31. package/dist/Extensions/String.js +17 -0
  32. package/dist/Extensions/index.d.ts +29 -0
  33. package/dist/Extensions/index.js +71 -0
  34. package/dist/Functions/GetCSSProperty.d.ts +15 -0
  35. package/dist/Functions/GetCSSProperty.js +26 -0
  36. package/dist/Functions/HTMLEvent.d.ts +11 -0
  37. package/dist/Functions/HTMLEvent.js +14 -0
  38. package/dist/Functions/SetNavigationSelected.js +2 -0
  39. package/dist/Functions/index.d.ts +2 -0
  40. package/dist/Functions/index.js +7 -1
  41. package/dist/Interfaces/ElementOptions.d.ts +12 -18
  42. package/dist/Interfaces/IReplacement.d.ts +3 -2
  43. package/dist/Interfaces/index.js +5 -1
  44. package/dist/Types/BetterTypes.d.ts +9 -0
  45. package/dist/Types/{IElement.js → BetterTypes.js} +0 -0
  46. package/dist/Types/Date.d.ts +6 -0
  47. package/dist/Types/{StringRegex.js → Date.js} +0 -0
  48. package/dist/Types/Events.d.ts +10 -0
  49. package/dist/Types/Events.js +2 -0
  50. package/dist/Types/PropertiesWith.d.ts +13 -0
  51. package/dist/Types/PropertiesWith.js +2 -0
  52. package/dist/Types/TransformTypes.d.ts +13 -0
  53. package/dist/Types/TransformTypes.js +2 -0
  54. package/dist/Types/index.d.ts +31 -3
  55. package/dist/Types/index.js +10 -4
  56. package/dist/index.d.ts +5 -9
  57. package/dist/index.js +19 -8
  58. package/docs/Classes.md +455 -0
  59. package/docs/Extensions.md +146 -0
  60. package/docs/Functions.md +53 -0
  61. package/docs/Interfaces.md +34 -0
  62. package/docs/Types.md +129 -0
  63. package/docs/index.md +29 -0
  64. package/package.json +22 -21
  65. package/src/Classes/{Event.ts → Events/Event.ts} +31 -20
  66. package/src/Classes/Events/EventCollection.ts +109 -0
  67. package/src/Classes/{EventEmitter.ts → Events/EventEmitter.ts} +16 -13
  68. package/src/Classes/Events/index.ts +3 -0
  69. package/src/Classes/Time/Date.ts +264 -0
  70. package/src/Classes/Time/Time.ts +134 -0
  71. package/src/Classes/Time/TimeProperties.ts +3 -0
  72. package/src/Classes/Time/TimeSpan.ts +195 -0
  73. package/src/Classes/Time/index.ts +4 -0
  74. package/src/Classes/index.ts +2 -2
  75. package/src/Extensions/Array.ts +57 -0
  76. package/src/Extensions/Map.ts +73 -0
  77. package/src/Extensions/Object.ts +25 -0
  78. package/src/Extensions/String.ts +43 -0
  79. package/src/Extensions/index.ts +83 -0
  80. package/src/Functions/GetCSSProperty.ts +27 -0
  81. package/src/Functions/HTMLEvent.ts +13 -0
  82. package/src/Functions/SetNavigationSelected.ts +1 -0
  83. package/src/Functions/index.ts +3 -1
  84. package/src/Interfaces/ElementOptions.ts +18 -16
  85. package/src/Interfaces/IReplacement.ts +4 -3
  86. package/src/Types/BetterTypes.ts +10 -0
  87. package/src/Types/Date.ts +7 -0
  88. package/src/Types/Events.ts +15 -0
  89. package/src/Types/PropertiesWith.ts +14 -0
  90. package/src/Types/TransformTypes.ts +18 -0
  91. package/src/Types/index.ts +36 -3
  92. package/src/index.ts +5 -13
  93. package/tsconfig.json +99 -7
  94. package/dist/Extensions.d.ts +0 -81
  95. package/dist/Extensions.js +0 -80
  96. package/dist/Types/EventHandler.d.ts +0 -6
  97. package/dist/Types/IElement.d.ts +0 -9
  98. package/dist/Types/StringRegex.d.ts +0 -2
  99. package/src/Classes/EventCollection.ts +0 -115
  100. package/src/Extensions.ts +0 -179
  101. package/src/Types/EventHandler.ts +0 -6
  102. package/src/Types/IElement.ts +0 -9
  103. package/src/Types/StringRegex.ts +0 -2
@@ -0,0 +1,455 @@
1
+ # [DanhoLibraryJS](../README.md)
2
+
3
+ ## Classes
4
+
5
+ ### Events
6
+
7
+ ```ts
8
+ /**
9
+ * Base event for @see EventEmitter
10
+ * @borrows EventHandler
11
+ * @borrows BaseEvent
12
+ */
13
+ class Event<
14
+ Event extends BaseEvent<string, Array<any>>,
15
+ Name extends keyof Events = keyof Events
16
+ > {
17
+ /**
18
+ * Base event for @see EventEmitter, @borrows EventHandler
19
+ * @param name Name of event
20
+ * @param listeners Listeners/Handlers to execute when emitted
21
+ */
22
+ constructor(name: Name, ...listeners: Array<EventHandler<Events, Name>>);
23
+
24
+ /**Name of event*/
25
+ public name: Name;
26
+ /**Listener limit - default: 0 */
27
+ public limit = 0;
28
+ /**Number of times event was emitted - default: 0*/
29
+ public get runs: number;
30
+ /**Timestamp of last emit - default: null*/
31
+ public get lastEmitted: Date;
32
+
33
+ /**
34
+ * Emits event and returns array of responses
35
+ * @param args Arguments required for event listeners
36
+ * @returns Return values of listeners' returns
37
+ */
38
+ public emit(...args: Events[Name]): any[];
39
+ /**
40
+ * Adds listener to listeners array and returns self with new listener added
41
+ * @param listener Listener to add
42
+ * @param prepend Add first (true) or last (false) - default: false
43
+ * @returns this with listener added
44
+ *
45
+ * @throws Limit error, if limit was reached
46
+ */
47
+ public on(listener: EventHandler<Events, Name>, prepend = false): this
48
+ /**
49
+ * Like Event#on, adds listener to listeners array and returns self with new listener added, however removes listener once emitted
50
+ * @param listener Listener to add
51
+ * @param prepend Add first (true) or last (false) - default: false
52
+ * @returns this with listener added
53
+ *
54
+ * @throws Limit error, if limit was reached
55
+ */
56
+ public once(listener: EventHandler<Events, Name>, prepend = false): this;
57
+ /**
58
+ * Returns true or false, depending if event includes listener
59
+ * @param listener Listener to test
60
+ * @returns True of false, depending if event includes listener
61
+ */
62
+ public includes(listener: EventHandler<Events, Name>): boolean;
63
+ /**
64
+ * Removes listener from internal listeners array
65
+ * @param listener Listener to remove. If none specified, all will be removed
66
+ * @param throwNotFoundError Throw error if listener isn't in listeners array - default: false
67
+ * @returns this, without listener
68
+ *
69
+ * @throws NotFound, if throwNotFoundError is true, and internal listeners array doesn't include listener provided
70
+ */
71
+ public off(listener?: EventHandler<Events, Name>, throwNotFoundError = false): this;
72
+ }
73
+
74
+ /**
75
+ * Collection of Events from @see EventEmitter
76
+ * @borrows EventHandler
77
+ * @borrows Event
78
+ * @borrows BaseEvent
79
+ */
80
+ class EventCollection<Events extends BaseEvent<string, Array<any>>> {
81
+ /**Events to add in construction - Map<eventName, eventHandlers>*/
82
+ constructor(events?: Map<keyof Events, EventHandler<Events>>);
83
+
84
+ /**Amount of events stored*/
85
+ public get size: number
86
+
87
+ /**
88
+ * Returns true if event is in collection
89
+ * @param event Event name
90
+ * @returns true if event is in collection
91
+ */
92
+ public has<EventName extends keyof Events>(event: EventName): boolean
93
+ /**
94
+ * Returns all event handlers for event name. T is return type for event
95
+ * @param event Event name
96
+ * @returns Event object stored
97
+ */
98
+ public get<EventName extends keyof Events>(event: EventName): Event<Events, EventName>
99
+ /**
100
+ * Adds handler to event collection with name as key
101
+ * @param name Event name
102
+ * @param handler Handler for event
103
+ * @param once Whether or not handler only should run once or all times
104
+ * @returns this
105
+ */
106
+ public add<EventName extends keyof Events>(name: EventName, handler: EventHandler<Events, keyof Events>, once = false): this
107
+ /**
108
+ * @summary clear(): Clears all events
109
+ * @summary clear("all", myEventHandler): Removes myEventHandler from all events that have it
110
+ * @summary clear("myEvent"): Clears all handlers tied to "myEvent"
111
+ * @summary clear("myEvent", myEventHandler): Removes myEventHandler from "myEvent"
112
+ *
113
+ * @param name Event name | "all"
114
+ * @param handler Specific handler to remove. If left blank, all handlers in name will be removed
115
+ * @returns this
116
+ */
117
+ public clear<EventName extends keyof Events>(name: EventName | 'all' = 'all', handler?: EventHandler): this
118
+ /**
119
+ * Emits event matching name, and provides args param to saved handers. Returns result from all handlers
120
+ * @param name Event name
121
+ * @param args Arguments for event handlers
122
+ * @returns Result from all handlers
123
+ */
124
+ public emit<Event extends keyof Events>(name: Event, ...args: Events[Event]): any[];
125
+ /**
126
+ * Limits how many events to accept using EventEmitter#on or EventEmitter#once
127
+ * @param limit Limit of events to keep
128
+ * @returns this with the new limit
129
+ *
130
+ * @throws Unknown event, if event name isn't recognized
131
+ */
132
+ public limit<Event extends keyof Events>(eventName: 'all' | Event, limit: number): this
133
+ }
134
+
135
+ /**
136
+ * Traditional Node.js EventEmitter for vanilla JavaScript
137
+ * @borrows EventCollection
138
+ * @borrows BaseEvent
139
+ * @borrows EventHandler
140
+ */
141
+ class EventEmitter<Events extends BaseEvent<string, Array<any>>> {
142
+ /**@param events Map<name: string, handlers: EventHandler[]>*/
143
+ constructor(events?: Map<keyof Events, EventHandler<Events>>);
144
+
145
+ /**
146
+ * Adds listener to event collection, and runs listener when event is emitted
147
+ * @param event Event to handle
148
+ * @param listener Callback function to run, when event occurs
149
+ * @returns this
150
+ */
151
+ on<Return extends any, Event extends keyof Events>(event: Event, listener: EventHandler<Events, Event, Return>): this;
152
+ /**
153
+ * Adds listener to event collection, and runs listener once when event is emitted
154
+ * @param event Event to handle
155
+ * @param listener Callback function to run, when event occurs
156
+ * @returns this
157
+ */
158
+ once<Return extends any, Event extends keyof Events>(event: Event, listener: EventHandler<Events, Event, Return>): this;
159
+ /**
160
+ * Removes listener(s) from event
161
+ * @param event Event to get collection of listeners | "all"
162
+ * @param listener If left null, removes all listeners tied to event, else only removes listener from event
163
+ * @returns this
164
+ */
165
+ off<Return extends any, Event extends keyof Events>(event: Event | 'all' = 'all', listener?: EventHandler<Events, Event, Return>): this;
166
+ /**
167
+ * Emits event and runs all listeners tied to event
168
+ * @param event Event to emit
169
+ * @param args Arguments for the event
170
+ * @fires event
171
+ * @returns Array of listeners' reponses
172
+ */
173
+ emit<Return extends any, Event extends keyof Events>(event: Event, ...args: Events[Event]): Array<Return>;
174
+ /**
175
+ * Limits how many events to accept using EventEmitter#on or EventEmitter#once
176
+ * @param event: Specific event to limit, or by default, 'all'
177
+ * @param limit Limit of events to keep. If you want to limit amount of events saved, use 'all'.
178
+ * @returns this with the new limit
179
+ */
180
+ public limit<Event extends keyof Events>(event: 'all' | Event, limit: number): this;
181
+ }
182
+
183
+ ```
184
+
185
+ ### Time
186
+
187
+ ```ts
188
+ class DanhoDate {
189
+ constructor(data: Constructor)
190
+
191
+ protected _date: Date;
192
+
193
+ /**
194
+ * Year of the date
195
+ */
196
+ public year: number
197
+
198
+ /**
199
+ * Month of the date
200
+ */
201
+ public month: number
202
+
203
+ /**
204
+ * Days in the month of the date
205
+ */
206
+ public daysInMonth: number
207
+
208
+ /**
209
+ * Week of the year the day is in
210
+ */
211
+ public week: number
212
+
213
+ /**
214
+ * Week of the month the day is in
215
+ */
216
+ public weekOfMonth: number
217
+
218
+ /**
219
+ * Day of the date
220
+ */
221
+ public day: number
222
+
223
+ /**
224
+ * Hours of the date
225
+ */
226
+ public hours: number
227
+
228
+ /**
229
+ * Minutes of the date
230
+ */
231
+ public minutes: number
232
+
233
+ /**
234
+ * Seconds of the date
235
+ */
236
+ public seconds: number
237
+
238
+ /**
239
+ * Milliseconds of the date
240
+ */
241
+ public milliseconds: number
242
+
243
+ /**
244
+ * Week day i.e. Monday
245
+ */
246
+ public get weekDay: LongDay
247
+
248
+ /**
249
+ * Short week day i.e. Mon
250
+ */
251
+ public get weekDayShort: ShortDay
252
+
253
+ /**
254
+ * Month name i.e. February
255
+ */
256
+ public get monthName: LongMonth
257
+
258
+ /**
259
+ * Short month name i.e. Feb
260
+ */
261
+ public get monthNameShort: ShortMonth
262
+
263
+ /**
264
+ * Sets internal date property
265
+ * @param data Time properties to set - replacement of i.e. Date.setHours(value: number): number
266
+ * @returns This, with updated properties
267
+ */
268
+ public set(data: Partial<Data>): this
269
+
270
+ /**
271
+ * Calculates the time between this date and provided date
272
+ * @returns TimeSpan between dates
273
+ */
274
+ public between(date: DanhoDate | Constructor): TimeSpan
275
+
276
+ /**
277
+ * String representation of Date. Use internal comment for formatting
278
+ */
279
+ public toString(format = "$dd/$MM/$year", relativeFormat?: TimeSpanFormat): string
280
+ }
281
+
282
+ /**
283
+ * Time utility class
284
+ * @borrows TimeDelay
285
+ * @borrows ms
286
+ */
287
+ class Time {
288
+ /**
289
+ * Array of amount of days in the months. 0 indexed
290
+ */
291
+ public static get daysInMonth: Array<number>
292
+
293
+ /**
294
+ * Amount of weeks per year
295
+ */
296
+ public static get weeksInYear: number
297
+
298
+ /**
299
+ * Amount of days per year
300
+ */
301
+ public static get daysInYear: number
302
+
303
+ /**
304
+ * Returns function that converts value into double digit string
305
+ * @returns (value: number): string
306
+ */
307
+ public static get DoubleDigit(): string
308
+
309
+ /**
310
+ * Array of names of the months. 0 idnexed
311
+ */
312
+ public static get MonthNames: Array<LongMonth>
313
+
314
+ /**
315
+ * Array of names of the days of the week. 0 indexed
316
+ */
317
+ public static get DayNames: Array<LongDay>
318
+
319
+ /*
320
+ * Millisecond in milliseconds (I know that sounds silly but it makes sense later on?)
321
+ */
322
+ public static get millisecond: number;
323
+ /*
324
+ * Second in milliseconds
325
+ */
326
+ public static get second: number;
327
+ /*
328
+ * Minute in milliseconds
329
+ */
330
+ public static get minute: number;
331
+ /*
332
+ * Hour in milliseconds
333
+ */
334
+ public static get hour: number;
335
+ /*
336
+ * Day in milliseconds
337
+ */
338
+ public static get day: number;
339
+ /*
340
+ * Week in milliseconds
341
+ */
342
+ public static get week: number;
343
+ /*
344
+ * Month in milliseconds
345
+ */
346
+ public static get month: number;
347
+ /*
348
+ * Year in milliseconds
349
+ */
350
+ public static get year: number;
351
+ /*
352
+ * Average month in milliseconds
353
+ */
354
+ public static get avgMonth: number;
355
+
356
+ /*
357
+ * Converts TimeDelay input into milliseconds
358
+ */
359
+ public static ms(input: TimeDelay): number
360
+ }
361
+
362
+ /**
363
+ * Timespan between 2 dates.
364
+ * @borrows TimeSpanValue
365
+ * @borrows Time
366
+ * @borrows TimeProperties
367
+ */
368
+ class TimeSpan implements TimeProperties<true> {
369
+ constructor(from: TimeSpanValue, to: TimeSpanValue = Date.now());
370
+
371
+ /*
372
+ * Total x between dates
373
+ */
374
+ public years: number;
375
+ /*
376
+ * Total x between dates
377
+ */
378
+ public months: number;
379
+ /*
380
+ * Total x between dates
381
+ */
382
+ public weeks: number;
383
+ /*
384
+ * Total x between dates
385
+ */
386
+ public days: number;
387
+ /*
388
+ * Total x between dates
389
+ */
390
+ public hours: number;
391
+ /*
392
+ * Total x between dates
393
+ */
394
+ public minutes: number;
395
+ /*
396
+ * Total x between dates
397
+ */
398
+ public seconds: number;
399
+ /*
400
+ * Total x between dates
401
+ */
402
+ public milliseconds: number;
403
+
404
+ /**
405
+ * Get the maximum amount of months between the two dates
406
+ * @returns Number of max amount of months that are between the two dates
407
+ */
408
+ public getTotalMonths(): number;
409
+ /**
410
+ * Get the maximum amount of weeks between the two dates
411
+ * @returns Number of max amount of weeks that are between the two dates
412
+ */
413
+ public getTotalWeeks(): number;
414
+ /**
415
+ * Get the maximum amount of days between the two dates
416
+ * @returns Number of max amount of days that are between the two dates
417
+ */
418
+ public getTotalDays(): number;
419
+ /**
420
+ * Get the maximum amount of hours between the two dates
421
+ * @returns Number of max amount of hours that are between the two dates
422
+ */
423
+ public getTotalHours(): number;
424
+ /**
425
+ * Get the maximum amount of minutes between the two dates
426
+ * @returns Number of max amount of minutes that are between the two dates
427
+ */
428
+ public getTotalMinutes(): number;
429
+ /**
430
+ * Get the maximum amount of seconds between the two dates
431
+ * @returns Number of max amount of seconds that are between the two dates
432
+ */
433
+ public getTotalSeconds(): number;
434
+ /**
435
+ * Get the maximum amount of milliseconds between the two dates
436
+ * @returns Number of max amount of milliseconds that are between the two dates
437
+ */
438
+ public getTotalMilliseconds(): number;
439
+
440
+ /**
441
+ * Start date of timespan
442
+ */
443
+ public from: DanhoDate;
444
+ /**
445
+ * End date of timespan
446
+ */
447
+ public to: DanhoDate;
448
+ /**
449
+ * Timespan is in the past
450
+ */
451
+ public pastTense: boolean;
452
+
453
+ public toString(includeMs: boolean = false): string
454
+ }
455
+ ```
@@ -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
+ ```
@@ -0,0 +1,34 @@
1
+ # [DanhoLibraryJS](../README.md)
2
+
3
+ ## Interfaces
4
+
5
+ ```ts
6
+ /**
7
+ * Construction options when creating an HTML element using:
8
+ * @see Document.createProperElement
9
+ * @borrows IElement
10
+ * @borrows Arrayable
11
+ */
12
+ interface ElementOptions<K extends keyof HTMLElementTagNameMap> {
13
+ /**css classes to give the element*/
14
+ classes?: Array<string>;
15
+ /**attributes to give the element*/
16
+ attributes?: Array<[string, string]>;
17
+ /**Children of the element*/
18
+ children?: Arrayable<IElement>;
19
+ /**Events for the element to listen to
20
+ * @use HTMLEvent<Event, RetrunType>(name: Event, handler: (e: Event) => ReturnType)
21
+ */
22
+ events?: Array<{ name: string, handler: (e: Event) => any }>
23
+ }
24
+ /**
25
+ * Replacement tool for
26
+ * @see String.toSnakeCase
27
+ * @see String.toKebabCase
28
+ * @borrows StringRegex
29
+ */
30
+ interface IReplacement {
31
+ replacer?: StringRegex,
32
+ replacement?: string
33
+ }
34
+ ```