svelte-common 6.6.10 → 6.6.12
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/package.json +1 -1
- package/src/filter.mjs +31 -32
- package/src/pagination.mjs +8 -0
package/package.json
CHANGED
package/src/filter.mjs
CHANGED
|
@@ -26,6 +26,10 @@ function allOp(value, against, op) {
|
|
|
26
26
|
|
|
27
27
|
switch (typeof against) {
|
|
28
28
|
case "object":
|
|
29
|
+
if (against instanceof Date && value instanceof Date) {
|
|
30
|
+
return dateOp(value, against, op);
|
|
31
|
+
}
|
|
32
|
+
|
|
29
33
|
if (value[Symbol.toPrimitive] && against[Symbol.toPrimitive]) {
|
|
30
34
|
return numberOp(
|
|
31
35
|
value[Symbol.toPrimitive]("number"),
|
|
@@ -38,25 +42,15 @@ function allOp(value, against, op) {
|
|
|
38
42
|
case "bigint":
|
|
39
43
|
case "number":
|
|
40
44
|
if (value[Symbol.toPrimitive]) {
|
|
41
|
-
return allOp(
|
|
42
|
-
value[Symbol.toPrimitive](typeof against),
|
|
43
|
-
against,
|
|
44
|
-
op
|
|
45
|
-
);
|
|
45
|
+
return allOp(value[Symbol.toPrimitive]("number"), against, op);
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
break;
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
case "string":
|
|
49
|
+
case "string":
|
|
50
|
+
if (value instanceof Date) {
|
|
52
51
|
return dateOp(value, new Date(against), op);
|
|
53
|
-
|
|
54
|
-
if (against instanceof Date) {
|
|
55
|
-
return dateOp(value, against, op);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
52
|
+
}
|
|
58
53
|
}
|
|
59
|
-
|
|
60
54
|
return value.toString().match(against);
|
|
61
55
|
case "string":
|
|
62
56
|
switch (typeof against) {
|
|
@@ -74,7 +68,7 @@ function allOp(value, against, op) {
|
|
|
74
68
|
|
|
75
69
|
if (against instanceof Map) {
|
|
76
70
|
for (const [k, v] of against) {
|
|
77
|
-
if (value
|
|
71
|
+
if (allOp(value, k, op) || allOp(value, v, op)) {
|
|
78
72
|
return true;
|
|
79
73
|
}
|
|
80
74
|
}
|
|
@@ -82,36 +76,41 @@ function allOp(value, against, op) {
|
|
|
82
76
|
|
|
83
77
|
if (against[Symbol.iterator]) {
|
|
84
78
|
for (const i of against) {
|
|
85
|
-
if (value
|
|
79
|
+
if (allOp(value, i, op)) {
|
|
86
80
|
return true;
|
|
87
81
|
}
|
|
88
82
|
}
|
|
83
|
+
return false;
|
|
89
84
|
}
|
|
90
85
|
}
|
|
91
86
|
|
|
92
87
|
return value.match(against);
|
|
93
88
|
case "bigint":
|
|
94
89
|
case "number":
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
switch (typeof against) {
|
|
91
|
+
case "object":
|
|
92
|
+
if (against instanceof RegExp) {
|
|
93
|
+
return against.test(value);
|
|
94
|
+
}
|
|
98
95
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
if (against instanceof Map) {
|
|
97
|
+
for (const [k, v] of against) {
|
|
98
|
+
if (numberOp(value, k, op) || numberOp(value, v, op)) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
103
|
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
104
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
if (against[Symbol.iterator]) {
|
|
106
|
+
for (const i of against) {
|
|
107
|
+
if (numberOp(value, i, op)) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
111
112
|
}
|
|
112
|
-
}
|
|
113
113
|
}
|
|
114
|
-
|
|
115
114
|
return numberOp(value, against, op);
|
|
116
115
|
case "boolean":
|
|
117
116
|
switch (typeof against) {
|
package/src/pagination.mjs
CHANGED
|
@@ -108,6 +108,9 @@ export class Pagination {
|
|
|
108
108
|
return () => this.#subscriptions.delete(s);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* @return {number}
|
|
113
|
+
*/
|
|
111
114
|
get numberOfPages() {
|
|
112
115
|
let n;
|
|
113
116
|
|
|
@@ -124,6 +127,11 @@ export class Pagination {
|
|
|
124
127
|
return Math.ceil(n / this.itemsPerPage);
|
|
125
128
|
}
|
|
126
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Deliver items per page.
|
|
132
|
+
* @see {itemsPerPage}
|
|
133
|
+
* @return {number}
|
|
134
|
+
*/
|
|
127
135
|
get length() {
|
|
128
136
|
return this.#itemsPerPage;
|
|
129
137
|
}
|