@thi.ng/resolve-map 7.1.62 → 7.1.64
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/CHANGELOG.md +1 -1
- package/README.md +11 -1
- package/index.d.ts +6 -2
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -232,6 +232,8 @@ Absolute refs are always resolved from the root level (the original object
|
|
|
232
232
|
passed to this function).
|
|
233
233
|
|
|
234
234
|
```ts
|
|
235
|
+
import { resolve } from "@thi.ng/resolve-map";
|
|
236
|
+
|
|
235
237
|
// `c` references sibling `d`
|
|
236
238
|
// `d` references top-level `a`
|
|
237
239
|
resolve({ a: 1, b: { c: "@d", d: "@/a"} })
|
|
@@ -262,6 +264,8 @@ The `resolve` function provided as arg to the user function accepts a path
|
|
|
262
264
|
object.
|
|
263
265
|
|
|
264
266
|
```ts
|
|
267
|
+
import { resolve } from "@thi.ng/resolve-map";
|
|
268
|
+
|
|
265
269
|
// `c` uses ES6 destructuring form to look up `a` & `b` values
|
|
266
270
|
// `d` uses provided resolve fn arg `$` to look up `c`
|
|
267
271
|
resolve({ a: 1, b: 2, c: ({ a, b }) => a + b, d: ($) => $("c") })
|
|
@@ -282,12 +286,14 @@ Similarly, if an actual string value should happen to start with `@`, it
|
|
|
282
286
|
needs to be wrapped in a function (see `f` key below).
|
|
283
287
|
|
|
284
288
|
```ts
|
|
289
|
+
import { resolve } from "@thi.ng/resolve-map";
|
|
290
|
+
|
|
285
291
|
// `a` is derived from 1st array element in `b.d`
|
|
286
292
|
// `b.c` is looked up from `b.d[0]`
|
|
287
293
|
// `b.d[1]` is derived from calling `e(2)`
|
|
288
294
|
// `e` is a wrapped function
|
|
289
295
|
// `f` is wrapped to ignore `@` prefix
|
|
290
|
-
res = resolve({
|
|
296
|
+
const res = resolve({
|
|
291
297
|
a: ($) => $("b/c") * 100,
|
|
292
298
|
b: { c: "@d/0", d: [2, ($) => $("../../e")(2) ] },
|
|
293
299
|
e: () => (x) => x * 10,
|
|
@@ -310,6 +316,8 @@ Unwrapped values will also be supplied to any lookup functions, no
|
|
|
310
316
|
there.
|
|
311
317
|
|
|
312
318
|
```ts
|
|
319
|
+
import { resolve, resolved } from "@thi.ng/resolve-map";
|
|
320
|
+
|
|
313
321
|
resolve({ a: 42, b: ({a}) => resolved(a) });
|
|
314
322
|
// { a: 42, b: 42 }
|
|
315
323
|
|
|
@@ -326,6 +334,8 @@ resolution behavior to **not** consider string values for resolution at all
|
|
|
326
334
|
anymore and instead requires the use of function values to trigger resolution.
|
|
327
335
|
|
|
328
336
|
```ts
|
|
337
|
+
import { resolve } from "@thi.ng/resolve-map";
|
|
338
|
+
|
|
329
339
|
// default behavior
|
|
330
340
|
resolve({ a: "@c", b: ({a}) => a, c: 42 })
|
|
331
341
|
// { a: 42, b: 42, c: 42 }
|
package/index.d.ts
CHANGED
|
@@ -79,7 +79,9 @@ export interface ResolveOpts {
|
|
|
79
79
|
* path (**without `@` prefix**) to look up any other values in the root
|
|
80
80
|
* object.
|
|
81
81
|
*
|
|
82
|
-
* ```
|
|
82
|
+
* ```ts
|
|
83
|
+
* import { resolve } from "@thi.ng/resolve-map";
|
|
84
|
+
*
|
|
83
85
|
* // `c` uses ES6 destructuring form to look up `a` & `b` values
|
|
84
86
|
* // `d` uses provided resolve fn arg `$` to look up `c`
|
|
85
87
|
* resolve({ a: 1, b: 2, c: ({ a, b }) => a + b, d: ($) => $("c") })
|
|
@@ -100,7 +102,9 @@ export interface ResolveOpts {
|
|
|
100
102
|
* start with `@`, it needs to be wrapped in a function (see `f` key
|
|
101
103
|
* below).
|
|
102
104
|
*
|
|
103
|
-
* ```
|
|
105
|
+
* ```ts
|
|
106
|
+
* import { resolve } from "@thi.ng/resolve-map";
|
|
107
|
+
*
|
|
104
108
|
* // `a` is derived from 1st array element in `b.d`
|
|
105
109
|
* // `b.c` is looked up from `b.d[0]`
|
|
106
110
|
* // `b.d[1]` is derived from calling `e(2)`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/resolve-map",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.64",
|
|
4
4
|
"description": "DAG resolution of vanilla objects & arrays with internally linked values",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -32,13 +32,14 @@
|
|
|
32
32
|
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
|
|
33
33
|
"doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
|
|
34
34
|
"pub": "yarn npm publish --access public",
|
|
35
|
-
"test": "bun test"
|
|
35
|
+
"test": "bun test",
|
|
36
|
+
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"@thi.ng/api": "^8.9.
|
|
39
|
-
"@thi.ng/checks": "^3.5.
|
|
40
|
-
"@thi.ng/errors": "^2.4.
|
|
41
|
-
"@thi.ng/paths": "^5.1.
|
|
39
|
+
"@thi.ng/api": "^8.9.28",
|
|
40
|
+
"@thi.ng/checks": "^3.5.2",
|
|
41
|
+
"@thi.ng/errors": "^2.4.20",
|
|
42
|
+
"@thi.ng/paths": "^5.1.71"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@microsoft/api-extractor": "^7.40.1",
|
|
@@ -76,5 +77,5 @@
|
|
|
76
77
|
],
|
|
77
78
|
"year": 2018
|
|
78
79
|
},
|
|
79
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "a421058a65ba76608d94129ac29451bfedaf201c\n"
|
|
80
81
|
}
|