Skip to content

Commit

Permalink
Convert to keyword parameter in misc and notations modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon committed Sep 15, 2024
1 parent b61caf1 commit 425d579
Show file tree
Hide file tree
Showing 37 changed files with 464 additions and 364 deletions.
4 changes: 3 additions & 1 deletion src/programmers/AssertProgrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export namespace AssertProgrammer {
}): FeatureProgrammer.IDecomposed => {
const is: FeatureProgrammer.IDecomposed = IsProgrammer.decompose({
...props,
equals: props.config.equals,
config: {
equals: props.config.equals,
},
});
const composed: FeatureProgrammer.IComposed = CheckerProgrammer.compose({
...props,
Expand Down
43 changes: 21 additions & 22 deletions src/programmers/misc/MiscAssertCloneProgrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IdentifierFactory } from "../../factories/IdentifierFactory";
import { StatementFactory } from "../../factories/StatementFactory";
import { TypeFactory } from "../../factories/TypeFactory";

import { IProgrammerProps } from "../../transformers/IProgrammerProps";
import { ITypiaContext } from "../../transformers/ITypiaContext";

import { AssertProgrammer } from "../AssertProgrammer";
Expand All @@ -13,16 +14,18 @@ import { MiscCloneProgrammer } from "./MiscCloneProgrammer";

export namespace MiscAssertCloneProgrammer {
export const decompose = (props: {
project: ITypiaContext;
context: ITypiaContext;
importer: FunctionImporter;
type: ts.Type;
name: string | undefined;
init: ts.Expression | undefined;
init?: ts.Expression | undefined;
}): FeatureProgrammer.IDecomposed => {
const assert: FeatureProgrammer.IDecomposed = AssertProgrammer.decompose({
...props,
equals: false,
guard: false,
config: {
equals: false,
guard: false,
},
});
const clone: FeatureProgrammer.IDecomposed = MiscCloneProgrammer.decompose({
...props,
Expand Down Expand Up @@ -66,22 +69,18 @@ export namespace MiscAssertCloneProgrammer {
};
};

export const write =
(project: ITypiaContext) =>
(modulo: ts.LeftHandSideExpression) =>
(type: ts.Type, name?: string, init?: ts.Expression): ts.CallExpression => {
const importer: FunctionImporter = new FunctionImporter(modulo.getText());
const result: FeatureProgrammer.IDecomposed = decompose({
project,
importer,
type,
name,
init,
});
return FeatureProgrammer.writeDecomposed({
modulo,
importer,
result,
});
};
export const write = (props: IProgrammerProps): ts.CallExpression => {
const importer: FunctionImporter = new FunctionImporter(
props.modulo.getText(),
);
const result: FeatureProgrammer.IDecomposed = decompose({
...props,
importer,
});
return FeatureProgrammer.writeDecomposed({
modulo: props.modulo,
importer,
result,
});
};
}
45 changes: 22 additions & 23 deletions src/programmers/misc/MiscAssertPruneProgrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IdentifierFactory } from "../../factories/IdentifierFactory";
import { StatementFactory } from "../../factories/StatementFactory";
import { TypeFactory } from "../../factories/TypeFactory";

import { IProgrammerProps } from "../../transformers/IProgrammerProps";
import { ITypiaContext } from "../../transformers/ITypiaContext";

import { AssertProgrammer } from "../AssertProgrammer";
Expand All @@ -13,16 +14,18 @@ import { MiscPruneProgrammer } from "./MiscPruneProgrammer";

export namespace MiscAssertPruneProgrammer {
export const decompose = (props: {
project: ITypiaContext;
context: ITypiaContext;
importer: FunctionImporter;
type: ts.Type;
name: string | undefined;
init: ts.Expression | undefined;
init?: ts.Expression | undefined;
}): FeatureProgrammer.IDecomposed => {
const assert: FeatureProgrammer.IDecomposed = AssertProgrammer.decompose({
...props,
equals: false,
guard: false,
config: {
equals: false,
guard: false,
},
});
const prune: FeatureProgrammer.IDecomposed = MiscPruneProgrammer.decompose({
...props,
Expand All @@ -48,7 +51,7 @@ export namespace MiscAssertPruneProgrammer {
],
ts.factory.createTypeReferenceNode(
props.name ??
TypeFactory.getFullName(props.project.checker)(props.type),
TypeFactory.getFullName(props.context.checker)(props.type),
),
undefined,
ts.factory.createBlock(
Expand Down Expand Up @@ -84,22 +87,18 @@ export namespace MiscAssertPruneProgrammer {
};
};

export const write =
(project: ITypiaContext) =>
(modulo: ts.LeftHandSideExpression) =>
(type: ts.Type, name?: string, init?: ts.Expression): ts.CallExpression => {
const importer: FunctionImporter = new FunctionImporter(modulo.getText());
const result: FeatureProgrammer.IDecomposed = decompose({
project,
importer,
type,
name,
init,
});
return FeatureProgrammer.writeDecomposed({
modulo,
importer,
result,
});
};
export const write = (props: IProgrammerProps): ts.CallExpression => {
const importer: FunctionImporter = new FunctionImporter(
props.modulo.getText(),
);
const result: FeatureProgrammer.IDecomposed = decompose({
...props,
importer,
});
return FeatureProgrammer.writeDecomposed({
modulo: props.modulo,
importer,
result,
});
};
}
40 changes: 19 additions & 21 deletions src/programmers/misc/MiscCloneProgrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { MetadataArray } from "../../schemas/metadata/MetadataArray";
import { MetadataTuple } from "../../schemas/metadata/MetadataTuple";
import { MetadataTupleType } from "../../schemas/metadata/MetadataTupleType";

import { IProgrammerProps } from "../../transformers/IProgrammerProps";
import { ITypiaContext } from "../../transformers/ITypiaContext";
import { TransformerError } from "../../transformers/TransformerError";

Expand All @@ -27,15 +28,15 @@ import { wrap_metadata_rest_tuple } from "../internal/wrap_metadata_rest_tuple";
export namespace MiscCloneProgrammer {
export const decompose = (props: {
validated: boolean;
project: ITypiaContext;
context: ITypiaContext;
importer: FunctionImporter;
type: ts.Type;
name: string | undefined;
}): FeatureProgrammer.IDecomposed => {
const config = configure(props.project)(props.importer);
const config = configure(props.context)(props.importer);
if (props.validated === false)
config.addition = (collection) =>
IsProgrammer.write_function_statements(props.project)(props.importer)(
IsProgrammer.write_function_statements(props.context)(props.importer)(
collection,
);
const composed: FeatureProgrammer.IComposed = FeatureProgrammer.compose({
Expand All @@ -56,24 +57,21 @@ export namespace MiscCloneProgrammer {
};
};

export const write =
(project: ITypiaContext) =>
(modulo: ts.LeftHandSideExpression) =>
(type: ts.Type, name?: string): ts.CallExpression => {
const importer: FunctionImporter = new FunctionImporter(modulo.getText());
const result: FeatureProgrammer.IDecomposed = decompose({
validated: false,
project,
importer,
type,
name,
});
return FeatureProgrammer.writeDecomposed({
modulo,
importer,
result,
});
};
export const write = (props: IProgrammerProps): ts.CallExpression => {
const importer: FunctionImporter = new FunctionImporter(
props.modulo.getText(),
);
const result: FeatureProgrammer.IDecomposed = decompose({
...props,
validated: false,
importer,
});
return FeatureProgrammer.writeDecomposed({
modulo: props.modulo,
importer,
result,
});
};

const write_array_functions =
(config: FeatureProgrammer.IConfig) =>
Expand Down
38 changes: 19 additions & 19 deletions src/programmers/misc/MiscIsCloneProgrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IdentifierFactory } from "../../factories/IdentifierFactory";
import { StatementFactory } from "../../factories/StatementFactory";
import { TypeFactory } from "../../factories/TypeFactory";

import { IProgrammerProps } from "../../transformers/IProgrammerProps";
import { ITypiaContext } from "../../transformers/ITypiaContext";

import { FeatureProgrammer } from "../FeatureProgrammer";
Expand All @@ -13,14 +14,16 @@ import { MiscCloneProgrammer } from "./MiscCloneProgrammer";

export namespace MiscIsCloneProgrammer {
export const decompose = (props: {
project: ITypiaContext;
context: ITypiaContext;
importer: FunctionImporter;
type: ts.Type;
name: string | undefined;
}): FeatureProgrammer.IDecomposed => {
const is: FeatureProgrammer.IDecomposed = IsProgrammer.decompose({
...props,
equals: false,
config: {
equals: false,
},
});
const clone: FeatureProgrammer.IDecomposed = MiscCloneProgrammer.decompose({
...props,
Expand Down Expand Up @@ -73,21 +76,18 @@ export namespace MiscIsCloneProgrammer {
};
};

export const write =
(project: ITypiaContext) =>
(modulo: ts.LeftHandSideExpression) =>
(type: ts.Type, name?: string): ts.CallExpression => {
const importer: FunctionImporter = new FunctionImporter(modulo.getText());
const result: FeatureProgrammer.IDecomposed = decompose({
project,
importer,
type,
name,
});
return FeatureProgrammer.writeDecomposed({
modulo,
importer,
result,
});
};
export const write = (props: IProgrammerProps): ts.CallExpression => {
const importer: FunctionImporter = new FunctionImporter(
props.modulo.getText(),
);
const result: FeatureProgrammer.IDecomposed = decompose({
...props,
importer,
});
return FeatureProgrammer.writeDecomposed({
modulo: props.modulo,
importer,
result,
});
};
}
38 changes: 19 additions & 19 deletions src/programmers/misc/MiscIsPruneProgrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IdentifierFactory } from "../../factories/IdentifierFactory";
import { StatementFactory } from "../../factories/StatementFactory";
import { TypeFactory } from "../../factories/TypeFactory";

import { IProgrammerProps } from "../../transformers/IProgrammerProps";
import { ITypiaContext } from "../../transformers/ITypiaContext";

import { FeatureProgrammer } from "../FeatureProgrammer";
Expand All @@ -13,14 +14,16 @@ import { MiscPruneProgrammer } from "./MiscPruneProgrammer";

export namespace MiscIsPruneProgrammer {
export const decompose = (props: {
project: ITypiaContext;
context: ITypiaContext;
importer: FunctionImporter;
type: ts.Type;
name: string | undefined;
}): FeatureProgrammer.IDecomposed => {
const is: FeatureProgrammer.IDecomposed = IsProgrammer.decompose({
...props,
equals: false,
config: {
equals: false,
},
});
const prune: FeatureProgrammer.IDecomposed = MiscPruneProgrammer.decompose({
...props,
Expand Down Expand Up @@ -71,21 +74,18 @@ export namespace MiscIsPruneProgrammer {
};
};

export const write =
(project: ITypiaContext) =>
(modulo: ts.LeftHandSideExpression) =>
(type: ts.Type, name?: string): ts.CallExpression => {
const importer: FunctionImporter = new FunctionImporter(modulo.getText());
const result: FeatureProgrammer.IDecomposed = decompose({
project,
importer,
type,
name,
});
return FeatureProgrammer.writeDecomposed({
modulo,
importer,
result,
});
};
export const write = (props: IProgrammerProps): ts.CallExpression => {
const importer: FunctionImporter = new FunctionImporter(
props.modulo.getText(),
);
const result: FeatureProgrammer.IDecomposed = decompose({
...props,
importer,
});
return FeatureProgrammer.writeDecomposed({
modulo: props.modulo,
importer,
result,
});
};
}
Loading

0 comments on commit 425d579

Please sign in to comment.