@duplojs/utils 1.1.12 → 1.1.13
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/dist/common/kind.cjs
CHANGED
|
@@ -35,22 +35,21 @@ function createKindNamespace(namespace) {
|
|
|
35
35
|
return kindHandler;
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
function kindHeritage(uniqueName, kind) {
|
|
38
|
+
function kindHeritage(uniqueName, kind, parent) {
|
|
39
39
|
const uniqueKind = createKind(uniqueName);
|
|
40
40
|
const kinds = kind instanceof Array
|
|
41
41
|
? kind
|
|
42
42
|
: [kind];
|
|
43
|
-
const
|
|
44
|
-
for (const kind of kinds) {
|
|
45
|
-
this[kind.runTimeKey] = params[kind.definition.name] ?? null;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
kinds.forEach((value) => {
|
|
49
|
-
ParentKindClass.prototype[value.runTimeKey] = null;
|
|
43
|
+
const Extendable = (parent ?? class {
|
|
50
44
|
});
|
|
51
|
-
ParentKindClass
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
const ParentKindClass = (class extends Extendable {
|
|
46
|
+
constructor(params = {}, parentParams = []) {
|
|
47
|
+
super(...parentParams);
|
|
48
|
+
for (const kind of kinds) {
|
|
49
|
+
this[kind.runTimeKey] = params[kind.definition.name] ?? null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
static [Symbol.hasInstance](value) {
|
|
54
53
|
if (!uniqueKind.has(value)) {
|
|
55
54
|
return false;
|
|
56
55
|
}
|
|
@@ -60,8 +59,12 @@ function kindHeritage(uniqueName, kind) {
|
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
61
|
return true;
|
|
63
|
-
}
|
|
62
|
+
}
|
|
64
63
|
});
|
|
64
|
+
kinds.forEach((value) => {
|
|
65
|
+
ParentKindClass.prototype[value.runTimeKey] = null;
|
|
66
|
+
});
|
|
67
|
+
ParentKindClass.prototype[uniqueKind.runTimeKey] = null;
|
|
65
68
|
return ParentKindClass;
|
|
66
69
|
}
|
|
67
70
|
function isRuntimeKind(value) {
|
package/dist/common/kind.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ForbiddenString } from "../string";
|
|
2
|
-
import { type Or, type IsEqual, type BreakGenericLink, type Adaptor, type UnionToIntersection } from "./types";
|
|
2
|
+
import { type Or, type IsEqual, type BreakGenericLink, type Adaptor, type UnionToIntersection, type AnyConstructor, type NeverCoalescing, type And } from "./types";
|
|
3
3
|
import { type GetPropsWithValue, type PartialKeys } from "../object";
|
|
4
4
|
export interface KindHandler<GenericKindDefinition extends KindDefinition = KindDefinition> {
|
|
5
5
|
definition: GenericKindDefinition;
|
|
@@ -49,6 +49,6 @@ export declare function createKindNamespace<GenericNamespace extends string>(nam
|
|
|
49
49
|
export type KindHeritageConstructorParams<GenericKindHandler extends KindHandler> = {
|
|
50
50
|
[KindHandler in GenericKindHandler as KindHandler["definition"]["name"]]: KindHandler["definition"]["value"];
|
|
51
51
|
} extends infer InferredResult extends object ? PartialKeys<InferredResult, GetPropsWithValue<InferredResult, unknown>> : never;
|
|
52
|
-
export declare function kindHeritage<GenericUniqueName extends string, GenericKindHandler extends KindHandler>(uniqueName: GenericUniqueName & ForbiddenKindCharacters<GenericUniqueName>, kind: GenericKindHandler | GenericKindHandler[]): new (...args: IsEqual<GenericKindHandler extends KindHandler ? IsEqual<GenericKindHandler["definition"]["value"], unknown> : never, true> extends true ? [params?: KindHeritageConstructorParams<GenericKindHandler>] : [params: KindHeritageConstructorParams<GenericKindHandler>]) => UnionToIntersection<(GenericKindHandler extends KindHandler ? Kind<GenericKindHandler["definition"]> : never) | Kind<KindDefinition<GenericUniqueName, unknown
|
|
52
|
+
export declare function kindHeritage<GenericUniqueName extends string, GenericKindHandler extends KindHandler, GenericParent extends AnyConstructor = never>(uniqueName: GenericUniqueName & ForbiddenKindCharacters<GenericUniqueName>, kind: GenericKindHandler | GenericKindHandler[], parent?: GenericParent): new (...args: And<[IsEqual<GenericKindHandler extends KindHandler ? IsEqual<GenericKindHandler["definition"]["value"], unknown> : never, true>, IsEqual<GenericParent, never>]> extends true ? [params?: KindHeritageConstructorParams<GenericKindHandler>] : [params: KindHeritageConstructorParams<GenericKindHandler>, ...parentArgs: IsEqual<ConstructorParameters<GenericParent>, never> extends true ? [parentParams?: ConstructorParameters<GenericParent>] : [parentParams: ConstructorParameters<GenericParent>]]) => UnionToIntersection<(GenericKindHandler extends KindHandler ? Kind<GenericKindHandler["definition"]> : never) | Kind<KindDefinition<GenericUniqueName, unknown>> | NeverCoalescing<GenericParent, {}>>;
|
|
53
53
|
export declare function isRuntimeKind(value: string): boolean;
|
|
54
54
|
export {};
|
package/dist/common/kind.mjs
CHANGED
|
@@ -33,22 +33,21 @@ function createKindNamespace(namespace) {
|
|
|
33
33
|
return kindHandler;
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
function kindHeritage(uniqueName, kind) {
|
|
36
|
+
function kindHeritage(uniqueName, kind, parent) {
|
|
37
37
|
const uniqueKind = createKind(uniqueName);
|
|
38
38
|
const kinds = kind instanceof Array
|
|
39
39
|
? kind
|
|
40
40
|
: [kind];
|
|
41
|
-
const
|
|
42
|
-
for (const kind of kinds) {
|
|
43
|
-
this[kind.runTimeKey] = params[kind.definition.name] ?? null;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
kinds.forEach((value) => {
|
|
47
|
-
ParentKindClass.prototype[value.runTimeKey] = null;
|
|
41
|
+
const Extendable = (parent ?? class {
|
|
48
42
|
});
|
|
49
|
-
ParentKindClass
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
const ParentKindClass = (class extends Extendable {
|
|
44
|
+
constructor(params = {}, parentParams = []) {
|
|
45
|
+
super(...parentParams);
|
|
46
|
+
for (const kind of kinds) {
|
|
47
|
+
this[kind.runTimeKey] = params[kind.definition.name] ?? null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
static [Symbol.hasInstance](value) {
|
|
52
51
|
if (!uniqueKind.has(value)) {
|
|
53
52
|
return false;
|
|
54
53
|
}
|
|
@@ -58,8 +57,12 @@ function kindHeritage(uniqueName, kind) {
|
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
return true;
|
|
61
|
-
}
|
|
60
|
+
}
|
|
62
61
|
});
|
|
62
|
+
kinds.forEach((value) => {
|
|
63
|
+
ParentKindClass.prototype[value.runTimeKey] = null;
|
|
64
|
+
});
|
|
65
|
+
ParentKindClass.prototype[uniqueKind.runTimeKey] = null;
|
|
63
66
|
return ParentKindClass;
|
|
64
67
|
}
|
|
65
68
|
function isRuntimeKind(value) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type UnwrapArray<GenericValue extends unknown> = GenericValue extends readonly any[] ? GenericValue[number] : GenericValue;
|