@bemedev/decompose 1.4.0 → 2.0.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/README.md +59 -0
- package/lib/constants/index.cjs +14 -0
- package/lib/constants/index.cjs.map +1 -0
- package/lib/constants/index.d.ts +3 -0
- package/lib/constants/index.d.ts.map +1 -0
- package/lib/constants/index.js +3 -0
- package/lib/constants/index.js.map +1 -0
- package/lib/constants/objects.cjs +15 -0
- package/lib/constants/objects.cjs.map +1 -0
- package/lib/constants/objects.d.ts +10 -0
- package/lib/constants/objects.d.ts.map +1 -0
- package/lib/constants/objects.js +12 -0
- package/lib/constants/objects.js.map +1 -0
- package/lib/contexts/assign.cjs +46 -0
- package/lib/contexts/assign.cjs.map +1 -0
- package/lib/contexts/assign.d.ts +19 -0
- package/lib/contexts/assign.d.ts.map +1 -0
- package/lib/contexts/assign.js +44 -0
- package/lib/contexts/assign.js.map +1 -0
- package/lib/contexts/constants.cjs +10 -0
- package/lib/contexts/constants.cjs.map +1 -0
- package/lib/contexts/constants.d.ts +6 -0
- package/lib/contexts/constants.d.ts.map +1 -0
- package/lib/contexts/constants.js +8 -0
- package/lib/contexts/constants.js.map +1 -0
- package/lib/contexts/get.cjs +26 -0
- package/lib/contexts/get.cjs.map +1 -0
- package/lib/contexts/get.d.ts +20 -0
- package/lib/contexts/get.d.ts.map +1 -0
- package/lib/contexts/get.js +24 -0
- package/lib/contexts/get.js.map +1 -0
- package/lib/contexts/index.cjs +10 -0
- package/lib/contexts/index.cjs.map +1 -0
- package/lib/contexts/index.d.ts +3 -0
- package/lib/contexts/index.d.ts.map +1 -0
- package/lib/contexts/index.js +3 -0
- package/lib/contexts/index.js.map +1 -0
- package/lib/decompose.cjs +11 -7
- package/lib/decompose.cjs.map +1 -1
- package/lib/decompose.d.ts +2 -2
- package/lib/decompose.d.ts.map +1 -1
- package/lib/decompose.js +10 -6
- package/lib/decompose.js.map +1 -1
- package/lib/flatByKey.cjs +2 -2
- package/lib/flatByKey.cjs.map +1 -1
- package/lib/flatByKey.js +1 -1
- package/lib/flatByKey.js.map +1 -1
- package/lib/helpers.cjs +14 -9
- package/lib/helpers.cjs.map +1 -1
- package/lib/helpers.d.ts +4 -9
- package/lib/helpers.d.ts.map +1 -1
- package/lib/helpers.js +11 -8
- package/lib/helpers.js.map +1 -1
- package/lib/index.cjs +12 -3
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/types.types.d.ts +19 -8
- package/lib/types.types.d.ts.map +1 -1
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -51,6 +51,65 @@ const decomposedSV = decomposeSV(sv);
|
|
|
51
51
|
// Result: ['red', 'red.walk', 'red.walk.stop']
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
+
### Arrays and tuples (v2.0.0+)
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
const objWithArray = {
|
|
58
|
+
users: [{ name: 'Alice' }, { name: 'Bob' }],
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const decomposed = decompose(objWithArray);
|
|
62
|
+
// Result: { 'users.0.name': 'Alice', 'users.1.name': 'Bob' }
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Nested tuples and optional properties are fully supported in the
|
|
66
|
+
`Decompose` type.
|
|
67
|
+
|
|
68
|
+
### `getByKey`
|
|
69
|
+
|
|
70
|
+
Retrieves a value from an object using a dot-notation key.
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { getByKey } from '@bemedev/decompose';
|
|
74
|
+
|
|
75
|
+
const obj = {
|
|
76
|
+
data: {
|
|
77
|
+
name: {
|
|
78
|
+
firstName: 'John',
|
|
79
|
+
lastName: 'Doe',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
getByKey(obj, 'data.name.firstName'); // 'John'
|
|
85
|
+
getByKey(obj, 'data.name.lastName'); // 'Doe'
|
|
86
|
+
|
|
87
|
+
// Works with array indices too
|
|
88
|
+
const arr = { users: [{ name: 'Alice' }, { name: 'Bob' }] };
|
|
89
|
+
|
|
90
|
+
getByKey(arr, 'users.[0].name'); // 'Alice'
|
|
91
|
+
getByKey(arr, 'users.[1].name'); // 'Bob'
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### `assignByKey`
|
|
95
|
+
|
|
96
|
+
Assigns a value to a path in an object using a dot-notation key. Creates
|
|
97
|
+
intermediate objects or arrays as needed.
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { assignByKey } from '@bemedev/decompose';
|
|
101
|
+
|
|
102
|
+
const obj = { data: { name: { firstName: 'John' } } };
|
|
103
|
+
|
|
104
|
+
const updated = assignByKey(obj, 'data.name.firstName', 'Jane');
|
|
105
|
+
// Result: { data: { name: { firstName: 'Jane' } } }
|
|
106
|
+
|
|
107
|
+
// Works with array indices too
|
|
108
|
+
const arr = { users: [{ name: 'Alice' }] };
|
|
109
|
+
const updated2 = assignByKey(arr, 'users.[0].name', 'Bob');
|
|
110
|
+
// Result: { users: [{ name: 'Bob' }] }
|
|
111
|
+
```
|
|
112
|
+
|
|
54
113
|
## [CHANGELOG](https://github.com/chlbri/decompose/blob/main/CHANGELOG.md)
|
|
55
114
|
|
|
56
115
|
## License
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constants_objects = require('./objects.cjs');
|
|
4
|
+
var constants_strings = require('./strings.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
exports.DEFAULT_DECOMPOSE_OPTIONS = constants_objects.DEFAULT_DECOMPOSE_OPTIONS;
|
|
9
|
+
exports.DEFAULT_FLAT_OPTIONS = constants_objects.DEFAULT_FLAT_OPTIONS;
|
|
10
|
+
exports.DELIMITER = constants_strings.DELIMITER;
|
|
11
|
+
exports.LEFT_BRACKET = constants_strings.LEFT_BRACKET;
|
|
12
|
+
exports.RIGHT_BRACKET = constants_strings.RIGHT_BRACKET;
|
|
13
|
+
exports.SEPARATOR = constants_strings.SEPARATOR;
|
|
14
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_FLAT_OPTIONS = {
|
|
4
|
+
sep: '.',
|
|
5
|
+
children: false,
|
|
6
|
+
};
|
|
7
|
+
const DEFAULT_DECOMPOSE_OPTIONS = {
|
|
8
|
+
sep: '.',
|
|
9
|
+
object: 'key',
|
|
10
|
+
start: true,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
exports.DEFAULT_DECOMPOSE_OPTIONS = DEFAULT_DECOMPOSE_OPTIONS;
|
|
14
|
+
exports.DEFAULT_FLAT_OPTIONS = DEFAULT_FLAT_OPTIONS;
|
|
15
|
+
//# sourceMappingURL=objects.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objects.cjs","sources":["../../src/constants/objects.ts"],"sourcesContent":["import type { DecomposeOptions, FlatOptions } from '../types.types';\n\nexport const DEFAULT_FLAT_OPTIONS = {\n sep: '.',\n children: false,\n} as const satisfies FlatOptions;\n\nexport const DEFAULT_DECOMPOSE_OPTIONS = {\n sep: '.',\n object: 'key',\n start: true,\n} as const satisfies DecomposeOptions;\n"],"names":[],"mappings":";;AAEO,MAAM,oBAAoB,GAAG;AAClC,IAAA,GAAG,EAAE,GAAG;AACR,IAAA,QAAQ,EAAE,KAAK;;AAGV,MAAM,yBAAyB,GAAG;AACvC,IAAA,GAAG,EAAE,GAAG;AACR,IAAA,MAAM,EAAE,KAAK;AACb,IAAA,KAAK,EAAE,IAAI;;;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const DEFAULT_FLAT_OPTIONS: {
|
|
2
|
+
readonly sep: ".";
|
|
3
|
+
readonly children: false;
|
|
4
|
+
};
|
|
5
|
+
export declare const DEFAULT_DECOMPOSE_OPTIONS: {
|
|
6
|
+
readonly sep: ".";
|
|
7
|
+
readonly object: "key";
|
|
8
|
+
readonly start: true;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=objects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../src/constants/objects.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB;;;CAGD,CAAC;AAEjC,eAAO,MAAM,yBAAyB;;;;CAID,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const DEFAULT_FLAT_OPTIONS = {
|
|
2
|
+
sep: '.',
|
|
3
|
+
children: false,
|
|
4
|
+
};
|
|
5
|
+
const DEFAULT_DECOMPOSE_OPTIONS = {
|
|
6
|
+
sep: '.',
|
|
7
|
+
object: 'key',
|
|
8
|
+
start: true,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { DEFAULT_DECOMPOSE_OPTIONS, DEFAULT_FLAT_OPTIONS };
|
|
12
|
+
//# sourceMappingURL=objects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objects.js","sources":["../../src/constants/objects.ts"],"sourcesContent":["import type { DecomposeOptions, FlatOptions } from '../types.types';\n\nexport const DEFAULT_FLAT_OPTIONS = {\n sep: '.',\n children: false,\n} as const satisfies FlatOptions;\n\nexport const DEFAULT_DECOMPOSE_OPTIONS = {\n sep: '.',\n object: 'key',\n start: true,\n} as const satisfies DecomposeOptions;\n"],"names":[],"mappings":"AAEO,MAAM,oBAAoB,GAAG;AAClC,IAAA,GAAG,EAAE,GAAG;AACR,IAAA,QAAQ,EAAE,KAAK;;AAGV,MAAM,yBAAyB,GAAG;AACvC,IAAA,GAAG,EAAE,GAAG;AACR,IAAA,MAAM,EAAE,KAAK;AACb,IAAA,KAAK,EAAE,IAAI;;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var helpers = require('../helpers.cjs');
|
|
4
|
+
|
|
5
|
+
const _assignByKey = (obj, key, value) => {
|
|
6
|
+
const segments = helpers.splitKey(key);
|
|
7
|
+
const [first, ...rest] = segments;
|
|
8
|
+
const out = obj ?? helpers.nextDefault(first);
|
|
9
|
+
if (rest.length === 0) {
|
|
10
|
+
if (helpers.isArrayIndex(first)) {
|
|
11
|
+
out[helpers.parseIndex(first)] = value;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
out[first] = value;
|
|
15
|
+
}
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
const nextKey = rest.join('.');
|
|
19
|
+
const next = rest[0];
|
|
20
|
+
const _nextDefault = helpers.nextDefault(next);
|
|
21
|
+
if (helpers.isArrayIndex(first)) {
|
|
22
|
+
const idx = helpers.parseIndex(first);
|
|
23
|
+
out[idx] = _assignByKey(out[idx] ?? _nextDefault, nextKey, value);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
out[first] = _assignByKey(out[first] ?? _nextDefault, nextKey, value);
|
|
27
|
+
}
|
|
28
|
+
return out;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Assigns a value to a path in an object.
|
|
32
|
+
* @param obj The object to assign the value to
|
|
33
|
+
* @param path The key to assign the value to, can be a nested key (e.g. 'a.b.c')
|
|
34
|
+
* @param value The value to assign to the key
|
|
35
|
+
* @returns The modified object with the value assigned to the specified key
|
|
36
|
+
*
|
|
37
|
+
* @see {@linkcode Decompose} for more details on object decomposition.
|
|
38
|
+
*/
|
|
39
|
+
const assignByKey = (obj, path, value) => {
|
|
40
|
+
return _assignByKey(obj, path, value);
|
|
41
|
+
};
|
|
42
|
+
assignByKey.low = assignByKey;
|
|
43
|
+
assignByKey.typed = assignByKey;
|
|
44
|
+
|
|
45
|
+
exports.assignByKey = assignByKey;
|
|
46
|
+
//# sourceMappingURL=assign.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assign.cjs","sources":["../../src/contexts/assign.ts"],"sourcesContent":["import {\n isArrayIndex,\n nextDefault,\n parseIndex,\n splitKey,\n} from '../helpers';\nimport type { Decompose, Ru } from '../types.types';\nimport type { DEFAULT_OPTIONS } from './constants';\n\n// #region type AssignByBey_F\nexport type AssignByBey_F = <\n T extends Ru,\n D extends Decompose<T, typeof DEFAULT_OPTIONS>,\n K extends Extract<keyof D, string>,\n R extends D[K],\n>(\n obj: T,\n key: K,\n value: R,\n) => T;\n// #endregion\n\nexport interface AssignByKey {\n (obj: any, key: string, value: any): any;\n low: (obj: any, key: string, value: any) => any;\n typed: AssignByBey_F;\n}\n\nconst _assignByKey: AssignByKey['low'] = (obj, key, value) => {\n const segments = splitKey(key);\n\n const [first, ...rest] = segments;\n const out: any = obj ?? nextDefault(first);\n\n if (rest.length === 0) {\n if (isArrayIndex(first)) {\n out[parseIndex(first)] = value;\n } else {\n out[first] = value;\n }\n return out;\n }\n\n const nextKey = rest.join('.');\n const next = rest[0];\n const _nextDefault = nextDefault(next);\n\n if (isArrayIndex(first)) {\n const idx = parseIndex(first);\n out[idx] = _assignByKey(out[idx] ?? _nextDefault, nextKey, value);\n } else {\n out[first] = _assignByKey(out[first] ?? _nextDefault, nextKey, value);\n }\n\n return out;\n};\n\n/**\n * Assigns a value to a path in an object.\n * @param obj The object to assign the value to\n * @param path The key to assign the value to, can be a nested key (e.g. 'a.b.c')\n * @param value The value to assign to the key\n * @returns The modified object with the value assigned to the specified key\n *\n * @see {@linkcode Decompose} for more details on object decomposition.\n */\nexport const assignByKey: AssignByKey = (obj, path, value) => {\n return _assignByKey(obj, path, value);\n};\n\nassignByKey.low = assignByKey;\nassignByKey.typed = assignByKey;\n"],"names":["splitKey","nextDefault","isArrayIndex","parseIndex"],"mappings":";;;;AA4BA,MAAM,YAAY,GAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAI;AAC3D,IAAA,MAAM,QAAQ,GAAGA,gBAAQ,CAAC,GAAG,CAAC;IAE9B,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,QAAQ;IACjC,MAAM,GAAG,GAAQ,GAAG,IAAIC,mBAAW,CAAC,KAAK,CAAC;AAE1C,IAAA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AACrB,QAAA,IAAIC,oBAAY,CAAC,KAAK,CAAC,EAAE;YACvB,GAAG,CAACC,kBAAU,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK;QAChC;aAAO;AACL,YAAA,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK;QACpB;AACA,QAAA,OAAO,GAAG;IACZ;IAEA,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AAC9B,IAAA,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC;AACpB,IAAA,MAAM,YAAY,GAAGF,mBAAW,CAAC,IAAI,CAAC;AAEtC,IAAA,IAAIC,oBAAY,CAAC,KAAK,CAAC,EAAE;AACvB,QAAA,MAAM,GAAG,GAAGC,kBAAU,CAAC,KAAK,CAAC;AAC7B,QAAA,GAAG,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC;IACnE;SAAO;AACL,QAAA,GAAG,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC;IACvE;AAEA,IAAA,OAAO,GAAG;AACZ,CAAC;AAED;;;;;;;;AAQG;AACI,MAAM,WAAW,GAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,KAAI;IAC3D,OAAO,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC;AACvC;AAEA,WAAW,CAAC,GAAG,GAAG,WAAW;AAC7B,WAAW,CAAC,KAAK,GAAG,WAAW;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Decompose, Ru } from '../types.types';
|
|
2
|
+
import type { DEFAULT_OPTIONS } from './constants';
|
|
3
|
+
export type AssignByBey_F = <T extends Ru, D extends Decompose<T, typeof DEFAULT_OPTIONS>, K extends Extract<keyof D, string>, R extends D[K]>(obj: T, key: K, value: R) => T;
|
|
4
|
+
export interface AssignByKey {
|
|
5
|
+
(obj: any, key: string, value: any): any;
|
|
6
|
+
low: (obj: any, key: string, value: any) => any;
|
|
7
|
+
typed: AssignByBey_F;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Assigns a value to a path in an object.
|
|
11
|
+
* @param obj The object to assign the value to
|
|
12
|
+
* @param path The key to assign the value to, can be a nested key (e.g. 'a.b.c')
|
|
13
|
+
* @param value The value to assign to the key
|
|
14
|
+
* @returns The modified object with the value assigned to the specified key
|
|
15
|
+
*
|
|
16
|
+
* @see {@linkcode Decompose} for more details on object decomposition.
|
|
17
|
+
*/
|
|
18
|
+
export declare const assignByKey: AssignByKey;
|
|
19
|
+
//# sourceMappingURL=assign.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assign.d.ts","sourceRoot":"","sources":["../../src/contexts/assign.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,MAAM,MAAM,aAAa,GAAG,CAC1B,CAAC,SAAS,EAAE,EACZ,CAAC,SAAS,SAAS,CAAC,CAAC,EAAE,OAAO,eAAe,CAAC,EAC9C,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,EAClC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAEd,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,CAAC,KACL,CAAC,CAAC;AAGP,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG,CAAC;IACzC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;IAChD,KAAK,EAAE,aAAa,CAAC;CACtB;AA+BD;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,EAAE,WAEzB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { splitKey, isArrayIndex, parseIndex, nextDefault } from '../helpers.js';
|
|
2
|
+
|
|
3
|
+
const _assignByKey = (obj, key, value) => {
|
|
4
|
+
const segments = splitKey(key);
|
|
5
|
+
const [first, ...rest] = segments;
|
|
6
|
+
const out = obj ?? nextDefault(first);
|
|
7
|
+
if (rest.length === 0) {
|
|
8
|
+
if (isArrayIndex(first)) {
|
|
9
|
+
out[parseIndex(first)] = value;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
out[first] = value;
|
|
13
|
+
}
|
|
14
|
+
return out;
|
|
15
|
+
}
|
|
16
|
+
const nextKey = rest.join('.');
|
|
17
|
+
const next = rest[0];
|
|
18
|
+
const _nextDefault = nextDefault(next);
|
|
19
|
+
if (isArrayIndex(first)) {
|
|
20
|
+
const idx = parseIndex(first);
|
|
21
|
+
out[idx] = _assignByKey(out[idx] ?? _nextDefault, nextKey, value);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
out[first] = _assignByKey(out[first] ?? _nextDefault, nextKey, value);
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Assigns a value to a path in an object.
|
|
30
|
+
* @param obj The object to assign the value to
|
|
31
|
+
* @param path The key to assign the value to, can be a nested key (e.g. 'a.b.c')
|
|
32
|
+
* @param value The value to assign to the key
|
|
33
|
+
* @returns The modified object with the value assigned to the specified key
|
|
34
|
+
*
|
|
35
|
+
* @see {@linkcode Decompose} for more details on object decomposition.
|
|
36
|
+
*/
|
|
37
|
+
const assignByKey = (obj, path, value) => {
|
|
38
|
+
return _assignByKey(obj, path, value);
|
|
39
|
+
};
|
|
40
|
+
assignByKey.low = assignByKey;
|
|
41
|
+
assignByKey.typed = assignByKey;
|
|
42
|
+
|
|
43
|
+
export { assignByKey };
|
|
44
|
+
//# sourceMappingURL=assign.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assign.js","sources":["../../src/contexts/assign.ts"],"sourcesContent":["import {\n isArrayIndex,\n nextDefault,\n parseIndex,\n splitKey,\n} from '../helpers';\nimport type { Decompose, Ru } from '../types.types';\nimport type { DEFAULT_OPTIONS } from './constants';\n\n// #region type AssignByBey_F\nexport type AssignByBey_F = <\n T extends Ru,\n D extends Decompose<T, typeof DEFAULT_OPTIONS>,\n K extends Extract<keyof D, string>,\n R extends D[K],\n>(\n obj: T,\n key: K,\n value: R,\n) => T;\n// #endregion\n\nexport interface AssignByKey {\n (obj: any, key: string, value: any): any;\n low: (obj: any, key: string, value: any) => any;\n typed: AssignByBey_F;\n}\n\nconst _assignByKey: AssignByKey['low'] = (obj, key, value) => {\n const segments = splitKey(key);\n\n const [first, ...rest] = segments;\n const out: any = obj ?? nextDefault(first);\n\n if (rest.length === 0) {\n if (isArrayIndex(first)) {\n out[parseIndex(first)] = value;\n } else {\n out[first] = value;\n }\n return out;\n }\n\n const nextKey = rest.join('.');\n const next = rest[0];\n const _nextDefault = nextDefault(next);\n\n if (isArrayIndex(first)) {\n const idx = parseIndex(first);\n out[idx] = _assignByKey(out[idx] ?? _nextDefault, nextKey, value);\n } else {\n out[first] = _assignByKey(out[first] ?? _nextDefault, nextKey, value);\n }\n\n return out;\n};\n\n/**\n * Assigns a value to a path in an object.\n * @param obj The object to assign the value to\n * @param path The key to assign the value to, can be a nested key (e.g. 'a.b.c')\n * @param value The value to assign to the key\n * @returns The modified object with the value assigned to the specified key\n *\n * @see {@linkcode Decompose} for more details on object decomposition.\n */\nexport const assignByKey: AssignByKey = (obj, path, value) => {\n return _assignByKey(obj, path, value);\n};\n\nassignByKey.low = assignByKey;\nassignByKey.typed = assignByKey;\n"],"names":[],"mappings":";;AA4BA,MAAM,YAAY,GAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAI;AAC3D,IAAA,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC;IAE9B,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,QAAQ;IACjC,MAAM,GAAG,GAAQ,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC;AAE1C,IAAA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AACrB,QAAA,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE;YACvB,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK;QAChC;aAAO;AACL,YAAA,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK;QACpB;AACA,QAAA,OAAO,GAAG;IACZ;IAEA,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AAC9B,IAAA,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC;AACpB,IAAA,MAAM,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC;AAEtC,IAAA,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE;AACvB,QAAA,MAAM,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC;AAC7B,QAAA,GAAG,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC;IACnE;SAAO;AACL,QAAA,GAAG,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC;IACvE;AAEA,IAAA,OAAO,GAAG;AACZ,CAAC;AAED;;;;;;;;AAQG;AACI,MAAM,WAAW,GAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,KAAI;IAC3D,OAAO,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC;AACvC;AAEA,WAAW,CAAC,GAAG,GAAG,WAAW;AAC7B,WAAW,CAAC,KAAK,GAAG,WAAW;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.cjs","sources":["../../src/contexts/constants.ts"],"sourcesContent":["import type { DecomposeOptions } from '../types.types';\n\nexport const DEFAULT_OPTIONS = {\n start: false,\n sep: '.',\n object: 'both',\n} as const satisfies DecomposeOptions;\n"],"names":[],"mappings":";;AAEO,MAAM,eAAe,GAAG;AAC7B,IAAA,KAAK,EAAE,KAAK;AACZ,IAAA,GAAG,EAAE,GAAG;AACR,IAAA,MAAM,EAAE,MAAM;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/contexts/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;;;CAIS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../src/contexts/constants.ts"],"sourcesContent":["import type { DecomposeOptions } from '../types.types';\n\nexport const DEFAULT_OPTIONS = {\n start: false,\n sep: '.',\n object: 'both',\n} as const satisfies DecomposeOptions;\n"],"names":[],"mappings":"AAEO,MAAM,eAAe,GAAG;AAC7B,IAAA,KAAK,EAAE,KAAK;AACZ,IAAA,GAAG,EAAE,GAAG;AACR,IAAA,MAAM,EAAE,MAAM;;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var decompose = require('../decompose.cjs');
|
|
4
|
+
|
|
5
|
+
const _getByKey = (obj, key) => {
|
|
6
|
+
const decomposed = decompose.decompose.low(obj, { start: false, object: 'both' });
|
|
7
|
+
return decomposed[key];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves a value from an object by a specified key.
|
|
11
|
+
* @param obj The object to retrieve the value from
|
|
12
|
+
* @param key The key to retrieve the value for, can be a nested key (e.g. 'a.b.c')
|
|
13
|
+
* @returns The value associated with the specified key in the object
|
|
14
|
+
*
|
|
15
|
+
* @see {@linkcode Decompose} for more details on object decomposition.
|
|
16
|
+
*/
|
|
17
|
+
const getByKey = (obj, key) => _getByKey(obj, key);
|
|
18
|
+
getByKey.low = getByKey;
|
|
19
|
+
getByKey.typed = getByKey;
|
|
20
|
+
getByKey.options = options => (obj, key) => {
|
|
21
|
+
const decomposed = decompose.decompose.low(obj, options);
|
|
22
|
+
return decomposed[key];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.getByKey = getByKey;
|
|
26
|
+
//# sourceMappingURL=get.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.cjs","sources":["../../src/contexts/get.ts"],"sourcesContent":["import type { DEFAULT_OPTIONS } from './constants';\nimport { decompose } from '../decompose';\nimport type { Decompose, DecomposeOptions, Ru } from '../types.types';\n\n// #region type GetByKey_F\nexport type GetByKey_F = <\n const T extends Ru,\n const K extends keyof Decompose<T, typeof DEFAULT_OPTIONS>,\n>(\n obj: T,\n key: Extract<K, string>,\n) => Decompose<T, typeof DEFAULT_OPTIONS>[K];\n\nexport type GetByKeyOption_F = <\n const O extends DecomposeOptions = typeof DEFAULT_OPTIONS,\n>(\n val: O,\n) => <const T extends Ru, const K extends keyof Decompose<T, O>>(\n obj: T,\n key: Extract<K, string>,\n) => Decompose<T, O>[K];\n// #endregion\n\nexport interface GetByKey {\n (obj: any, key: string): any;\n low: (obj: any, key: string) => any;\n typed: GetByKey_F;\n options: GetByKeyOption_F;\n}\n\nconst _getByKey: GetByKey['low'] = (obj, key) => {\n const decomposed = decompose.low(obj, { start: false, object: 'both' });\n return (decomposed as any)[key];\n};\n\n/**\n * Retrieves a value from an object by a specified key.\n * @param obj The object to retrieve the value from\n * @param key The key to retrieve the value for, can be a nested key (e.g. 'a.b.c')\n * @returns The value associated with the specified key in the object\n *\n * @see {@linkcode Decompose} for more details on object decomposition.\n */\nexport const getByKey: GetByKey = (obj, key) => _getByKey(obj, key);\n\ngetByKey.low = getByKey;\ngetByKey.typed = getByKey;\ngetByKey.options = options => (obj, key) => {\n const decomposed = decompose.low(obj, options);\n return decomposed[key];\n};\n"],"names":["decompose"],"mappings":";;;;AA8BA,MAAM,SAAS,GAAoB,CAAC,GAAG,EAAE,GAAG,KAAI;AAC9C,IAAA,MAAM,UAAU,GAAGA,mBAAS,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACvE,IAAA,OAAQ,UAAkB,CAAC,GAAG,CAAC;AACjC,CAAC;AAED;;;;;;;AAOG;AACI,MAAM,QAAQ,GAAa,CAAC,GAAG,EAAE,GAAG,KAAK,SAAS,CAAC,GAAG,EAAE,GAAG;AAElE,QAAQ,CAAC,GAAG,GAAG,QAAQ;AACvB,QAAQ,CAAC,KAAK,GAAG,QAAQ;AACzB,QAAQ,CAAC,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,KAAI;IACzC,MAAM,UAAU,GAAGA,mBAAS,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC;AAC9C,IAAA,OAAO,UAAU,CAAC,GAAG,CAAC;AACxB,CAAC;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DEFAULT_OPTIONS } from './constants';
|
|
2
|
+
import type { Decompose, DecomposeOptions, Ru } from '../types.types';
|
|
3
|
+
export type GetByKey_F = <const T extends Ru, const K extends keyof Decompose<T, typeof DEFAULT_OPTIONS>>(obj: T, key: Extract<K, string>) => Decompose<T, typeof DEFAULT_OPTIONS>[K];
|
|
4
|
+
export type GetByKeyOption_F = <const O extends DecomposeOptions = typeof DEFAULT_OPTIONS>(val: O) => <const T extends Ru, const K extends keyof Decompose<T, O>>(obj: T, key: Extract<K, string>) => Decompose<T, O>[K];
|
|
5
|
+
export interface GetByKey {
|
|
6
|
+
(obj: any, key: string): any;
|
|
7
|
+
low: (obj: any, key: string) => any;
|
|
8
|
+
typed: GetByKey_F;
|
|
9
|
+
options: GetByKeyOption_F;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves a value from an object by a specified key.
|
|
13
|
+
* @param obj The object to retrieve the value from
|
|
14
|
+
* @param key The key to retrieve the value for, can be a nested key (e.g. 'a.b.c')
|
|
15
|
+
* @returns The value associated with the specified key in the object
|
|
16
|
+
*
|
|
17
|
+
* @see {@linkcode Decompose} for more details on object decomposition.
|
|
18
|
+
*/
|
|
19
|
+
export declare const getByKey: GetByKey;
|
|
20
|
+
//# sourceMappingURL=get.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../src/contexts/get.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAGtE,MAAM,MAAM,UAAU,GAAG,CACvB,KAAK,CAAC,CAAC,SAAS,EAAE,EAClB,KAAK,CAAC,CAAC,SAAS,MAAM,SAAS,CAAC,CAAC,EAAE,OAAO,eAAe,CAAC,EAE1D,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,KACpB,SAAS,CAAC,CAAC,EAAE,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GAAG,CAC7B,KAAK,CAAC,CAAC,SAAS,gBAAgB,GAAG,OAAO,eAAe,EAEzD,GAAG,EAAE,CAAC,KACH,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,EAAE,KAAK,CAAC,CAAC,SAAS,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAC7D,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,KACpB,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAGxB,MAAM,WAAW,QAAQ;IACvB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAC7B,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,KAAK,GAAG,CAAC;IACpC,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAOD;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,QAA4C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { decompose } from '../decompose.js';
|
|
2
|
+
|
|
3
|
+
const _getByKey = (obj, key) => {
|
|
4
|
+
const decomposed = decompose.low(obj, { start: false, object: 'both' });
|
|
5
|
+
return decomposed[key];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves a value from an object by a specified key.
|
|
9
|
+
* @param obj The object to retrieve the value from
|
|
10
|
+
* @param key The key to retrieve the value for, can be a nested key (e.g. 'a.b.c')
|
|
11
|
+
* @returns The value associated with the specified key in the object
|
|
12
|
+
*
|
|
13
|
+
* @see {@linkcode Decompose} for more details on object decomposition.
|
|
14
|
+
*/
|
|
15
|
+
const getByKey = (obj, key) => _getByKey(obj, key);
|
|
16
|
+
getByKey.low = getByKey;
|
|
17
|
+
getByKey.typed = getByKey;
|
|
18
|
+
getByKey.options = options => (obj, key) => {
|
|
19
|
+
const decomposed = decompose.low(obj, options);
|
|
20
|
+
return decomposed[key];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { getByKey };
|
|
24
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.js","sources":["../../src/contexts/get.ts"],"sourcesContent":["import type { DEFAULT_OPTIONS } from './constants';\nimport { decompose } from '../decompose';\nimport type { Decompose, DecomposeOptions, Ru } from '../types.types';\n\n// #region type GetByKey_F\nexport type GetByKey_F = <\n const T extends Ru,\n const K extends keyof Decompose<T, typeof DEFAULT_OPTIONS>,\n>(\n obj: T,\n key: Extract<K, string>,\n) => Decompose<T, typeof DEFAULT_OPTIONS>[K];\n\nexport type GetByKeyOption_F = <\n const O extends DecomposeOptions = typeof DEFAULT_OPTIONS,\n>(\n val: O,\n) => <const T extends Ru, const K extends keyof Decompose<T, O>>(\n obj: T,\n key: Extract<K, string>,\n) => Decompose<T, O>[K];\n// #endregion\n\nexport interface GetByKey {\n (obj: any, key: string): any;\n low: (obj: any, key: string) => any;\n typed: GetByKey_F;\n options: GetByKeyOption_F;\n}\n\nconst _getByKey: GetByKey['low'] = (obj, key) => {\n const decomposed = decompose.low(obj, { start: false, object: 'both' });\n return (decomposed as any)[key];\n};\n\n/**\n * Retrieves a value from an object by a specified key.\n * @param obj The object to retrieve the value from\n * @param key The key to retrieve the value for, can be a nested key (e.g. 'a.b.c')\n * @returns The value associated with the specified key in the object\n *\n * @see {@linkcode Decompose} for more details on object decomposition.\n */\nexport const getByKey: GetByKey = (obj, key) => _getByKey(obj, key);\n\ngetByKey.low = getByKey;\ngetByKey.typed = getByKey;\ngetByKey.options = options => (obj, key) => {\n const decomposed = decompose.low(obj, options);\n return decomposed[key];\n};\n"],"names":[],"mappings":";;AA8BA,MAAM,SAAS,GAAoB,CAAC,GAAG,EAAE,GAAG,KAAI;AAC9C,IAAA,MAAM,UAAU,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACvE,IAAA,OAAQ,UAAkB,CAAC,GAAG,CAAC;AACjC,CAAC;AAED;;;;;;;AAOG;AACI,MAAM,QAAQ,GAAa,CAAC,GAAG,EAAE,GAAG,KAAK,SAAS,CAAC,GAAG,EAAE,GAAG;AAElE,QAAQ,CAAC,GAAG,GAAG,QAAQ;AACvB,QAAQ,CAAC,KAAK,GAAG,QAAQ;AACzB,QAAQ,CAAC,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,KAAI;IACzC,MAAM,UAAU,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC;AAC9C,IAAA,OAAO,UAAU,CAAC,GAAG,CAAC;AACxB,CAAC;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contexts/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/lib/decompose.cjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var constants_objects = require('./constants/objects.cjs');
|
|
3
4
|
var constants_strings = require('./constants/strings.cjs');
|
|
4
5
|
var helpers = require('./helpers.cjs');
|
|
5
6
|
|
|
6
|
-
function ddecompose(arg, prev = '', options =
|
|
7
|
+
function ddecompose(arg, prev = '', options = constants_objects.DEFAULT_DECOMPOSE_OPTIONS, first = true) {
|
|
7
8
|
const { object } = {
|
|
8
|
-
...
|
|
9
|
+
...constants_objects.DEFAULT_DECOMPOSE_OPTIONS,
|
|
9
10
|
...options,
|
|
10
11
|
};
|
|
11
12
|
const canAddObjectKeys = object === 'both' || object === 'object';
|
|
@@ -14,10 +15,10 @@ function ddecompose(arg, prev = '', options = helpers.DEFAULT_DECOMPOSE_OPTIONS)
|
|
|
14
15
|
const output = [];
|
|
15
16
|
const isArray = Array.isArray(arg);
|
|
16
17
|
if (isArray) {
|
|
17
|
-
if (canAddObjectKeys)
|
|
18
|
+
if (canAddObjectKeys && !first)
|
|
18
19
|
output.push([`${prev}`, arg]);
|
|
19
20
|
arg.forEach((item, index) => {
|
|
20
|
-
const values = ddecompose(item, `${_prev}${constants_strings.LEFT_BRACKET}${index}${constants_strings.RIGHT_BRACKET}`, options);
|
|
21
|
+
const values = ddecompose(item, `${_prev}${constants_strings.LEFT_BRACKET}${index}${constants_strings.RIGHT_BRACKET}`, options, false);
|
|
21
22
|
output.push(...values);
|
|
22
23
|
});
|
|
23
24
|
return output;
|
|
@@ -33,7 +34,7 @@ function ddecompose(arg, prev = '', options = helpers.DEFAULT_DECOMPOSE_OPTIONS)
|
|
|
33
34
|
output.push([`${prev}`, arg]);
|
|
34
35
|
const entries1 = Object.entries(arg);
|
|
35
36
|
entries1.forEach(([key, value]) => {
|
|
36
|
-
const values = ddecompose(value, `${_prev}${key}`, options);
|
|
37
|
+
const values = ddecompose(value, `${_prev}${key}`, options, false);
|
|
37
38
|
output.push(...values);
|
|
38
39
|
});
|
|
39
40
|
return output;
|
|
@@ -41,11 +42,14 @@ function ddecompose(arg, prev = '', options = helpers.DEFAULT_DECOMPOSE_OPTIONS)
|
|
|
41
42
|
const _decompose = (val, options) => {
|
|
42
43
|
const entries1 = ddecompose(val, '', options);
|
|
43
44
|
const { sep, start } = {
|
|
44
|
-
...
|
|
45
|
+
...constants_objects.DEFAULT_DECOMPOSE_OPTIONS,
|
|
45
46
|
...options,
|
|
46
47
|
};
|
|
47
|
-
if (entries1.length == 0)
|
|
48
|
+
if (entries1.length == 0) {
|
|
49
|
+
if (Array.isArray(val))
|
|
50
|
+
return [];
|
|
48
51
|
return {};
|
|
52
|
+
}
|
|
49
53
|
const regexDel = new RegExp(constants_strings.DELIMITER, 'g');
|
|
50
54
|
const regexLeft = new RegExp(constants_strings.LEFT_BRACKET, 'g');
|
|
51
55
|
const regexRight = new RegExp(constants_strings.RIGHT_BRACKET, 'g');
|
package/lib/decompose.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decompose.cjs","sources":["../src/decompose.ts"],"sourcesContent":["import {\n DELIMITER,\n LEFT_BRACKET,\n RIGHT_BRACKET,\n} from './constants/strings';\nimport {
|
|
1
|
+
{"version":3,"file":"decompose.cjs","sources":["../src/decompose.ts"],"sourcesContent":["import { DEFAULT_DECOMPOSE_OPTIONS } from './constants';\nimport {\n DELIMITER,\n LEFT_BRACKET,\n RIGHT_BRACKET,\n} from './constants/strings';\nimport { isPrimitive } from './helpers';\nimport type { Decompose, DecomposeOptions } from './types.types';\n\nfunction ddecompose(\n arg: any,\n prev = '',\n options: DecomposeOptions = DEFAULT_DECOMPOSE_OPTIONS,\n first = true,\n) {\n const { object } = {\n ...DEFAULT_DECOMPOSE_OPTIONS,\n ...options,\n };\n const canAddObjectKeys = object === 'both' || object === 'object';\n const canAddKeys = object === 'both' || object === 'key';\n\n const _prev = prev ? prev + DELIMITER : '';\n const output: [string, any][] = [];\n\n const isArray = Array.isArray(arg);\n if (isArray) {\n if (canAddObjectKeys && !first) output.push([`${prev}`, arg]);\n\n arg.forEach((item, index) => {\n const values = ddecompose(\n item,\n `${_prev}${LEFT_BRACKET}${index}${RIGHT_BRACKET}`,\n options,\n false,\n );\n output.push(...values);\n });\n return output;\n }\n\n const isPrimit = isPrimitive(arg);\n if (isPrimit) {\n const isFirst = !prev.includes(DELIMITER);\n if (canAddKeys || isFirst) output.push([`${prev}`, arg]);\n return output;\n }\n\n if (canAddObjectKeys && prev !== '') output.push([`${prev}`, arg]);\n\n const entries1 = Object.entries(arg);\n entries1.forEach(([key, value]) => {\n const values = ddecompose(value, `${_prev}${key}`, options, false);\n output.push(...values);\n });\n\n return output;\n}\n\ntype Decompose_F = <\n T,\n const O extends DecomposeOptions = typeof DEFAULT_DECOMPOSE_OPTIONS,\n>(\n val: T,\n options?: O,\n) => Decompose<T, O>;\ntype _Decompose_F = (val: any, options?: DecomposeOptions) => any;\n\nexport type Decomposer = Decompose_F & {\n strict: Decompose_F;\n low: _Decompose_F;\n};\n\nconst _decompose: _Decompose_F = (val, options) => {\n const entries1 = ddecompose(val, '', options);\n\n const { sep, start } = {\n ...DEFAULT_DECOMPOSE_OPTIONS,\n ...options,\n };\n if (entries1.length == 0) {\n if (Array.isArray(val)) return [];\n return {};\n }\n\n const regexDel = new RegExp(DELIMITER, 'g');\n const regexLeft = new RegExp(LEFT_BRACKET, 'g');\n const regexRight = new RegExp(RIGHT_BRACKET, 'g');\n const entries2 = entries1.map(([__key, value]) => {\n const _key = __key\n .replace(regexDel, sep)\n .replace(regexLeft, `[`)\n .replace(regexRight, `]`);\n const key = start ? `${sep}${_key}` : _key;\n return [key, value];\n });\n\n const output = Object.fromEntries(entries2);\n return output;\n};\n\n/* v8 ignore next 1 */\nexport const decompose: Decomposer = (val, options) =>\n _decompose(val, options);\ndecompose.low = _decompose;\ndecompose.strict = _decompose;\n"],"names":["DEFAULT_DECOMPOSE_OPTIONS","DELIMITER","LEFT_BRACKET","RIGHT_BRACKET","isPrimitive"],"mappings":";;;;;;AASA,SAAS,UAAU,CACjB,GAAQ,EACR,IAAI,GAAG,EAAE,EACT,OAAA,G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AACV,aAAA,OAAO,CAAC,QAAQ,EAAE,GAAG;AACrB,aAAA,OAAO,CAAC,SAAS,EAAE,CAAA,CAAA,CAAG;AACtB,aAAA,OAAO,CAAC,UAAU,EAAE,CAAA,CAAA,CAAG,CAAC;AAC3B,QAAA,MAAM,GAAG,GAAG,KAAK,GAAG,CAAA,EAAG,GAAG,CAAA,EAAG,IAAI,CAAA,CAAE,GAAG,IAAI;AAC1C,QAAA,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;AACrB,IAAA,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC;AAC3C,IAAA,OAAO,MAAM;AACf,CAAC;AAED;AACO,MAAM,SAAS,GAAe,CAAC,GAAG,EAAE,OAAO,KAChD,UAAU,CAAC,GAAG,EAAE,OAAO;AACzB,SAAS,CAAC,GAAG,GAAG,UAAU;AAC1B,SAAS,CAAC,MAAM,GAAG,UAAU;;;;"}
|
package/lib/decompose.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DEFAULT_DECOMPOSE_OPTIONS } from './
|
|
1
|
+
import { DEFAULT_DECOMPOSE_OPTIONS } from './constants';
|
|
2
2
|
import type { Decompose, DecomposeOptions } from './types.types';
|
|
3
|
-
type Decompose_F = <T, O extends DecomposeOptions = typeof DEFAULT_DECOMPOSE_OPTIONS>(val: T, options?: O) => Decompose<T, O>;
|
|
3
|
+
type Decompose_F = <T, const O extends DecomposeOptions = typeof DEFAULT_DECOMPOSE_OPTIONS>(val: T, options?: O) => Decompose<T, O>;
|
|
4
4
|
type _Decompose_F = (val: any, options?: DecomposeOptions) => any;
|
|
5
5
|
export type Decomposer = Decompose_F & {
|
|
6
6
|
strict: Decompose_F;
|
package/lib/decompose.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decompose.d.ts","sourceRoot":"","sources":["../src/decompose.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decompose.d.ts","sourceRoot":"","sources":["../src/decompose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAOxD,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAoDjE,KAAK,WAAW,GAAG,CACjB,CAAC,EACD,KAAK,CAAC,CAAC,SAAS,gBAAgB,GAAG,OAAO,yBAAyB,EAEnE,GAAG,EAAE,CAAC,EACN,OAAO,CAAC,EAAE,CAAC,KACR,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACrB,KAAK,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,gBAAgB,KAAK,GAAG,CAAC;AAElE,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG;IACrC,MAAM,EAAE,WAAW,CAAC;IACpB,GAAG,EAAE,YAAY,CAAC;CACnB,CAAC;AA+BF,eAAO,MAAM,SAAS,EAAE,UACE,CAAC"}
|
package/lib/decompose.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { DEFAULT_DECOMPOSE_OPTIONS } from './constants/objects.js';
|
|
1
2
|
import { LEFT_BRACKET, RIGHT_BRACKET, DELIMITER } from './constants/strings.js';
|
|
2
|
-
import {
|
|
3
|
+
import { isPrimitive } from './helpers.js';
|
|
3
4
|
|
|
4
|
-
function ddecompose(arg, prev = '', options = DEFAULT_DECOMPOSE_OPTIONS) {
|
|
5
|
+
function ddecompose(arg, prev = '', options = DEFAULT_DECOMPOSE_OPTIONS, first = true) {
|
|
5
6
|
const { object } = {
|
|
6
7
|
...DEFAULT_DECOMPOSE_OPTIONS,
|
|
7
8
|
...options,
|
|
@@ -12,10 +13,10 @@ function ddecompose(arg, prev = '', options = DEFAULT_DECOMPOSE_OPTIONS) {
|
|
|
12
13
|
const output = [];
|
|
13
14
|
const isArray = Array.isArray(arg);
|
|
14
15
|
if (isArray) {
|
|
15
|
-
if (canAddObjectKeys)
|
|
16
|
+
if (canAddObjectKeys && !first)
|
|
16
17
|
output.push([`${prev}`, arg]);
|
|
17
18
|
arg.forEach((item, index) => {
|
|
18
|
-
const values = ddecompose(item, `${_prev}${LEFT_BRACKET}${index}${RIGHT_BRACKET}`, options);
|
|
19
|
+
const values = ddecompose(item, `${_prev}${LEFT_BRACKET}${index}${RIGHT_BRACKET}`, options, false);
|
|
19
20
|
output.push(...values);
|
|
20
21
|
});
|
|
21
22
|
return output;
|
|
@@ -31,7 +32,7 @@ function ddecompose(arg, prev = '', options = DEFAULT_DECOMPOSE_OPTIONS) {
|
|
|
31
32
|
output.push([`${prev}`, arg]);
|
|
32
33
|
const entries1 = Object.entries(arg);
|
|
33
34
|
entries1.forEach(([key, value]) => {
|
|
34
|
-
const values = ddecompose(value, `${_prev}${key}`, options);
|
|
35
|
+
const values = ddecompose(value, `${_prev}${key}`, options, false);
|
|
35
36
|
output.push(...values);
|
|
36
37
|
});
|
|
37
38
|
return output;
|
|
@@ -42,8 +43,11 @@ const _decompose = (val, options) => {
|
|
|
42
43
|
...DEFAULT_DECOMPOSE_OPTIONS,
|
|
43
44
|
...options,
|
|
44
45
|
};
|
|
45
|
-
if (entries1.length == 0)
|
|
46
|
+
if (entries1.length == 0) {
|
|
47
|
+
if (Array.isArray(val))
|
|
48
|
+
return [];
|
|
46
49
|
return {};
|
|
50
|
+
}
|
|
47
51
|
const regexDel = new RegExp(DELIMITER, 'g');
|
|
48
52
|
const regexLeft = new RegExp(LEFT_BRACKET, 'g');
|
|
49
53
|
const regexRight = new RegExp(RIGHT_BRACKET, 'g');
|
package/lib/decompose.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decompose.js","sources":["../src/decompose.ts"],"sourcesContent":["import {\n DELIMITER,\n LEFT_BRACKET,\n RIGHT_BRACKET,\n} from './constants/strings';\nimport {
|
|
1
|
+
{"version":3,"file":"decompose.js","sources":["../src/decompose.ts"],"sourcesContent":["import { DEFAULT_DECOMPOSE_OPTIONS } from './constants';\nimport {\n DELIMITER,\n LEFT_BRACKET,\n RIGHT_BRACKET,\n} from './constants/strings';\nimport { isPrimitive } from './helpers';\nimport type { Decompose, DecomposeOptions } from './types.types';\n\nfunction ddecompose(\n arg: any,\n prev = '',\n options: DecomposeOptions = DEFAULT_DECOMPOSE_OPTIONS,\n first = true,\n) {\n const { object } = {\n ...DEFAULT_DECOMPOSE_OPTIONS,\n ...options,\n };\n const canAddObjectKeys = object === 'both' || object === 'object';\n const canAddKeys = object === 'both' || object === 'key';\n\n const _prev = prev ? prev + DELIMITER : '';\n const output: [string, any][] = [];\n\n const isArray = Array.isArray(arg);\n if (isArray) {\n if (canAddObjectKeys && !first) output.push([`${prev}`, arg]);\n\n arg.forEach((item, index) => {\n const values = ddecompose(\n item,\n `${_prev}${LEFT_BRACKET}${index}${RIGHT_BRACKET}`,\n options,\n false,\n );\n output.push(...values);\n });\n return output;\n }\n\n const isPrimit = isPrimitive(arg);\n if (isPrimit) {\n const isFirst = !prev.includes(DELIMITER);\n if (canAddKeys || isFirst) output.push([`${prev}`, arg]);\n return output;\n }\n\n if (canAddObjectKeys && prev !== '') output.push([`${prev}`, arg]);\n\n const entries1 = Object.entries(arg);\n entries1.forEach(([key, value]) => {\n const values = ddecompose(value, `${_prev}${key}`, options, false);\n output.push(...values);\n });\n\n return output;\n}\n\ntype Decompose_F = <\n T,\n const O extends DecomposeOptions = typeof DEFAULT_DECOMPOSE_OPTIONS,\n>(\n val: T,\n options?: O,\n) => Decompose<T, O>;\ntype _Decompose_F = (val: any, options?: DecomposeOptions) => any;\n\nexport type Decomposer = Decompose_F & {\n strict: Decompose_F;\n low: _Decompose_F;\n};\n\nconst _decompose: _Decompose_F = (val, options) => {\n const entries1 = ddecompose(val, '', options);\n\n const { sep, start } = {\n ...DEFAULT_DECOMPOSE_OPTIONS,\n ...options,\n };\n if (entries1.length == 0) {\n if (Array.isArray(val)) return [];\n return {};\n }\n\n const regexDel = new RegExp(DELIMITER, 'g');\n const regexLeft = new RegExp(LEFT_BRACKET, 'g');\n const regexRight = new RegExp(RIGHT_BRACKET, 'g');\n const entries2 = entries1.map(([__key, value]) => {\n const _key = __key\n .replace(regexDel, sep)\n .replace(regexLeft, `[`)\n .replace(regexRight, `]`);\n const key = start ? `${sep}${_key}` : _key;\n return [key, value];\n });\n\n const output = Object.fromEntries(entries2);\n return output;\n};\n\n/* v8 ignore next 1 */\nexport const decompose: Decomposer = (val, options) =>\n _decompose(val, options);\ndecompose.low = _decompose;\ndecompose.strict = _decompose;\n"],"names":[],"mappings":";;;;AASA,SAAS,UAAU,CACjB,GAAQ,EACR,IAAI,GAAG,EAAE,EACT,OAAA,GAA4B,yBAAyB,EACrD,KAAK,GAAG,IAAI,EAAA;IAEZ,MAAM,EAAE,MAAM,EAAE,GAAG;AACjB,QAAA,GAAG,yBAAyB;AAC5B,QAAA,GAAG,OAAO;KACX;IACD,MAAM,gBAAgB,GAAG,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,QAAQ;IACjE,MAAM,UAAU,GAAG,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,KAAK;AAExD,IAAA,MAAM,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,EAAE;IAC1C,MAAM,MAAM,GAAoB,EAAE;IAElC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;IAClC,IAAI,OAAO,EAAE;QACX,IAAI,gBAAgB,IAAI,CAAC,KAAK;YAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA,EAAG,IAAI,CAAA,CAAE,EAAE,GAAG,CAAC,CAAC;QAE7D,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,KAAI;YAC1B,MAAM,MAAM,GAAG,UAAU,CACvB,IAAI,EACJ,CAAA,EAAG,KAAK,CAAA,EAAG,YAAY,GAAG,KAAK,CAAA,EAAG,aAAa,CAAA,CAAE,EACjD,OAAO,EACP,K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I,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;AAAE,YAAA,OAAO,EAAE;AACjC,QAAA,OAAO,EAAE;IACX;IAEA,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC;IAC3C,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,YAAY,EAAE,GAAG,CAAC;IAC/C,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC;AACjD,IAAA,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,KAAI;QAC/C,MAAM,IAAI,GAAG;AACV,aAAA,OAAO,CAAC,QAAQ,EAAE,GAAG;AACrB,aAAA,OAAO,CAAC,SAAS,EAAE,CAAA,CAAA,CAAG;AACtB,aAAA,OAAO,CAAC,UAAU,EAAE,CAAA,CAAA,CAAG,CAAC;AAC3B,QAAA,MAAM,GAAG,GAAG,KAAK,GAAG,CAAA,EAAG,GAAG,CAAA,EAAG,IAAI,CAAA,CAAE,GAAG,IAAI;AAC1C,QAAA,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;AACrB,IAAA,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC;AAC3C,IAAA,OAAO,MAAM;AACf,CAAC;AAED;AACO,MAAM,SAAS,GAAe,CAAC,GAAG,EAAE,OAAO,KAChD,UAAU,CAAC,GAAG,EAAE,OAAO;AACzB,SAAS,CAAC,GAAG,GAAG,UAAU;AAC1B,SAAS,CAAC,MAAM,GAAG,UAAU;;;;"}
|
package/lib/flatByKey.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var constants_objects = require('./constants/objects.cjs');
|
|
4
4
|
|
|
5
5
|
const _flat = (val, omitKey, options, path = '') => {
|
|
6
|
-
const _options = { ...
|
|
6
|
+
const _options = { ...constants_objects.DEFAULT_FLAT_OPTIONS, ...options };
|
|
7
7
|
const { [omitKey]: recursives, ...rest } = val;
|
|
8
8
|
const check = _options.children;
|
|
9
9
|
let out = {};
|
package/lib/flatByKey.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flatByKey.cjs","sources":["../src/flatByKey.ts"],"sourcesContent":["import type { types } from '@bemedev/types';\nimport { DEFAULT_FLAT_OPTIONS } from './
|
|
1
|
+
{"version":3,"file":"flatByKey.cjs","sources":["../src/flatByKey.ts"],"sourcesContent":["import type { types } from '@bemedev/types';\nimport { DEFAULT_FLAT_OPTIONS } from './constants';\nimport type { FlatByKey, FlatOptions } from './types.types';\n\ntype Flat_F = <\n T extends types.Ru,\n omit extends types.PickKeysBy<T, object> & string,\n>(\n val: T,\n omitKey: omit,\n options?: FlatOptions,\n) => FlatByKey<T, omit, FlatOptions>;\n\ntype _Flat_F = (\n val: any,\n omitKey: string,\n options?: FlatOptions,\n path?: string,\n) => any;\n\nexport type Flat = Flat_F & {\n strict: Flat_F;\n low: _Flat_F;\n};\n\nconst _flat: _Flat_F = (val, omitKey, options, path = '') => {\n const _options = { ...DEFAULT_FLAT_OPTIONS, ...options };\n const { [omitKey]: recursives, ...rest } = val;\n\n const check = _options.children;\n\n let out: any = {};\n out[path === '' ? _options.sep : path] = check ? val : rest;\n\n if (recursives) {\n for (const key in recursives) {\n if (Object.prototype.hasOwnProperty.call(recursives, key)) {\n const element = recursives[key];\n const inner = _flat(\n element,\n omitKey,\n options,\n `${path}${_options.sep}${key}`,\n );\n out = { ...out, ...inner };\n }\n }\n }\n\n return out;\n};\n\nexport const flatByKey: Flat = (val, key, options) =>\n _flat(val, key, options);\nflatByKey.low = _flat;\nflatByKey.strict = _flat;\n"],"names":["DEFAULT_FLAT_OPTIONS"],"mappings":";;;;AAyBA,MAAM,KAAK,GAAY,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,KAAI;IAC1D,MAAM,QAAQ,GAAG,EAAE,GAAGA,sCAAoB,EAAE,GAAG,OAAO,EAAE;AACxD,IAAA,MAAM,EAAE,CAAC,OAAO,GAAG,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG;AAE9C,IAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ;IAE/B,IAAI,GAAG,GAAQ,EAAE;IACjB,GAAG,CAAC,IAAI,KAAK,EAAE,GAAG,QAAQ,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,KAAK,GAAG,GAAG,GAAG,IAAI;IAE3D,IAAI,UAAU,EAAE;AACd,QAAA,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;AAC5B,YAAA,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE;AACzD,gBAAA,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC;gBAC/B,MAAM,KAAK,GAAG,KAAK,CACjB,OAAO,EACP,OAAO,EACP,OAAO,EACP,GAAG,IAAI,CAAA,EAAG,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAA,CAAE,CAC/B;gBACD,GAAG,GAAG,EAAE,GAAG,GAAG,EAAE,GAAG,KAAK,EAAE;YAC5B;QACF;IACF;AAEA,IAAA,OAAO,GAAG;AACZ,CAAC;MAEY,SAAS,GAAS,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,KAC/C,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO;AACzB,SAAS,CAAC,GAAG,GAAG,KAAK;AACrB,SAAS,CAAC,MAAM,GAAG,KAAK;;;;"}
|
package/lib/flatByKey.js
CHANGED
package/lib/flatByKey.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flatByKey.js","sources":["../src/flatByKey.ts"],"sourcesContent":["import type { types } from '@bemedev/types';\nimport { DEFAULT_FLAT_OPTIONS } from './
|
|
1
|
+
{"version":3,"file":"flatByKey.js","sources":["../src/flatByKey.ts"],"sourcesContent":["import type { types } from '@bemedev/types';\nimport { DEFAULT_FLAT_OPTIONS } from './constants';\nimport type { FlatByKey, FlatOptions } from './types.types';\n\ntype Flat_F = <\n T extends types.Ru,\n omit extends types.PickKeysBy<T, object> & string,\n>(\n val: T,\n omitKey: omit,\n options?: FlatOptions,\n) => FlatByKey<T, omit, FlatOptions>;\n\ntype _Flat_F = (\n val: any,\n omitKey: string,\n options?: FlatOptions,\n path?: string,\n) => any;\n\nexport type Flat = Flat_F & {\n strict: Flat_F;\n low: _Flat_F;\n};\n\nconst _flat: _Flat_F = (val, omitKey, options, path = '') => {\n const _options = { ...DEFAULT_FLAT_OPTIONS, ...options };\n const { [omitKey]: recursives, ...rest } = val;\n\n const check = _options.children;\n\n let out: any = {};\n out[path === '' ? _options.sep : path] = check ? val : rest;\n\n if (recursives) {\n for (const key in recursives) {\n if (Object.prototype.hasOwnProperty.call(recursives, key)) {\n const element = recursives[key];\n const inner = _flat(\n element,\n omitKey,\n options,\n `${path}${_options.sep}${key}`,\n );\n out = { ...out, ...inner };\n }\n }\n }\n\n return out;\n};\n\nexport const flatByKey: Flat = (val, key, options) =>\n _flat(val, key, options);\nflatByKey.low = _flat;\nflatByKey.strict = _flat;\n"],"names":[],"mappings":";;AAyBA,MAAM,KAAK,GAAY,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,KAAI;IAC1D,MAAM,QAAQ,GAAG,EAAE,GAAG,oBAAoB,EAAE,GAAG,OAAO,EAAE;AACxD,IAAA,MAAM,EAAE,CAAC,OAAO,GAAG,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG;AAE9C,IAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ;IAE/B,IAAI,GAAG,GAAQ,EAAE;IACjB,GAAG,CAAC,IAAI,KAAK,EAAE,GAAG,QAAQ,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,KAAK,GAAG,GAAG,GAAG,IAAI;IAE3D,IAAI,UAAU,EAAE;AACd,QAAA,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;AAC5B,YAAA,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE;AACzD,gBAAA,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC;gBAC/B,MAAM,KAAK,GAAG,KAAK,CACjB,OAAO,EACP,OAAO,EACP,OAAO,EACP,GAAG,IAAI,CAAA,EAAG,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAA,CAAE,CAC/B;gBACD,GAAG,GAAG,EAAE,GAAG,GAAG,EAAE,GAAG,KAAK,EAAE;YAC5B;QACF;IACF;AAEA,IAAA,OAAO,GAAG;AACZ,CAAC;MAEY,SAAS,GAAS,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,KAC/C,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO;AACzB,SAAS,CAAC,GAAG,GAAG,KAAK;AACrB,SAAS,CAAC,MAAM,GAAG,KAAK;;;;"}
|
package/lib/helpers.cjs
CHANGED
|
@@ -7,17 +7,22 @@ function isPrimitive(arg) {
|
|
|
7
7
|
arg === undefined ||
|
|
8
8
|
arg === null);
|
|
9
9
|
}
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
children: false,
|
|
10
|
+
const isArrayIndex = (segment) => {
|
|
11
|
+
return /^\[\d+\]$/.test(segment);
|
|
13
12
|
};
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const parseIndex = (segment) => {
|
|
14
|
+
return parseInt(segment.slice(1, -1), 10);
|
|
15
|
+
};
|
|
16
|
+
const splitKey = (key) => {
|
|
17
|
+
return key.split('.').filter(s => s !== '');
|
|
18
|
+
};
|
|
19
|
+
const nextDefault = (segment) => {
|
|
20
|
+
return isArrayIndex(segment) ? [] : {};
|
|
18
21
|
};
|
|
19
22
|
|
|
20
|
-
exports.
|
|
21
|
-
exports.DEFAULT_FLAT_OPTIONS = DEFAULT_FLAT_OPTIONS;
|
|
23
|
+
exports.isArrayIndex = isArrayIndex;
|
|
22
24
|
exports.isPrimitive = isPrimitive;
|
|
25
|
+
exports.nextDefault = nextDefault;
|
|
26
|
+
exports.parseIndex = parseIndex;
|
|
27
|
+
exports.splitKey = splitKey;
|
|
23
28
|
//# sourceMappingURL=helpers.cjs.map
|
package/lib/helpers.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.cjs","sources":["../src/helpers.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"helpers.cjs","sources":["../src/helpers.ts"],"sourcesContent":["type Primitive = string | number | boolean | null | undefined;\n\nexport function isPrimitive(arg: unknown): arg is Primitive {\n return (\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'boolean' ||\n arg === undefined ||\n arg === null\n );\n}\n\nexport const isArrayIndex = (segment: string): boolean => {\n return /^\\[\\d+\\]$/.test(segment);\n};\n\nexport const parseIndex = (segment: string): number => {\n return parseInt(segment.slice(1, -1), 10);\n};\n\nexport const splitKey = (key: string): string[] => {\n return key.split('.').filter(s => s !== '');\n};\n\nexport const nextDefault = (segment: string): any => {\n return isArrayIndex(segment) ? [] : {};\n};\n"],"names":[],"mappings":";;AAEM,SAAU,WAAW,CAAC,GAAY,EAAA;AACtC,IAAA,QACE,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAO,GAAG,KAAK,SAAS;AACxB,QAAA,GAAG,KAAK,SAAS;QACjB,GAAG,KAAK,IAAI;AAEhB;AAEO,MAAM,YAAY,GAAG,CAAC,OAAe,KAAa;AACvD,IAAA,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC;AAClC;AAEO,MAAM,UAAU,GAAG,CAAC,OAAe,KAAY;AACpD,IAAA,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;AAC3C;AAEO,MAAM,QAAQ,GAAG,CAAC,GAAW,KAAc;AAChD,IAAA,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;AAC7C;AAEO,MAAM,WAAW,GAAG,CAAC,OAAe,KAAS;AAClD,IAAA,OAAO,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE;AACxC;;;;;;;;"}
|
package/lib/helpers.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
type Primitive = string | number | boolean | null | undefined;
|
|
2
2
|
export declare function isPrimitive(arg: unknown): arg is Primitive;
|
|
3
|
-
export declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare const DEFAULT_DECOMPOSE_OPTIONS: {
|
|
8
|
-
readonly sep: ".";
|
|
9
|
-
readonly object: "key";
|
|
10
|
-
readonly start: true;
|
|
11
|
-
};
|
|
3
|
+
export declare const isArrayIndex: (segment: string) => boolean;
|
|
4
|
+
export declare const parseIndex: (segment: string) => number;
|
|
5
|
+
export declare const splitKey: (key: string) => string[];
|
|
6
|
+
export declare const nextDefault: (segment: string) => any;
|
|
12
7
|
export {};
|
|
13
8
|
//# sourceMappingURL=helpers.d.ts.map
|
package/lib/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAE9D,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,SAAS,CAQ1D;AAED,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,OAE9C,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,KAAG,MAE5C,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,KAAG,MAAM,EAE5C,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,KAAG,GAE7C,CAAC"}
|
package/lib/helpers.js
CHANGED
|
@@ -5,15 +5,18 @@ function isPrimitive(arg) {
|
|
|
5
5
|
arg === undefined ||
|
|
6
6
|
arg === null);
|
|
7
7
|
}
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
children: false,
|
|
8
|
+
const isArrayIndex = (segment) => {
|
|
9
|
+
return /^\[\d+\]$/.test(segment);
|
|
11
10
|
};
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const parseIndex = (segment) => {
|
|
12
|
+
return parseInt(segment.slice(1, -1), 10);
|
|
13
|
+
};
|
|
14
|
+
const splitKey = (key) => {
|
|
15
|
+
return key.split('.').filter(s => s !== '');
|
|
16
|
+
};
|
|
17
|
+
const nextDefault = (segment) => {
|
|
18
|
+
return isArrayIndex(segment) ? [] : {};
|
|
16
19
|
};
|
|
17
20
|
|
|
18
|
-
export {
|
|
21
|
+
export { isArrayIndex, isPrimitive, nextDefault, parseIndex, splitKey };
|
|
19
22
|
//# sourceMappingURL=helpers.js.map
|
package/lib/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../src/helpers.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../src/helpers.ts"],"sourcesContent":["type Primitive = string | number | boolean | null | undefined;\n\nexport function isPrimitive(arg: unknown): arg is Primitive {\n return (\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'boolean' ||\n arg === undefined ||\n arg === null\n );\n}\n\nexport const isArrayIndex = (segment: string): boolean => {\n return /^\\[\\d+\\]$/.test(segment);\n};\n\nexport const parseIndex = (segment: string): number => {\n return parseInt(segment.slice(1, -1), 10);\n};\n\nexport const splitKey = (key: string): string[] => {\n return key.split('.').filter(s => s !== '');\n};\n\nexport const nextDefault = (segment: string): any => {\n return isArrayIndex(segment) ? [] : {};\n};\n"],"names":[],"mappings":"AAEM,SAAU,WAAW,CAAC,GAAY,EAAA;AACtC,IAAA,QACE,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAO,GAAG,KAAK,SAAS;AACxB,QAAA,GAAG,KAAK,SAAS;QACjB,GAAG,KAAK,IAAI;AAEhB;AAEO,MAAM,YAAY,GAAG,CAAC,OAAe,KAAa;AACvD,IAAA,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC;AAClC;AAEO,MAAM,UAAU,GAAG,CAAC,OAAe,KAAY;AACpD,IAAA,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;AAC3C;AAEO,MAAM,QAAQ,GAAG,CAAC,GAAW,KAAc;AAChD,IAAA,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;AAC7C;AAEO,MAAM,WAAW,GAAG,CAAC,OAAe,KAAS;AAClD,IAAA,OAAO,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE;AACxC;;;;"}
|
package/lib/index.cjs
CHANGED
|
@@ -6,7 +6,10 @@ var decomposeSV = require('./decomposeSV.cjs');
|
|
|
6
6
|
var flatByKey = require('./flatByKey.cjs');
|
|
7
7
|
var recompose = require('./recompose.cjs');
|
|
8
8
|
var sortMap = require('./sortMap.cjs');
|
|
9
|
-
var
|
|
9
|
+
var contexts_assign = require('./contexts/assign.cjs');
|
|
10
|
+
var contexts_get = require('./contexts/get.cjs');
|
|
11
|
+
var constants_objects = require('./constants/objects.cjs');
|
|
12
|
+
var constants_strings = require('./constants/strings.cjs');
|
|
10
13
|
|
|
11
14
|
|
|
12
15
|
|
|
@@ -17,6 +20,12 @@ exports.flatByKey = flatByKey.flatByKey;
|
|
|
17
20
|
exports.recompose = recompose.recompose;
|
|
18
21
|
exports.recomposeObjectUrl = recompose.recomposeObjectUrl;
|
|
19
22
|
exports.sortMap = sortMap.sortMap;
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
23
|
+
exports.assignByKey = contexts_assign.assignByKey;
|
|
24
|
+
exports.getByKey = contexts_get.getByKey;
|
|
25
|
+
exports.DEFAULT_DECOMPOSE_OPTIONS = constants_objects.DEFAULT_DECOMPOSE_OPTIONS;
|
|
26
|
+
exports.DEFAULT_FLAT_OPTIONS = constants_objects.DEFAULT_FLAT_OPTIONS;
|
|
27
|
+
exports.DELIMITER = constants_strings.DELIMITER;
|
|
28
|
+
exports.LEFT_BRACKET = constants_strings.LEFT_BRACKET;
|
|
29
|
+
exports.RIGHT_BRACKET = constants_strings.RIGHT_BRACKET;
|
|
30
|
+
exports.SEPARATOR = constants_strings.SEPARATOR;
|
|
22
31
|
//# sourceMappingURL=index.cjs.map
|
package/lib/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/lib/index.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ export * from './flatByKey';
|
|
|
5
5
|
export * from './recompose';
|
|
6
6
|
export * from './sortMap';
|
|
7
7
|
export * from './types.types';
|
|
8
|
-
export
|
|
8
|
+
export * from './contexts';
|
|
9
|
+
export * from './constants';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -4,5 +4,8 @@ export { decomposeSV } from './decomposeSV.js';
|
|
|
4
4
|
export { flatByKey } from './flatByKey.js';
|
|
5
5
|
export { recompose, recomposeObjectUrl } from './recompose.js';
|
|
6
6
|
export { sortMap } from './sortMap.js';
|
|
7
|
-
export {
|
|
7
|
+
export { assignByKey } from './contexts/assign.js';
|
|
8
|
+
export { getByKey } from './contexts/get.js';
|
|
9
|
+
export { DEFAULT_DECOMPOSE_OPTIONS, DEFAULT_FLAT_OPTIONS } from './constants/objects.js';
|
|
10
|
+
export { DELIMITER, LEFT_BRACKET, RIGHT_BRACKET, SEPARATOR } from './constants/strings.js';
|
|
8
11
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
package/lib/types.types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { types } from '@bemedev/types';
|
|
2
|
-
import type { DEFAULT_DECOMPOSE_OPTIONS, DEFAULT_FLAT_OPTIONS } from './
|
|
2
|
+
import type { DEFAULT_DECOMPOSE_OPTIONS, DEFAULT_FLAT_OPTIONS } from './constants';
|
|
3
3
|
export type StateMatching<T extends StateValue, Key = keyof T> = T extends StateValueMap ? Key extends string ? T[Key] extends StateValueMap ? `${Key}.${StateMatching<T[Key]>}` | Key : `${Key}.${T[Key] & string}` | Key : never : T;
|
|
4
4
|
export type KeysMatching<T extends types.TrueObject, AddObjectKeys extends boolean = true, Key extends keyof T = keyof T> = Key extends string ? Required<T[Key]> extends types.TrueObject ? `${Key}.${KeysMatching<Required<T[Key]>, AddObjectKeys> & string}` | (AddObjectKeys extends true ? Key : never) : Key : never;
|
|
5
5
|
export type EmptyObject = {};
|
|
@@ -20,12 +20,21 @@ export type SeparateUndefinedAndRequiredKeys<T> = {
|
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
type WO = 'key' | 'object' | 'both';
|
|
23
|
+
type _DecomposeTupleElement<TK2, sep extends string, wo extends WO, KeyPrefix extends string> = TK2 extends types.AnyArray<infer A> ? number extends TK2['length'] ? // Dynamic array inside tuple element - use UnionToIntersection to preserve template literal keys
|
|
24
|
+
(wo extends 'object' | 'both' ? Record<KeyPrefix, TK2> : EmptyObject) & (A extends Ru ? types.UnionToIntersection<_Decompose<A, sep, wo, `${KeyPrefix}${sep}[${number}]${sep}`>> & (wo extends 'object' | 'both' ? {
|
|
25
|
+
[Key in `${KeyPrefix}${sep}[${number}]`]: A;
|
|
26
|
+
} : EmptyObject) : wo extends 'key' | 'both' ? {
|
|
27
|
+
[Key in `${KeyPrefix}${sep}[${number}]`]: A;
|
|
28
|
+
} : EmptyObject) : // Nested tuple inside tuple element
|
|
29
|
+
_DecomposeTupleRec<TK2, sep, wo, KeyPrefix> & (wo extends 'object' | 'both' ? Record<KeyPrefix, TK2> : EmptyObject) : TK2 extends Ru ? types.UnionToIntersection<_Decompose<TK2, sep, wo, `${KeyPrefix}${sep}`>> & (wo extends 'object' | 'both' ? Record<KeyPrefix, TK2> : EmptyObject) : wo extends 'key' | 'both' ? Record<KeyPrefix, TK2> : EmptyObject;
|
|
30
|
+
type _DecomposeTupleRec<Tk extends readonly unknown[], sep extends string, wo extends WO, Prefix extends string, I extends readonly unknown[] = []> = I['length'] extends Tk['length'] ? EmptyObject : _DecomposeTupleElement<Tk[I['length']], sep, wo, `${Prefix}${sep}[${I['length']}]`> & _DecomposeTupleRec<Tk, sep, wo, Prefix, [...I, unknown]>;
|
|
23
31
|
type _Decompose<T, sep extends string = '.', wo extends WO = 'key', Remaining extends string = ''> = {
|
|
24
|
-
[k in Exclude<keyof T, undefined>]: T[k] extends infer Tk ? types._UnionToIntersection2<Tk extends types.AnyArray<infer A> ? number extends Tk['length'] ? (wo extends 'object' | 'both' ? Record<`${Remaining}${k & string}`, Tk> : EmptyObject) & (wo extends '
|
|
32
|
+
[k in Exclude<keyof T, undefined>]: T[k] extends infer Tk ? types._UnionToIntersection2<Tk extends types.AnyArray<infer A> ? number extends Tk['length'] ? (wo extends 'object' | 'both' ? Record<`${Remaining}${k & string}`, Tk> : EmptyObject) & (A extends Ru ? types.UnionToIntersection<_Decompose<A, sep, wo, `${Remaining}${k & string}${sep}[${number}]${sep}`>> & (wo extends 'object' | 'both' ? {
|
|
25
33
|
[Key in `${Remaining}${k & string}${sep}[${number}]`]: A;
|
|
26
|
-
} : EmptyObject) :
|
|
27
|
-
[Key in
|
|
28
|
-
}
|
|
34
|
+
} : EmptyObject) : wo extends 'key' | 'both' ? {
|
|
35
|
+
[Key in `${Remaining}${k & string}${sep}[${number}]`]: A;
|
|
36
|
+
} : EmptyObject) : // Tuple - use recursive helper that produces intersection directly
|
|
37
|
+
_DecomposeTupleRec<Tk, sep, wo, `${Remaining}${k & string}`> & (wo extends 'object' | 'both' ? Record<`${Remaining}${k & string}`, Tk> : EmptyObject) : Tk extends Ru ? EmptyObject extends Required<Tk> ? Record<`${Remaining}${k & string}`, Tk> : _Decompose<Tk, sep, wo, `${Remaining}${k & string}${sep}`> & (wo extends 'object' | 'both' ? Record<`${Remaining}${k & string}`, Tk> : EmptyObject) : wo extends 'key' | 'both' ? Record<`${Remaining}${k & string}`, Tk> : never> : never;
|
|
29
38
|
}[Exclude<keyof T, undefined>];
|
|
30
39
|
export type DecomposeOptions = {
|
|
31
40
|
sep?: string;
|
|
@@ -33,9 +42,11 @@ export type DecomposeOptions = {
|
|
|
33
42
|
start?: boolean;
|
|
34
43
|
};
|
|
35
44
|
type DefaultDecomposeOptions = typeof DEFAULT_DECOMPOSE_OPTIONS;
|
|
36
|
-
export type Decompose<T, O extends DecomposeOptions = DefaultDecomposeOptions, sep extends string = O['sep'] extends string ? O['sep'] : DefaultDecomposeOptions['sep']> = EmptyObject extends Required<T> ? EmptyObject :
|
|
37
|
-
|
|
38
|
-
} :
|
|
45
|
+
export type Decompose<T, O extends DecomposeOptions = DefaultDecomposeOptions, sep extends string = O['sep'] extends string ? O['sep'] : DefaultDecomposeOptions['sep']> = EmptyObject extends Required<T> ? EmptyObject : T extends types.AnyArray ? types.UnionToIntersection<_Decompose<{
|
|
46
|
+
' ': T;
|
|
47
|
+
}, sep, O['object'] extends WO ? O['object'] : DefaultDecomposeOptions['object'], O['start'] extends infer S extends boolean ? S extends true ? sep : '' : sep>> extends infer P1 ? {
|
|
48
|
+
[K in keyof P1 as K extends `${sep} ${infer P}` ? P extends '' ? never : P : never]: P1[K];
|
|
49
|
+
} : never : types.UnionToIntersection<_Decompose<T, sep, O['object'] extends WO ? O['object'] : DefaultDecomposeOptions['object'], O['start'] extends infer S extends boolean ? S extends true ? sep : '' : sep>> extends infer P ? P : never;
|
|
39
50
|
type _ExcludeFrom<S extends string, T extends string, Delimiter extends string = '.'> = Exclude<S extends `${string}${T}${infer V}` ? _ExcludeFrom<V, T, Delimiter> : S, `${string}${string}${Delimiter}${string}` | ''>;
|
|
40
51
|
export type ExtractEndsFrom<S extends string, T extends string, Delimiter extends string = '.'> = Extract<S, `${string}${Delimiter}${T}${_ExcludeFrom<S, T, Delimiter>}`>;
|
|
41
52
|
export type ExcludeFrom<S extends string, T extends string, Delimiter extends string = '.'> = S extends `${infer P}${Delimiter}${T}${infer V}` ? ExcludeFrom<`${P}${V}`, T, Delimiter> : S;
|
package/lib/types.types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.types.d.ts","sourceRoot":"","sources":["../src/types.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EACV,yBAAyB,EACzB,oBAAoB,EACrB,MAAM,
|
|
1
|
+
{"version":3,"file":"types.types.d.ts","sourceRoot":"","sources":["../src/types.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EACV,yBAAyB,EACzB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,aAAa,CACvB,CAAC,SAAS,UAAU,EACpB,GAAG,GAAG,MAAM,CAAC,IACX,CAAC,SAAS,aAAa,GACvB,GAAG,SAAS,MAAM,GAChB,CAAC,CAAC,GAAG,CAAC,SAAS,aAAa,GAC1B,GAAG,GAAG,IAAI,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,GACvC,GAAG,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,GAAG,GACnC,KAAK,GACP,CAAC,CAAC;AAEN,MAAM,MAAM,YAAY,CACtB,CAAC,SAAS,KAAK,CAAC,UAAU,EAC1B,aAAa,SAAS,OAAO,GAAG,IAAI,EACpC,GAAG,SAAS,MAAM,CAAC,GAAG,MAAM,CAAC,IAC3B,GAAG,SAAS,MAAM,GAClB,QAAQ,CAAC,CAAC,CAAC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T,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemedev/decompose",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Decompose object and so more",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "bri_lvi@icloud.com",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"rinit": "pnpm run rm && pnpm run config",
|
|
45
45
|
"rinit:off": "pnpm run rm && pnpm run config:off",
|
|
46
46
|
"test": "pnpm run test:coverage --no-coverage",
|
|
47
|
-
"test:coverage": "vitest run --passWithNoTests",
|
|
47
|
+
"test:coverage": "pnpm run pretest && vitest run --passWithNoTests && pnpm run posttest",
|
|
48
48
|
"test:watch": "vitest --passWithNoTests",
|
|
49
49
|
"remove": "rm -rf lib node_modules pnpm-lock.yaml",
|
|
50
50
|
"clean": "pnpm run remove && pnpm run config",
|
|
@@ -62,21 +62,21 @@
|
|
|
62
62
|
"@bemedev/vitest-alias": "^0.0.3",
|
|
63
63
|
"@bemedev/vitest-exclude": "^0.1.1",
|
|
64
64
|
"@bemedev/vitest-extended": "^1.5.3",
|
|
65
|
-
"@eslint/eslintrc": "^3.3.
|
|
66
|
-
"@eslint/js": "^
|
|
67
|
-
"@types/node": "^
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
69
|
-
"@typescript-eslint/parser": "^8.
|
|
65
|
+
"@eslint/eslintrc": "^3.3.4",
|
|
66
|
+
"@eslint/js": "^10.0.1",
|
|
67
|
+
"@types/node": "^25.3.0",
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
69
|
+
"@typescript-eslint/parser": "^8.56.1",
|
|
70
70
|
"@vitest/coverage-v8": "^3.2.4",
|
|
71
|
-
"eslint": "^
|
|
72
|
-
"glob": "^13.0.
|
|
73
|
-
"globals": "^
|
|
71
|
+
"eslint": "^10.0.2",
|
|
72
|
+
"glob": "^13.0.6",
|
|
73
|
+
"globals": "^17.3.0",
|
|
74
74
|
"husky": "^9.1.7",
|
|
75
|
-
"immer": "^11.
|
|
75
|
+
"immer": "^11.1.4",
|
|
76
76
|
"onchange": "^7.1.0",
|
|
77
|
-
"prettier": "^3.
|
|
77
|
+
"prettier": "^3.8.1",
|
|
78
78
|
"pretty-quick": "^4.2.2",
|
|
79
|
-
"rollup": "^4.
|
|
79
|
+
"rollup": "^4.59.0",
|
|
80
80
|
"rollup-plugin-tsc-alias": "^1.1.4",
|
|
81
81
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
82
82
|
"tslib": "^2.8.1",
|