aprog 2.2.3 → 2.2.4

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.
package/src/helper.js CHANGED
@@ -1,6 +1,15 @@
1
1
  import StateWrapper from "./classes/StateWrapper.js";
2
2
  import SmartWrapper from "./classes/SmartWrapper.js";
3
+ import AbortError from "./classes/AbortError.js";
4
+ import Toast from "./classes/Toast.js";
3
5
 
4
6
  export const state = (value) => new StateWrapper(value);
5
7
 
6
8
  export const wrap = (value) => new SmartWrapper(value);
9
+
10
+ export const toast = (opt = {}) => new Toast(opt);
11
+
12
+ export const abort = (message = "") => {
13
+ toast().error(message);
14
+ throw new AbortError(`=> ${message}`);
15
+ };
package/src/html.js CHANGED
@@ -1,92 +1,92 @@
1
1
  export function pushHTMLElementPrototype() {
2
- if (!HTMLElement.prototype.push) {
3
- HTMLElement.prototype.push = function(element) {
4
- this.innerHTML = null;
5
- this.append(element);
6
- };
7
- }
2
+ if (!HTMLElement.prototype.push) {
3
+ HTMLElement.prototype.push = function (element) {
4
+ this.innerHTML = null;
5
+ this.append(element);
6
+ };
7
+ }
8
8
  }
9
9
 
10
10
  export function prepushHTMLElementPrototype() {
11
- if (!HTMLElement.prototype.prepush) {
12
- HTMLElement.prototype.prepush = function(element) {
13
- this.innerHTML = null;
14
- this.prepend(element);
15
- };
16
- }
11
+ if (!HTMLElement.prototype.prepush) {
12
+ HTMLElement.prototype.prepush = function (element) {
13
+ this.innerHTML = null;
14
+ this.prepend(element);
15
+ };
16
+ }
17
17
  }
18
18
 
19
19
  export function pushAfterHTMLElementPrototype() {
20
- if (!HTMLElement.prototype.pushAfter) {
21
- HTMLElement.prototype.pushAfter = function (element, existingChild) {
22
- this.insertBefore(element, existingChild.nextSibling);
23
- };
24
- }
20
+ if (!HTMLElement.prototype.pushAfter) {
21
+ HTMLElement.prototype.pushAfter = function (element, existingChild) {
22
+ this.insertBefore(element, existingChild.nextSibling);
23
+ };
24
+ }
25
25
  }
26
26
 
27
27
  export function pushBeforeHTMLElementPrototype() {
28
- if (!HTMLElement.prototype.pushBefore) {
29
- HTMLElement.prototype.pushBefore = function (element, existingChild) {
30
- this.insertBefore(element, existingChild);
31
- };
32
- }
28
+ if (!HTMLElement.prototype.pushBefore) {
29
+ HTMLElement.prototype.pushBefore = function (element, existingChild) {
30
+ this.insertBefore(element, existingChild);
31
+ };
32
+ }
33
33
  }
34
34
 
35
35
  export function dataHTMLElementPrototype() {
36
- if (!HTMLElement.prototype.data) {
37
- HTMLElement.prototype.data = function (name, value = undefined) {
38
- if (value === undefined) {
39
- return this.getAttribute(`data-${name}`);
40
- } else {
41
- this.setAttribute(`data-${name}`, value);
42
- }
43
- };
44
- }
36
+ if (!HTMLElement.prototype.data) {
37
+ HTMLElement.prototype.data = function (name, value = undefined) {
38
+ if (value === undefined) {
39
+ return this.getAttribute(`data-${name}`);
40
+ } else {
41
+ this.setAttribute(`data-${name}`, value);
42
+ }
43
+ };
44
+ }
45
45
  }
46
46
 
47
47
  export function toKebabCaseStringPrototype() {
48
- if (!String.prototype.toKebabCase) {
49
- String.prototype.toKebabCase = function () {
50
- return this
51
- .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
52
- .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')
53
- .toLowerCase();
54
- };
55
- }
48
+ if (!String.prototype.toKebabCase) {
49
+ String.prototype.toKebabCase = function () {
50
+ return this
51
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
52
+ .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')
53
+ .toLowerCase();
54
+ };
55
+ }
56
56
  }
57
57
 
58
58
  export function toSnakeCaseStringPrototype() {
59
- if (!String.prototype.toSnakeCase) {
60
- String.prototype.toSnakeCase = function () {
61
- return this
62
- .replace(/([a-z0-9])([A-Z])/g, '$1_$2')
63
- .replace(/([A-Z])([A-Z][a-z])/g, '$1_$2')
64
- .toLowerCase();
65
- };
66
- }
59
+ if (!String.prototype.toSnakeCase) {
60
+ String.prototype.toSnakeCase = function () {
61
+ return this
62
+ .replace(/([a-z0-9])([A-Z])/g, '$1_$2')
63
+ .replace(/([A-Z])([A-Z][a-z])/g, '$1_$2')
64
+ .toLowerCase();
65
+ };
66
+ }
67
67
  }
68
68
 
69
69
  export function repeatHTMLElementPrototype() {
70
- if (!HTMLElement.prototype.repeat) {
71
- HTMLElement.prototype.repeat = function (newElement) {
72
- if (!(newElement instanceof HTMLElement)) {
73
- throw new Error('Argument must be an HTMLElement');
74
- }
75
- this.replaceWith(newElement);
76
- };
77
- }
70
+ if (!HTMLElement.prototype.repeat) {
71
+ HTMLElement.prototype.repeat = function (newElement) {
72
+ if (!(newElement instanceof HTMLElement)) {
73
+ throw new Error('Argument must be an HTMLElement');
74
+ }
75
+ this.replaceWith(newElement);
76
+ };
77
+ }
78
78
  }
79
79
 
80
80
  export function replaceChildrenHTMLElementPrototype() {
81
- if (!HTMLElement.prototype.replaceChildren) {
82
- HTMLElement.prototype.replaceChildren = function (newElement) {
83
- if (!(newElement instanceof HTMLElement)) {
84
- throw new Error('Argument must be an HTMLElement');
85
- }
86
- this.innerHTML = null;
87
- this.appendChild(HTMLElement);
88
- };
89
- }
81
+ if (!HTMLElement.prototype.replaceChildren) {
82
+ HTMLElement.prototype.replaceChildren = function (newElement) {
83
+ if (!(newElement instanceof HTMLElement)) {
84
+ throw new Error('Argument must be an HTMLElement');
85
+ }
86
+ this.innerHTML = null;
87
+ this.appendChild(HTMLElement);
88
+ };
89
+ }
90
90
  }
91
91
 
92
92
  pushHTMLElementPrototype();