@ditojs/utils 2.31.0 → 2.32.2
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ditojs/utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.32.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Dito.js Utility Functions – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js",
|
|
6
6
|
"repository": "https://github.com/ditojs/dito/tree/master/packages/utils",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"punycode": "^2.3.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"typescript": "^5.
|
|
35
|
+
"typescript": "^5.6.2"
|
|
36
36
|
},
|
|
37
37
|
"types": "types",
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "e39e6be34ced2fea17083c0d8a2cb90d41aaf435"
|
|
39
39
|
}
|
|
@@ -12,10 +12,15 @@ export function normalizeDataPath(path) {
|
|
|
12
12
|
path.splice(--i, 2)
|
|
13
13
|
i--
|
|
14
14
|
} else if (token === '') {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
if (i === path.length - 1) {
|
|
16
|
+
// Remove trailing slash
|
|
17
|
+
path.splice(i, 1)
|
|
18
|
+
} else {
|
|
19
|
+
// The beginning of a concatenated absolute path:
|
|
20
|
+
// Start from scratch, see `parseDataPath.test.js`
|
|
21
|
+
path.splice(0, i + 1)
|
|
22
|
+
i = 0
|
|
23
|
+
}
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
26
|
return path.join('/')
|
|
@@ -16,8 +16,14 @@ describe('normalizeDataPath()', () => {
|
|
|
16
16
|
})
|
|
17
17
|
|
|
18
18
|
it('should normalize relative tokens', () => {
|
|
19
|
+
expect(normalizeDataPath('/object/property1/..'))
|
|
20
|
+
.toStrictEqual('object')
|
|
21
|
+
expect(normalizeDataPath('/object/property1/../'))
|
|
22
|
+
.toStrictEqual('object')
|
|
19
23
|
expect(normalizeDataPath('/object/property1/../value'))
|
|
20
24
|
.toStrictEqual('object/value')
|
|
25
|
+
expect(normalizeDataPath('/object/property1/../value/'))
|
|
26
|
+
.toStrictEqual('object/value')
|
|
21
27
|
expect(normalizeDataPath('/object/property1/../property2/../value'))
|
|
22
28
|
.toStrictEqual('object/value')
|
|
23
29
|
expect(normalizeDataPath('/object/property1/property2/../../value'))
|
package/types/index.d.ts
CHANGED
|
@@ -671,7 +671,7 @@ export function toPromiseCallback<T, R>(
|
|
|
671
671
|
|
|
672
672
|
/* -------------------------------- dataPath -------------------------------- */
|
|
673
673
|
|
|
674
|
-
export function
|
|
674
|
+
export function getValueAtDataPath(
|
|
675
675
|
obj: any,
|
|
676
676
|
path: OrArrayOf<string>,
|
|
677
677
|
handleError?: (obj: any, part: string, index: number) => void
|
|
@@ -681,7 +681,11 @@ export function normalizeDataPath(path: OrArrayOf<string>): string
|
|
|
681
681
|
|
|
682
682
|
export function parseDataPath(path: OrArrayOf<string>): string
|
|
683
683
|
|
|
684
|
-
export function
|
|
684
|
+
export function setValueAtDataPath<O>(
|
|
685
|
+
obj: O,
|
|
686
|
+
path: OrArrayOf<string>,
|
|
687
|
+
value: any
|
|
688
|
+
): O
|
|
685
689
|
|
|
686
690
|
/* ---------------------------------- html ---------------------------------- */
|
|
687
691
|
|