is-my-json-valid
Advanced tools
Comparing version 2.20.2 to 2.20.3
29
index.js
@@ -48,9 +48,2 @@ var genobj = require('generate-object-property') | ||
var formatName = function(field) { | ||
field = JSON.stringify(field) | ||
var pattern = /\[([^\[\]"]+)\]/ | ||
while (pattern.test(field)) field = field.replace(pattern, '."+$1+"') | ||
return field | ||
} | ||
var types = {} | ||
@@ -127,6 +120,25 @@ | ||
var syms = {} | ||
var allocated = [] | ||
var gensym = function(name) { | ||
return name+(syms[name] = (syms[name] || 0)+1) | ||
var res = name+(syms[name] = (syms[name] || 0)+1) | ||
allocated.push(res) | ||
return res | ||
} | ||
var formatName = function(field) { | ||
var s = JSON.stringify(field) | ||
try { | ||
var pattern = /\[([^\[\]"]+)\]/ | ||
while (pattern.test(s)) s = s.replace(pattern, replacer) | ||
return s | ||
} catch (_) { | ||
return JSON.stringify(field) | ||
} | ||
function replacer (match, v) { | ||
if (allocated.indexOf(v) === -1) throw new Error('Unreplaceable') | ||
return '." + ' + v + ' + "' | ||
} | ||
} | ||
var reversePatterns = {} | ||
@@ -145,2 +157,3 @@ var patterns = function(p) { | ||
vars.push(v+v[0]) | ||
allocated.push(v) | ||
return v | ||
@@ -147,0 +160,0 @@ } |
{ | ||
"name": "is-my-json-valid", | ||
"version": "2.20.2", | ||
"version": "2.20.3", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": "mafintosh/is-my-json-valid", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40167
675