Skip to content

Commit

Permalink
Merge pull request #192 from samchon/v3.2
Browse files Browse the repository at this point in the history
Fix #191 - index identifier not by random generator but by sequential…
  • Loading branch information
samchon authored Sep 14, 2022
2 parents d795c30 + 0a1e09b commit dcaeff8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-json",
"version": "3.2.4",
"version": "3.2.5",
"description": "Runtime type checkers and 5x faster JSON.stringify() function",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/programmers/CheckerProgrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ export namespace CheckerProgrammer {
trace: config.trace,
decoder: decode(project, config, importer),
},
importer,
config.joiner.array,
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/programmers/FeatureProgrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { IProject } from "../transformers/IProject";

import { Escaper } from "../utils/Escaper";

import { FunctionImporter } from "./helpers/FunctionImporeter";
import { IExpressionEntry } from "./helpers/IExpressionEntry";
import { UnionExplorer } from "./helpers/UnionExplorer";

Expand Down Expand Up @@ -259,13 +260,14 @@ export namespace FeatureProgrammer {
----------------------------------------------------------- */
export function decode_array(
config: Pick<IConfig, "trace" | "decoder">,
importer: FunctionImporter,
combiner: (
input: ts.Expression,
arrow: ts.ArrowFunction,
tags: IMetadataTag[],
) => ts.Expression,
) {
const rand: string = Math.random().toString().slice(2);
const rand: string = importer.increment().toString();
const tail = config.trace
? [
ts.factory.createParameterDeclaration(
Expand Down
1 change: 1 addition & 0 deletions src/programmers/StringifyProgrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ export namespace StringifyProgrammer {
const decode_array = (project: IProject, importer: FunctionImporter) =>
FeatureProgrammer.decode_array(
CONFIG(project, importer),
importer,
StringifyJoiner.array,
);

Expand Down
5 changes: 5 additions & 0 deletions src/programmers/helpers/FunctionImporeter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { StatementFactory } from "../../factories/StatementFactory";

export class FunctionImporter {
private readonly used_: Set<string> = new Set();
private sequence_: number = 0;

public empty(): boolean {
return this.used_.size === 0;
Expand All @@ -24,4 +25,8 @@ export class FunctionImporter {
),
);
}

public increment(): number {
return ++this.sequence_;
}
}

0 comments on commit dcaeff8

Please sign in to comment.