From d1a2f9f9246dfa3a37d6af86e6328913ee38c80b Mon Sep 17 00:00:00 2001 From: Nicolas Froidure Date: Sat, 29 Mar 2014 14:20:23 +0100 Subject: [PATCH] Dependencies update --- .npmignore | 6 ++++++ package.json | 6 +++--- src/VarStream.js | 8 ++++---- src/VarStreamReader.js | 37 +++++++++++++++++++------------------ 4 files changed, 32 insertions(+), 25 deletions(-) create mode 100755 .npmignore diff --git a/.npmignore b/.npmignore new file mode 100755 index 0000000..96347ba --- /dev/null +++ b/.npmignore @@ -0,0 +1,6 @@ +*~ +*.swp +node_modules/ +.git +.coveralls.yml +tests/results diff --git a/package.json b/package.json index 5b3c945..1d1c76d 100755 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/VarStream.js b/src/VarStream.js index ab93360..bc2c983 100755 --- a/src/VarStream.js +++ b/src/VarStream.js @@ -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 @@ -63,7 +63,7 @@ function VarStream(rootObject, rootProperty, options) { this.push(null); }; -}; +} // Parse helper VarStream.parse = function(content) { diff --git a/src/VarStreamReader.js b/src/VarStreamReader.js index de9e604..6f46c6e 100755 --- a/src/VarStreamReader.js +++ b/src/VarStreamReader.js @@ -1,4 +1,3 @@ -'use strict'; /* * Copyright (C) 2012-2013 Nicolas Froidure * @@ -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 @@ -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 @@ -88,7 +88,7 @@ // 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; } @@ -96,8 +96,8 @@ } 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; } @@ -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; } @@ -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; @@ -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 @@ -162,12 +163,11 @@ // Looping throught chunk chars for(var i=0, j=chunk.length; i