Navigation Menu

Skip to content

Commit

Permalink
Dependencies update
Browse files Browse the repository at this point in the history
  • Loading branch information
nfroidure committed Mar 29, 2014
1 parent 0e7194f commit d1a2f9f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 25 deletions.
6 changes: 6 additions & 0 deletions .npmignore
@@ -0,0 +1,6 @@
*~
*.swp
node_modules/
.git
.coveralls.yml
tests/results
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -14,10 +14,10 @@
"readable-stream": "^1.0.26-2"
},
"devDependencies": {
"mocha": "~1.17.1",
"mocha": "~1.18.2",
"mocha-lcov-reporter": "0.0.1",
"coveralls": "~2.7.1",
"istanbul": "~0.2.4"
"coveralls": "~2.10.0",
"istanbul": "~0.2.6"
},
"scripts": {
"test": "node_modules/mocha/bin/mocha tests/*.mocha.js",
Expand Down
8 changes: 4 additions & 4 deletions src/VarStream.js
Expand Up @@ -24,15 +24,15 @@ function VarStream(rootObject, rootProperty, options) {

// Ensure new were used
if(!(this instanceof VarStream)) {
throw Error('Please use the "new" operator to instanciate a VarStream.');
throw new Error('Please use the "new" operator to instanciate a VarStream.');
}

// Ensure we had root object and property
if(!(rootObject instanceof Object)) {
throw Error('No root object provided.');
throw new Error('No root object provided.');
}
if('string' !== typeof rootProperty) {
throw Error('No root property name given.');
throw new Error('No root property name given.');
}

// Parent constructor
Expand Down Expand Up @@ -63,7 +63,7 @@ function VarStream(rootObject, rootProperty, options) {
this.push(null);
};

};
}

// Parse helper
VarStream.parse = function(content) {
Expand Down
37 changes: 19 additions & 18 deletions src/VarStreamReader.js
@@ -1,4 +1,3 @@
'use strict';
/*
* Copyright (C) 2012-2013 Nicolas Froidure
*
Expand All @@ -13,6 +12,7 @@
// AMD + global + NodeJS : You can use this object by inserting a script
// or using an AMD loader (like RequireJS) or using NodeJS
(function(root,define){ define([], function() {
'use strict';
// START: Module logic start

// Constructor
Expand All @@ -22,7 +22,7 @@
// Save the options
this.options=options;
// Store current scopes for backward references
this.previousNodes=new Array();
this.previousNodes=[];
// The parse state
this.state=PARSE_NEWLINE;
// The current values
Expand Down Expand Up @@ -88,16 +88,16 @@
// check it
if(!BCK_CHARS.test(nodes[0])) {
if(this.options&VarStreamReader.STRICT_MODE) {
throw Error('Malformed backward reference.');
throw new Error('Malformed backward reference.');
}
return null;
}
n = parseInt(nodes[0].substring(1), 10);
}
if(n > this.previousNodes.length) {
if(this.options&VarStreamReader.STRICT_MODE) {
throw Error('Backward reference index is greater than the previous'
+ ' node max index.');
throw new SyntaxError('Backward reference index is greater than the'
+ ' previous node max index.');
}
return null;
}
Expand All @@ -111,7 +111,7 @@
// Checking if the node is not empty
if(''===nodes[i]) {
if(this.options&VarStreamReader.STRICT_MODE) {
throw Error('The leftValue can\'t have empty nodes ('+val+').');
throw new Error('The leftValue can\'t have empty nodes ('+val+').');
}
return null;
}
Expand All @@ -120,7 +120,7 @@
// Ensure the scope is an array
if('undefined'=== typeof scope.root[scope.prop]
||!(scope.root[scope.prop] instanceof Array)) {
scope.root[scope.prop]=new Array();
scope.root[scope.prop]=[];
}
if(nodes[i]===CHR_PLU) {
nodes[i]=scope.root[scope.prop].length;
Expand All @@ -135,14 +135,15 @@
// Checking node chars
if(!PROP_NODE_CHARS.test(nodes[i])) {
if(this.options&VarStreamReader.STRICT_MODE) {
throw Error('Illegal chars found in a the node "'+nodes[i]+'".');
throw new SyntaxError('Illegal chars found in a the node'
+ ' "'+nodes[i]+'".');
}
return null;
}
// Ensure the scope is an object
if('undefined'=== typeof scope.root[scope.prop]
||!(scope.root[scope.prop] instanceof Object)) {
scope.root[scope.prop]=new Object();
scope.root[scope.prop]={};
}
}
// Resolving the node scope
Expand All @@ -162,12 +163,11 @@
// Looping throught chunk chars
for(var i=0, j=chunk.length; i<j; i++) {
// detect escaped chars
if(chunk[i]===CHR_ESC
&&(
if(chunk[i]===CHR_ESC && (
this.state===PARSE_RVAL
||this.state===PARSE_SILENT
||this.state===PARSE_MLSTRING
)
)
) {
if(this.escaped) {
this.escaped=ESC_NONE;
Expand Down Expand Up @@ -210,7 +210,7 @@
// Fail if a new line is found
if(chunk[i]===CHR_ENDL||chunk[i]===CHR_CR) {
if(this.options&VarStreamReader.STRICT_MODE) {
throw Error('Unexpected new line found while parsing '
throw SyntaxError('Unexpected new line found while parsing '
+' a leftValue.');
}
this.state=PARSE_NEWLINE;
Expand All @@ -225,7 +225,7 @@
// Left value should not be empty
if(''===this.leftValue) {
if(this.options&VarStreamReader.STRICT_MODE) {
throw Error('Found an empty leftValue.');
throw SyntaxError('Found an empty leftValue.');
}
this.state=PARSE_SILENT;
}
Expand All @@ -236,7 +236,7 @@
if(this.operator!=CHR_EQ&&''===this.rightValue
&&this.escaped===ESC_NONE) {
if(this.options&VarStreamReader.STRICT_MODE) {
throw Error('Found an empty rightValue.');
throw SyntaxError('Found an empty rightValue.');
}
this.state=PARSE_NEWLINE;
continue;
Expand Down Expand Up @@ -334,12 +334,13 @@
} else {
if(this.escaped===ESC_LF) {
if(this.options&VarStreamReader.STRICT_MODE) {
throw Error('Assuming a LF after an escaped CR, '
throw new SyntaxError('Assuming a LF after an escaped CR, '
+chunk[i]+' found instead.');
}
} else {
if(this.options&VarStreamReader.STRICT_MODE) {
throw Error('Found an escape char but there was nothing to escape.');
throw new SyntaxError('Found an escape char but there was'
+ 'nothing to escape.');
}
this.leftValue.root[this.leftValue.prop]+='\\';
}
Expand All @@ -359,7 +360,7 @@
continue;
}
if(this.options&VarStreamReader.STRICT_MODE) {
throw Error('Unexpected char after the "'+this.operator+'"'+
throw new SyntaxError('Unexpected char after the "'+this.operator+'"'+
' operator. Expected =, found '+chunk[i]+'.');
}
if(chunk[i]===CHR_EQ||chunk[i]===CHR_CR) {
Expand Down

0 comments on commit d1a2f9f

Please sign in to comment.