Skip to content

Commit

Permalink
Improve variable names and keep the type of coerceTypes consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
nwoltman committed Jan 16, 2018
1 parent 4729fde commit 4afc503
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions compile-json-stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ function compileJSONStringify(schema) {
class CodeBuilder {
constructor(schema) {
this.schema = schema;
this.coerceTypes = schema.coerceTypes;
this.coerceTypes = schema.coerceTypes || false;

this.schemaID = 0;
this.arrayID = 0;
this.objectID = 0;
this.schemaFnID = 0;
this.arrayFnID = 0;
this.objectFnID = 0;

this.reusableSchemaFnNames = new Set();
this.reusableArrayFnNames = new Set();
Expand Down Expand Up @@ -56,7 +56,7 @@ class CodeBuilder {
// Continue building the function
}

const name = reusableFnName || `$schema${this.schemaID++}`;
const name = reusableFnName || `$schema${this.schemaFnID++}`;
var code = `\nfunction ${name}(value) {\n`;

const {coerceTypes} = this;
Expand Down Expand Up @@ -295,7 +295,7 @@ class CodeBuilder {
this.reusableArrayFnNames.add(reusableFnName);
}

const name = reusableFnName || `$array${this.arrayID++}`;
const name = reusableFnName || `$array${this.arrayFnID++}`;

return items instanceof Array
? this.buildTupleArrayFn(items, name)
Expand Down Expand Up @@ -339,7 +339,7 @@ class CodeBuilder {

buildObjectFn(properties) {
const {coerceTypes} = this;
const name = `$object${this.objectID++}`;
const name = `$object${this.objectFnID++}`;
var code = `
function ${name}(obj) {
var str = '{'
Expand Down

0 comments on commit 4afc503

Please sign in to comment.