relaxed-json
Advanced tools
Comparing version
@@ -25,3 +25,3 @@ #!/usr/bin/env node | ||
console.log(program.help()); | ||
return 0; | ||
return 1; | ||
} | ||
@@ -46,2 +46,4 @@ | ||
} | ||
return 0; | ||
} | ||
@@ -48,0 +50,0 @@ |
{ | ||
"name": "relaxed-json", | ||
"description": "Relaxed JSON is strict superset JSON, relaxing strictness of valilla JSON", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"homepage": "https://github.com/phadej/relaxed-json", | ||
@@ -30,10 +30,10 @@ "author": { | ||
"devDependencies": { | ||
"david": "^6.1.4", | ||
"eslint": "^0.24.1", | ||
"istanbul": "~0.3.0", | ||
"jscs": "^1.11.3", | ||
"david": "^11.0.0", | ||
"eslint": "^3.17.1", | ||
"istanbul": "^0.4.5", | ||
"jscs": "^3.0.7", | ||
"jshint": "^2.6.0", | ||
"jsverify": "^0.6.0-alpha.1", | ||
"mocha": "^2.1.0", | ||
"uglify-js": "~2.4.13", | ||
"jsverify": "^0.7.1", | ||
"mocha": "^3.2.0", | ||
"uglify-js": "^2.8.9", | ||
"underscore": "^1.8.2" | ||
@@ -40,0 +40,0 @@ }, |
@@ -5,4 +5,5 @@ # Relaxed JSON | ||
[](http://badge.fury.io/js/relaxed-json) | ||
[](https://gemnasium.com/phadej/relaxed-json) | ||
[)](https://codeclimate.com/github/phadej/relaxed-json) | ||
[](https://david-dm.org/phadej/relaxed-json) | ||
[](https://david-dm.org/phadej/relaxed-json#info=devDependencies) | ||
[](https://codeclimate.com/github/phadej/relaxed-json) | ||
@@ -49,3 +50,3 @@ Are you frustrated that you cannot add comments into your configuration JSON | ||
% rjson package.json | ||
% rjson package.json | ||
{ | ||
@@ -60,2 +61,6 @@ "name": "relaxed-json", | ||
- 1.0.1 — 2017-03-08 — Meteor compatibility | ||
- [#9](https://github.com/phadej/relaxed-json/issues/9) | ||
[#14](https://github.com/phadej/relaxed-json/pull/14) | ||
[#15](https://github.com/phadej/relaxed-json/pull/15) | ||
- 1.0.0 — 2015-07-13 — Stable release | ||
@@ -62,0 +67,0 @@ - Forward slashes bug fixed |
@@ -60,2 +60,4 @@ /* | ||
}; | ||
} else { | ||
return undefined; | ||
} | ||
@@ -127,5 +129,8 @@ }); | ||
// comments are whitespace, leave only linefeeds | ||
return { type: " ", match: m[0].replace(/./g, function (c) { | ||
return (/\s/).test(c) ? c : " "; | ||
}) }; | ||
return { | ||
type: " ", | ||
match: m[0].replace(/./g, function (c) { | ||
return (/\s/).test(c) ? c : " "; | ||
}), | ||
}; | ||
} | ||
@@ -144,5 +149,6 @@ | ||
switch (m[1]) { | ||
case "null": value = null; break; | ||
case "true": value = true; break; | ||
case "false": value = false; break; | ||
case "null": value = null; break; | ||
case "true": value = true; break; | ||
case "false": value = false; break; | ||
// no default | ||
} | ||
@@ -198,2 +204,3 @@ return { | ||
} | ||
return undefined; | ||
} | ||
@@ -254,10 +261,10 @@ | ||
switch (token.type) { | ||
case "atom": | ||
case "string": | ||
case "number": | ||
return token.type + " " + token.match; | ||
case "eof": | ||
return "end-of-file"; | ||
default: | ||
return "'" + token.type + "'"; | ||
case "atom": | ||
case "string": | ||
case "number": | ||
return token.type + " " + token.match; | ||
case "eof": | ||
return "end-of-file"; | ||
default: | ||
return "'" + token.type + "'"; | ||
} | ||
@@ -288,3 +295,3 @@ } | ||
var token = popToken(tokens, state); | ||
while (true) { | ||
while (true) { // eslint-disable-line no-constant-condition | ||
if (valid && valid.indexOf(token.type) !== -1) { | ||
@@ -353,27 +360,28 @@ return token; | ||
switch (token.type) { | ||
case ":": | ||
token = { | ||
type: "string", | ||
value: "null", | ||
line: token.line, | ||
}; | ||
case ":": | ||
token = { | ||
type: "string", | ||
value: "null", | ||
line: token.line, | ||
}; | ||
state.pos -= 1; | ||
break; | ||
state.pos -= 1; | ||
break; | ||
case "number": | ||
case "atom": | ||
token = { | ||
type: "string", | ||
value: "" + token.value, | ||
line: token.line, | ||
}; | ||
break; | ||
case "number": | ||
case "atom": | ||
token = { | ||
type: "string", | ||
value: "" + token.value, | ||
line: token.line, | ||
}; | ||
break; | ||
case "[": | ||
case "{": | ||
state.pos -= 1; | ||
value = parseAny(tokens, state); | ||
appendPair(state, obj, "null", value); | ||
return; | ||
case "[": | ||
case "{": | ||
state.pos -= 1; | ||
value = parseAny(tokens, state); // eslint-disable-line no-use-before-define | ||
appendPair(state, obj, "null", value); | ||
return; | ||
// no default | ||
} | ||
@@ -385,3 +393,3 @@ } | ||
skipColon(tokens, state); | ||
value = parseAny(tokens, state); | ||
value = parseAny(tokens, state); // eslint-disable-line no-use-before-define | ||
@@ -393,3 +401,3 @@ appendPair(state, obj, key, value); | ||
var key = arr.length; | ||
var value = parseAny(tokens, state); | ||
var value = parseAny(tokens, state); // eslint-disable-line no-use-before-define | ||
arr[key] = state.reviver ? state.reviver("" + key, value) : value; | ||
@@ -399,3 +407,3 @@ } | ||
function parseObject(tokens, state) { | ||
return parseMany(tokens, state, {}, { | ||
return parseMany(tokens, state, {}, { // eslint-disable-line no-use-before-define | ||
skip: [":", "}"], | ||
@@ -409,3 +417,3 @@ elementParser: parsePair, | ||
function parseArray(tokens, state) { | ||
return parseMany(tokens, state, [], { | ||
return parseMany(tokens, state, [], { // eslint-disable-line no-use-before-define | ||
skip: ["]"], | ||
@@ -431,13 +439,13 @@ elementParser: parseElement, | ||
switch (token.type) { | ||
case opts.endSymbol: | ||
return obj; | ||
case opts.endSymbol: | ||
return obj; | ||
default: | ||
state.pos -= 1; // push the token back | ||
opts.elementParser(tokens, state, obj); | ||
break; | ||
default: | ||
state.pos -= 1; // push the token back | ||
opts.elementParser(tokens, state, obj); | ||
break; | ||
} | ||
// Rest | ||
while (true) { | ||
while (true) { // eslint-disable-line no-constant-condition | ||
token = popToken(tokens, state); | ||
@@ -457,8 +465,9 @@ | ||
switch (token.type) { | ||
case opts.endSymbol: | ||
return obj; | ||
case opts.endSymbol: | ||
return obj; | ||
case ",": | ||
opts.elementParser(tokens, state, obj); | ||
break; | ||
case ",": | ||
opts.elementParser(tokens, state, obj); | ||
break; | ||
// no default | ||
} | ||
@@ -494,13 +503,14 @@ } | ||
switch (token.type) { | ||
case "{": | ||
ret = parseObject(tokens, state); | ||
break; | ||
case "[": | ||
ret = parseArray(tokens, state); | ||
break; | ||
case "string": | ||
case "number": | ||
case "atom": | ||
ret = token.value; | ||
break; | ||
case "{": | ||
ret = parseObject(tokens, state); | ||
break; | ||
case "[": | ||
ret = parseArray(tokens, state); | ||
break; | ||
case "string": | ||
case "number": | ||
case "atom": | ||
ret = token.value; | ||
break; | ||
// no default | ||
} | ||
@@ -519,3 +529,3 @@ | ||
return JSON.parse(transform(text), opts); | ||
} else if (new Object(opts) !== opts) { | ||
} else if (new Object(opts) !== opts) { // eslint-disable-line no-new-object | ||
throw new TypeError("opts/reviver should be undefined, a function or an object"); | ||
@@ -558,3 +568,3 @@ } | ||
function stringifyPair(obj, key) { | ||
return JSON.stringify(key) + ":" + stringify(obj[key]); | ||
return JSON.stringify(key) + ":" + stringify(obj[key]); // eslint-disable-line no-use-before-define | ||
} | ||
@@ -568,2 +578,3 @@ | ||
return JSON.stringify(obj); | ||
// no default | ||
} | ||
@@ -573,3 +584,3 @@ if (Array.isArray(obj)) { | ||
} | ||
if (new Object(obj) === obj) { | ||
if (new Object(obj) === obj) { // eslint-disable-line no-new-object | ||
var keys = Object.keys(obj); | ||
@@ -592,5 +603,7 @@ keys.sort(); | ||
window.RJSON = RJSON; | ||
} else if (typeof module !== "undefined") { | ||
} | ||
if (typeof module !== "undefined") { | ||
module.exports = RJSON; | ||
} | ||
}()); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
47410
90.51%546
2.44%95
5.56%