@xyo-network/module-resolver 2.93.0 → 2.93.1

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
@@ -16,7 +16,7 @@
16
16
  "@xylabs/lodash": "^3.0.24",
17
17
  "@xylabs/object": "^3.0.24",
18
18
  "@xylabs/promise": "^3.0.24",
19
- "@xyo-network/module-model": "~2.93.0",
19
+ "@xyo-network/module-model": "~2.93.1",
20
20
  "lru-cache": "^10.2.0"
21
21
  },
22
22
  "devDependencies": {
@@ -65,6 +65,6 @@
65
65
  "url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
66
66
  },
67
67
  "sideEffects": false,
68
- "version": "2.93.0",
68
+ "version": "2.93.1",
69
69
  "type": "module"
70
70
  }
@@ -1,3 +0,0 @@
1
- import { JsonValue } from '@xylabs/object';
2
- export declare const toJson: (value: unknown, maxDepth?: number) => JsonValue;
3
- //# sourceMappingURL=toJson.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toJson.d.ts","sourceRoot":"","sources":["../../src/toJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,SAAS,EAAE,MAAM,gBAAgB,CAAA;AA0CjE,eAAO,MAAM,MAAM,UAAW,OAAO,wBAAiB,SAErD,CAAA"}
@@ -1,3 +0,0 @@
1
- import { JsonValue } from '@xylabs/object';
2
- export declare const toJson: (value: unknown, maxDepth?: number) => JsonValue;
3
- //# sourceMappingURL=toJson.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toJson.d.ts","sourceRoot":"","sources":["../../src/toJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,SAAS,EAAE,MAAM,gBAAgB,CAAA;AA0CjE,eAAO,MAAM,MAAM,UAAW,OAAO,wBAAiB,SAErD,CAAA"}
@@ -1,3 +0,0 @@
1
- import { JsonValue } from '@xylabs/object';
2
- export declare const toJson: (value: unknown, maxDepth?: number) => JsonValue;
3
- //# sourceMappingURL=toJson.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toJson.d.ts","sourceRoot":"","sources":["../../src/toJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,SAAS,EAAE,MAAM,gBAAgB,CAAA;AA0CjE,eAAO,MAAM,MAAM,UAAW,OAAO,wBAAiB,SAErD,CAAA"}
@@ -1,3 +0,0 @@
1
- import { JsonValue } from '@xylabs/object';
2
- export declare const toJson: (value: unknown, maxDepth?: number) => JsonValue;
3
- //# sourceMappingURL=toJson.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toJson.d.ts","sourceRoot":"","sources":["../../src/toJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,SAAS,EAAE,MAAM,gBAAgB,CAAA;AA0CjE,eAAO,MAAM,MAAM,UAAW,OAAO,wBAAiB,SAErD,CAAA"}
@@ -1,3 +0,0 @@
1
- import { JsonValue } from '@xylabs/object';
2
- export declare const toJson: (value: unknown, maxDepth?: number) => JsonValue;
3
- //# sourceMappingURL=toJson.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toJson.d.ts","sourceRoot":"","sources":["../../src/toJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,SAAS,EAAE,MAAM,gBAAgB,CAAA;AA0CjE,eAAO,MAAM,MAAM,UAAW,OAAO,wBAAiB,SAErD,CAAA"}
@@ -1,3 +0,0 @@
1
- import { JsonValue } from '@xylabs/object';
2
- export declare const toJson: (value: unknown, maxDepth?: number) => JsonValue;
3
- //# sourceMappingURL=toJson.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toJson.d.ts","sourceRoot":"","sources":["../../src/toJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,SAAS,EAAE,MAAM,gBAAgB,CAAA;AA0CjE,eAAO,MAAM,MAAM,UAAW,OAAO,wBAAiB,SAErD,CAAA"}
package/src/toJson.ts DELETED
@@ -1,45 +0,0 @@
1
- import { JsonArray, JsonObject, JsonValue } from '@xylabs/object'
2
-
3
- const toJsonArray = (value: unknown[], cycleList?: unknown[], maxDepth = 3): JsonArray => {
4
- return value.map((item) => toJsonValue(item, cycleList, maxDepth))
5
- }
6
-
7
- const toJsonObject = (value: object, cycleList?: unknown[], maxDepth = 3): JsonObject => {
8
- const result: JsonObject = {}
9
- for (const [key, entry] of Object.entries(value)) {
10
- result[key] = value === undefined ? '[Undefined]' : toJsonValue(entry, cycleList, maxDepth)
11
- }
12
- return result
13
- }
14
-
15
- const toJsonValue = (value: unknown, cycleList?: unknown[], maxDepth = 3): JsonValue => {
16
- console.log(`toJsonValue: ${maxDepth}`)
17
- if (maxDepth <= 0 && typeof value === 'object') {
18
- return '[MaxDepth]'
19
- }
20
- if (cycleList?.includes(value)) {
21
- return '[Circular]'
22
- }
23
- switch (typeof value) {
24
- case 'string':
25
- case 'boolean':
26
- case 'number': {
27
- return value
28
- }
29
- case 'object': {
30
- if (value === null) {
31
- return null
32
- }
33
- const newCycleList = cycleList ?? []
34
- newCycleList.push(value)
35
- return Array.isArray(value) ? toJsonArray(value, newCycleList, maxDepth - 1) : toJsonObject(value, newCycleList, maxDepth - 1)
36
- }
37
- default: {
38
- return `[${typeof value}]`
39
- }
40
- }
41
- }
42
-
43
- export const toJson = (value: unknown, maxDepth = 3): JsonValue => {
44
- return toJsonValue(value, undefined, maxDepth)
45
- }