typebox 1.1.16 → 1.1.17

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.
@@ -1,9 +1,7 @@
1
1
  export interface TExternal {
2
- /** The name of the variable that holds external variables in generated code */
3
- identifier: string;
4
- /** An array of external variables */
2
+ identifier: 'External';
5
3
  variables: unknown[];
6
4
  }
7
- export declare function ResetExternal(): void;
8
5
  export declare function CreateVariable(value: unknown): string;
6
+ export declare function ResetExternal(): void;
9
7
  export declare function GetExternal(): TExternal;
@@ -1,34 +1,25 @@
1
1
  // deno-fmt-ignore-file
2
- const identifier = 'external_';
3
- let resetCount = 0;
4
2
  const state = {
5
- identifier: `${identifier}${resetCount}`,
3
+ identifier: 'External',
6
4
  variables: []
7
5
  };
8
6
  // ------------------------------------------------------------------
9
- // ResetExternals
10
- //
11
- // Each reset results in a new external group identifier. This is done
12
- // to prevent variable name overlap when generating and evaluating
13
- // multiple types in the same scope.
14
- //
15
- // ------------------------------------------------------------------
16
- export function ResetExternal() {
17
- state.identifier = `${identifier}${resetCount}`;
18
- state.variables = [];
19
- resetCount += 1;
20
- }
21
- // ------------------------------------------------------------------
22
7
  // CreateVariable
23
8
  // ------------------------------------------------------------------
24
9
  export function CreateVariable(value) {
25
- const call = `${state.identifier}[${state.variables.length}]`;
10
+ const call = `External[${state.variables.length}]`;
26
11
  state.variables.push(value);
27
12
  return call;
28
13
  }
29
14
  // ------------------------------------------------------------------
15
+ // ResetExternal
16
+ // ------------------------------------------------------------------
17
+ export function ResetExternal() {
18
+ state.variables = [];
19
+ }
20
+ // ------------------------------------------------------------------
30
21
  // GetExternals
31
22
  // ------------------------------------------------------------------
32
23
  export function GetExternal() {
33
- return state;
24
+ return { ...state };
34
25
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typebox",
3
3
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
4
- "version": "1.1.16",
4
+ "version": "1.1.17",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"