@bemedev/typings 0.1.0 → 0.2.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.
Files changed (49) hide show
  1. package/README.md +8 -7
  2. package/lib/constants.cjs +9 -2
  3. package/lib/constants.cjs.map +1 -1
  4. package/lib/constants.d.ts +2 -2
  5. package/lib/constants.js +9 -2
  6. package/lib/constants.js.map +1 -1
  7. package/lib/helpers/any.cjs.map +1 -1
  8. package/lib/helpers/any.d.ts +2 -2
  9. package/lib/helpers/any.js.map +1 -1
  10. package/lib/helpers/array.cjs.map +1 -1
  11. package/lib/helpers/array.d.ts +2 -2
  12. package/lib/helpers/array.js.map +1 -1
  13. package/lib/helpers/index.cjs +2 -0
  14. package/lib/helpers/index.d.ts +13 -12
  15. package/lib/helpers/index.js +2 -1
  16. package/lib/helpers/optional.cjs.map +1 -1
  17. package/lib/helpers/optional.d.ts +2 -2
  18. package/lib/helpers/optional.js.map +1 -1
  19. package/lib/helpers/partial.cjs.map +1 -1
  20. package/lib/helpers/partial.d.ts +2 -2
  21. package/lib/helpers/partial.js.map +1 -1
  22. package/lib/helpers/primitiveObject.cjs +10 -0
  23. package/lib/helpers/primitiveObject.cjs.map +1 -0
  24. package/lib/helpers/primitiveObject.d.ts +5 -0
  25. package/lib/helpers/primitiveObject.js +11 -0
  26. package/lib/helpers/primitiveObject.js.map +1 -0
  27. package/lib/helpers/record.cjs.map +1 -1
  28. package/lib/helpers/record.d.ts +2 -2
  29. package/lib/helpers/record.js.map +1 -1
  30. package/lib/helpers/soa.cjs.map +1 -1
  31. package/lib/helpers/soa.d.ts +2 -2
  32. package/lib/helpers/soa.js.map +1 -1
  33. package/lib/helpers/tuple.cjs.map +1 -1
  34. package/lib/helpers/tuple.d.ts +2 -2
  35. package/lib/helpers/tuple.js.map +1 -1
  36. package/lib/helpers/union.cjs.map +1 -1
  37. package/lib/helpers/union.d.ts +3 -3
  38. package/lib/helpers/union.js.map +1 -1
  39. package/lib/index.cjs +2 -0
  40. package/lib/index.js +2 -1
  41. package/lib/type.d.ts +1 -1
  42. package/lib/type.types.d.ts +4 -3
  43. package/lib/types.d.ts +25 -20
  44. package/lib/utils/expandFn.cjs +2 -0
  45. package/lib/utils/expandFn.cjs.map +1 -1
  46. package/lib/utils/expandFn.d.ts +1 -1
  47. package/lib/utils/expandFn.js +2 -0
  48. package/lib/utils/expandFn.js.map +1 -1
  49. package/package.json +16 -17
package/README.md CHANGED
@@ -5,7 +5,7 @@ Typings by variables
5
5
  ## Usage
6
6
 
7
7
  ```ts
8
- import { type } from '@bemedev/typings';
8
+ import { type } from "@bemedev/typings";
9
9
 
10
10
  const result = type(({ array, optional, intersection }) => ({
11
11
  nodes: optional(
@@ -13,16 +13,16 @@ const result = type(({ array, optional, intersection }) => ({
13
13
  intersection(
14
14
  {
15
15
  position: {
16
- x: 'number',
17
- y: 'number',
16
+ x: "number",
17
+ y: "number",
18
18
  },
19
19
  data: {
20
- label: optional('string'),
21
- content: 'string',
20
+ label: optional("string"),
21
+ content: "string",
22
22
  },
23
- input: 'boolean',
23
+ input: "boolean",
24
24
  },
25
- { id: 'string' },
25
+ { id: "string" },
26
26
  ),
27
27
  ),
28
28
  ),
@@ -49,6 +49,7 @@ expectTypeOf(result).toEqualTypeOf<{
49
49
  - `litterals`: Literal types
50
50
  - `optional`: Optional types
51
51
  - `partial`: Partial types
52
+ - `primitiveObject`: Primitive object schema
52
53
  - `record`: Record types
53
54
  - `soa`: Single or Array types
54
55
  - `sv`: State Value
package/lib/constants.cjs CHANGED
@@ -7,9 +7,16 @@ const PRIMITIVES = [
7
7
  "bigint",
8
8
  "symbol",
9
9
  "undefined",
10
- "null"
10
+ "null",
11
+ "unknown",
12
+ "never",
13
+ "primitive"
14
+ ];
15
+ const PRIMITIVE_OBJECTS = [
16
+ "date",
17
+ "any",
18
+ "object"
11
19
  ];
12
- const PRIMITIVE_OBJECTS = ["date", "primitive"];
13
20
  const OPTIONAL = "$$app-ts => optional$$";
14
21
  const CUSTOM = "$$app-ts => custom$$";
15
22
  const PARTIAL = "$$app-ts => partial$$";
@@ -1 +1 @@
1
- {"version":3,"file":"constants.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["export const PRIMITIVES = [\n 'string',\n 'number',\n 'boolean',\n 'bigint',\n 'symbol',\n 'undefined',\n 'null',\n] as const;\n\nexport const PRIMITIVE_OBJECTS = ['date', 'primitive'] as const;\nexport const OPTIONAL = '$$app-ts => optional$$' as const;\nexport const CUSTOM = '$$app-ts => custom$$' as const;\nexport const PARTIAL = '$$app-ts => partial$$' as const;\nexport const ARRAY = '$$app-ts => array$$' as const;\nexport const SOA = '$$app-ts => soa$$' as const;\n"],"mappings":";;AAAA,MAAa,aAAa;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,oBAAoB,CAAC,QAAQ,YAAY;AACtD,MAAa,WAAW;AACxB,MAAa,SAAS;AACtB,MAAa,UAAU;AACvB,MAAa,QAAQ;AACrB,MAAa,MAAM"}
1
+ {"version":3,"file":"constants.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["export const PRIMITIVES = [\n \"string\",\n \"number\",\n \"boolean\",\n \"bigint\",\n \"symbol\",\n \"undefined\",\n \"null\",\n \"unknown\",\n \"never\",\n \"primitive\",\n] as const;\n\nexport const PRIMITIVE_OBJECTS = [\"date\", \"any\", \"object\"] as const;\nexport const OPTIONAL = \"$$app-ts => optional$$\" as const;\nexport const CUSTOM = \"$$app-ts => custom$$\" as const;\nexport const PARTIAL = \"$$app-ts => partial$$\" as const;\nexport const ARRAY = \"$$app-ts => array$$\" as const;\nexport const SOA = \"$$app-ts => soa$$\" as const;\n"],"mappings":";;AAAA,MAAa,aAAa;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,oBAAoB;CAAC;CAAQ;CAAO;CAAS;AAC1D,MAAa,WAAW;AACxB,MAAa,SAAS;AACtB,MAAa,UAAU;AACvB,MAAa,QAAQ;AACrB,MAAa,MAAM"}
@@ -1,5 +1,5 @@
1
- export declare const PRIMITIVES: readonly ["string", "number", "boolean", "bigint", "symbol", "undefined", "null"];
2
- export declare const PRIMITIVE_OBJECTS: readonly ["date", "primitive"];
1
+ export declare const PRIMITIVES: readonly ["string", "number", "boolean", "bigint", "symbol", "undefined", "null", "unknown", "never", "primitive"];
2
+ export declare const PRIMITIVE_OBJECTS: readonly ["date", "any", "object"];
3
3
  export declare const OPTIONAL: "$$app-ts => optional$$";
4
4
  export declare const CUSTOM: "$$app-ts => custom$$";
5
5
  export declare const PARTIAL: "$$app-ts => partial$$";
package/lib/constants.js CHANGED
@@ -6,9 +6,16 @@ const PRIMITIVES = [
6
6
  "bigint",
7
7
  "symbol",
8
8
  "undefined",
9
- "null"
9
+ "null",
10
+ "unknown",
11
+ "never",
12
+ "primitive"
13
+ ];
14
+ const PRIMITIVE_OBJECTS = [
15
+ "date",
16
+ "any",
17
+ "object"
10
18
  ];
11
- const PRIMITIVE_OBJECTS = ["date", "primitive"];
12
19
  const OPTIONAL = "$$app-ts => optional$$";
13
20
  const CUSTOM = "$$app-ts => custom$$";
14
21
  const PARTIAL = "$$app-ts => partial$$";
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["export const PRIMITIVES = [\n 'string',\n 'number',\n 'boolean',\n 'bigint',\n 'symbol',\n 'undefined',\n 'null',\n] as const;\n\nexport const PRIMITIVE_OBJECTS = ['date', 'primitive'] as const;\nexport const OPTIONAL = '$$app-ts => optional$$' as const;\nexport const CUSTOM = '$$app-ts => custom$$' as const;\nexport const PARTIAL = '$$app-ts => partial$$' as const;\nexport const ARRAY = '$$app-ts => array$$' as const;\nexport const SOA = '$$app-ts => soa$$' as const;\n"],"mappings":";AAAA,MAAa,aAAa;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,oBAAoB,CAAC,QAAQ,YAAY;AACtD,MAAa,WAAW;AACxB,MAAa,SAAS;AACtB,MAAa,UAAU;AACvB,MAAa,QAAQ;AACrB,MAAa,MAAM"}
1
+ {"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["export const PRIMITIVES = [\n \"string\",\n \"number\",\n \"boolean\",\n \"bigint\",\n \"symbol\",\n \"undefined\",\n \"null\",\n \"unknown\",\n \"never\",\n \"primitive\",\n] as const;\n\nexport const PRIMITIVE_OBJECTS = [\"date\", \"any\", \"object\"] as const;\nexport const OPTIONAL = \"$$app-ts => optional$$\" as const;\nexport const CUSTOM = \"$$app-ts => custom$$\" as const;\nexport const PARTIAL = \"$$app-ts => partial$$\" as const;\nexport const ARRAY = \"$$app-ts => array$$\" as const;\nexport const SOA = \"$$app-ts => soa$$\" as const;\n"],"mappings":";AAAA,MAAa,aAAa;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,oBAAoB;CAAC;CAAQ;CAAO;CAAS;AAC1D,MAAa,WAAW;AACxB,MAAa,SAAS;AACtB,MAAa,UAAU;AACvB,MAAa,QAAQ;AACrB,MAAa,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"any.cjs","names":[],"sources":["../../src/helpers/any.ts"],"sourcesContent":["import type { ObjectS } from '../types';\n\nconst any = <T extends ObjectS = ObjectS>(value?: T) => value as T;\nexport default any;\n"],"mappings":";AAEA,MAAM,OAAoC,UAAc"}
1
+ {"version":3,"file":"any.cjs","names":[],"sources":["../../src/helpers/any.ts"],"sourcesContent":["import type { ObjectT } from \"../types\";\n\nconst any = <T extends ObjectT = ObjectT>(value?: T) =>\n value as ObjectT extends T ? \"any\" : T;\nexport default any;\n"],"mappings":";AAEA,MAAM,OAAoC,UACxC"}
@@ -1,3 +1,3 @@
1
- import type { ObjectS } from '../types';
2
- declare const any: <T extends ObjectS = ObjectS>(value?: T) => T;
1
+ import type { ObjectT } from "../types";
2
+ declare const any: <T extends ObjectT = ObjectT>(value?: T) => ObjectT extends T ? "any" : T;
3
3
  export default any;
@@ -1 +1 @@
1
- {"version":3,"file":"any.js","names":[],"sources":["../../src/helpers/any.ts"],"sourcesContent":["import type { ObjectS } from '../types';\n\nconst any = <T extends ObjectS = ObjectS>(value?: T) => value as T;\nexport default any;\n"],"mappings":";AAEA,MAAM,OAAoC,UAAc"}
1
+ {"version":3,"file":"any.js","names":[],"sources":["../../src/helpers/any.ts"],"sourcesContent":["import type { ObjectT } from \"../types\";\n\nconst any = <T extends ObjectT = ObjectT>(value?: T) =>\n value as ObjectT extends T ? \"any\" : T;\nexport default any;\n"],"mappings":";AAEA,MAAM,OAAoC,UACxC"}
@@ -1 +1 @@
1
- {"version":3,"file":"array.cjs","names":["ARRAY"],"sources":["../../src/helpers/array.ts"],"sourcesContent":["import { ARRAY } from '../constants';\nimport type { ArrayCustom, NotReadonly, ObjectS } from '../types';\n\nconst array = <const T extends ObjectS>(value: T) => {\n type Out = ArrayCustom<Extract<NotReadonly<T>, ObjectS>>;\n\n return { [ARRAY]: value } as Out;\n};\n\nexport default array;\n"],"mappings":";;AAGA,MAAM,SAAkC,UAAa;AAGnD,QAAO,GAAGA,kBAAAA,QAAQ,OAAO"}
1
+ {"version":3,"file":"array.cjs","names":["ARRAY"],"sources":["../../src/helpers/array.ts"],"sourcesContent":["import { ARRAY } from \"../constants\";\nimport type { ArrayCustom, NotReadonly, ObjectT } from \"../types\";\n\nconst array = <const T extends ObjectT>(value: T) => {\n type Out = ArrayCustom<Extract<NotReadonly<T>, ObjectT>>;\n\n return { [ARRAY]: value } as Out;\n};\n\nexport default array;\n"],"mappings":";;AAGA,MAAM,SAAkC,UAAa;AAGnD,QAAO,GAAGA,kBAAAA,QAAQ,OAAO"}
@@ -1,3 +1,3 @@
1
- import type { ArrayCustom, NotReadonly, ObjectS } from '../types';
2
- declare const array: <const T extends ObjectS>(value: T) => ArrayCustom<Extract<NotReadonly<T>, ObjectS>>;
1
+ import type { ArrayCustom, NotReadonly, ObjectT } from "../types";
2
+ declare const array: <const T extends ObjectT>(value: T) => ArrayCustom<Extract<NotReadonly<T>, ObjectT>>;
3
3
  export default array;
@@ -1 +1 @@
1
- {"version":3,"file":"array.js","names":[],"sources":["../../src/helpers/array.ts"],"sourcesContent":["import { ARRAY } from '../constants';\nimport type { ArrayCustom, NotReadonly, ObjectS } from '../types';\n\nconst array = <const T extends ObjectS>(value: T) => {\n type Out = ArrayCustom<Extract<NotReadonly<T>, ObjectS>>;\n\n return { [ARRAY]: value } as Out;\n};\n\nexport default array;\n"],"mappings":";;AAGA,MAAM,SAAkC,UAAa;AAGnD,QAAO,GAAG,QAAQ,OAAO"}
1
+ {"version":3,"file":"array.js","names":[],"sources":["../../src/helpers/array.ts"],"sourcesContent":["import { ARRAY } from \"../constants\";\nimport type { ArrayCustom, NotReadonly, ObjectT } from \"../types\";\n\nconst array = <const T extends ObjectT>(value: T) => {\n type Out = ArrayCustom<Extract<NotReadonly<T>, ObjectT>>;\n\n return { [ARRAY]: value } as Out;\n};\n\nexport default array;\n"],"mappings":";;AAGA,MAAM,SAAkC,UAAa;AAGnD,QAAO,GAAG,QAAQ,OAAO"}
@@ -11,6 +11,7 @@ const require_helpers_soa = require("./soa.cjs");
11
11
  const require_helpers_sv = require("./sv.cjs");
12
12
  const require_helpers_tuple = require("./tuple.cjs");
13
13
  const require_helpers_union = require("./union.cjs");
14
+ const require_helpers_primitiveObject = require("./primitiveObject.cjs");
14
15
  exports.any = require_helpers_any;
15
16
  exports.array = require_helpers_array;
16
17
  exports.custom = require_helpers_custom;
@@ -18,6 +19,7 @@ exports.intersection = require_helpers_intersection;
18
19
  exports.litterals = require_helpers_litterals;
19
20
  exports.optional = require_helpers_optional;
20
21
  exports.partial = require_helpers_partial;
22
+ exports.primitiveObject = require_helpers_primitiveObject;
21
23
  exports.record = require_helpers_record;
22
24
  exports.soa = require_helpers_soa;
23
25
  exports.sv = require_helpers_sv;
@@ -1,12 +1,13 @@
1
- export { default as any } from './any';
2
- export { default as array } from './array';
3
- export { default as custom } from './custom';
4
- export { default as intersection } from './intersection';
5
- export { default as litterals } from './litterals';
6
- export { default as optional } from './optional';
7
- export { default as partial } from './partial';
8
- export { default as record } from './record';
9
- export { default as soa } from './soa';
10
- export { default as sv } from './sv';
11
- export { default as tuple } from './tuple';
12
- export { default as union } from './union';
1
+ export { default as any } from "./any";
2
+ export { default as array } from "./array";
3
+ export { default as custom } from "./custom";
4
+ export { default as intersection } from "./intersection";
5
+ export { default as litterals } from "./litterals";
6
+ export { default as optional } from "./optional";
7
+ export { default as partial } from "./partial";
8
+ export { default as record } from "./record";
9
+ export { default as soa } from "./soa";
10
+ export { default as sv } from "./sv";
11
+ export { default as tuple } from "./tuple";
12
+ export { default as union } from "./union";
13
+ export { default as primitiveObject } from "./primitiveObject";
@@ -10,4 +10,5 @@ import soa from "./soa.js";
10
10
  import sv from "./sv.js";
11
11
  import tuple from "./tuple.js";
12
12
  import fn from "./union.js";
13
- export { any, array, custom, intersection, litterals, optional, partial, record, soa, sv, tuple, fn as union };
13
+ import primitiveObject from "./primitiveObject.js";
14
+ export { any, array, custom, intersection, litterals, optional, partial, primitiveObject, record, soa, sv, tuple, fn as union };
@@ -1 +1 @@
1
- {"version":3,"file":"optional.cjs","names":["OPTIONAL"],"sources":["../../src/helpers/optional.ts"],"sourcesContent":["import { OPTIONAL } from '../constants';\nimport type { __ObjectS, AnyArray, ArrayCustom, Optional } from '../types';\n\nconst optional = <T extends __ObjectS | ArrayCustom | AnyArray<__ObjectS>>(\n value?: T,\n) =>\n ({\n [OPTIONAL]: value,\n }) as Optional<T>;\n\nexport default optional;\n"],"mappings":";;AAGA,MAAM,YACJ,WAEC,GACEA,kBAAAA,WAAW,OACb"}
1
+ {"version":3,"file":"optional.cjs","names":["OPTIONAL"],"sources":["../../src/helpers/optional.ts"],"sourcesContent":["import { OPTIONAL } from \"../constants\";\nimport type { __ObjectT, AnyArray, ArrayCustom, Optional } from \"../types\";\n\nconst optional = <T extends __ObjectT | ArrayCustom | AnyArray<__ObjectT>>(\n value?: T,\n) =>\n ({\n [OPTIONAL]: value,\n }) as Optional<T>;\n\nexport default optional;\n"],"mappings":";;AAGA,MAAM,YACJ,WAEC,GACEA,kBAAAA,WAAW,OACb"}
@@ -1,3 +1,3 @@
1
- import type { __ObjectS, AnyArray, ArrayCustom, Optional } from '../types';
2
- declare const optional: <T extends __ObjectS | ArrayCustom | AnyArray<__ObjectS>>(value?: T) => Optional<T>;
1
+ import type { __ObjectT, AnyArray, ArrayCustom, Optional } from "../types";
2
+ declare const optional: <T extends __ObjectT | ArrayCustom | AnyArray<__ObjectT>>(value?: T) => Optional<T>;
3
3
  export default optional;
@@ -1 +1 @@
1
- {"version":3,"file":"optional.js","names":[],"sources":["../../src/helpers/optional.ts"],"sourcesContent":["import { OPTIONAL } from '../constants';\nimport type { __ObjectS, AnyArray, ArrayCustom, Optional } from '../types';\n\nconst optional = <T extends __ObjectS | ArrayCustom | AnyArray<__ObjectS>>(\n value?: T,\n) =>\n ({\n [OPTIONAL]: value,\n }) as Optional<T>;\n\nexport default optional;\n"],"mappings":";;AAGA,MAAM,YACJ,WAEC,GACE,WAAW,OACb"}
1
+ {"version":3,"file":"optional.js","names":[],"sources":["../../src/helpers/optional.ts"],"sourcesContent":["import { OPTIONAL } from \"../constants\";\nimport type { __ObjectT, AnyArray, ArrayCustom, Optional } from \"../types\";\n\nconst optional = <T extends __ObjectT | ArrayCustom | AnyArray<__ObjectT>>(\n value?: T,\n) =>\n ({\n [OPTIONAL]: value,\n }) as Optional<T>;\n\nexport default optional;\n"],"mappings":";;AAGA,MAAM,YACJ,WAEC,GACE,WAAW,OACb"}
@@ -1 +1 @@
1
- {"version":3,"file":"partial.cjs","names":["PARTIAL"],"sources":["../../src/helpers/partial.ts"],"sourcesContent":["import { PARTIAL } from '../constants';\nimport type { ObjectS, PartialCustom } from '../types';\n\nconst partial = <T extends ObjectS>(value: T): T & PartialCustom => {\n const entries = Object.entries(value).filter(([key]) => key !== PARTIAL);\n const out: any = {};\n\n entries.forEach(([key, value]) => {\n out[key] = value;\n });\n\n return out;\n};\n\nexport default partial;\n"],"mappings":";;AAGA,MAAM,WAA8B,UAAgC;CAClE,MAAM,UAAU,OAAO,QAAQ,MAAM,CAAC,QAAQ,CAAC,SAAS,QAAQA,kBAAAA,QAAQ;CACxE,MAAM,MAAW,EAAE;AAEnB,SAAQ,SAAS,CAAC,KAAK,WAAW;AAChC,MAAI,OAAO;GACX;AAEF,QAAO"}
1
+ {"version":3,"file":"partial.cjs","names":["PARTIAL"],"sources":["../../src/helpers/partial.ts"],"sourcesContent":["import { PARTIAL } from \"../constants\";\nimport type { ObjectT, PartialCustom } from \"../types\";\n\nconst partial = <T extends ObjectT>(value: T): T & PartialCustom => {\n const entries = Object.entries(value).filter(([key]) => key !== PARTIAL);\n const out: any = {};\n\n entries.forEach(([key, value]) => {\n out[key] = value;\n });\n\n return out;\n};\n\nexport default partial;\n"],"mappings":";;AAGA,MAAM,WAA8B,UAAgC;CAClE,MAAM,UAAU,OAAO,QAAQ,MAAM,CAAC,QAAQ,CAAC,SAAS,QAAQA,kBAAAA,QAAQ;CACxE,MAAM,MAAW,EAAE;AAEnB,SAAQ,SAAS,CAAC,KAAK,WAAW;AAChC,MAAI,OAAO;GACX;AAEF,QAAO"}
@@ -1,3 +1,3 @@
1
- import type { ObjectS, PartialCustom } from '../types';
2
- declare const partial: <T extends ObjectS>(value: T) => T & PartialCustom;
1
+ import type { ObjectT, PartialCustom } from "../types";
2
+ declare const partial: <T extends ObjectT>(value: T) => T & PartialCustom;
3
3
  export default partial;
@@ -1 +1 @@
1
- {"version":3,"file":"partial.js","names":[],"sources":["../../src/helpers/partial.ts"],"sourcesContent":["import { PARTIAL } from '../constants';\nimport type { ObjectS, PartialCustom } from '../types';\n\nconst partial = <T extends ObjectS>(value: T): T & PartialCustom => {\n const entries = Object.entries(value).filter(([key]) => key !== PARTIAL);\n const out: any = {};\n\n entries.forEach(([key, value]) => {\n out[key] = value;\n });\n\n return out;\n};\n\nexport default partial;\n"],"mappings":";;AAGA,MAAM,WAA8B,UAAgC;CAClE,MAAM,UAAU,OAAO,QAAQ,MAAM,CAAC,QAAQ,CAAC,SAAS,QAAQ,QAAQ;CACxE,MAAM,MAAW,EAAE;AAEnB,SAAQ,SAAS,CAAC,KAAK,WAAW;AAChC,MAAI,OAAO;GACX;AAEF,QAAO"}
1
+ {"version":3,"file":"partial.js","names":[],"sources":["../../src/helpers/partial.ts"],"sourcesContent":["import { PARTIAL } from \"../constants\";\nimport type { ObjectT, PartialCustom } from \"../types\";\n\nconst partial = <T extends ObjectT>(value: T): T & PartialCustom => {\n const entries = Object.entries(value).filter(([key]) => key !== PARTIAL);\n const out: any = {};\n\n entries.forEach(([key, value]) => {\n out[key] = value;\n });\n\n return out;\n};\n\nexport default partial;\n"],"mappings":";;AAGA,MAAM,WAA8B,UAAgC;CAClE,MAAM,UAAU,OAAO,QAAQ,MAAM,CAAC,QAAQ,CAAC,SAAS,QAAQ,QAAQ;CACxE,MAAM,MAAW,EAAE;AAEnB,SAAQ,SAAS,CAAC,KAAK,WAAW;AAChC,MAAI,OAAO;GACX;AAEF,QAAO"}
@@ -0,0 +1,10 @@
1
+ //#region src/helpers/primitiveObject.ts
2
+ const primitiveObject = require("../utils/expandFn.cjs").expandFn((value) => {
3
+ return value || {};
4
+ }, { map: (value) => {
5
+ return value || {};
6
+ } });
7
+ //#endregion
8
+ module.exports = primitiveObject;
9
+
10
+ //# sourceMappingURL=primitiveObject.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitiveObject.cjs","names":["expandFn"],"sources":["../../src/helpers/primitiveObject.ts"],"sourcesContent":["import type {\n NotReadonly,\n PrimitiveObjectMapS,\n PrimitiveObjectT,\n} from \"../types\";\nimport { expandFn } from \"../utils/expandFn\";\n\nconst primitiveObject = expandFn(\n <const T extends PrimitiveObjectT = PrimitiveObjectT>(\n value?: T,\n ): Exclude<NotReadonly<T>, undefined> => {\n return (value || {}) as any;\n },\n {\n map: <const T extends PrimitiveObjectMapS = PrimitiveObjectMapS>(\n value?: T,\n ): Exclude<NotReadonly<T>, undefined> => {\n return (value || {}) as any;\n },\n },\n);\n\nexport default primitiveObject;\n"],"mappings":";AAOA,MAAM,mDAAkBA,UAEpB,UACuC;AACvC,QAAQ,SAAS,EAAE;GAErB,EACE,MACE,UACuC;AACvC,QAAQ,SAAS,EAAE;GAEtB,CACF"}
@@ -0,0 +1,5 @@
1
+ import type { NotReadonly, PrimitiveObjectMapS, PrimitiveObjectT } from "../types";
2
+ declare const primitiveObject: import("..").FnBasic<(<const T extends PrimitiveObjectT = PrimitiveObjectT>(value?: T) => Exclude<NotReadonly<T>, undefined>), {
3
+ readonly map: <const T extends PrimitiveObjectMapS = PrimitiveObjectMapS>(value?: T) => Exclude<NotReadonly<T>, undefined>;
4
+ }>;
5
+ export default primitiveObject;
@@ -0,0 +1,11 @@
1
+ import { expandFn } from "../utils/expandFn.js";
2
+ //#region src/helpers/primitiveObject.ts
3
+ const primitiveObject = expandFn((value) => {
4
+ return value || {};
5
+ }, { map: (value) => {
6
+ return value || {};
7
+ } });
8
+ //#endregion
9
+ export { primitiveObject as default };
10
+
11
+ //# sourceMappingURL=primitiveObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitiveObject.js","names":[],"sources":["../../src/helpers/primitiveObject.ts"],"sourcesContent":["import type {\n NotReadonly,\n PrimitiveObjectMapS,\n PrimitiveObjectT,\n} from \"../types\";\nimport { expandFn } from \"../utils/expandFn\";\n\nconst primitiveObject = expandFn(\n <const T extends PrimitiveObjectT = PrimitiveObjectT>(\n value?: T,\n ): Exclude<NotReadonly<T>, undefined> => {\n return (value || {}) as any;\n },\n {\n map: <const T extends PrimitiveObjectMapS = PrimitiveObjectMapS>(\n value?: T,\n ): Exclude<NotReadonly<T>, undefined> => {\n return (value || {}) as any;\n },\n },\n);\n\nexport default primitiveObject;\n"],"mappings":";;AAOA,MAAM,kBAAkB,UAEpB,UACuC;AACvC,QAAQ,SAAS,EAAE;GAErB,EACE,MACE,UACuC;AACvC,QAAQ,SAAS,EAAE;GAEtB,CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"record.cjs","names":[],"sources":["../../src/helpers/record.ts"],"sourcesContent":["import type { Keys, ObjectS } from '../types';\n\nconst record = <const K extends Keys[], V extends ObjectS>(\n value: V,\n ...keys: K\n) => {\n const object = keys.reduce((acc, key) => {\n acc[key] = value;\n return acc;\n }, {} as any);\n\n return object as Record<K[number] extends never ? Keys : K[number], V>;\n};\n\nexport default record;\n"],"mappings":";AAEA,MAAM,UACJ,OACA,GAAG,SACA;AAMH,QALe,KAAK,QAAQ,KAAK,QAAQ;AACvC,MAAI,OAAO;AACX,SAAO;IACN,EAAE,CAAQ"}
1
+ {"version":3,"file":"record.cjs","names":[],"sources":["../../src/helpers/record.ts"],"sourcesContent":["import type { Keys, ObjectT } from \"../types\";\n\nconst record = <const K extends Keys[], V extends ObjectT>(\n value: V,\n ...keys: K\n) => {\n const object = keys.reduce((acc, key) => {\n acc[key] = value;\n return acc;\n }, {} as any);\n\n return object as Record<K[number] extends never ? Keys : K[number], V>;\n};\n\nexport default record;\n"],"mappings":";AAEA,MAAM,UACJ,OACA,GAAG,SACA;AAMH,QALe,KAAK,QAAQ,KAAK,QAAQ;AACvC,MAAI,OAAO;AACX,SAAO;IACN,EAAE,CAAQ"}
@@ -1,3 +1,3 @@
1
- import type { Keys, ObjectS } from '../types';
2
- declare const record: <const K extends Keys[], V extends ObjectS>(value: V, ...keys: K) => Record<K[number] extends never ? Keys : K[number], V>;
1
+ import type { Keys, ObjectT } from "../types";
2
+ declare const record: <const K extends Keys[], V extends ObjectT>(value: V, ...keys: K) => Record<K[number] extends never ? Keys : K[number], V>;
3
3
  export default record;
@@ -1 +1 @@
1
- {"version":3,"file":"record.js","names":[],"sources":["../../src/helpers/record.ts"],"sourcesContent":["import type { Keys, ObjectS } from '../types';\n\nconst record = <const K extends Keys[], V extends ObjectS>(\n value: V,\n ...keys: K\n) => {\n const object = keys.reduce((acc, key) => {\n acc[key] = value;\n return acc;\n }, {} as any);\n\n return object as Record<K[number] extends never ? Keys : K[number], V>;\n};\n\nexport default record;\n"],"mappings":";AAEA,MAAM,UACJ,OACA,GAAG,SACA;AAMH,QALe,KAAK,QAAQ,KAAK,QAAQ;AACvC,MAAI,OAAO;AACX,SAAO;IACN,EAAE,CAAQ"}
1
+ {"version":3,"file":"record.js","names":[],"sources":["../../src/helpers/record.ts"],"sourcesContent":["import type { Keys, ObjectT } from \"../types\";\n\nconst record = <const K extends Keys[], V extends ObjectT>(\n value: V,\n ...keys: K\n) => {\n const object = keys.reduce((acc, key) => {\n acc[key] = value;\n return acc;\n }, {} as any);\n\n return object as Record<K[number] extends never ? Keys : K[number], V>;\n};\n\nexport default record;\n"],"mappings":";AAEA,MAAM,UACJ,OACA,GAAG,SACA;AAMH,QALe,KAAK,QAAQ,KAAK,QAAQ;AACvC,MAAI,OAAO;AACX,SAAO;IACN,EAAE,CAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"soa.cjs","names":["SOA"],"sources":["../../src/helpers/soa.ts"],"sourcesContent":["import { SOA } from '../constants';\nimport type { NotReadonly, ObjectS, SoaCustom } from '../types';\n\nconst soa = <const T extends ObjectS>(value: T) => {\n type Out = SoaCustom<Extract<NotReadonly<T>, ObjectS>>;\n return { [SOA]: value } as Out;\n};\n\nexport default soa;\n"],"mappings":";;AAGA,MAAM,OAAgC,UAAa;AAEjD,QAAO,GAAGA,kBAAAA,MAAM,OAAO"}
1
+ {"version":3,"file":"soa.cjs","names":["SOA"],"sources":["../../src/helpers/soa.ts"],"sourcesContent":["import { SOA } from \"../constants\";\nimport type { NotReadonly, ObjectT, SoaCustom } from \"../types\";\n\nconst soa = <const T extends ObjectT>(value: T) => {\n type Out = SoaCustom<Extract<NotReadonly<T>, ObjectT>>;\n return { [SOA]: value } as Out;\n};\n\nexport default soa;\n"],"mappings":";;AAGA,MAAM,OAAgC,UAAa;AAEjD,QAAO,GAAGA,kBAAAA,MAAM,OAAO"}
@@ -1,3 +1,3 @@
1
- import type { NotReadonly, ObjectS, SoaCustom } from '../types';
2
- declare const soa: <const T extends ObjectS>(value: T) => SoaCustom<Extract<NotReadonly<T>, ObjectS>>;
1
+ import type { NotReadonly, ObjectT, SoaCustom } from "../types";
2
+ declare const soa: <const T extends ObjectT>(value: T) => SoaCustom<Extract<NotReadonly<T>, ObjectT>>;
3
3
  export default soa;
@@ -1 +1 @@
1
- {"version":3,"file":"soa.js","names":[],"sources":["../../src/helpers/soa.ts"],"sourcesContent":["import { SOA } from '../constants';\nimport type { NotReadonly, ObjectS, SoaCustom } from '../types';\n\nconst soa = <const T extends ObjectS>(value: T) => {\n type Out = SoaCustom<Extract<NotReadonly<T>, ObjectS>>;\n return { [SOA]: value } as Out;\n};\n\nexport default soa;\n"],"mappings":";;AAGA,MAAM,OAAgC,UAAa;AAEjD,QAAO,GAAG,MAAM,OAAO"}
1
+ {"version":3,"file":"soa.js","names":[],"sources":["../../src/helpers/soa.ts"],"sourcesContent":["import { SOA } from \"../constants\";\nimport type { NotReadonly, ObjectT, SoaCustom } from \"../types\";\n\nconst soa = <const T extends ObjectT>(value: T) => {\n type Out = SoaCustom<Extract<NotReadonly<T>, ObjectT>>;\n return { [SOA]: value } as Out;\n};\n\nexport default soa;\n"],"mappings":";;AAGA,MAAM,OAAgC,UAAa;AAEjD,QAAO,GAAG,MAAM,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"tuple.cjs","names":[],"sources":["../../src/helpers/tuple.ts"],"sourcesContent":["import type {\n __ObjectS,\n ArrayCustom,\n NotReadonly,\n Optional,\n} from '../types';\n\nconst tuple = <\n const T extends [\n __ObjectS | Optional | ArrayCustom,\n __ObjectS | Optional | ArrayCustom,\n ...(__ObjectS | Optional | ArrayCustom)[],\n ],\n>(\n ...values: T\n) => values as NotReadonly<T>;\n\nexport default tuple;\n"],"mappings":";AAOA,MAAM,SAOJ,GAAG,WACA"}
1
+ {"version":3,"file":"tuple.cjs","names":[],"sources":["../../src/helpers/tuple.ts"],"sourcesContent":["import type { NotReadonly, ObjectT } from \"../types\";\n\nconst tuple = <const T extends [ObjectT, ...ObjectT[]]>(...values: T) =>\n values as NotReadonly<T>;\n\nexport default tuple;\n"],"mappings":";AAEA,MAAM,SAAkD,GAAG,WACzD"}
@@ -1,3 +1,3 @@
1
- import type { __ObjectS, ArrayCustom, NotReadonly, Optional } from '../types';
2
- declare const tuple: <const T extends [__ObjectS | Optional | ArrayCustom, __ObjectS | Optional | ArrayCustom, ...(__ObjectS | Optional | ArrayCustom)[]]>(...values: T) => NotReadonly<T>;
1
+ import type { NotReadonly, ObjectT } from "../types";
2
+ declare const tuple: <const T extends [ObjectT, ...ObjectT[]]>(...values: T) => NotReadonly<T>;
3
3
  export default tuple;
@@ -1 +1 @@
1
- {"version":3,"file":"tuple.js","names":[],"sources":["../../src/helpers/tuple.ts"],"sourcesContent":["import type {\n __ObjectS,\n ArrayCustom,\n NotReadonly,\n Optional,\n} from '../types';\n\nconst tuple = <\n const T extends [\n __ObjectS | Optional | ArrayCustom,\n __ObjectS | Optional | ArrayCustom,\n ...(__ObjectS | Optional | ArrayCustom)[],\n ],\n>(\n ...values: T\n) => values as NotReadonly<T>;\n\nexport default tuple;\n"],"mappings":";AAOA,MAAM,SAOJ,GAAG,WACA"}
1
+ {"version":3,"file":"tuple.js","names":[],"sources":["../../src/helpers/tuple.ts"],"sourcesContent":["import type { NotReadonly, ObjectT } from \"../types\";\n\nconst tuple = <const T extends [ObjectT, ...ObjectT[]]>(...values: T) =>\n values as NotReadonly<T>;\n\nexport default tuple;\n"],"mappings":";AAEA,MAAM,SAAkD,GAAG,WACzD"}
@@ -1 +1 @@
1
- {"version":3,"file":"union.cjs","names":["expandFn"],"sources":["../../src/helpers/union.ts"],"sourcesContent":["import type { Keys, ObjectMapS, ObjectS } from '../types';\nimport { expandFn } from '../utils/expandFn';\n\nconst union = <T extends [ObjectS, ObjectS, ...ObjectS[]]>(\n ...values: T\n) => {\n return values[0] as T[number];\n};\n\ntype Discriminated<K extends Keys> = ObjectMapS & Record<K, ObjectS>;\n\nconst fn = expandFn(union, {\n discriminated: <\n const K extends Keys,\n T extends [Discriminated<K>, Discriminated<K>, ...Discriminated<K>[]],\n >(\n _key: K,\n ...values: T\n ) => union(...values),\n});\n\nexport default fn;\n"],"mappings":";;AAGA,MAAM,SACJ,GAAG,WACA;AACH,QAAO,OAAO;;AAKhB,MAAM,KAAKA,uBAAAA,SAAS,OAAO,EACzB,gBAIE,MACA,GAAG,WACA,MAAM,GAAG,OAAO,EACtB,CAAC"}
1
+ {"version":3,"file":"union.cjs","names":["expandFn"],"sources":["../../src/helpers/union.ts"],"sourcesContent":["import type { Keys, ObjectMapS, ObjectT } from \"../types\";\nimport { expandFn } from \"../utils/expandFn\";\n\nconst union = <T extends [ObjectT, ObjectT, ...ObjectT[]]>(...values: T) => {\n return values[0] as T[number];\n};\n\ntype Discriminated<K extends Keys> = ObjectMapS & Record<K, ObjectT>;\n\nconst fn = expandFn(union, {\n discriminated: <\n const K extends Keys,\n T extends [Discriminated<K>, Discriminated<K>, ...Discriminated<K>[]],\n >(\n _key: K,\n ...values: T\n ) => union(...values),\n});\n\nexport default fn;\n"],"mappings":";;AAGA,MAAM,SAAqD,GAAG,WAAc;AAC1E,QAAO,OAAO;;AAKhB,MAAM,KAAKA,uBAAAA,SAAS,OAAO,EACzB,gBAIE,MACA,GAAG,WACA,MAAM,GAAG,OAAO,EACtB,CAAC"}
@@ -1,6 +1,6 @@
1
- import type { Keys, ObjectMapS, ObjectS } from '../types';
2
- type Discriminated<K extends Keys> = ObjectMapS & Record<K, ObjectS>;
3
- declare const fn: import("..").FnBasic<(<T extends [ObjectS, ObjectS, ...ObjectS[]]>(...values: T) => T[number]), {
1
+ import type { Keys, ObjectMapS, ObjectT } from "../types";
2
+ type Discriminated<K extends Keys> = ObjectMapS & Record<K, ObjectT>;
3
+ declare const fn: import("..").FnBasic<(<T extends [ObjectT, ObjectT, ...ObjectT[]]>(...values: T) => T[number]), {
4
4
  readonly discriminated: <const K extends Keys, T extends [Discriminated<K>, Discriminated<K>, ...Discriminated<K>[]]>(_key: K, ...values: T) => T[number];
5
5
  }>;
6
6
  export default fn;
@@ -1 +1 @@
1
- {"version":3,"file":"union.js","names":[],"sources":["../../src/helpers/union.ts"],"sourcesContent":["import type { Keys, ObjectMapS, ObjectS } from '../types';\nimport { expandFn } from '../utils/expandFn';\n\nconst union = <T extends [ObjectS, ObjectS, ...ObjectS[]]>(\n ...values: T\n) => {\n return values[0] as T[number];\n};\n\ntype Discriminated<K extends Keys> = ObjectMapS & Record<K, ObjectS>;\n\nconst fn = expandFn(union, {\n discriminated: <\n const K extends Keys,\n T extends [Discriminated<K>, Discriminated<K>, ...Discriminated<K>[]],\n >(\n _key: K,\n ...values: T\n ) => union(...values),\n});\n\nexport default fn;\n"],"mappings":";;AAGA,MAAM,SACJ,GAAG,WACA;AACH,QAAO,OAAO;;AAKhB,MAAM,KAAK,SAAS,OAAO,EACzB,gBAIE,MACA,GAAG,WACA,MAAM,GAAG,OAAO,EACtB,CAAC"}
1
+ {"version":3,"file":"union.js","names":[],"sources":["../../src/helpers/union.ts"],"sourcesContent":["import type { Keys, ObjectMapS, ObjectT } from \"../types\";\nimport { expandFn } from \"../utils/expandFn\";\n\nconst union = <T extends [ObjectT, ObjectT, ...ObjectT[]]>(...values: T) => {\n return values[0] as T[number];\n};\n\ntype Discriminated<K extends Keys> = ObjectMapS & Record<K, ObjectT>;\n\nconst fn = expandFn(union, {\n discriminated: <\n const K extends Keys,\n T extends [Discriminated<K>, Discriminated<K>, ...Discriminated<K>[]],\n >(\n _key: K,\n ...values: T\n ) => union(...values),\n});\n\nexport default fn;\n"],"mappings":";;AAGA,MAAM,SAAqD,GAAG,WAAc;AAC1E,QAAO,OAAO;;AAKhB,MAAM,KAAK,SAAS,OAAO,EACzB,gBAIE,MACA,GAAG,WACA,MAAM,GAAG,OAAO,EACtB,CAAC"}
package/lib/index.cjs CHANGED
@@ -13,6 +13,7 @@ const require_helpers_soa = require("./helpers/soa.cjs");
13
13
  const require_helpers_sv = require("./helpers/sv.cjs");
14
14
  const require_helpers_tuple = require("./helpers/tuple.cjs");
15
15
  const require_helpers_union = require("./helpers/union.cjs");
16
+ const require_helpers_primitiveObject = require("./helpers/primitiveObject.cjs");
16
17
  require("./helpers/index.cjs");
17
18
  const require_type = require("./type.cjs");
18
19
  exports.ARRAY = require_constants.ARRAY;
@@ -30,6 +31,7 @@ exports.intersection = require_helpers_intersection;
30
31
  exports.litterals = require_helpers_litterals;
31
32
  exports.optional = require_helpers_optional;
32
33
  exports.partial = require_helpers_partial;
34
+ exports.primitiveObject = require_helpers_primitiveObject;
33
35
  exports.record = require_helpers_record;
34
36
  exports.soa = require_helpers_soa;
35
37
  exports.sv = require_helpers_sv;
package/lib/index.js CHANGED
@@ -12,6 +12,7 @@ import soa from "./helpers/soa.js";
12
12
  import sv from "./helpers/sv.js";
13
13
  import tuple from "./helpers/tuple.js";
14
14
  import fn from "./helpers/union.js";
15
+ import primitiveObject from "./helpers/primitiveObject.js";
15
16
  import "./helpers/index.js";
16
17
  import { type } from "./type.js";
17
- export { ARRAY, CUSTOM, OPTIONAL, OptionalHelperClass, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, any, array, custom, intersection, litterals, optional, partial, record, soa, sv, tuple, type, fn as union };
18
+ export { ARRAY, CUSTOM, OPTIONAL, OptionalHelperClass, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, any, array, custom, intersection, litterals, optional, partial, primitiveObject, record, soa, sv, tuple, type, fn as union };
package/lib/type.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import type { Transform_F } from './type.types';
1
+ import type { Transform_F } from "./type.types";
2
2
  export declare const type: Transform_F;
@@ -1,5 +1,5 @@
1
- import type { any, custom, intersection, litterals, optional, partial, record, soa, sv, union, array, tuple } from './helpers';
2
- import type { ObjectS, TransformS } from './types';
1
+ import type { any, array, custom, intersection, litterals, optional, partial, primitiveObject, record, soa, sv, tuple, union } from "./helpers";
2
+ import type { inferT, ObjectT } from "./types";
3
3
  export type Helpers = {
4
4
  any: typeof any;
5
5
  custom: typeof custom;
@@ -13,5 +13,6 @@ export type Helpers = {
13
13
  union: typeof union;
14
14
  array: typeof array;
15
15
  tuple: typeof tuple;
16
+ primitiveObject: typeof primitiveObject;
16
17
  };
17
- export type Transform_F = <T extends ObjectS = ObjectS>(option: (helpers: Helpers) => T) => TransformS<T>;
18
+ export type Transform_F = <T extends ObjectT = ObjectT>(option?: ((helpers: Helpers) => T) | T) => inferT<T>;
package/lib/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ARRAY, CUSTOM, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA } from './constants';
1
+ import type { ARRAY, CUSTOM, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA } from "./constants";
2
2
  export type Ru = Record<Keys, unknown>;
3
3
  export type TrueObject = Ru & {
4
4
  [Symbol.iterator]?: never;
@@ -24,52 +24,57 @@ type RecursiveArrayOf<T> = Array<_SingleOrRecursiveArrayOf<T>> | ReadonlyArray<_
24
24
  type _SingleOrRecursiveArrayOf<T> = T | RecursiveArrayOf<T>;
25
25
  export type SingleOrRecursiveArrayOf<T> = T | RecursiveArrayOf<T>;
26
26
  export type SoRa<T> = SingleOrRecursiveArrayOf<T>;
27
+ export type Primiive = string | number | boolean | bigint | null | undefined | symbol | unknown | never;
27
28
  export type PrimitiveS = (typeof PRIMITIVES)[number];
28
- type TransformPrimitiveS<T extends PrimitiveS> = T extends 'string' ? string : T extends 'number' ? number : T extends 'boolean' ? boolean : T extends 'bigint' ? bigint : T extends 'null' ? null : T extends 'undefined' ? undefined : T extends 'symbol' ? symbol : never;
29
+ type TransformPrimitiveS<T extends PrimitiveS> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : T extends "bigint" ? bigint : T extends "null" ? null : T extends "undefined" ? undefined : T extends "symbol" ? symbol : T extends "never" ? never : T extends "unknown" ? unknown : PrimitiveS;
29
30
  export type Types = PrimitiveS | (typeof PRIMITIVE_OBJECTS)[number];
30
- export type TransformTypes<T extends Types> = T extends PrimitiveS ? TransformPrimitiveS<T> : T extends 'date' ? Date : {};
31
+ export type TransformTypes<T extends Types> = T extends PrimitiveS ? TransformPrimitiveS<T> : T extends "date" ? Date : T extends "any" ? any : object;
31
32
  export type Custom<T = any> = {
32
33
  [CUSTOM]: T;
33
34
  };
34
- export type SoaCustom<T extends ObjectS = any> = {
35
+ export type SoaCustom<T extends ObjectT = any> = {
35
36
  [SOA]: T;
36
37
  };
37
38
  export type PartialCustom = {
38
39
  [PARTIAL]: undefined;
39
40
  };
40
- export type __ObjectS = Types | ObjectMapS | Custom | PartialCustom;
41
- export type Optional<T extends __ObjectS | ArrayCustom | AnyArray<__ObjectS> = __ObjectS> = {
41
+ export type __ObjectT = Types | ObjectMapS | Custom | PartialCustom;
42
+ export type Optional<T extends __ObjectT | ArrayCustom | AnyArray<__ObjectT> = __ObjectT> = {
42
43
  [OPTIONAL]: T;
43
44
  };
44
- export type ArrayCustom<T extends ObjectS = any> = {
45
+ export type ArrayCustom<T extends ObjectT = any> = {
45
46
  [ARRAY]: T;
46
47
  };
47
48
  export type ObjectMapS = {
48
- [key: Keys]: SoRa<_ObjectS>;
49
+ [key: Keys]: SoRa<_ObjectT>;
49
50
  };
50
51
  export declare class OptionalHelperClass {
51
52
  readonly __NO_TYPE__ = "@bemedev/addons/NO_TYPE";
52
53
  private constructor();
53
54
  }
54
- type _ObjectS = __ObjectS | Optional | ArrayCustom;
55
+ type _ObjectT = __ObjectT | Optional | ArrayCustom;
56
+ export type PrimitiveObjectT = Types | ArrayCustom<Types> | Optional<Types> | PrimitiveObjectMapS | (PrimitiveObjectMapS & PartialCustom);
57
+ export interface PrimitiveObjectMapS {
58
+ [key: Keys]: PrimitiveObjectT;
59
+ }
55
60
  /**
56
61
  * A type that represents a primitive object, which can be a primitive value or an object
57
62
  *
58
63
  * @remark
59
64
  */
60
- export type ObjectS = _ObjectS | SoRa<_ObjectS>;
61
- export type POS = ObjectS;
62
- type ReduceTuple2<T extends AnyArray<ObjectS>> = T extends [
65
+ export type ObjectT = SoRa<_ObjectT | PrimitiveObjectT>;
66
+ export type POS = ObjectT;
67
+ type ReduceTuple2<T extends AnyArray<ObjectT>> = T extends [
63
68
  infer First,
64
- ...infer Rest extends AnyArray<ObjectS>
65
- ] ? [TransformS<First>, ...ReduceTuple2<Rest>] : T extends AnyArray<infer A extends ObjectS> ? TransformS<A>[] : [];
66
- type __TransformPrimitiveObject<T> = T extends Types ? TransformTypes<T> : T extends ArrayCustom<infer A> ? TransformS<A>[] : T extends SoaCustom<infer TSoA> ? SoA<__TransformPrimitiveObject<TSoA>> : T extends Custom<infer TCustom> ? TCustom : T extends AnyArray<ObjectS> ? ReduceTuple2<T> : T extends PartialCustom ? Partial<__TransformPrimitiveObject<NOmit<T, typeof PARTIAL>>> : T extends Optional<infer TOptional> ? __TransformPrimitiveObject<TOptional> | OptionalHelperClass : {
67
- [K in keyof T]: __TransformPrimitiveObject<T[K]>;
68
- };
69
+ ...infer Rest extends AnyArray<ObjectT>
70
+ ] ? [TransformT<First>, ...ReduceTuple2<Rest>] : T extends AnyArray<infer A extends ObjectT> ? TransformT<A>[] : [];
69
71
  type ReduceTupleU<T extends AnyArray> = T extends [
70
72
  infer First,
71
73
  ...infer Rest extends AnyArray
72
- ] ? [Undefiny<First>, ...ReduceTupleU<Rest>] : T[number] extends never ? [] : T['length'] extends 0 ? [] : number extends T['length'] ? T : Undefiny<T[number]>[];
74
+ ] ? [Undefiny<First>, ...ReduceTupleU<Rest>] : T[number] extends never ? [] : T["length"] extends 0 ? [] : number extends T["length"] ? T : Undefiny<T[number]>[];
75
+ type __TransformPrimitiveObject<T> = T extends Types ? TransformTypes<T> : T extends ArrayCustom<infer A> ? TransformT<A>[] : T extends SoaCustom<infer TSoA> ? SoA<__TransformPrimitiveObject<TSoA>> : T extends Custom<infer TCustom> ? TCustom : T extends AnyArray<ObjectT> ? ReduceTuple2<T> : T extends PartialCustom ? Partial<__TransformPrimitiveObject<NOmit<T, typeof PARTIAL>>> : T extends Optional<infer TOptional> ? __TransformPrimitiveObject<TOptional> | OptionalHelperClass : {
76
+ [K in keyof T]: __TransformPrimitiveObject<T[K]>;
77
+ };
73
78
  type HasUndefined<T> = OptionalHelperClass extends T ? true : false;
74
79
  type UndefinyObject<T extends object> = {
75
80
  [K in keyof T as HasUndefined<T[K]> extends true ? never : K]: Undefiny<T[K]>;
@@ -79,7 +84,7 @@ type UndefinyObject<T extends object> = {
79
84
  [K in keyof F]: F[K];
80
85
  } : never;
81
86
  type Undefiny<T, U = Exclude<T, OptionalHelperClass>> = U extends AnyArray ? ReduceTupleU<U> : U extends Ru ? UndefinyObject<U> : U;
82
- export type TransformS<T> = Undefiny<__TransformPrimitiveObject<T>>;
83
- export type inferT<T extends ObjectS> = TransformS<T>;
87
+ type TransformT<T> = Undefiny<__TransformPrimitiveObject<T>>;
88
+ export type inferT<T extends ObjectT = ObjectT> = ObjectT extends T ? unknown : TransformT<T>;
84
89
  export type FnBasic<Main extends Fn, Tr extends object> = Tr & Main;
85
90
  export {};
@@ -2,7 +2,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/utils/expandFn.ts
3
3
  const expandFn = (main, extensions) => {
4
4
  const out = main;
5
+ /* v8 ignore start -- @preserve */
5
6
  if (extensions) Object.assign(out, extensions);
7
+ /* v8 ignore stop -- @preserve */
6
8
  return out;
7
9
  };
8
10
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"expandFn.cjs","names":[],"sources":["../../src/utils/expandFn.ts"],"sourcesContent":["import type { Fn, FnBasic } from '../types';\n\nexport const expandFn = <\n Main extends Fn,\n const Tr extends object = object,\n>(\n main: Main,\n extensions?: Tr,\n): FnBasic<Main, Tr> => {\n const out: any = main;\n\n if (extensions) {\n Object.assign(out, extensions);\n }\n\n return out;\n};\n"],"mappings":";;AAEA,MAAa,YAIX,MACA,eACsB;CACtB,MAAM,MAAW;AAEjB,KAAI,WACF,QAAO,OAAO,KAAK,WAAW;AAGhC,QAAO"}
1
+ {"version":3,"file":"expandFn.cjs","names":[],"sources":["../../src/utils/expandFn.ts"],"sourcesContent":["import type { Fn, FnBasic } from \"../types\";\n\nexport const expandFn = <Main extends Fn, const Tr extends object = object>(\n main: Main,\n extensions?: Tr,\n): FnBasic<Main, Tr> => {\n const out: any = main;\n\n /* v8 ignore start -- @preserve */\n if (extensions) Object.assign(out, extensions);\n /* v8 ignore stop -- @preserve */\n\n return out;\n};\n"],"mappings":";;AAEA,MAAa,YACX,MACA,eACsB;CACtB,MAAM,MAAW;;AAGjB,KAAI,WAAY,QAAO,OAAO,KAAK,WAAW;;AAG9C,QAAO"}
@@ -1,2 +1,2 @@
1
- import type { Fn, FnBasic } from '../types';
1
+ import type { Fn, FnBasic } from "../types";
2
2
  export declare const expandFn: <Main extends Fn, const Tr extends object = object>(main: Main, extensions?: Tr) => FnBasic<Main, Tr>;
@@ -1,7 +1,9 @@
1
1
  //#region src/utils/expandFn.ts
2
2
  const expandFn = (main, extensions) => {
3
3
  const out = main;
4
+ /* v8 ignore start -- @preserve */
4
5
  if (extensions) Object.assign(out, extensions);
6
+ /* v8 ignore stop -- @preserve */
5
7
  return out;
6
8
  };
7
9
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"expandFn.js","names":[],"sources":["../../src/utils/expandFn.ts"],"sourcesContent":["import type { Fn, FnBasic } from '../types';\n\nexport const expandFn = <\n Main extends Fn,\n const Tr extends object = object,\n>(\n main: Main,\n extensions?: Tr,\n): FnBasic<Main, Tr> => {\n const out: any = main;\n\n if (extensions) {\n Object.assign(out, extensions);\n }\n\n return out;\n};\n"],"mappings":";AAEA,MAAa,YAIX,MACA,eACsB;CACtB,MAAM,MAAW;AAEjB,KAAI,WACF,QAAO,OAAO,KAAK,WAAW;AAGhC,QAAO"}
1
+ {"version":3,"file":"expandFn.js","names":[],"sources":["../../src/utils/expandFn.ts"],"sourcesContent":["import type { Fn, FnBasic } from \"../types\";\n\nexport const expandFn = <Main extends Fn, const Tr extends object = object>(\n main: Main,\n extensions?: Tr,\n): FnBasic<Main, Tr> => {\n const out: any = main;\n\n /* v8 ignore start -- @preserve */\n if (extensions) Object.assign(out, extensions);\n /* v8 ignore stop -- @preserve */\n\n return out;\n};\n"],"mappings":";AAEA,MAAa,YACX,MACA,eACsB;CACtB,MAAM,MAAW;;AAGjB,KAAI,WAAY,QAAO,OAAO,KAAK,WAAW;;AAG9C,QAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemedev/typings",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Typings by variables",
5
5
  "author": {
6
6
  "email": "bri_lvi@icloud.com",
@@ -40,7 +40,7 @@
40
40
  "public"
41
41
  ],
42
42
  "engines": {
43
- "node": ">=20"
43
+ "node": ">=24"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "pnpm rm:lib && pnpm run rolldown",
@@ -49,7 +49,6 @@
49
49
  "clean": "pnpm run rm && pnpm run config",
50
50
  "config": "pnpm install",
51
51
  "config:off": "pnpm run config --offline",
52
- "config:vitest": "pnpm add -D @vitest/coverage-v8@3.2.4 @vitest/ui@3.2.4 vitest@3.2.4",
53
52
  "fmt": "oxfmt",
54
53
  "fmt:check": "oxfmt --check",
55
54
  "lint": "pnpm run fmt && pnpm run lint:fix",
@@ -73,8 +72,8 @@
73
72
  "test:only": "pnpm run test:coverage --no-coverage",
74
73
  "test:ui": "vitest --ui",
75
74
  "test:watch": "vitest",
76
- "upgrade": "pnpm dlx @bemedev/upgrade-npm-package && pnpm run config:vitest",
77
- "upgrade:fast": "pnpm up --latest && pnpm run config:vitest"
75
+ "upgrade": "pnpm dlx @bemedev/upgrade-npm-package",
76
+ "upgrade:fast": "pnpm up --latest"
78
77
  },
79
78
  "size-limit": [
80
79
  {
@@ -87,24 +86,24 @@
87
86
  }
88
87
  ],
89
88
  "devDependencies": {
90
- "@bemedev/dev-utils": "^0.5.2",
89
+ "@bemedev/dev-utils": "^0.6.2",
91
90
  "@bemedev/fsf": "^1.0.1",
92
- "@size-limit/file": "^12.0.1",
93
- "@types/node": "^25.5.2",
94
- "@vitest/coverage-v8": "^3.2.4",
95
- "@vitest/ui": "3.2.4",
91
+ "@size-limit/file": "^12.1.0",
92
+ "@types/node": "^25.6.0",
93
+ "@vitest/coverage-v8": "^4.1.4",
94
+ "@vitest/ui": "4.1.4",
96
95
  "glob": "^13.0.6",
97
- "globals": "^17.4.0",
96
+ "globals": "^17.5.0",
98
97
  "husky": "^9.1.7",
99
98
  "onchange": "^7.1.0",
100
- "oxfmt": "^0.43.0",
101
- "oxlint": "^1.58.0",
99
+ "oxfmt": "^0.45.0",
100
+ "oxlint": "^1.60.0",
102
101
  "pretty-quick": "^4.2.2",
103
- "rolldown": "1.0.0-rc.13",
104
- "size-limit": "^12.0.1",
102
+ "rolldown": "1.0.0-rc.16",
103
+ "size-limit": "^12.1.0",
105
104
  "tslib": "^2.8.1",
106
- "typescript": "^6.0.2",
107
- "vitest": "^3.2.4"
105
+ "typescript": "^6.0.3",
106
+ "vitest": "^4.1.4"
108
107
  },
109
108
  "pnpm": {
110
109
  "onlyBuiltDependencies": [