entropic-bond 1.36.1 → 1.37.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/LICENSE +21 -0
- package/lib/types/utility-types.d.ts +4 -4
- package/lib/types/utility-types.spec.js +23 -15
- package/lib/types/utility-types.spec.js.map +1 -1
- package/lib/utils/test-utils/test-person.d.ts +15 -0
- package/lib/utils/test-utils/test-person.js +4 -1
- package/lib/utils/test-utils/test-person.js.map +1 -1
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Entropic Bond colaborators
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -27,8 +27,8 @@ export declare type ClassPropNamesOfType<T, U> = {
|
|
|
27
27
|
type Primitive = string | number | bigint | boolean | undefined | symbol;
|
|
28
28
|
type Decr = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
29
29
|
type Concat<T, U> = `${string & T}${string & U}`;
|
|
30
|
-
export type PropPath<T extends {}, MaxDepth extends number =
|
|
31
|
-
[P in keyof T]: T[P] extends Primitive | ArrayLike<any> ? Concat<Prefix, P> : Concat<Prefix, P> | PropPath<T[P], Decr[MaxDepth], `${Concat<Prefix, P>}
|
|
32
|
-
}[keyof T] : never;
|
|
33
|
-
export type PropPathType<T, Path, MaxDepth extends number =
|
|
30
|
+
export type PropPath<T extends {}, AllowedTypes = any, MaxDepth extends number = 3, Prefix = ''> = MaxDepth extends number ? {
|
|
31
|
+
[P in keyof T]: T[P] extends Function ? never : T[P] extends AllowedTypes ? T[P] extends Primitive | ArrayLike<any> ? Concat<Prefix, P> : Concat<Prefix, P> | PropPath<T[P], AllowedTypes, Decr[MaxDepth], `${Concat<Prefix, P>}.`> : never;
|
|
32
|
+
}[keyof T] & string : never;
|
|
33
|
+
export type PropPathType<T, Path, MaxDepth extends number = 2> = MaxDepth extends number ? Path extends keyof T ? T[Path] : Path extends `${infer PropName}.${infer SubPropName}` ? PropName extends keyof T ? PropPathType<T[PropName], SubPropName, Decr[MaxDepth]> : never : never : never;
|
|
34
34
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const test_person_1 = require("../utils/test-utils/test-person");
|
|
4
|
+
const utils_1 = require("../utils/utils");
|
|
4
5
|
const person = (0, test_person_1.samplePerson)();
|
|
5
6
|
/*******************************************************************************
|
|
6
7
|
*
|
|
@@ -19,7 +20,11 @@ const d = 'address.coordinates.nothing';
|
|
|
19
20
|
const e = 'address.nothing.x';
|
|
20
21
|
//@ts-expect-error
|
|
21
22
|
const f = 'nothing.coordinates';
|
|
22
|
-
|
|
23
|
+
//@ts-expect-error
|
|
24
|
+
const g0 = 'testMethod';
|
|
25
|
+
//@ts-expect-error
|
|
26
|
+
const g1 = 'address.senderMethod';
|
|
27
|
+
const h = [
|
|
23
28
|
'name',
|
|
24
29
|
'name.firstName',
|
|
25
30
|
'name.secondName',
|
|
@@ -29,21 +34,24 @@ const g = [
|
|
|
29
34
|
'address.coordinates.y',
|
|
30
35
|
'address.postalAddress',
|
|
31
36
|
'age',
|
|
32
|
-
'id'
|
|
37
|
+
'id',
|
|
38
|
+
'deepProp.l1.l2.l3.l4.l5'
|
|
39
|
+
];
|
|
40
|
+
//@ts-expect-error
|
|
41
|
+
const i = 'id';
|
|
42
|
+
const j = [
|
|
43
|
+
'age'
|
|
33
44
|
];
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const addressCoordinatesX = getDeepValue(person, 'address.coordinates.x');
|
|
45
|
-
const addressCoordinatesY = getDeepValue(person, 'address.coordinates.y');
|
|
46
|
-
const addressPostalAddress = getDeepValue(person, 'address.postalAddress');
|
|
45
|
+
const id = (0, utils_1.getDeepValue)(person, 'id');
|
|
46
|
+
const age = (0, utils_1.getDeepValue)(person, 'age');
|
|
47
|
+
const name = (0, utils_1.getDeepValue)(person, 'name');
|
|
48
|
+
const nameFirstName = (0, utils_1.getDeepValue)(person, 'name.firstName');
|
|
49
|
+
const nameSecondName = (0, utils_1.getDeepValue)(person, 'name.secondName');
|
|
50
|
+
const address = (0, utils_1.getDeepValue)(person, 'address');
|
|
51
|
+
const addressCoordinates = (0, utils_1.getDeepValue)(person, 'address.coordinates');
|
|
52
|
+
const addressCoordinatesX = (0, utils_1.getDeepValue)(person, 'address.coordinates.x');
|
|
53
|
+
const addressCoordinatesY = (0, utils_1.getDeepValue)(person, 'address.coordinates.y');
|
|
54
|
+
const addressPostalAddress = (0, utils_1.getDeepValue)(person, 'address.postalAddress');
|
|
47
55
|
it('should compile everything above', () => {
|
|
48
56
|
expect(true).toBeTruthy();
|
|
49
57
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utility-types.spec.js","sourceRoot":"","sources":["../../src/types/utility-types.spec.ts"],"names":[],"mappings":";;AACA,iEAA6F;
|
|
1
|
+
{"version":3,"file":"utility-types.spec.js","sourceRoot":"","sources":["../../src/types/utility-types.spec.ts"],"names":[],"mappings":";;AACA,iEAA6F;AAC7F,0CAA6C;AAG7C,MAAM,MAAM,GAAG,IAAA,0BAAY,GAAE,CAAA;AAG7B;;;;iFAIiF;AAEjF,kBAAkB;AAClB,MAAM,CAAC,GAAyB,SAAS,CAAA;AAEzC,kBAAkB;AAClB,MAAM,CAAC,GAAyB,cAAc,CAAA;AAE9C,kBAAkB;AAClB,MAAM,CAAC,GAAyB,iBAAiB,CAAA;AAEjD,kBAAkB;AAClB,MAAM,CAAC,GAAyB,6BAA6B,CAAA;AAE7D,kBAAkB;AAClB,MAAM,CAAC,GAAyB,mBAAmB,CAAA;AAEnD,kBAAkB;AAClB,MAAM,CAAC,GAAyB,qBAAqB,CAAA;AAErD,kBAAkB;AAClB,MAAM,EAAE,GAAyB,YAAY,CAAA;AAE7C,kBAAkB;AAClB,MAAM,EAAE,GAAyB,sBAAsB,CAAA;AAEvD,MAAM,CAAC,GAAmC;IACzC,MAAM;IACN,gBAAgB;IAChB,iBAAiB;IACjB,SAAS;IACT,qBAAqB;IACrB,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;IACvB,KAAK;IACL,IAAI;IACJ,yBAAyB;CACzB,CAAA;AAED,kBAAkB;AAClB,MAAM,CAAC,GAAiC,IAAI,CAAA;AAE5C,MAAM,CAAC,GAAmC;IACzC,KAAK;CACL,CAAA;AAcD,MAAM,EAAE,GAAG,IAAA,oBAAY,EAAE,MAAM,EAAE,IAAI,CAAE,CAAA;AACvC,MAAM,GAAG,GAAG,IAAA,oBAAY,EAAE,MAAM,EAAE,KAAK,CAAE,CAAA;AACzC,MAAM,IAAI,GAAG,IAAA,oBAAY,EAAE,MAAM,EAAE,MAAM,CAAE,CAAA;AAC3C,MAAM,aAAa,GAAG,IAAA,oBAAY,EAAE,MAAM,EAAE,gBAAgB,CAAE,CAAA;AAC9D,MAAM,cAAc,GAAG,IAAA,oBAAY,EAAE,MAAM,EAAE,iBAAiB,CAAE,CAAA;AAChE,MAAM,OAAO,GAAG,IAAA,oBAAY,EAAE,MAAM,EAAE,SAAS,CAAE,CAAA;AACjD,MAAM,kBAAkB,GAAG,IAAA,oBAAY,EAAE,MAAM,EAAE,qBAAqB,CAAE,CAAA;AACxE,MAAM,mBAAmB,GAAG,IAAA,oBAAY,EAAE,MAAM,EAAE,uBAAuB,CAAE,CAAA;AAC3E,MAAM,mBAAmB,GAAG,IAAA,oBAAY,EAAE,MAAM,EAAE,uBAAuB,CAAE,CAAA;AAC3E,MAAM,oBAAoB,GAAG,IAAA,oBAAY,EAAE,MAAM,EAAE,uBAAuB,CAAE,CAAA;AAe5E,EAAE,CAAC,iCAAiC,EAAC,GAAE,EAAE;IACxC,MAAM,CAAE,IAAI,CAAE,CAAC,UAAU,EAAE,CAAA;AAC5B,CAAC,CAAC,CAAA"}
|
|
@@ -13,6 +13,21 @@ export interface TestPerson {
|
|
|
13
13
|
address: {
|
|
14
14
|
coordinates: Coordinates;
|
|
15
15
|
postalAddress: string;
|
|
16
|
+
senderMethod: () => void;
|
|
17
|
+
};
|
|
18
|
+
testMethod: () => void;
|
|
19
|
+
deepProp: {
|
|
20
|
+
l1: {
|
|
21
|
+
l2: {
|
|
22
|
+
l3: {
|
|
23
|
+
l4: {
|
|
24
|
+
l5: {
|
|
25
|
+
l6: {};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
16
31
|
};
|
|
17
32
|
}
|
|
18
33
|
export declare function samplePerson(): TestPerson;
|
|
@@ -14,8 +14,11 @@ function samplePerson() {
|
|
|
14
14
|
x: 10,
|
|
15
15
|
y: 20
|
|
16
16
|
},
|
|
17
|
-
postalAddress: 'Madison Av.'
|
|
17
|
+
postalAddress: 'Madison Av.',
|
|
18
|
+
senderMethod() { }
|
|
18
19
|
},
|
|
20
|
+
testMethod() { },
|
|
21
|
+
deepProp: { l1: { l2: { l3: { l4: { l5: { l6: {} } } } } } }
|
|
19
22
|
});
|
|
20
23
|
}
|
|
21
24
|
exports.samplePerson = samplePerson;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-person.js","sourceRoot":"","sources":["../../../src/utils/test-utils/test-person.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"test-person.js","sourceRoot":"","sources":["../../../src/utils/test-utils/test-person.ts"],"names":[],"mappings":";;;AAuBA,SAAgB,YAAY;IAC3B,OAAO,CAAC;QACP,EAAE,EAAE,cAAc;QAClB,GAAG,EAAE,EAAE;QACP,IAAI,EAAE;YACL,SAAS,EAAE,KAAK;YAChB,UAAU,EAAE,SAAS;SACrB;QACD,OAAO,EAAE;YACR,WAAW,EAAE;gBACZ,CAAC,EAAE,EAAE;gBACL,CAAC,EAAE,EAAE;aACL;YACD,aAAa,EAAE,aAAa;YAC5B,YAAY,KAAG,CAAC;SAChB;QACD,UAAU,KAAG,CAAC;QACd,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAC,EAAC,EAAC,EAAC,EAAC,EAAC;KACtD,CAAC,CAAA;AACH,CAAC;AAnBD,oCAmBC"}
|