Skip to content

Commit

Permalink
add null type to parser
Browse files Browse the repository at this point in the history
  • Loading branch information
siarheidudko committed Jan 16, 2020
1 parent 6bc9d4e commit 960bc4d
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-se
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Wed Jan 15 2020 09:30:06 GMT+0300 (GMT+03:00)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Thu Jan 16 2020 17:05:37 GMT+0300 (GMT+03:00)
</footer>

<script> prettyPrint(); </script>
Expand Down
4 changes: 3 additions & 1 deletion docs/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ <h1 class="page-title">Source: index.js</h1>
case 'string':
return true;
case 'object':
if(obj === null)
return true;
if((obj.__proto__ === {}.__proto__) || (it &amp;&amp; (obj.__proto__ === [].__proto__))){
let keys = Object.keys(obj);
for(let i = 0; i &lt; keys.length; i++){
Expand Down Expand Up @@ -296,7 +298,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-se
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Wed Jan 15 2020 09:30:06 GMT+0300 (GMT+03:00)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Thu Jan 16 2020 17:05:37 GMT+0300 (GMT+03:00)
</footer>

<script> prettyPrint(); </script>
Expand Down
4 changes: 2 additions & 2 deletions docs/module-sergdudko_objectstream-Parser.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line108">line 108</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line110">line 110</a>
</li></ul></dd>


Expand Down Expand Up @@ -275,7 +275,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-se
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Wed Jan 15 2020 09:30:06 GMT+0300 (GMT+03:00)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Thu Jan 16 2020 17:05:37 GMT+0300 (GMT+03:00)
</footer>

<script> prettyPrint(); </script>
Expand Down
4 changes: 2 additions & 2 deletions docs/module-sergdudko_objectstream-Stringifer.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line43">line 43</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line45">line 45</a>
</li></ul></dd>


Expand Down Expand Up @@ -275,7 +275,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-se
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Wed Jan 15 2020 09:30:06 GMT+0300 (GMT+03:00)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Thu Jan 16 2020 17:05:37 GMT+0300 (GMT+03:00)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-sergdudko_objectstream.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-se
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Wed Jan 15 2020 09:30:06 GMT+0300 (GMT+03:00)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Thu Jan 16 2020 17:05:37 GMT+0300 (GMT+03:00)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ let validator = function(obj, it = true){
case 'string':
return true;
case 'object':
if(obj === null)
return true;
if((obj.__proto__ === {}.__proto__) || (it && (obj.__proto__ === [].__proto__))){
let keys = Object.keys(obj);
for(let i = 0; i < keys.length; i++){
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sergdudko/objectstream",
"version": "1.7.6",
"version": "1.7.7",
"description": "Creates a stream to convert json from string or convert json to string.",
"main": "index.js",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions test/parser.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ describe('Parser: Valid data type test_1:', function() {

describe('Parser: Valid data type test_2:', function() {
let parser = new ObjectStream.Parser();
it('data === "{"w":1,"c":{"k":true,"l":"t"}}"', function(done){
it('data === "{"w":1,"c":{"k":true,"l":"t","d":null}}"', function(done){
parser.once('data', function(data){
mycompare(Lodash.isEqual(data, {"w":1,"c":{"k":true,"l":"t"}}), done);
mycompare(Lodash.isEqual(data, {"w":1,"c":{"k":true,"l":"t","d":null}}), done);
});
parser.write('{"w":1,"c":{"k":true,"l":"t"}}');
parser.write('{"w":1,"c":{"k":true,"l":"t","d":null}}');
});
});

Expand Down

0 comments on commit 960bc4d

Please sign in to comment.