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,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ Array.prototype.add = function (...items) {
4
+ this.push(...items);
5
+ return this;
6
+ };
7
+ Array.prototype.update = function (old, updated) {
8
+ const item = typeof old === 'number' ? this[old] : typeof old === 'function' ? this.find(old) : old;
9
+ if (!item)
10
+ throw new Error('Old was not found in array!');
11
+ const index = this.indexOf(item);
12
+ return this[index] = updated;
13
+ };
14
+ Array.prototype.remove = function (value) {
15
+ const index = typeof value === 'number' ? value : this.indexOf(value);
16
+ if (index > -1)
17
+ this.splice(index, 1);
18
+ return this;
19
+ };
20
+ Array.prototype.random = function () {
21
+ const randomIndex = Math.round(Math.random() * this.length);
22
+ return this[randomIndex];
23
+ };
24
+ Array.prototype.index = function (i) {
25
+ return this[i < 0 ? this.length + i : i];
26
+ };
@@ -0,0 +1,38 @@
1
+ export {};
2
+ declare global {
3
+ interface Map<K, V> {
4
+ /**
5
+ * Converts into Array<[Key, Value]>
6
+ */
7
+ array(): Array<[K, V]>;
8
+ /**
9
+ * Maps values into new types of generics
10
+ * @param callback Callbacking function to map values
11
+ */
12
+ map<EK, EV>(callback: (value: V, key: K, index: number, self: this) => [EK, EV]): Map<EK, EV>;
13
+ /**
14
+ * Returns array of "accepted" values. Criteria defined in callback param
15
+ * @param callback Callbacking function to filter away unwanted values
16
+ */
17
+ filter(callback: (value: V, key: K, index: number, self: this) => boolean): Map<K, V>;
18
+ /**
19
+ * Returns array of keys
20
+ */
21
+ keyArr(): Array<K>;
22
+ /**
23
+ * Returns array of values
24
+ */
25
+ valueArr(): Array<V>;
26
+ /**
27
+ * Returns first [key, value] match to callback param. Returns undefined if nothing found
28
+ * @param callback Callbacking function to find KeyValuePair
29
+ */
30
+ find(callback: (value: V, key: K, index: number, self: this) => boolean): [K, V] | undefined;
31
+ /**
32
+ * Whether or not map includes a value. Returns true if it does, false if not ¯\_(ツ)_/¯
33
+ * @param value Value that may be includded in map
34
+ * @param fromIndex Start looking for value from specific index+. Default: 0
35
+ */
36
+ includes(value: V, fromIndex?: number): boolean;
37
+ }
38
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ Map.prototype.array = function () {
4
+ let result = new Array();
5
+ for (const kvp of this) {
6
+ result.push(kvp);
7
+ }
8
+ return result;
9
+ };
10
+ Map.prototype.map = function (callback) {
11
+ return this.array()
12
+ .map(([k, v], i) => callback(v, k, i, this))
13
+ .reduce((map, [key, value]) => map.set(key, value), new Map());
14
+ };
15
+ Map.prototype.filter = function (callback) {
16
+ return this.array()
17
+ .filter(([k, v], i) => callback(v, k, i, this))
18
+ .reduce((map, [key, value]) => map.set(key, value), new Map());
19
+ };
20
+ Map.prototype.keyArr = function () {
21
+ return this.array().map(([k]) => k);
22
+ };
23
+ Map.prototype.valueArr = function () {
24
+ return this.array().map(([_, v]) => v);
25
+ };
26
+ Map.prototype.find = function (callback) {
27
+ return this.array().find(([k, v], i) => callback(v, k, i, this));
28
+ };
29
+ Map.prototype.includes = function (item, fromIndex) {
30
+ return this.valueArr().includes(item, fromIndex);
31
+ };
@@ -0,0 +1,16 @@
1
+ import { ValueOf } from "../Types";
2
+ export {};
3
+ declare global {
4
+ interface ObjectConstructor {
5
+ /**
6
+ * Destructures object into array of [property, value]
7
+ * @param from Object to destruct
8
+ */
9
+ array<From = {}>(from: From): Array<[keyof From, ValueOf<From>]>;
10
+ /**
11
+ * Destructures object into array of property keys
12
+ * @param from Object to destruct
13
+ */
14
+ keysOf<From = {}>(from: From): Array<keyof From>;
15
+ }
16
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ Object.keysOf = function (from) {
4
+ return Object.keys(from);
5
+ };
6
+ Object.array = function (from) {
7
+ return Object.keysOf(from).map(prop => [prop, from[prop]]);
8
+ };
@@ -0,0 +1,26 @@
1
+ import IReplacement from "../Interfaces/IReplacement";
2
+ export {};
3
+ declare global {
4
+ interface String {
5
+ /**
6
+ * Uppercases first letter of string
7
+ */
8
+ toPascalCase(): string;
9
+ /**
10
+ * Replaces "replacer" (default: ' ') with "replacement" (default: '_')
11
+ * @param replaceOptions This is practically your stereotypical String.replace, if you really want it to be
12
+ */
13
+ toSnakeCase(replaceOptions?: IReplacement): string;
14
+ /**
15
+ * Replaces "replacer" (default: ' ') with "replacement" (default: '-')
16
+ * @param replaceOptions This is practically your stereotypical String.replace, if you really want it to be
17
+ */
18
+ toKebabCase(replaceOptions?: IReplacement): string;
19
+ /**
20
+ * String.substring but accepting negative numbers to cut from length
21
+ * @param start Start of string. 0 indexed, if negative number, subtracts number from length
22
+ * @param end End of string. 0 indexed, if negative number, substracts number from length
23
+ */
24
+ clip(start: number, end?: number): string;
25
+ }
26
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ String.prototype.toPascalCase = function () {
4
+ return this.substring(0, 1).toUpperCase() + this.substring(1);
5
+ };
6
+ function spaceReplacer(self, replacer, replacement) {
7
+ return self.replace(new RegExp(`${typeof replacer == 'string' ? replacer : replacer.source}+`), replacement);
8
+ }
9
+ String.prototype.toSnakeCase = function (replaceOptions) {
10
+ return spaceReplacer(this, replaceOptions.replacer || ' ', replaceOptions.replacement || '_');
11
+ };
12
+ String.prototype.toKebabCase = function (replaceOptions) {
13
+ return spaceReplacer(this, replaceOptions.replacer || ' ', replaceOptions.replacement || '-');
14
+ };
15
+ String.prototype.clip = function (start, end) {
16
+ return this.substring(start < 0 ? this.length - start : start, end && end < 0 ? this.length + end : end);
17
+ };
@@ -0,0 +1,29 @@
1
+ import ElementOptions from "../Interfaces/ElementOptions";
2
+ import { IElement } from "../Types";
3
+ export * from './Array';
4
+ export * from './Map';
5
+ export * from './Object';
6
+ export * from './String';
7
+ declare global {
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
+ interface Document {
15
+ /**
16
+ * Creates an element like Document#createElement, however with construction options to assign values in construction instead of after construction.
17
+ * @param tagName HTMLElement tag name
18
+ * @param options Construction options, instead of assigning values after construction
19
+ */
20
+ createProperElement<K extends keyof HTMLElementTagNameMap>(tagName: K, options?: ElementOptions, ...children: Array<IElement>): HTMLElementTagNameMap[K];
21
+ createFromHtml<K extends keyof HTMLElementTagNameMap>(html: string, parentTag?: K): HTMLElementTagNameMap[K];
22
+ }
23
+ interface HTMLCollection {
24
+ /**
25
+ * Converts HTMLCollection to Element[]
26
+ */
27
+ array(): Element[];
28
+ }
29
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Array"), exports);
18
+ __exportStar(require("./Map"), exports);
19
+ __exportStar(require("./Object"), exports);
20
+ __exportStar(require("./String"), exports);
21
+ Boolean.parseBoolean = function (value) {
22
+ return value === "true";
23
+ };
24
+ try {
25
+ Document.prototype.createProperElement = function (tagName, options, ...children) {
26
+ let baseElement = document.createElement(tagName);
27
+ if (!options)
28
+ return baseElement;
29
+ const { id, class: className, dataset, ...rest } = options;
30
+ if (id)
31
+ baseElement.id = id;
32
+ if (className) {
33
+ const classNames = Array.isArray(className) ? className : [className];
34
+ classNames.forEach(className => baseElement.classList.add(className));
35
+ }
36
+ children ?? options.children;
37
+ if (children) {
38
+ const childrenElements = Array.isArray(children) ? children : [children];
39
+ childrenElements.forEach(child => baseElement.append(child));
40
+ }
41
+ if (dataset)
42
+ Object.entries(dataset).forEach(([key, value]) => baseElement.dataset[key] = value);
43
+ for (const optionKey in rest) {
44
+ const optionValue = rest[optionKey];
45
+ if (optionValue === undefined)
46
+ continue;
47
+ if (typeof optionValue === 'function') {
48
+ baseElement.addEventListener(optionKey.substring(2), rest[optionKey]);
49
+ }
50
+ else {
51
+ baseElement.setAttribute(optionKey, optionValue.toString());
52
+ }
53
+ }
54
+ return baseElement;
55
+ };
56
+ Document.prototype.createFromHtml = function (html, parentTag) {
57
+ return new DOMParser().parseFromString(html, 'text/html').body.firstChild;
58
+ };
59
+ HTMLCollection.prototype.array = function () {
60
+ let result = new Array();
61
+ for (let i = 0; i < this.length; i++) {
62
+ const item = this.item(i);
63
+ if (item !== null)
64
+ result.push(item);
65
+ }
66
+ return result;
67
+ };
68
+ }
69
+ catch {
70
+ // Used in node.js
71
+ }
@@ -0,0 +1,15 @@
1
+ declare type CSSReturnTypes = {
2
+ string: string;
3
+ number: number;
4
+ };
5
+ /**
6
+ * Gets the value of "property" in type "type" from query "query"
7
+ * Basically, you can get your --color-primary from :root
8
+ *
9
+ * @param property Name of the property to get
10
+ * @param type Type of the property to parse
11
+ * @param query Query to get the element that has the property
12
+ * @returns Property value converted to type
13
+ */
14
+ export declare function GetCSSProperty<Type extends keyof CSSReturnTypes>(property: string, type: Type, query?: string): CSSReturnTypes[Type];
15
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetCSSProperty = void 0;
4
+ /**
5
+ * Gets the value of "property" in type "type" from query "query"
6
+ * Basically, you can get your --color-primary from :root
7
+ *
8
+ * @param property Name of the property to get
9
+ * @param type Type of the property to parse
10
+ * @param query Query to get the element that has the property
11
+ * @returns Property value converted to type
12
+ */
13
+ function GetCSSProperty(property, type, query = ":root") {
14
+ const rootEl = document.querySelector(query);
15
+ if (!rootEl)
16
+ throw new Error(`${query} does not exist!`);
17
+ const rootStyles = getComputedStyle(rootEl);
18
+ const cssProp = rootStyles.getPropertyValue(property);
19
+ if (type === 'string')
20
+ return cssProp;
21
+ const numberValue = parseInt(cssProp);
22
+ if (isNaN(numberValue))
23
+ throw new Error(`${property} is not a number!: ${cssProp}`);
24
+ return numberValue;
25
+ }
26
+ exports.GetCSSProperty = GetCSSProperty;
@@ -1,3 +1,9 @@
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
+ */
1
7
  export declare function HTMLEvent<Event extends keyof HTMLElementEventMap, ReturnType extends any>(name: Event, handler: (event: HTMLElementEventMap[Event]) => ReturnType): {
2
8
  name: Event;
3
9
  handler: (event: HTMLElementEventMap[Event]) => ReturnType;
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HTMLEvent = void 0;
4
+ /**
5
+ * Create HTMLEvent object from function
6
+ * @param name Name of the event
7
+ * @param handler Handler for the event
8
+ * @returns Parameters as object
9
+ */
4
10
  function HTMLEvent(name, handler) {
5
11
  return { name, handler };
6
12
  }
@@ -10,6 +10,8 @@ exports.SetNavigationSelected = void 0;
10
10
  */
11
11
  function SetNavigationSelected(query, ...currentPageClasses) {
12
12
  const header = document.querySelector(query);
13
+ if (!header)
14
+ throw { message: `Couldn't find header from query, ${query}` };
13
15
  const children = header.children.array().filter(c => c.tagName === 'a');
14
16
  const currentPage = document.location.href;
15
17
  children.forEach(gc => {
@@ -1,3 +1,4 @@
1
1
  export * from './CopyToClipboard';
2
+ export * from './GetCSSProperty';
2
3
  export * from './SetNavigationSelected';
3
4
  export * from './HTMLEvent';
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -11,5 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
17
  __exportStar(require("./CopyToClipboard"), exports);
18
+ __exportStar(require("./GetCSSProperty"), exports);
14
19
  __exportStar(require("./SetNavigationSelected"), exports);
15
20
  __exportStar(require("./HTMLEvent"), exports);
@@ -1,18 +1,15 @@
1
- import IElement from "../Types/IElement";
1
+ import { Arrayable, IElement } from "../Types";
2
+ declare type Events = Record<`on${Capitalize<keyof HTMLElementEventMap>}`, (event: Event) => void>;
2
3
  /**
3
4
  * Construction options when creating an HTML element using:
4
- * @see Document.createProperElement */
5
- export interface ElementOptions {
6
- /**css classes to give the element*/
7
- classes?: string[];
8
- /**attributes to give the element*/
9
- attributes?: [string, string][];
10
- /**Children of the element*/
11
- children?: IElement | IElement[];
12
- /**Events for the element to listen to*/
13
- events?: Array<{
14
- name: string;
15
- handler: (e: Event) => any;
16
- }>;
17
- }
5
+ * @see Document.createProperElement
6
+ * @borwwos IElement
7
+ * @borrows Arrayable
8
+ */
9
+ export declare type ElementOptions = Partial<Events & Record<string, any> & {
10
+ id: string;
11
+ class: Arrayable<string>;
12
+ children: Arrayable<IElement>;
13
+ dataset: Record<string, string>;
14
+ }>;
18
15
  export default ElementOptions;
@@ -1,4 +1,4 @@
1
- import StringRegex from "../Types/StringRegex";
1
+ import { StringRegex } from "../Types";
2
2
  /**
3
3
  * Replacement tool for
4
4
  * @see String.toSnakeCase
@@ -1,3 +1,2 @@
1
1
  export * from './ElementOptions';
2
2
  export * from './IReplacement';
3
- export * from './BaseEventInterface';
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -12,4 +16,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
17
  __exportStar(require("./ElementOptions"), exports);
14
18
  __exportStar(require("./IReplacement"), exports);
15
- __exportStar(require("./BaseEventInterface"), exports);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Construct a type with the properties of Type except for those in type Properties.
3
+ */
4
+ export declare 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 declare type BetterExtract<From, Properties extends From> = Extract<From, Properties>;
9
+ export declare type PartialExcept<From, Properties extends keyof From> = Partial<From> & Required<Pick<From, Properties>>;
@@ -0,0 +1,6 @@
1
+ export declare type LongMonth = 'Janurary' | 'February' | 'March' | 'April' | 'May' | 'June' | 'July' | 'August' | 'September' | 'October' | 'November' | 'December';
2
+ export declare type ShortMonth = 'Jan' | 'Feb' | 'Mar' | 'Apr' | 'May' | 'Jun' | 'Jul' | 'Aug' | 'Sep' | 'Oct' | 'Nov' | 'Dec';
3
+ export declare type Month = LongMonth | ShortMonth;
4
+ export declare type ShortDay = 'Mon' | 'Tue' | 'Wed' | 'Thu' | 'Fri' | 'Sat' | 'Sun';
5
+ export declare type LongDay = `${'Mon' | 'Tues' | 'Wednes' | 'Thurs' | 'Fri' | 'Satur' | 'Sun'}day`;
6
+ export declare type Day = ShortDay | LongDay;
File without changes
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Default eventhandler mapper. Object with properties that are arrays
3
+ */
4
+ export declare type BaseEvent<Keys extends string, Types extends Array<any>> = Record<Keys, Types>;
5
+ /**
6
+ * Eventhandler type for:
7
+ * @see EventCollection
8
+ * @borrows BaseEvent
9
+ */
10
+ export declare type EventHandler<Events extends BaseEvent<string, Array<any>> = BaseEvent<string, Array<any>>, Event extends keyof Events = keyof Events, ReturnType = any> = (...args: Events[Event]) => ReturnType;
File without changes
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Filters all properties from From that has the return type of Type
3
+ */
4
+ export declare 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
+ * Fitlers all properties from From that don't have the return type of Type
10
+ */
11
+ export declare type PropertiesWithout<Type, From> = {
12
+ [Key in keyof From as From[Key] extends Type ? never : Key]: From[Key];
13
+ };
File without changes
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Converts Start types to Switch types in From type
3
+ */
4
+ export declare type TransformType<From, Start, Switch> = {
5
+ [Key in keyof From]: From[Key] extends Start ? Switch : From[Key];
6
+ };
7
+ /**
8
+ * Returns object with properties matching BaseType with types of NewType
9
+ */
10
+ export declare type TransformTypes<From, BaseType, NewType> = Record<keyof {
11
+ [Key in keyof From as From[Key] extends BaseType ? Key : never]: Key;
12
+ }, NewType>;
13
+ export default TransformTypes;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,31 @@
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
+ * Item is single or multiple
8
+ */
9
+ export declare type Arrayable<T> = T | Array<T>;
10
+ /**
11
+ * Used for HTMLElement.append in ElementOptions, Document.createProperElement.
12
+ * IElement accepts HTML Elements or HTMl-like strings.
13
+ *
14
+ * @see HTMLElement.append
15
+ * @see Document.createProperElement
16
+ */
17
+ export declare type IElement = HTMLElement | string;
18
+ /**
19
+ * Return types of T
20
+ */
21
+ export declare type ValueOf<T> = T[keyof T];
22
+ /**
23
+ * Type's properties are ReturnType
24
+ */
25
+ export declare type AllPropsAre<ReturnType> = {
26
+ [key: string]: ReturnType;
27
+ };
28
+ /**
29
+ * string or RegExp.. pretty self-explanatory
30
+ */
31
+ export declare type StringRegex = string | RegExp;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -10,6 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./EventHandler"), exports);
14
- __exportStar(require("./IElement"), exports);
15
- __exportStar(require("./StringRegex"), exports);
17
+ __exportStar(require("./BetterTypes"), exports);
18
+ __exportStar(require("./Date"), exports);
19
+ __exportStar(require("./Events"), exports);
20
+ __exportStar(require("./TransformTypes"), exports);
21
+ __exportStar(require("./PropertiesWith"), exports);
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { EventCollection, EventEmitter, Event } from './Classes';
2
- export { CopyToClipboard, SetNavigationSelected, HTMLEvent } from './Functions';
3
- export { ElementOptions, IReplacement } from './Interfaces';
4
- export { EventHandler, IElement, StringRegex } from './Types';
5
- 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/dist/index.js CHANGED
@@ -1,12 +1,21 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Extensions = exports.HTMLEvent = exports.SetNavigationSelected = exports.CopyToClipboard = exports.Event = exports.EventEmitter = exports.EventCollection = void 0;
4
- var Classes_1 = require("./Classes");
5
- Object.defineProperty(exports, "EventCollection", { enumerable: true, get: function () { return Classes_1.EventCollection; } });
6
- Object.defineProperty(exports, "EventEmitter", { enumerable: true, get: function () { return Classes_1.EventEmitter; } });
7
- Object.defineProperty(exports, "Event", { enumerable: true, get: function () { return Classes_1.Event; } });
8
- var Functions_1 = require("./Functions");
9
- Object.defineProperty(exports, "CopyToClipboard", { enumerable: true, get: function () { return Functions_1.CopyToClipboard; } });
10
- Object.defineProperty(exports, "SetNavigationSelected", { enumerable: true, get: function () { return Functions_1.SetNavigationSelected; } });
11
- Object.defineProperty(exports, "HTMLEvent", { enumerable: true, get: function () { return Functions_1.HTMLEvent; } });
12
- exports.Extensions = require("./Extensions");
17
+ __exportStar(require("./Classes"), exports);
18
+ __exportStar(require("./Extensions"), exports);
19
+ __exportStar(require("./Functions"), exports);
20
+ __exportStar(require("./Interfaces"), exports);
21
+ __exportStar(require("./Types"), exports);