Skip to content

Commit cef7d59

Browse files
committed
fix: typo disableRecusionLimit to disableRecursionLimit
1 parent 0a8c84e commit cef7d59

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/draft2019-09/methods/getData.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type TemplateOptions = {
3131
*/
3232
recursionLimit?: number;
3333
/** @internal disables recursion limit for next call */
34-
disableRecusionLimit?: boolean;
34+
disableRecursionLimit?: boolean;
3535
/** @internal context to track recursion limit */
3636
cache?: Record<string, Record<string, number>>;
3737
};
@@ -46,10 +46,10 @@ function safeResolveRef(node: SchemaNode, options: TemplateOptions) {
4646
cache[origin] = cache[origin] ?? {};
4747
cache[origin][node.$ref] = cache[origin][node.$ref] ?? 0;
4848
const value = cache[origin][node.$ref];
49-
if (value >= recursionLimit && options.disableRecusionLimit !== true) {
49+
if (value >= recursionLimit && options.disableRecursionLimit !== true) {
5050
return false;
5151
}
52-
options.disableRecusionLimit = false;
52+
options.disableRecursionLimit = false;
5353
cache[origin][node.$ref] += 1;
5454
const resolvedNode = node.resolveRef();
5555
if (resolvedNode && resolvedNode !== node) {
@@ -178,10 +178,10 @@ export function getData(node: SchemaNode, data?: unknown, opts?: TemplateOptions
178178

179179
const TYPE: Record<string, (node: SchemaNode, data: unknown, opts: TemplateOptions) => unknown> = {
180180
null: (node, data, opts) => getDefault(node, data, null, opts.useTypeDefaults),
181-
string: (node, data,opts) => getDefault(node, data, "", opts.useTypeDefaults),
182-
number: (node, data,opts) => getDefault(node, data, 0, opts.useTypeDefaults),
183-
integer: (node, data,opts) => getDefault(node, data, 0, opts.useTypeDefaults),
184-
boolean: (node, data,opts) => getDefault(node, data, false, opts.useTypeDefaults),
181+
string: (node, data, opts) => getDefault(node, data, "", opts.useTypeDefaults),
182+
number: (node, data, opts) => getDefault(node, data, 0, opts.useTypeDefaults),
183+
integer: (node, data, opts) => getDefault(node, data, 0, opts.useTypeDefaults),
184+
boolean: (node, data, opts) => getDefault(node, data, false, opts.useTypeDefaults),
185185
// object: (draft, schema, data: Record<string, unknown> | undefined, pointer: JsonPointer, opts: TemplateOptions) => {
186186
object: (node, data, opts) => {
187187
const schema = node.schema;
@@ -197,7 +197,7 @@ const TYPE: Record<string, (node: SchemaNode, data: unknown, opts: TemplateOptio
197197
const value = data === undefined || input === undefined ? getValue(template, propertyName) : input;
198198
// Omit adding a property if it is not required or optional props should be added
199199
if (value != null || isRequired || opts.addOptionalProps) {
200-
const propertyValue = propertyNode.getData(value, opts);
200+
const propertyValue = propertyNode.getData(value, opts);
201201
if (propertyValue !== undefined || opts.useTypeDefaults !== false) {
202202
d[propertyName] = propertyValue;
203203
}
@@ -320,7 +320,7 @@ const TYPE: Record<string, (node: SchemaNode, data: unknown, opts: TemplateOptio
320320
const cache = { ...opts.cache };
321321
for (let i = 0, l = Math.max(minItems, d.length); i < l; i += 1) {
322322
opts.cache = copy(cache);
323-
const options = { ...opts, disableRecusionLimit: true };
323+
const options = { ...opts, disableRecursionLimit: true };
324324
const result = node.items.getData(d[i] == null ? template[i] : d[i], options);
325325
// @attention if getData aborts recursion it currently returns undefined)
326326
if (result === undefined) {
@@ -346,4 +346,4 @@ function getDefault({ schema }: SchemaNode, templateValue: any, initValue: any,
346346
return initValue;
347347
}
348348
return schema.default;
349-
}
349+
}

src/methods/getData.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type TemplateOptions = {
3131
*/
3232
recursionLimit?: number;
3333
/** @internal disables recursion limit for next call */
34-
disableRecusionLimit?: boolean;
34+
disableRecursionLimit?: boolean;
3535
/** @internal context to track recursion limit */
3636
cache?: Record<string, Record<string, number>>;
3737
};
@@ -46,10 +46,10 @@ function safeResolveRef(node: SchemaNode, options: TemplateOptions) {
4646
cache[origin] = cache[origin] ?? {};
4747
cache[origin][node.$ref] = cache[origin][node.$ref] ?? 0;
4848
const value = cache[origin][node.$ref];
49-
if (value >= recursionLimit && options.disableRecusionLimit !== true) {
49+
if (value >= recursionLimit && options.disableRecursionLimit !== true) {
5050
return false;
5151
}
52-
options.disableRecusionLimit = false;
52+
options.disableRecursionLimit = false;
5353
cache[origin][node.$ref] += 1;
5454
const resolvedNode = node.resolveRef();
5555
if (resolvedNode && resolvedNode !== node) {
@@ -169,10 +169,10 @@ export function getData(node: SchemaNode, data?: unknown, opts?: TemplateOptions
169169

170170
const TYPE: Record<string, (node: SchemaNode, data: unknown, opts: TemplateOptions) => unknown> = {
171171
null: (node, data, opts) => getDefault(node, data, null, opts.useTypeDefaults),
172-
string: (node, data,opts) => getDefault(node, data, "", opts.useTypeDefaults),
173-
number: (node, data,opts) => getDefault(node, data, 0, opts.useTypeDefaults),
174-
integer: (node, data,opts) => getDefault(node, data, 0, opts.useTypeDefaults),
175-
boolean: (node, data,opts) => getDefault(node, data, false, opts.useTypeDefaults),
172+
string: (node, data, opts) => getDefault(node, data, "", opts.useTypeDefaults),
173+
number: (node, data, opts) => getDefault(node, data, 0, opts.useTypeDefaults),
174+
integer: (node, data, opts) => getDefault(node, data, 0, opts.useTypeDefaults),
175+
boolean: (node, data, opts) => getDefault(node, data, false, opts.useTypeDefaults),
176176
// object: (draft, schema, data: Record<string, unknown> | undefined, pointer: JsonPointer, opts: TemplateOptions) => {
177177
object: (node, data, opts) => {
178178
const schema = node.schema;
@@ -188,8 +188,8 @@ const TYPE: Record<string, (node: SchemaNode, data: unknown, opts: TemplateOptio
188188
const value = data === undefined || input === undefined ? getValue(template, propertyName) : input;
189189
// Omit adding a property if it is not required or optional props should be added
190190
if (value != null || isRequired || opts.addOptionalProps) {
191-
const propertyValue = propertyNode.getData(value, opts);
192-
if(propertyValue !== undefined || opts.useTypeDefaults !== false) {
191+
const propertyValue = propertyNode.getData(value, opts);
192+
if (propertyValue !== undefined || opts.useTypeDefaults !== false) {
193193
d[propertyName] = propertyValue;
194194
}
195195
}
@@ -277,7 +277,7 @@ const TYPE: Record<string, (node: SchemaNode, data: unknown, opts: TemplateOptio
277277
const itemCount = Math.max(minItems, d.length);
278278
for (let i = 0; i < itemCount; i += 1) {
279279
opts.cache = copy(cache);
280-
const options = { ...opts, disableRecusionLimit: true };
280+
const options = { ...opts, disableRecursionLimit: true };
281281
d[i] = node.items.getData(d[i] == null ? template[i] : d[i], options);
282282
}
283283
}
@@ -316,7 +316,7 @@ const TYPE: Record<string, (node: SchemaNode, data: unknown, opts: TemplateOptio
316316
const cache = { ...opts.cache };
317317
for (let i = 0, l = Math.max(minItems, d.length); i < l; i += 1) {
318318
opts.cache = copy(cache);
319-
const options = { ...opts, disableRecusionLimit: true };
319+
const options = { ...opts, disableRecursionLimit: true };
320320
const result = node.items.getData(d[i] == null ? template[i] : d[i], options);
321321
// @attention if getData aborts recursion it currently returns undefined)
322322
if (result === undefined) {
@@ -342,4 +342,4 @@ function getDefault({ schema }: SchemaNode, templateValue: any, initValue: any,
342342
return initValue;
343343
}
344344
return schema.default;
345-
}
345+
}

0 commit comments

Comments
 (0)