repository-provider 32.2.2 → 32.3.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/package.json +3 -3
- package/src/attribute.mjs +45 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repository-provider",
|
|
3
|
-
"version": "32.
|
|
3
|
+
"version": "32.3.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"ava": "^5.1.0",
|
|
38
|
-
"browser-ava": "^1.3.
|
|
38
|
+
"browser-ava": "^1.3.7",
|
|
39
39
|
"c8": "^7.12.0",
|
|
40
40
|
"documentation": "^14.0.0",
|
|
41
|
-
"repository-provider-test-support": "^2.2.
|
|
41
|
+
"repository-provider-test-support": "^2.2.20",
|
|
42
42
|
"semantic-release": "^19.0.5",
|
|
43
43
|
"typescript": "^4.8.4"
|
|
44
44
|
},
|
package/src/attribute.mjs
CHANGED
|
@@ -156,6 +156,35 @@ export function setAttribute(object, name, value) {
|
|
|
156
156
|
object[last] = value;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Split property path into tokens
|
|
161
|
+
* @param {string} string
|
|
162
|
+
* @return {Iterator<string>}
|
|
163
|
+
*/
|
|
164
|
+
function* tokens(string) {
|
|
165
|
+
let identifier = "";
|
|
166
|
+
|
|
167
|
+
for (const c of string) {
|
|
168
|
+
switch (c) {
|
|
169
|
+
case ".":
|
|
170
|
+
case "[":
|
|
171
|
+
case "]":
|
|
172
|
+
if (identifier.length) {
|
|
173
|
+
yield identifier;
|
|
174
|
+
identifier = "";
|
|
175
|
+
}
|
|
176
|
+
yield c;
|
|
177
|
+
break;
|
|
178
|
+
default:
|
|
179
|
+
identifier += c;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (identifier.length) {
|
|
184
|
+
yield identifier;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
159
188
|
/**
|
|
160
189
|
* Deliver attribute value.
|
|
161
190
|
* The name may be a property path like 'a.b.c'.
|
|
@@ -164,20 +193,27 @@ export function setAttribute(object, name, value) {
|
|
|
164
193
|
* @returns {any} value associated with the given property name
|
|
165
194
|
*/
|
|
166
195
|
export function getAttribute(object, name) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
if (value && value[name] !== undefined) {
|
|
170
|
-
return value[name];
|
|
196
|
+
if (object && object[name] !== undefined) {
|
|
197
|
+
return object[name];
|
|
171
198
|
}
|
|
172
199
|
|
|
173
|
-
for (const
|
|
174
|
-
|
|
175
|
-
|
|
200
|
+
for (const token of tokens(name)) {
|
|
201
|
+
switch (token) {
|
|
202
|
+
case ".":
|
|
203
|
+
case "[":
|
|
204
|
+
case "]":
|
|
205
|
+
break;
|
|
206
|
+
|
|
207
|
+
default:
|
|
208
|
+
if (object === undefined) {
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
object = object[token];
|
|
176
213
|
}
|
|
177
|
-
value = value[p];
|
|
178
214
|
}
|
|
179
215
|
|
|
180
|
-
return
|
|
216
|
+
return object;
|
|
181
217
|
}
|
|
182
218
|
|
|
183
219
|
/**
|