@bemedev/typings 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/lib/_virtual/_rolldown/runtime.cjs +13 -0
- package/lib/_virtual/_rolldown/runtime.js +13 -0
- package/lib/constants.cjs +9 -2
- package/lib/constants.cjs.map +1 -1
- package/lib/constants.d.ts +2 -2
- package/lib/constants.js +9 -2
- package/lib/constants.js.map +1 -1
- package/lib/helpers/any.cjs +2 -1
- package/lib/helpers/any.cjs.map +1 -1
- package/lib/helpers/any.d.ts +3 -3
- package/lib/helpers/any.js +1 -1
- package/lib/helpers/any.js.map +1 -1
- package/lib/helpers/array.cjs +2 -1
- package/lib/helpers/array.cjs.map +1 -1
- package/lib/helpers/array.d.ts +3 -3
- package/lib/helpers/array.js +1 -1
- package/lib/helpers/array.js.map +1 -1
- package/lib/helpers/custom.cjs +2 -1
- package/lib/helpers/custom.cjs.map +1 -1
- package/lib/helpers/custom.d.ts +2 -2
- package/lib/helpers/custom.js +1 -1
- package/lib/helpers/custom.js.map +1 -1
- package/lib/helpers/index.cjs +40 -12
- package/lib/helpers/index.cjs.map +1 -0
- package/lib/helpers/index.d.ts +13 -12
- package/lib/helpers/index.js +34 -13
- package/lib/helpers/index.js.map +1 -0
- package/lib/helpers/intersection.cjs +2 -1
- package/lib/helpers/intersection.cjs.map +1 -1
- package/lib/helpers/intersection.d.ts +2 -2
- package/lib/helpers/intersection.js +1 -1
- package/lib/helpers/intersection.js.map +1 -1
- package/lib/helpers/litterals.cjs +2 -1
- package/lib/helpers/litterals.cjs.map +1 -1
- package/lib/helpers/litterals.d.ts +2 -2
- package/lib/helpers/litterals.js +1 -1
- package/lib/helpers/litterals.js.map +1 -1
- package/lib/helpers/optional.cjs +2 -1
- package/lib/helpers/optional.cjs.map +1 -1
- package/lib/helpers/optional.d.ts +3 -3
- package/lib/helpers/optional.js +1 -1
- package/lib/helpers/optional.js.map +1 -1
- package/lib/helpers/partial.cjs +2 -1
- package/lib/helpers/partial.cjs.map +1 -1
- package/lib/helpers/partial.d.ts +3 -3
- package/lib/helpers/partial.js +1 -1
- package/lib/helpers/partial.js.map +1 -1
- package/lib/helpers/primitiveObject.cjs +11 -0
- package/lib/helpers/primitiveObject.cjs.map +1 -0
- package/lib/helpers/primitiveObject.d.ts +5 -0
- package/lib/helpers/primitiveObject.js +11 -0
- package/lib/helpers/primitiveObject.js.map +1 -0
- package/lib/helpers/record.cjs +2 -1
- package/lib/helpers/record.cjs.map +1 -1
- package/lib/helpers/record.d.ts +3 -3
- package/lib/helpers/record.js +1 -1
- package/lib/helpers/record.js.map +1 -1
- package/lib/helpers/soa.cjs +2 -1
- package/lib/helpers/soa.cjs.map +1 -1
- package/lib/helpers/soa.d.ts +3 -3
- package/lib/helpers/soa.js +1 -1
- package/lib/helpers/soa.js.map +1 -1
- package/lib/helpers/sv.cjs +2 -1
- package/lib/helpers/sv.cjs.map +1 -1
- package/lib/helpers/sv.d.ts +2 -2
- package/lib/helpers/sv.js +1 -1
- package/lib/helpers/sv.js.map +1 -1
- package/lib/helpers/tuple.cjs +2 -1
- package/lib/helpers/tuple.cjs.map +1 -1
- package/lib/helpers/tuple.d.ts +3 -3
- package/lib/helpers/tuple.js +1 -1
- package/lib/helpers/tuple.js.map +1 -1
- package/lib/helpers/union.cjs +4 -3
- package/lib/helpers/union.cjs.map +1 -1
- package/lib/helpers/union.d.ts +4 -4
- package/lib/helpers/union.js +3 -3
- package/lib/helpers/union.js.map +1 -1
- package/lib/index.cjs +7 -25
- package/lib/index.d.ts +4 -4
- package/lib/index.js +2 -14
- package/lib/type.d.ts +1 -1
- package/lib/type.types.d.ts +4 -3
- package/lib/types.d.ts +25 -20
- package/lib/utils/expandFn.cjs +2 -0
- package/lib/utils/expandFn.cjs.map +1 -1
- package/lib/utils/expandFn.d.ts +1 -1
- package/lib/utils/expandFn.js +2 -0
- package/lib/utils/expandFn.js.map +1 -1
- package/package.json +16 -17
|
@@ -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 { 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 };
|
|
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 { primitiveObject };\n"],"mappings":";;AAOA,MAAM,kBAAkB,UAEpB,UACuC;AACvC,QAAQ,SAAS,EAAE;GAErB,EACE,MACE,UACuC;AACvC,QAAQ,SAAS,EAAE;GAEtB,CACF"}
|
package/lib/helpers/record.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
1
2
|
//#region src/helpers/record.ts
|
|
2
3
|
const record = (value, ...keys) => {
|
|
3
4
|
return keys.reduce((acc, key) => {
|
|
@@ -6,6 +7,6 @@ const record = (value, ...keys) => {
|
|
|
6
7
|
}, {});
|
|
7
8
|
};
|
|
8
9
|
//#endregion
|
|
9
|
-
|
|
10
|
+
exports.record = record;
|
|
10
11
|
|
|
11
12
|
//# sourceMappingURL=record.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.cjs","names":[],"sources":["../../src/helpers/record.ts"],"sourcesContent":["import type { Keys,
|
|
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 { record };\n"],"mappings":";;AAEA,MAAM,UACJ,OACA,GAAG,SACA;AAMH,QALe,KAAK,QAAQ,KAAK,QAAQ;AACvC,MAAI,OAAO;AACX,SAAO;IACN,EAAE,CAAQ"}
|
package/lib/helpers/record.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Keys,
|
|
2
|
-
declare const record: <const K extends Keys[], V extends
|
|
3
|
-
export
|
|
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
|
+
export { record };
|
package/lib/helpers/record.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.js","names":[],"sources":["../../src/helpers/record.ts"],"sourcesContent":["import type { Keys,
|
|
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 { record };\n"],"mappings":";AAEA,MAAM,UACJ,OACA,GAAG,SACA;AAMH,QALe,KAAK,QAAQ,KAAK,QAAQ;AACvC,MAAI,OAAO;AACX,SAAO;IACN,EAAE,CAAQ"}
|
package/lib/helpers/soa.cjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
1
2
|
const require_constants = require("../constants.cjs");
|
|
2
3
|
//#region src/helpers/soa.ts
|
|
3
4
|
const soa = (value) => {
|
|
4
5
|
return { [require_constants.SOA]: value };
|
|
5
6
|
};
|
|
6
7
|
//#endregion
|
|
7
|
-
|
|
8
|
+
exports.soa = soa;
|
|
8
9
|
|
|
9
10
|
//# sourceMappingURL=soa.cjs.map
|
package/lib/helpers/soa.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"soa.cjs","names":["SOA"],"sources":["../../src/helpers/soa.ts"],"sourcesContent":["import { SOA } from
|
|
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 { soa };\n"],"mappings":";;;AAGA,MAAM,OAAgC,UAAa;AAEjD,QAAO,GAAGA,kBAAAA,MAAM,OAAO"}
|
package/lib/helpers/soa.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { NotReadonly,
|
|
2
|
-
declare const soa: <const T extends
|
|
3
|
-
export
|
|
1
|
+
import type { NotReadonly, ObjectT, SoaCustom } from "../types";
|
|
2
|
+
declare const soa: <const T extends ObjectT>(value: T) => SoaCustom<Extract<NotReadonly<T>, ObjectT>>;
|
|
3
|
+
export { soa };
|
package/lib/helpers/soa.js
CHANGED
package/lib/helpers/soa.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"soa.js","names":[],"sources":["../../src/helpers/soa.ts"],"sourcesContent":["import { SOA } from
|
|
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 { soa };\n"],"mappings":";;AAGA,MAAM,OAAgC,UAAa;AAEjD,QAAO,GAAG,MAAM,OAAO"}
|
package/lib/helpers/sv.cjs
CHANGED
package/lib/helpers/sv.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sv.cjs","names":[],"sources":["../../src/helpers/sv.ts"],"sourcesContent":["import type { Custom, StateValue } from
|
|
1
|
+
{"version":3,"file":"sv.cjs","names":[],"sources":["../../src/helpers/sv.ts"],"sourcesContent":["import type { Custom, StateValue } from \"../types\";\n\nconst sv = {} as Custom<StateValue>;\nexport { sv };\n"],"mappings":";;AAEA,MAAM,KAAK,EAAE"}
|
package/lib/helpers/sv.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Custom, StateValue } from
|
|
1
|
+
import type { Custom, StateValue } from "../types";
|
|
2
2
|
declare const sv: Custom<StateValue>;
|
|
3
|
-
export
|
|
3
|
+
export { sv };
|
package/lib/helpers/sv.js
CHANGED
package/lib/helpers/sv.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sv.js","names":[],"sources":["../../src/helpers/sv.ts"],"sourcesContent":["import type { Custom, StateValue } from
|
|
1
|
+
{"version":3,"file":"sv.js","names":[],"sources":["../../src/helpers/sv.ts"],"sourcesContent":["import type { Custom, StateValue } from \"../types\";\n\nconst sv = {} as Custom<StateValue>;\nexport { sv };\n"],"mappings":";AAEA,MAAM,KAAK,EAAE"}
|
package/lib/helpers/tuple.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tuple.cjs","names":[],"sources":["../../src/helpers/tuple.ts"],"sourcesContent":["import type {
|
|
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 { tuple };\n"],"mappings":";;AAEA,MAAM,SAAkD,GAAG,WACzD"}
|
package/lib/helpers/tuple.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare const tuple: <const T extends [
|
|
3
|
-
export
|
|
1
|
+
import type { NotReadonly, ObjectT } from "../types";
|
|
2
|
+
declare const tuple: <const T extends [ObjectT, ...ObjectT[]]>(...values: T) => NotReadonly<T>;
|
|
3
|
+
export { tuple };
|
package/lib/helpers/tuple.js
CHANGED
package/lib/helpers/tuple.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tuple.js","names":[],"sources":["../../src/helpers/tuple.ts"],"sourcesContent":["import type {
|
|
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 { tuple };\n"],"mappings":";AAEA,MAAM,SAAkD,GAAG,WACzD"}
|
package/lib/helpers/union.cjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
1
2
|
const require_utils_expandFn = require("../utils/expandFn.cjs");
|
|
2
3
|
//#region src/helpers/union.ts
|
|
3
|
-
const
|
|
4
|
+
const _union = (...values) => {
|
|
4
5
|
return values[0];
|
|
5
6
|
};
|
|
6
|
-
const
|
|
7
|
+
const union = require_utils_expandFn.expandFn(_union, { discriminated: (_key, ...values) => _union(...values) });
|
|
7
8
|
//#endregion
|
|
8
|
-
|
|
9
|
+
exports.union = union;
|
|
9
10
|
|
|
10
11
|
//# sourceMappingURL=union.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union.cjs","names":["expandFn"],"sources":["../../src/helpers/union.ts"],"sourcesContent":["import type { Keys, ObjectMapS,
|
|
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 union = 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 { union };\n"],"mappings":";;;AAGA,MAAM,UAAsD,GAAG,WAAc;AAC3E,QAAO,OAAO;;AAKhB,MAAM,QAAQA,uBAAAA,SAAS,QAAQ,EAC7B,gBAIE,MACA,GAAG,WACA,OAAO,GAAG,OAAO,EACvB,CAAC"}
|
package/lib/helpers/union.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Keys, ObjectMapS,
|
|
2
|
-
type Discriminated<K extends Keys> = ObjectMapS & Record<K,
|
|
3
|
-
declare const
|
|
1
|
+
import type { Keys, ObjectMapS, ObjectT } from "../types";
|
|
2
|
+
type Discriminated<K extends Keys> = ObjectMapS & Record<K, ObjectT>;
|
|
3
|
+
declare const union: 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
|
-
export
|
|
6
|
+
export { union };
|
package/lib/helpers/union.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { expandFn } from "../utils/expandFn.js";
|
|
2
2
|
//#region src/helpers/union.ts
|
|
3
|
-
const
|
|
3
|
+
const _union = (...values) => {
|
|
4
4
|
return values[0];
|
|
5
5
|
};
|
|
6
|
-
const
|
|
6
|
+
const union = expandFn(_union, { discriminated: (_key, ...values) => _union(...values) });
|
|
7
7
|
//#endregion
|
|
8
|
-
export {
|
|
8
|
+
export { union };
|
|
9
9
|
|
|
10
10
|
//# sourceMappingURL=union.js.map
|
package/lib/helpers/union.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union.js","names":[],"sources":["../../src/helpers/union.ts"],"sourcesContent":["import type { Keys, ObjectMapS,
|
|
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 union = 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 { union };\n"],"mappings":";;AAGA,MAAM,UAAsD,GAAG,WAAc;AAC3E,QAAO,OAAO;;AAKhB,MAAM,QAAQ,SAAS,QAAQ,EAC7B,gBAIE,MACA,GAAG,WACA,OAAO,GAAG,OAAO,EACvB,CAAC"}
|
package/lib/index.cjs
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_types = require("./types.cjs");
|
|
3
3
|
const require_constants = require("./constants.cjs");
|
|
4
|
-
const
|
|
5
|
-
const require_helpers_array = require("./helpers/array.cjs");
|
|
6
|
-
const require_helpers_custom = require("./helpers/custom.cjs");
|
|
7
|
-
const require_helpers_intersection = require("./helpers/intersection.cjs");
|
|
8
|
-
const require_helpers_litterals = require("./helpers/litterals.cjs");
|
|
9
|
-
const require_helpers_optional = require("./helpers/optional.cjs");
|
|
10
|
-
const require_helpers_partial = require("./helpers/partial.cjs");
|
|
11
|
-
const require_helpers_record = require("./helpers/record.cjs");
|
|
12
|
-
const require_helpers_soa = require("./helpers/soa.cjs");
|
|
13
|
-
const require_helpers_sv = require("./helpers/sv.cjs");
|
|
14
|
-
const require_helpers_tuple = require("./helpers/tuple.cjs");
|
|
15
|
-
const require_helpers_union = require("./helpers/union.cjs");
|
|
16
|
-
require("./helpers/index.cjs");
|
|
4
|
+
const require_helpers_index = require("./helpers/index.cjs");
|
|
17
5
|
const require_type = require("./type.cjs");
|
|
18
6
|
exports.ARRAY = require_constants.ARRAY;
|
|
19
7
|
exports.CUSTOM = require_constants.CUSTOM;
|
|
@@ -23,16 +11,10 @@ exports.PARTIAL = require_constants.PARTIAL;
|
|
|
23
11
|
exports.PRIMITIVES = require_constants.PRIMITIVES;
|
|
24
12
|
exports.PRIMITIVE_OBJECTS = require_constants.PRIMITIVE_OBJECTS;
|
|
25
13
|
exports.SOA = require_constants.SOA;
|
|
26
|
-
exports
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
exports.partial = require_helpers_partial;
|
|
33
|
-
exports.record = require_helpers_record;
|
|
34
|
-
exports.soa = require_helpers_soa;
|
|
35
|
-
exports.sv = require_helpers_sv;
|
|
36
|
-
exports.tuple = require_helpers_tuple;
|
|
14
|
+
Object.defineProperty(exports, "helpers", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function() {
|
|
17
|
+
return require_helpers_index.helpers_exports;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
37
20
|
exports.type = require_type.type;
|
|
38
|
-
exports.union = require_helpers_union;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from "./constants";
|
|
2
|
+
export * as helpers from "./helpers";
|
|
3
|
+
export * from "./type";
|
|
4
|
+
export * from "./types";
|
package/lib/index.js
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import { OptionalHelperClass } from "./types.js";
|
|
2
2
|
import { ARRAY, CUSTOM, OPTIONAL, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA } from "./constants.js";
|
|
3
|
-
import
|
|
4
|
-
import array from "./helpers/array.js";
|
|
5
|
-
import custom from "./helpers/custom.js";
|
|
6
|
-
import intersection from "./helpers/intersection.js";
|
|
7
|
-
import litterals from "./helpers/litterals.js";
|
|
8
|
-
import optional from "./helpers/optional.js";
|
|
9
|
-
import partial from "./helpers/partial.js";
|
|
10
|
-
import record from "./helpers/record.js";
|
|
11
|
-
import soa from "./helpers/soa.js";
|
|
12
|
-
import sv from "./helpers/sv.js";
|
|
13
|
-
import tuple from "./helpers/tuple.js";
|
|
14
|
-
import fn from "./helpers/union.js";
|
|
15
|
-
import "./helpers/index.js";
|
|
3
|
+
import { helpers_exports } from "./helpers/index.js";
|
|
16
4
|
import { type } from "./type.js";
|
|
17
|
-
export { ARRAY, CUSTOM, OPTIONAL, OptionalHelperClass, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA,
|
|
5
|
+
export { ARRAY, CUSTOM, OPTIONAL, OptionalHelperClass, PARTIAL, PRIMITIVES, PRIMITIVE_OBJECTS, SOA, helpers_exports as helpers, type };
|
package/lib/type.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Transform_F } from
|
|
1
|
+
import type { Transform_F } from "./type.types";
|
|
2
2
|
export declare const type: Transform_F;
|
package/lib/type.types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { any, custom, intersection, litterals, optional, partial, record, soa, sv,
|
|
2
|
-
import type {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
41
|
-
export type Optional<T extends
|
|
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
|
|
45
|
+
export type ArrayCustom<T extends ObjectT = any> = {
|
|
45
46
|
[ARRAY]: T;
|
|
46
47
|
};
|
|
47
48
|
export type ObjectMapS = {
|
|
48
|
-
[key: Keys]: SoRa<
|
|
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
|
|
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
|
|
61
|
-
export type POS =
|
|
62
|
-
type ReduceTuple2<T extends AnyArray<
|
|
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<
|
|
65
|
-
] ? [
|
|
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[
|
|
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
|
-
|
|
83
|
-
export type inferT<T extends
|
|
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 {};
|
package/lib/utils/expandFn.cjs
CHANGED
|
@@ -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
|
|
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"}
|
package/lib/utils/expandFn.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Fn, FnBasic } from
|
|
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>;
|
package/lib/utils/expandFn.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expandFn.js","names":[],"sources":["../../src/utils/expandFn.ts"],"sourcesContent":["import type { Fn, FnBasic } from
|
|
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
|
|
3
|
+
"version": "0.2.1",
|
|
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": ">=
|
|
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
|
|
77
|
-
"upgrade:fast": "pnpm up --latest
|
|
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.
|
|
89
|
+
"@bemedev/dev-utils": "^0.6.2",
|
|
91
90
|
"@bemedev/fsf": "^1.0.1",
|
|
92
|
-
"@size-limit/file": "^12.0
|
|
93
|
-
"@types/node": "^25.
|
|
94
|
-
"@vitest/coverage-v8": "^
|
|
95
|
-
"@vitest/ui": "
|
|
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.
|
|
96
|
+
"globals": "^17.5.0",
|
|
98
97
|
"husky": "^9.1.7",
|
|
99
98
|
"onchange": "^7.1.0",
|
|
100
|
-
"oxfmt": "^0.
|
|
101
|
-
"oxlint": "^1.
|
|
99
|
+
"oxfmt": "^0.45.0",
|
|
100
|
+
"oxlint": "^1.60.0",
|
|
102
101
|
"pretty-quick": "^4.2.2",
|
|
103
|
-
"rolldown": "1.0.0-rc.
|
|
104
|
-
"size-limit": "^12.0
|
|
102
|
+
"rolldown": "1.0.0-rc.16",
|
|
103
|
+
"size-limit": "^12.1.0",
|
|
105
104
|
"tslib": "^2.8.1",
|
|
106
|
-
"typescript": "^6.0.
|
|
107
|
-
"vitest": "^
|
|
105
|
+
"typescript": "^6.0.3",
|
|
106
|
+
"vitest": "^4.1.4"
|
|
108
107
|
},
|
|
109
108
|
"pnpm": {
|
|
110
109
|
"onlyBuiltDependencies": [
|