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,73 @@
1
+ export {}
2
+
3
+ declare global {
4
+ interface Map<K, V> {
5
+ /**
6
+ * Converts into Array<[Key, Value]>
7
+ */
8
+ array(): Array<[K, V]>
9
+ /**
10
+ * Maps values into new types of generics
11
+ * @param callback Callbacking function to map values
12
+ */
13
+ map<EK, EV>(callback: (value: V, key: K, index: number, self: this) => [EK, EV]): Map<EK, EV>
14
+ /**
15
+ * Returns array of "accepted" values. Criteria defined in callback param
16
+ * @param callback Callbacking function to filter away unwanted values
17
+ */
18
+ filter(callback: (value: V, key: K, index: number, self: this) => boolean): Map<K, V>
19
+ /**
20
+ * Returns array of keys
21
+ */
22
+ keyArr(): Array<K>
23
+ /**
24
+ * Returns array of values
25
+ */
26
+ valueArr(): Array<V>
27
+ /**
28
+ * Returns first [key, value] match to callback param. Returns undefined if nothing found
29
+ * @param callback Callbacking function to find KeyValuePair
30
+ */
31
+ find(callback: (value: V, key: K, index: number, self: this) => boolean): [K, V] | undefined
32
+ /**
33
+ * Whether or not map includes a value. Returns true if it does, false if not ¯\_(ツ)_/¯
34
+ * @param value Value that may be includded in map
35
+ * @param fromIndex Start looking for value from specific index+. Default: 0
36
+ */
37
+ includes(value: V, fromIndex?: number): boolean
38
+ }
39
+ }
40
+
41
+ Map.prototype.array = function<K, V>(this: Map<K, V>): Array<[K, V]> {
42
+ let result = new Array<[K, V]>();
43
+ for (const kvp of this) {
44
+ result.push(kvp);
45
+ }
46
+ return result;
47
+ }
48
+ Map.prototype.map = function<K, V, EK, EV>(this: Map<K, V>, callback: (value: V, key: K, index: number, map: Map<K, V>) => [EK, EV]): Map<EK, EV> {
49
+ return this.array()
50
+ .map(([k, v], i) => callback(v, k, i, this))
51
+ .reduce((map, [key, value]) =>
52
+ map.set(key, value),
53
+ new Map<EK, EV>())
54
+ }
55
+ Map.prototype.filter = function<K, V>(this: Map<K, V>, callback: (value: V, key: K, index: number, map: Map<K, V>) => boolean): Map<K, V> {
56
+ return this.array()
57
+ .filter(([k, v], i) => callback(v, k, i, this))
58
+ .reduce((map, [key, value]) =>
59
+ map.set(key, value),
60
+ new Map<K, V>())
61
+ }
62
+ Map.prototype.keyArr = function<K, V>(this: Map<K, V>): Array<K> {
63
+ return this.array().map(([k]) => k);
64
+ }
65
+ Map.prototype.valueArr = function<K, V>(this: Map<K, V>): Array<V> {
66
+ return this.array().map(([_, v]) => v);
67
+ }
68
+ Map.prototype.find = function<K, V>(this: Map<K, V>, callback: (value: V, key: K, index: number, map: Map<K, V>) => boolean) {
69
+ return this.array().find(([k, v], i) => callback(v, k, i, this));
70
+ }
71
+ Map.prototype.includes = function<K, V>(this: Map<K, V>, item: V, fromIndex?: number) {
72
+ return this.valueArr().includes(item, fromIndex);
73
+ }
@@ -0,0 +1,25 @@
1
+ import { ValueOf } from "../Types";
2
+
3
+ export {};
4
+
5
+ declare global {
6
+ interface ObjectConstructor {
7
+ /**
8
+ * Destructures object into array of [property, value]
9
+ * @param from Object to destruct
10
+ */
11
+ array<From = {}>(from: From): Array<[keyof From, ValueOf<From>]>
12
+ /**
13
+ * Destructures object into array of property keys
14
+ * @param from Object to destruct
15
+ */
16
+ keysOf<From = {}>(from: From): Array<keyof From>
17
+ }
18
+ }
19
+
20
+ Object.keysOf = function<From = {}>(this: object, from: From): Array<keyof From> {
21
+ return Object.keys(from) as Array<keyof From>;
22
+ }
23
+ Object.array = function<From = {}>(this: object, from: From): Array<[keyof From, ValueOf<From>]> {
24
+ return Object.keysOf(from).map(prop => [prop, from[prop]]) as Array<[keyof From, ValueOf<From>]>;
25
+ }
@@ -0,0 +1,43 @@
1
+ import IReplacement from "../Interfaces/IReplacement";
2
+ export {}
3
+
4
+ declare global {
5
+ interface String {
6
+ /**
7
+ * Uppercases first letter of string
8
+ */
9
+ toPascalCase(): string
10
+ /**
11
+ * Replaces "replacer" (default: ' ') with "replacement" (default: '_')
12
+ * @param replaceOptions This is practically your stereotypical String.replace, if you really want it to be
13
+ */
14
+ toSnakeCase(replaceOptions?: IReplacement): string
15
+ /**
16
+ * Replaces "replacer" (default: ' ') with "replacement" (default: '-')
17
+ * @param replaceOptions This is practically your stereotypical String.replace, if you really want it to be
18
+ */
19
+ toKebabCase(replaceOptions?: IReplacement): string,
20
+ /**
21
+ * String.substring but accepting negative numbers to cut from length
22
+ * @param start Start of string. 0 indexed, if negative number, subtracts number from length
23
+ * @param end End of string. 0 indexed, if negative number, substracts number from length
24
+ */
25
+ clip(start: number, end?: number): string
26
+ }
27
+ }
28
+
29
+ String.prototype.toPascalCase = function(this: string) {
30
+ return this.substring(0, 1).toUpperCase() + this.substring(1);
31
+ }
32
+ function spaceReplacer(self: string, replacer: string | RegExp, replacement: string) {
33
+ return self.replace(new RegExp(`${typeof replacer == 'string' ? replacer : replacer.source}+`), replacement);
34
+ }
35
+ String.prototype.toSnakeCase = function(this: string, replaceOptions: IReplacement) {
36
+ return spaceReplacer(this, replaceOptions.replacer || ' ', replaceOptions.replacement || '_')
37
+ }
38
+ String.prototype.toKebabCase = function(this: string, replaceOptions: IReplacement) {
39
+ return spaceReplacer(this, replaceOptions.replacer || ' ', replaceOptions.replacement || '-');
40
+ }
41
+ String.prototype.clip = function(this: string, start: number, end?: number) {
42
+ return this.substring(start < 0 ? this.length - start : start, end && end < 0 ? this.length + end : end);
43
+ }
@@ -0,0 +1,83 @@
1
+ import ElementOptions from "../Interfaces/ElementOptions";
2
+ import { EventHandler, IElement } from "../Types";
3
+ export * from './Array';
4
+ export * from './Map';
5
+ export * from './Object';
6
+ export * from './String';
7
+
8
+ declare global {
9
+ interface BooleanConstructor {
10
+ /**
11
+ * Parses string to boolean. Will only return true if value === "true" otherwise false
12
+ */
13
+ parseBoolean(value: string): boolean
14
+ }
15
+
16
+ interface Document {
17
+ /**
18
+ * Creates an element like Document#createElement, however with construction options to assign values in construction instead of after construction.
19
+ * @param tagName HTMLElement tag name
20
+ * @param options Construction options, instead of assigning values after construction
21
+ */
22
+ createProperElement<K extends keyof HTMLElementTagNameMap>(tagName: K, options?: ElementOptions, ...children: Array<IElement>): HTMLElementTagNameMap[K]
23
+ createFromHtml<K extends keyof HTMLElementTagNameMap>(html: string, parentTag?: K): HTMLElementTagNameMap[K]
24
+ }
25
+ interface HTMLCollection {
26
+ /**
27
+ * Converts HTMLCollection to Element[]
28
+ */
29
+ array(): Element[]
30
+ }
31
+ }
32
+
33
+ Boolean.parseBoolean = function(value: string) {
34
+ return value === "true";
35
+ };
36
+
37
+ try {
38
+ Document.prototype.createProperElement = function<K extends keyof HTMLElementTagNameMap>(this: Document, tagName: K, options?: ElementOptions, ...children: Array<IElement>): HTMLElementTagNameMap[K] {
39
+ let baseElement = document.createElement(tagName);
40
+ if (!options) return baseElement;
41
+
42
+ const { id, class: className, dataset, ...rest } = options;
43
+ if (id) baseElement.id = id;
44
+ if (className) {
45
+ const classNames = Array.isArray(className) ? className : [className];
46
+ classNames.forEach(className => baseElement.classList.add(className));
47
+ }
48
+ children ?? options.children;
49
+ if (children) {
50
+ const childrenElements = Array.isArray(children) ? children : [children];
51
+ childrenElements.forEach(child => baseElement.append(child));
52
+ }
53
+ if (dataset) Object.entries(dataset).forEach(([key, value]) => baseElement.dataset[key] = value);
54
+
55
+ for (const optionKey in rest) {
56
+ const optionValue = rest[optionKey as keyof typeof rest] as EventHandler | object;
57
+ if (optionValue === undefined) continue;
58
+
59
+ if (typeof optionValue === 'function') {
60
+ baseElement.addEventListener(optionKey.substring(2), rest[optionKey as keyof typeof rest] as EventListener);
61
+ } else {
62
+ baseElement.setAttribute(optionKey, optionValue.toString());
63
+ }
64
+ }
65
+
66
+ return baseElement;
67
+ }
68
+ Document.prototype.createFromHtml = function<K extends keyof HTMLElementTagNameMap>(this: Document, html: string, parentTag?: K): HTMLElementTagNameMap[K] {
69
+ return new DOMParser().parseFromString(html, 'text/html').body.firstChild as HTMLElementTagNameMap[K];
70
+ }
71
+
72
+ HTMLCollection.prototype.array = function(this: HTMLCollection) {
73
+ let result = new Array<Element>();
74
+
75
+ for (let i = 0; i < this.length; i++) {
76
+ const item = this.item(i);
77
+ if (item !== null) result.push(item);
78
+ }
79
+ return result;
80
+ }
81
+ } catch {
82
+ // Used in node.js
83
+ }
@@ -0,0 +1,27 @@
1
+ type CSSReturnTypes = {
2
+ string: string,
3
+ number: number
4
+ }
5
+
6
+ /**
7
+ * Gets the value of "property" in type "type" from query "query"
8
+ * Basically, you can get your --color-primary from :root
9
+ *
10
+ * @param property Name of the property to get
11
+ * @param type Type of the property to parse
12
+ * @param query Query to get the element that has the property
13
+ * @returns Property value converted to type
14
+ */
15
+ export function GetCSSProperty<Type extends keyof CSSReturnTypes>(property: string, type: Type, query = ":root"): CSSReturnTypes[Type] {
16
+ const rootEl = document.querySelector(query);
17
+ if (!rootEl) throw new Error(`${query} does not exist!`);
18
+
19
+ const rootStyles = getComputedStyle(rootEl);
20
+ const cssProp = rootStyles.getPropertyValue(property);
21
+ if (type === 'string') return cssProp as CSSReturnTypes[Type];
22
+
23
+ const numberValue = parseInt(cssProp);
24
+ if (isNaN(numberValue)) throw new Error(`${property} is not a number!: ${cssProp}`);
25
+ return numberValue as CSSReturnTypes[Type];
26
+ }
27
+
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Create HTMLEvent object from function
3
+ * @param name Name of the event
4
+ * @param handler Handler for the event
5
+ * @returns Parameters as object
6
+ */
7
+ export function HTMLEvent<
8
+ Event extends keyof HTMLElementEventMap,
9
+ ReturnType extends any
10
+ >(name: Event, handler: (event: HTMLElementEventMap[Event]) => ReturnType) {
11
+ return { name, handler };
12
+ }
13
+ export default HTMLEvent;
@@ -7,6 +7,7 @@
7
7
  */
8
8
  export function SetNavigationSelected(query: string, ...currentPageClasses: string[]) {
9
9
  const header = document.querySelector(query);
10
+ if (!header) throw { message: `Couldn't find header from query, ${query}` }
10
11
  const children = header.children.array().filter(c => c.tagName === 'a') as HTMLAnchorElement[];
11
12
  const currentPage = document.location.href;
12
13
 
@@ -1,2 +1,4 @@
1
1
  export * from './CopyToClipboard';
2
- export * from './SetNavigationSelected';
2
+ export * from './GetCSSProperty';
3
+ export * from './SetNavigationSelected';
4
+ export * from './HTMLEvent';
@@ -1,19 +1,21 @@
1
- import { EventHandler } from "..";
2
- import IElement from "../Types/IElement";
1
+ import { Arrayable, IElement } from "../Types"
2
+
3
+ type Events = Record<
4
+ `on${Capitalize<keyof HTMLElementEventMap>}`,
5
+ (event: Event) => void
6
+ >
3
7
 
4
8
  /**
5
9
  * Construction options when creating an HTML element using:
6
- * @see Document.createProperElement */
7
- export interface ElementOptions {
8
- /**css classes to give the element*/
9
- classes?: string[],
10
- /**attributes to give the element*/
11
- attributes?: [string, string][],
12
- /**Children of the element*/
13
- children?: IElement[],
14
- /**Events for the element to listen to
15
- * @borrows EventHandler
16
- */
17
- events?: Array<{ name: string, handlers: EventHandler[] }>
18
- }
19
- export default ElementOptions
10
+ * @see Document.createProperElement
11
+ * @borwwos IElement
12
+ * @borrows Arrayable
13
+ */
14
+ export type ElementOptions = Partial<
15
+ Events & Record<string, any> & {
16
+ id: string,
17
+ class: Arrayable<string>;
18
+ children: Arrayable<IElement>;
19
+ dataset: Record<string, string>
20
+ }>
21
+ export default ElementOptions;
@@ -1,4 +1,4 @@
1
- import StringRegex from "../Types/StringRegex";
1
+ import { StringRegex } from "../Types";
2
2
 
3
3
  /**
4
4
  * Replacement tool for
@@ -6,7 +6,8 @@ import StringRegex from "../Types/StringRegex";
6
6
  * @see String.toKebabCase
7
7
  * @borrows StringRegex
8
8
  */
9
- export default interface IReplacement {
9
+ export interface IReplacement {
10
10
  replacer?: StringRegex,
11
11
  replacement?: string
12
- }
12
+ }
13
+ export default IReplacement;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Construct a type with the properties of Type except for those in type Properties.
3
+ */
4
+ export type BetterOmit<Type, Properties extends keyof Type> = Omit<Type, Properties>;
5
+ /**
6
+ * Extract from From those types that are assignable to Properties
7
+ */
8
+ export type BetterExtract<From, Properties extends From> = Extract<From, Properties>;
9
+
10
+ export type PartialExcept<From, Properties extends keyof From> = Partial<From> & Required<Pick<From, Properties>>
@@ -0,0 +1,7 @@
1
+ export type LongMonth = 'Janurary' | 'February' | 'March' | 'April' | 'May' | 'June' | 'July' | 'August' | 'September' | 'October' | 'November' | 'December';
2
+ export type ShortMonth = 'Jan' | 'Feb' | 'Mar' | 'Apr' | 'May' | 'Jun' | 'Jul' | 'Aug' | 'Sep' | 'Oct' | 'Nov' | 'Dec';
3
+ export type Month = LongMonth | ShortMonth;
4
+
5
+ export type ShortDay = 'Mon' | 'Tue' | 'Wed' | 'Thu' | 'Fri' | 'Sat' | 'Sun';
6
+ export type LongDay = `${'Mon' | 'Tues' | 'Wednes' | 'Thurs' | 'Fri' | 'Satur' | 'Sun'}day`;
7
+ export type Day = ShortDay | LongDay;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Default eventhandler mapper. Object with properties that are arrays
3
+ */
4
+ export type BaseEvent<Keys extends string, Types extends Array<any>> = Record<Keys, Types>;
5
+
6
+ /**
7
+ * Eventhandler type for:
8
+ * @see EventCollection
9
+ * @borrows BaseEvent
10
+ */
11
+ export type EventHandler<
12
+ Events extends BaseEvent<string, Array<any>> = BaseEvent<string, Array<any>>,
13
+ Event extends keyof Events = keyof Events,
14
+ ReturnType = any
15
+ > = (...args: Events[Event]) => ReturnType;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Filters all properties from From that has the return type of Type
3
+ */
4
+ export type PropertiesWith<Type, From> = {
5
+ [Key in keyof From as From[Key] extends Type ? Key : never]: From[Key]
6
+ }
7
+ export default PropertiesWith;
8
+
9
+ /**
10
+ * Fitlers all properties from From that don't have the return type of Type
11
+ */
12
+ export type PropertiesWithout<Type, From> = {
13
+ [Key in keyof From as From[Key] extends Type ? never : Key]: From[Key]
14
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Converts Start types to Switch types in From type
3
+ */
4
+ export type TransformType<From, Start, Switch> = {
5
+ [Key in keyof From]: From[Key] extends Start ? Switch : From[Key]
6
+ }
7
+
8
+ /**
9
+ * Returns object with properties matching BaseType with types of NewType
10
+ */
11
+ export type TransformTypes<From, BaseType, NewType> = Record<keyof {
12
+ [Key in keyof From as From[Key] extends BaseType ? Key : never]: Key
13
+ }, NewType>
14
+
15
+ //Returns From with properties switched from BaseType to NewType
16
+ // export type TransformTypes<From, BaseType, NewType> = TransformType<From, BaseType[keyof BaseType], NewType>;
17
+
18
+ export default TransformTypes;
@@ -1,3 +1,36 @@
1
- export * from './EventHandler';
2
- export * from './IElement';
3
- export * from './StringRegex';
1
+ export * from './BetterTypes';
2
+ export * from './Date';
3
+ export * from './Events';
4
+ export * from './TransformTypes';
5
+ export * from './PropertiesWith';
6
+
7
+ /**
8
+ * Item is single or multiple
9
+ */
10
+ export type Arrayable<T> = T | Array<T>;
11
+
12
+ /**
13
+ * Used for HTMLElement.append in ElementOptions, Document.createProperElement.
14
+ * IElement accepts HTML Elements or HTMl-like strings.
15
+ *
16
+ * @see HTMLElement.append
17
+ * @see Document.createProperElement
18
+ */
19
+ export type IElement = HTMLElement | string;
20
+
21
+ /**
22
+ * Return types of T
23
+ */
24
+ export type ValueOf<T> = T[keyof T];
25
+
26
+ /**
27
+ * Type's properties are ReturnType
28
+ */
29
+ export type AllPropsAre<ReturnType> = {
30
+ [key: string]: ReturnType
31
+ }
32
+
33
+ /**
34
+ * string or RegExp.. pretty self-explanatory
35
+ */
36
+ export type StringRegex = string | RegExp;
package/src/index.ts CHANGED
@@ -1,13 +1,5 @@
1
- import { EventHandler, IElement } from './Types';
2
- export { EventHandler, IElement };
3
-
4
- import { ElementOptions } from './Interfaces';
5
- export { ElementOptions };
6
-
7
- import { EventCollection, EventEmitter } from './Classes';
8
- export { EventCollection, EventEmitter };
9
-
10
- import { CopyToClipboard, SetNavigationSelected } from './Functions';
11
- export { CopyToClipboard, SetNavigationSelected };
12
-
13
- export * as Extensions from './Extensions';
1
+ export * from './Classes';
2
+ export * from './Extensions';
3
+ export * from './Functions';
4
+ export * from './Interfaces';
5
+ export * from './Types';
package/tsconfig.json CHANGED
@@ -1,10 +1,102 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "module": "commonjs",
4
- "target": "esnext",
5
- "declaration": true,
6
- "outDir": "./dist",
7
- "resolveJsonModule": true,
8
- "watch": true
9
- }
3
+ /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Enable incremental compilation */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "esnext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
+ "lib": ["ESNext", "DOM"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
+ // "jsx": "preserve", /* Specify what JSX code is generated. */
17
+ // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
20
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
22
+ // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
23
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
+
26
+ /* Modules */
27
+ "module": "commonjs", /* Specify what module code is generated. */
28
+ "rootDir": "./src", /* Specify the root folder within your source files. */
29
+ // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
30
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
31
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
32
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
33
+ // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
34
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
35
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
36
+ "resolveJsonModule": true, /* Enable importing .json files */
37
+ // "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
38
+
39
+ /* JavaScript Support */
40
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
41
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
42
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
43
+
44
+ /* Emit */
45
+ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
46
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
47
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
48
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
49
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
50
+ "outDir": "./dist", /* Specify an output folder for all emitted files. */
51
+ // "removeComments": true, /* Disable emitting comments. */
52
+ // "noEmit": true, /* Disable emitting files from a compilation. */
53
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
54
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
55
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
56
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
57
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
58
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
59
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
60
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
61
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
62
+ // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
63
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
64
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
65
+ // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
66
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
67
+ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
68
+
69
+ /* Interop Constraints */
70
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
71
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
72
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */
73
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
74
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
75
+
76
+ /* Type Checking */
77
+ "strict": true, /* Enable all strict type-checking options. */
78
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
79
+ // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
80
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
81
+ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
82
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
83
+ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
84
+ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
85
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
86
+ // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
87
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
88
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
89
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
90
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
91
+ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
92
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
93
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
94
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
95
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
96
+
97
+ /* Completeness */
98
+ "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
99
+ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
100
+ "watch": true,
101
+ },
10
102
  }