svelte-common 4.21.27 → 4.21.28

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/README.md CHANGED
@@ -45,7 +45,7 @@ or the [live example](https://arlac77.github.io/components/svelte-common/example
45
45
 
46
46
  ## filter
47
47
 
48
- Generate filter function
48
+ Generate filter function.
49
49
 
50
50
  ### Parameters
51
51
 
@@ -114,7 +114,7 @@ Returns **WriteableStore** 
114
114
 
115
115
  ## tokens
116
116
 
117
- Split property path into tokens
117
+ Split property path into tokens.
118
118
 
119
119
  ### Parameters
120
120
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-common",
3
- "version": "4.21.27",
3
+ "version": "4.21.28",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -45,12 +45,12 @@
45
45
  "c8": "^7.12.0",
46
46
  "documentation": "^14.0.1",
47
47
  "mf-styling": "^1.7.42",
48
- "npm-pkgbuild": "^11.1.11",
48
+ "npm-pkgbuild": "^11.1.12",
49
49
  "semantic-release": "^20.1.0",
50
50
  "stylelint": "^14.16.1",
51
51
  "stylelint-config-standard": "^29.0.0",
52
52
  "svelte": "^3.55.1",
53
- "testcafe": "^2.2.0",
53
+ "testcafe": "^2.3.0",
54
54
  "vite": "^4.0.4"
55
55
  },
56
56
  "optionalDependencies": {
@@ -0,0 +1,104 @@
1
+
2
+ /**
3
+ * Split property path into tokens
4
+ * @param {string} string
5
+ * @return {Iterator<string>}
6
+ */
7
+ function* tokens(string) {
8
+ let identifier = "";
9
+
10
+ for (const c of string) {
11
+ switch (c) {
12
+ case "\t":
13
+ case " ":
14
+ break;
15
+
16
+ case ">":
17
+ case "<":
18
+
19
+ case ".":
20
+ case "[":
21
+ case "]":
22
+ if (identifier.length) {
23
+ yield identifier;
24
+ identifier = "";
25
+ }
26
+ yield c;
27
+ break;
28
+ default:
29
+ identifier += c;
30
+ }
31
+ }
32
+
33
+ if (identifier.length) {
34
+ yield identifier;
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Set Object attribute.
40
+ * The name may be a property path like 'a.b.c'.
41
+ * @param {Object} object
42
+ * @param {string} name
43
+ * @param {any} value
44
+ */
45
+ export function setAttribute(object, name, value) {
46
+ let lastObject = object;
47
+ let lastKey;
48
+
49
+ for (const token of tokens(name)) {
50
+ switch (token) {
51
+ case ">":
52
+ case "<":
53
+ case ".":
54
+ case "[":
55
+ case "]":
56
+ break;
57
+
58
+ default:
59
+ if (object[token] === undefined || typeof object[token] !== "object") {
60
+ object[token] = {};
61
+ }
62
+
63
+ lastObject = object;
64
+ lastKey = token;
65
+
66
+ object = object[token];
67
+ }
68
+ }
69
+
70
+ lastObject[lastKey] = value;
71
+ }
72
+
73
+ /**
74
+ * Deliver attribute value.
75
+ * The name may be a property path like 'a.b.c'.
76
+ * @param {Object} object
77
+ * @param {string} name
78
+ * @returns {any} value associated with the given property name
79
+ */
80
+ export function getAttribute(object, name) {
81
+ if (object && object[name] !== undefined) {
82
+ return object[name];
83
+ }
84
+
85
+ for (const token of tokens(name)) {
86
+ switch (token) {
87
+ case ">":
88
+ case "<":
89
+ case ".":
90
+ case "[":
91
+ case "]":
92
+ break;
93
+
94
+ default:
95
+ if (object === undefined) {
96
+ break;
97
+ }
98
+
99
+ object = object[token];
100
+ }
101
+ }
102
+
103
+ return object;
104
+ }
package/src/filter.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getAttribute } from "./util.mjs";
1
+ import { getAttribute } from "./attribute.mjs";
2
2
 
3
3
  /**
4
4
  * Generate filter function.
package/src/sorting.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getAttribute } from "./util.mjs";
1
+ import { getAttribute } from "./attribute.mjs";
2
2
 
3
3
  export const SORT_NONE = "none";
4
4
  export const SORT_ASCENDING = "ascending";
package/src/util.mjs CHANGED
@@ -164,65 +164,3 @@ export function keyPrefixStore(store, prefix) {
164
164
  }
165
165
  };
166
166
  }
167
-
168
- /**
169
- * Split property path into tokens.
170
- * @param {string} string
171
- * @return {Iterator<string>}
172
- */
173
- function* tokens(string) {
174
- let identifier = "";
175
-
176
- for (const c of string) {
177
- switch (c) {
178
- case "\t":
179
- case " ": break;
180
- case ".":
181
- case "[":
182
- case "]":
183
- if (identifier.length) {
184
- yield identifier;
185
- identifier = "";
186
- }
187
- yield c;
188
- break;
189
- default:
190
- identifier += c;
191
- }
192
- }
193
-
194
- if (identifier.length) {
195
- yield identifier;
196
- }
197
- }
198
-
199
- /**
200
- * Deliver attribute value.
201
- * The name may be a property path like 'a.b.c'.
202
- * @param {Object} object
203
- * @param {string} name
204
- * @returns {any} value associated with the given property name
205
- */
206
- export function getAttribute(object, name) {
207
- if (object && object[name] !== undefined) {
208
- return object[name];
209
- }
210
-
211
- for (const token of tokens(name)) {
212
- switch (token) {
213
- case ".":
214
- case "[":
215
- case "]":
216
- break;
217
-
218
- default:
219
- if (object === undefined) {
220
- break;
221
- }
222
-
223
- object = object[token];
224
- }
225
- }
226
-
227
- return object;
228
- }