@oscarpalmer/atoms 0.53.0 → 0.55.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.
- package/dist/js/element/index.js +8 -7
- package/dist/js/element/index.mjs +3 -7
- package/dist/js/equal.js +8 -4
- package/dist/js/equal.mjs +8 -4
- package/dist/js/index.js +268 -187
- package/dist/js/index.mjs +1 -0
- package/dist/js/logger.js +7 -6
- package/dist/js/logger.mjs +4 -6
- package/dist/js/query.js +146 -0
- package/dist/js/query.mjs +65 -0
- package/dist/js/string.js +7 -0
- package/dist/js/string.mjs +7 -0
- package/dist/js/timer.js +13 -5
- package/dist/js/timer.mjs +13 -5
- package/dist/js/value.js +17 -2
- package/dist/js/value.mjs +12 -3
- package/package.json +6 -6
- package/src/js/element/index.ts +4 -8
- package/src/js/equal.ts +26 -4
- package/src/js/index.ts +1 -1
- package/src/js/logger.ts +9 -11
- package/src/js/query.ts +95 -0
- package/src/js/string.ts +14 -0
- package/src/js/timer.ts +14 -4
- package/src/js/value.ts +21 -3
- package/types/equal.d.ts +4 -0
- package/types/index.d.ts +1 -0
- package/types/logger.d.ts +4 -4
- package/types/query.d.ts +9 -0
- package/types/string.d.ts +4 -0
package/dist/js/element/index.js
CHANGED
|
@@ -10,6 +10,12 @@ function getString(value) {
|
|
|
10
10
|
const asString = valueOff?.toString?.() ?? String(valueOff);
|
|
11
11
|
return asString.startsWith("[object ") ? JSON.stringify(value) : asString;
|
|
12
12
|
}
|
|
13
|
+
function parse(value, reviver) {
|
|
14
|
+
try {
|
|
15
|
+
return JSON.parse(value, reviver);
|
|
16
|
+
} catch {
|
|
17
|
+
}
|
|
18
|
+
}
|
|
13
19
|
|
|
14
20
|
// src/js/is.ts
|
|
15
21
|
function isNullableOrWhitespace(value) {
|
|
@@ -93,13 +99,8 @@ function getData(element, keys) {
|
|
|
93
99
|
}
|
|
94
100
|
var getDataValue = function(element, key) {
|
|
95
101
|
const value = element.dataset[key];
|
|
96
|
-
if (value
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
try {
|
|
100
|
-
return JSON.parse(value);
|
|
101
|
-
} catch {
|
|
102
|
-
return;
|
|
102
|
+
if (value != null) {
|
|
103
|
+
return parse(value);
|
|
103
104
|
}
|
|
104
105
|
};
|
|
105
106
|
function getElementUnderPointer(skipIgnore) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/js/element/index.ts
|
|
2
2
|
import {isNullableOrWhitespace, isPlainObject} from "../is";
|
|
3
|
+
import {parse} from "../string";
|
|
3
4
|
function findElement(selector, context) {
|
|
4
5
|
return findElementOrElements(selector, context, true);
|
|
5
6
|
}
|
|
@@ -69,13 +70,8 @@ function getData(element, keys) {
|
|
|
69
70
|
}
|
|
70
71
|
var getDataValue = function(element, key) {
|
|
71
72
|
const value = element.dataset[key];
|
|
72
|
-
if (value
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
try {
|
|
76
|
-
return JSON.parse(value);
|
|
77
|
-
} catch {
|
|
78
|
-
return;
|
|
73
|
+
if (value != null) {
|
|
74
|
+
return parse(value);
|
|
79
75
|
}
|
|
80
76
|
};
|
|
81
77
|
function getElementUnderPointer(skipIgnore) {
|
package/dist/js/equal.js
CHANGED
|
@@ -8,7 +8,7 @@ function isPlainObject(value) {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
// src/js/equal.ts
|
|
11
|
-
function equal(first, second) {
|
|
11
|
+
function equal(first, second, ignoreCase) {
|
|
12
12
|
switch (true) {
|
|
13
13
|
case first === second:
|
|
14
14
|
return true;
|
|
@@ -34,6 +34,8 @@ function equal(first, second) {
|
|
|
34
34
|
case (Array.isArray(first) && Array.isArray(second)):
|
|
35
35
|
case (isPlainObject(first) && isPlainObject(second)):
|
|
36
36
|
return equalNested(first, second);
|
|
37
|
+
case (typeof first === "string" && ignoreCase === true):
|
|
38
|
+
return Object.is(first.toLowerCase(), second.toLowerCase());
|
|
37
39
|
default:
|
|
38
40
|
return Object.is(first, second);
|
|
39
41
|
}
|
|
@@ -84,11 +86,13 @@ var equalProperties = function(first, second, properties) {
|
|
|
84
86
|
return true;
|
|
85
87
|
};
|
|
86
88
|
var equalSet = function(first, second) {
|
|
87
|
-
|
|
89
|
+
const { size } = first;
|
|
90
|
+
if (size !== second.size) {
|
|
88
91
|
return false;
|
|
89
92
|
}
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
const values = [...second];
|
|
94
|
+
for (const item of first) {
|
|
95
|
+
if (!values.some((value) => equal(item, value))) {
|
|
92
96
|
return false;
|
|
93
97
|
}
|
|
94
98
|
}
|
package/dist/js/equal.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/js/equal.ts
|
|
2
2
|
import {isPlainObject} from "./is";
|
|
3
|
-
function equal(first, second) {
|
|
3
|
+
function equal(first, second, ignoreCase) {
|
|
4
4
|
switch (true) {
|
|
5
5
|
case first === second:
|
|
6
6
|
return true;
|
|
@@ -26,6 +26,8 @@ function equal(first, second) {
|
|
|
26
26
|
case (Array.isArray(first) && Array.isArray(second)):
|
|
27
27
|
case (isPlainObject(first) && isPlainObject(second)):
|
|
28
28
|
return equalNested(first, second);
|
|
29
|
+
case (typeof first === "string" && ignoreCase === true):
|
|
30
|
+
return Object.is(first.toLowerCase(), second.toLowerCase());
|
|
29
31
|
default:
|
|
30
32
|
return Object.is(first, second);
|
|
31
33
|
}
|
|
@@ -76,11 +78,13 @@ var equalProperties = function(first, second, properties) {
|
|
|
76
78
|
return true;
|
|
77
79
|
};
|
|
78
80
|
var equalSet = function(first, second) {
|
|
79
|
-
|
|
81
|
+
const { size } = first;
|
|
82
|
+
if (size !== second.size) {
|
|
80
83
|
return false;
|
|
81
84
|
}
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
const values = [...second];
|
|
86
|
+
for (const item of first) {
|
|
87
|
+
if (!values.some((value) => equal(item, value))) {
|
|
84
88
|
return false;
|
|
85
89
|
}
|
|
86
90
|
}
|