Comparing version 0.1.0 to 0.2.0
{ | ||
"name": "toml", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "TOML parser for Node.js", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "./node_modules/.bin/nodeunit test/test_*.js" | ||
}, | ||
@@ -15,3 +15,6 @@ "repository": "git://github.com/BinaryMuse/toml-node.git", | ||
"author": "Brandon Tilley <brandon@brandontilley.com>", | ||
"license": "MIT" | ||
"license": "MIT", | ||
"devDependencies": { | ||
"nodeunit": "~0.7.4" | ||
} | ||
} |
TOML Parser for Node.js | ||
======================= | ||
[![Build Status](https://travis-ci.org/BinaryMuse/toml-node.png?branch=master)](https://travis-ci.org/BinaryMuse/toml-node) | ||
If you haven't heard of TOML, well you're just missing out. [Go check it out now.](https://github.com/mojombo/toml) Back? Good. | ||
@@ -16,2 +18,4 @@ | ||
Say you have some awesome TOML in a variable called `someTomlString`. Maybe it came from the web; maybe it came from a file; wherever it came from, it came asynchronously! Let's turn that sucker into a JavaScript object. | ||
var toml = require('toml'); | ||
@@ -26,15 +30,5 @@ var data = toml.parse(someTomlString); | ||
Known Bugs | ||
---------- | ||
Building & Tests | ||
---------------- | ||
* Doesn't produce error if overwriting a previously set key | ||
Unknown Bugs | ||
------------ | ||
* There's bound to be some. Report 'em, or better yet, fix 'em and submit a pull request! | ||
Hacking | ||
------- | ||
toml-node uses the Jison parser generator. | ||
@@ -44,2 +38,8 @@ | ||
jison toml.jison # generates toml.js | ||
node test/test.js # basic smoke test against example.toml | ||
npm test | ||
toml-node runs on Travis CI and is tested against: | ||
* Node 0.6 | ||
* Node 0.8 | ||
* Node 0.9 |
101
toml.js
@@ -5,5 +5,5 @@ /* parser generated by jison 0.4.2 */ | ||
yy: {}, | ||
symbols_: {"error":2,"file":3,"lines":4,"line":5,"comment":6,"keygroup":7,"assignment":8,"EOF":9,"COMMENT":10,"identifier":11,"EQUALS":12,"value":13,"IDENTIFIER":14,"[":15,"keygroupid":16,"]":17,".":18,"STR":19,"float":20,"integer":21,"bool":22,"DATETIME":23,"array":24,"INTEGER":25,"-":26,"FLOAT":27,"arrayelem":28,",":29,"TRUE":30,"FALSE":31,"$accept":0,"$end":1}, | ||
terminals_: {2:"error",9:"EOF",10:"COMMENT",12:"EQUALS",14:"IDENTIFIER",15:"[",17:"]",18:".",19:"STR",23:"DATETIME",25:"INTEGER",26:"-",27:"FLOAT",29:",",30:"TRUE",31:"FALSE"}, | ||
productions_: [0,[3,1],[4,1],[4,2],[5,1],[5,1],[5,1],[5,2],[6,1],[8,3],[11,1],[7,3],[16,1],[16,3],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[21,1],[21,2],[20,1],[20,2],[24,3],[28,1],[28,3],[22,1],[22,1]], | ||
symbols_: {"error":2,"file":3,"lines":4,"line":5,"comment":6,"keygroup":7,"assignment":8,"EOF":9,"COMMENT":10,"identifier":11,"EQUALS":12,"value":13,"IDENTIFIER":14,"[":15,"keygroupid":16,"]":17,".":18,"string":19,"float":20,"integer":21,"bool":22,"datetime":23,"array":24,"STR":25,"DATETIME":26,"INTEGER":27,"-":28,"FLOAT":29,"strarray":30,"floatarray":31,"integerarray":32,"boolarray":33,"datetimearray":34,"arrayarray":35,",":36,"TRUE":37,"FALSE":38,"$accept":0,"$end":1}, | ||
terminals_: {2:"error",9:"EOF",10:"COMMENT",12:"EQUALS",14:"IDENTIFIER",15:"[",17:"]",18:".",25:"STR",26:"DATETIME",27:"INTEGER",28:"-",29:"FLOAT",36:",",37:"TRUE",38:"FALSE"}, | ||
productions_: [0,[3,1],[4,1],[4,2],[5,1],[5,1],[5,1],[5,2],[6,1],[8,3],[11,1],[7,3],[16,1],[16,3],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[19,1],[23,1],[21,1],[21,2],[20,1],[20,2],[24,3],[24,3],[24,3],[24,3],[24,3],[24,3],[30,1],[30,3],[31,1],[31,3],[32,1],[32,3],[33,1],[33,3],[34,1],[34,3],[35,1],[35,3],[22,1],[22,1]], | ||
performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) { | ||
@@ -21,5 +21,7 @@ | ||
break; | ||
case 11: parser.toml.currentGroup = $$[$0-1]; | ||
case 11: | ||
parser.toml.setCurrentGroup($$[$0-1]); | ||
break; | ||
case 14: this.$ = parseString($$[$0]) | ||
case 14: this.$ = $$[$0] | ||
break; | ||
@@ -32,27 +34,61 @@ case 15: this.$ = $$[$0] | ||
break; | ||
case 18: this.$ = new Date($$[$0]) | ||
case 18: this.$ = $$[$0] | ||
break; | ||
case 19: this.$ = $$[$0] | ||
break; | ||
case 20: this.$ = parseInt($$[$0], 10); | ||
case 20: this.$ = parseString($$[$0]) | ||
break; | ||
case 21: this.$ = $$[$0] * -1 | ||
case 21: this.$ = new Date($$[$0]) | ||
break; | ||
case 22: this.$ = parseFloat($$[$0], 10); | ||
case 22: this.$ = parseInt($$[$0], 10); | ||
break; | ||
case 23: this.$ = $$[$0] * -1 | ||
break; | ||
case 24: this.$ = $$[$0-1] | ||
case 24: this.$ = parseFloat($$[$0], 10); | ||
break; | ||
case 25: this.$ = [$$[$0]] | ||
case 25: this.$ = $$[$0] * -1 | ||
break; | ||
case 26: $$[$0-2].push($$[$0]) | ||
case 26: this.$ = $$[$0-1] | ||
break; | ||
case 27: this.$ = true; | ||
case 27: this.$ = $$[$0-1] | ||
break; | ||
case 28: this.$ = false; | ||
case 28: this.$ = $$[$0-1] | ||
break; | ||
case 29: this.$ = $$[$0-1] | ||
break; | ||
case 30: this.$ = $$[$0-1] | ||
break; | ||
case 31: this.$ = $$[$0-1] | ||
break; | ||
case 32: this.$ = [$$[$0]] | ||
break; | ||
case 33: $$[$0-2].push($$[$0]) | ||
break; | ||
case 34: this.$ = [$$[$0]] | ||
break; | ||
case 35: $$[$0-2].push($$[$0]) | ||
break; | ||
case 36: this.$ = [$$[$0]] | ||
break; | ||
case 37: $$[$0-2].push($$[$0]) | ||
break; | ||
case 38: this.$ = [$$[$0]] | ||
break; | ||
case 39: $$[$0-2].push($$[$0]) | ||
break; | ||
case 40: this.$ = [$$[$0]] | ||
break; | ||
case 41: $$[$0-2].push($$[$0]) | ||
break; | ||
case 42: this.$ = [$$[$0]] | ||
break; | ||
case 43: $$[$0-2].push($$[$0]) | ||
break; | ||
case 44: this.$ = true; | ||
break; | ||
case 45: this.$ = false; | ||
break; | ||
} | ||
}, | ||
table: [{3:1,4:2,5:3,6:4,7:5,8:6,10:[1,7],11:9,14:[1,10],15:[1,8]},{1:[3]},{1:[2,1],5:11,6:4,7:5,8:6,10:[1,7],11:9,14:[1,10],15:[1,8]},{1:[2,2],9:[1,12],10:[2,2],14:[2,2],15:[2,2]},{1:[2,4],9:[2,4],10:[2,4],14:[2,4],15:[2,4]},{1:[2,5],9:[2,5],10:[2,5],14:[2,5],15:[2,5]},{1:[2,6],9:[2,6],10:[2,6],14:[2,6],15:[2,6]},{1:[2,8],9:[2,8],10:[2,8],14:[2,8],15:[2,8]},{11:14,14:[1,10],16:13},{12:[1,15]},{12:[2,10],17:[2,10],18:[2,10]},{1:[2,3],9:[1,12],10:[2,3],14:[2,3],15:[2,3]},{1:[2,7],9:[2,7],10:[2,7],14:[2,7],15:[2,7]},{17:[1,16],18:[1,17]},{17:[2,12],18:[2,12]},{13:18,15:[1,30],19:[1,19],20:20,21:21,22:22,23:[1,23],24:24,25:[1,27],26:[1,26],27:[1,25],30:[1,28],31:[1,29]},{1:[2,11],9:[2,11],10:[2,11],14:[2,11],15:[2,11]},{11:31,14:[1,10]},{1:[2,9],9:[2,9],10:[2,9],14:[2,9],15:[2,9]},{1:[2,14],9:[2,14],10:[2,14],14:[2,14],15:[2,14],17:[2,14],29:[2,14]},{1:[2,15],9:[2,15],10:[2,15],14:[2,15],15:[2,15],17:[2,15],29:[2,15]},{1:[2,16],9:[2,16],10:[2,16],14:[2,16],15:[2,16],17:[2,16],29:[2,16]},{1:[2,17],9:[2,17],10:[2,17],14:[2,17],15:[2,17],17:[2,17],29:[2,17]},{1:[2,18],9:[2,18],10:[2,18],14:[2,18],15:[2,18],17:[2,18],29:[2,18]},{1:[2,19],9:[2,19],10:[2,19],14:[2,19],15:[2,19],17:[2,19],29:[2,19]},{1:[2,22],9:[2,22],10:[2,22],14:[2,22],15:[2,22],17:[2,22],29:[2,22]},{20:32,21:33,25:[1,27],26:[1,26],27:[1,25]},{1:[2,20],9:[2,20],10:[2,20],14:[2,20],15:[2,20],17:[2,20],29:[2,20]},{1:[2,27],9:[2,27],10:[2,27],14:[2,27],15:[2,27],17:[2,27],29:[2,27]},{1:[2,28],9:[2,28],10:[2,28],14:[2,28],15:[2,28],17:[2,28],29:[2,28]},{13:35,15:[1,30],19:[1,19],20:20,21:21,22:22,23:[1,23],24:24,25:[1,27],26:[1,26],27:[1,25],28:34,30:[1,28],31:[1,29]},{17:[2,13],18:[2,13]},{1:[2,23],9:[2,23],10:[2,23],14:[2,23],15:[2,23],17:[2,23],29:[2,23]},{1:[2,21],9:[2,21],10:[2,21],14:[2,21],15:[2,21],17:[2,21],29:[2,21]},{17:[1,36],29:[1,37]},{17:[2,25],29:[2,25]},{1:[2,24],9:[2,24],10:[2,24],14:[2,24],15:[2,24],17:[2,24],29:[2,24]},{13:38,15:[1,30],19:[1,19],20:20,21:21,22:22,23:[1,23],24:24,25:[1,27],26:[1,26],27:[1,25],30:[1,28],31:[1,29]},{17:[2,26],29:[2,26]}], | ||
table: [{3:1,4:2,5:3,6:4,7:5,8:6,10:[1,7],11:9,14:[1,10],15:[1,8]},{1:[3]},{1:[2,1],5:11,6:4,7:5,8:6,10:[1,7],11:9,14:[1,10],15:[1,8]},{1:[2,2],9:[1,12],10:[2,2],14:[2,2],15:[2,2]},{1:[2,4],9:[2,4],10:[2,4],14:[2,4],15:[2,4]},{1:[2,5],9:[2,5],10:[2,5],14:[2,5],15:[2,5]},{1:[2,6],9:[2,6],10:[2,6],14:[2,6],15:[2,6]},{1:[2,8],9:[2,8],10:[2,8],14:[2,8],15:[2,8]},{11:14,14:[1,10],16:13},{12:[1,15]},{12:[2,10],17:[2,10],18:[2,10]},{1:[2,3],9:[1,12],10:[2,3],14:[2,3],15:[2,3]},{1:[2,7],9:[2,7],10:[2,7],14:[2,7],15:[2,7]},{17:[1,16],18:[1,17]},{17:[2,12],18:[2,12]},{13:18,15:[1,32],19:19,20:20,21:21,22:22,23:23,24:24,25:[1,25],26:[1,31],27:[1,28],28:[1,27],29:[1,26],37:[1,29],38:[1,30]},{1:[2,11],9:[2,11],10:[2,11],14:[2,11],15:[2,11]},{11:33,14:[1,10]},{1:[2,9],9:[2,9],10:[2,9],14:[2,9],15:[2,9]},{1:[2,14],9:[2,14],10:[2,14],14:[2,14],15:[2,14]},{1:[2,15],9:[2,15],10:[2,15],14:[2,15],15:[2,15]},{1:[2,16],9:[2,16],10:[2,16],14:[2,16],15:[2,16]},{1:[2,17],9:[2,17],10:[2,17],14:[2,17],15:[2,17]},{1:[2,18],9:[2,18],10:[2,18],14:[2,18],15:[2,18]},{1:[2,19],9:[2,19],10:[2,19],14:[2,19],15:[2,19]},{1:[2,20],9:[2,20],10:[2,20],14:[2,20],15:[2,20],17:[2,20],36:[2,20]},{1:[2,24],9:[2,24],10:[2,24],14:[2,24],15:[2,24],17:[2,24],36:[2,24]},{20:34,21:35,27:[1,28],28:[1,27],29:[1,26]},{1:[2,22],9:[2,22],10:[2,22],14:[2,22],15:[2,22],17:[2,22],36:[2,22]},{1:[2,44],9:[2,44],10:[2,44],14:[2,44],15:[2,44],17:[2,44],36:[2,44]},{1:[2,45],9:[2,45],10:[2,45],14:[2,45],15:[2,45],17:[2,45],36:[2,45]},{1:[2,21],9:[2,21],10:[2,21],14:[2,21],15:[2,21],17:[2,21],36:[2,21]},{15:[1,32],19:42,20:43,21:44,22:45,23:46,24:47,25:[1,25],26:[1,31],27:[1,28],28:[1,27],29:[1,26],30:36,31:37,32:38,33:39,34:40,35:41,37:[1,29],38:[1,30]},{17:[2,13],18:[2,13]},{1:[2,25],9:[2,25],10:[2,25],14:[2,25],15:[2,25],17:[2,25],36:[2,25]},{1:[2,23],9:[2,23],10:[2,23],14:[2,23],15:[2,23],17:[2,23],36:[2,23]},{17:[1,48],36:[1,49]},{17:[1,50],36:[1,51]},{17:[1,52],36:[1,53]},{17:[1,54],36:[1,55]},{17:[1,56],36:[1,57]},{17:[1,58],36:[1,59]},{17:[2,32],36:[2,32]},{17:[2,34],36:[2,34]},{17:[2,36],36:[2,36]},{17:[2,38],36:[2,38]},{17:[2,40],36:[2,40]},{17:[2,42],36:[2,42]},{1:[2,26],9:[2,26],10:[2,26],14:[2,26],15:[2,26],17:[2,26],36:[2,26]},{19:60,25:[1,25]},{1:[2,27],9:[2,27],10:[2,27],14:[2,27],15:[2,27],17:[2,27],36:[2,27]},{20:61,28:[1,62],29:[1,26]},{1:[2,28],9:[2,28],10:[2,28],14:[2,28],15:[2,28],17:[2,28],36:[2,28]},{21:63,27:[1,28],28:[1,64]},{1:[2,29],9:[2,29],10:[2,29],14:[2,29],15:[2,29],17:[2,29],36:[2,29]},{22:65,37:[1,29],38:[1,30]},{1:[2,30],9:[2,30],10:[2,30],14:[2,30],15:[2,30],17:[2,30],36:[2,30]},{23:66,26:[1,31]},{1:[2,31],9:[2,31],10:[2,31],14:[2,31],15:[2,31],17:[2,31],36:[2,31]},{15:[1,32],24:67},{17:[2,33],36:[2,33]},{17:[2,35],36:[2,35]},{20:34,28:[1,62],29:[1,26]},{17:[2,37],36:[2,37]},{21:35,27:[1,28],28:[1,64]},{17:[2,39],36:[2,39]},{17:[2,41],36:[2,41]},{17:[2,43],36:[2,43]}], | ||
defaultActions: {}, | ||
@@ -179,3 +215,3 @@ parseError: function parseError(str, hash) { | ||
function deepSet(obj, path, value) { | ||
function deepValue(obj, path, value) { | ||
var tags = path.split("."), len = tags.length - 1; | ||
@@ -186,3 +222,6 @@ for (var i = 0; i < len; i++) { | ||
} | ||
obj[tags[len]] = value; | ||
if (value !== undefined) | ||
obj[tags[len]] = value; | ||
else | ||
return obj[tags[len]] | ||
} | ||
@@ -193,7 +232,11 @@ | ||
currentGroup: null, | ||
setCurrentGroup: function(group) { | ||
if (deepValue(this.data, group)) | ||
throw new Error("Cannot overrite previously set key " + group + " with keygroup"); | ||
this.currentGroup = group; | ||
}, | ||
set: function(key, value) { | ||
if (this.currentGroup) { | ||
key = this.currentGroup + "." + key; | ||
} | ||
deepSet(this.data, key, value); | ||
if (this.currentGroup) | ||
key = this.currentGroup + '.' + key; | ||
deepValue(this.data, key, value); | ||
} | ||
@@ -377,9 +420,9 @@ }; | ||
break; | ||
case 1:return 30 | ||
case 1:return 37 | ||
break; | ||
case 2:return 31 | ||
case 2:return 38 | ||
break; | ||
case 3:return 23 | ||
case 3:return 26 | ||
break; | ||
case 4:return 19 | ||
case 4:return 25 | ||
break; | ||
@@ -390,7 +433,7 @@ case 5:return 12 | ||
break; | ||
case 7:return 27 | ||
case 7:return 29 | ||
break; | ||
case 8:return 25 | ||
case 8:return 27 | ||
break; | ||
case 9:return 26 | ||
case 9:return 28 | ||
break; | ||
@@ -401,3 +444,3 @@ case 10:return 15 | ||
break; | ||
case 12:return 29 | ||
case 12:return 36 | ||
break; | ||
@@ -404,0 +447,0 @@ case 13:return 14 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
26290
10
538
2
0
1
4