From 3866daa6ef7122e5031806b7225ea1b4ad479aa9 Mon Sep 17 00:00:00 2001 From: royreiss Date: Thu, 8 Dec 2016 21:35:21 -0500 Subject: [PATCH 1/4] Add conversion of booleans and a test --- index.js | 8 +++++++- test.js | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 1b2c110..5caec0d 100644 --- a/index.js +++ b/index.js @@ -42,7 +42,13 @@ ArrayParser.prototype.newEntry = function (includeEmpty) { if (entry === 'NULL' && !includeEmpty) { entry = null } - if (entry !== null) entry = this.transform(entry) + if (entry === 'true') { + entry = true + } + if(entry === 'false'){ + entry = false; + } + if (entry !== null && entry !== true && entry !== false) entry = this.transform(entry) this.entries.push(entry) this.recorded = [] } diff --git a/test.js b/test.js index 6512e00..fed4253 100644 --- a/test.js +++ b/test.js @@ -10,6 +10,7 @@ test(function (t) { t.deepEqual(string('{""}'), [''], 'empty string') t.deepEqual(string('{1,2,3}'), ['1', '2', '3'], 'numerics') t.deepEqual(string('{a,b,c}'), ['a', 'b', 'c'], 'strings') + t.deepEqual(string('{true,false,true}'), [true, false, true], 'booleans') t.deepEqual(string('{"\\"\\"\\"","\\\\\\\\\\\\"}'), ['"""', '\\\\\\'], 'escaped') t.deepEqual(string('{NULL,NULL}'), [null, null], 'null') From d1a8d8c32350d1973546938be75c1d1db30586ad Mon Sep 17 00:00:00 2001 From: royreiss Date: Fri, 9 Dec 2016 09:28:18 -0500 Subject: [PATCH 2/4] Revised boolean check --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 5caec0d..9160d11 100644 --- a/index.js +++ b/index.js @@ -48,7 +48,7 @@ ArrayParser.prototype.newEntry = function (includeEmpty) { if(entry === 'false'){ entry = false; } - if (entry !== null && entry !== true && entry !== false) entry = this.transform(entry) + if (entry !== null && typeof(entry) !== 'boolean') entry = this.transform(entry) this.entries.push(entry) this.recorded = [] } From cbeaebc4cc951b4ffbd1db3c872c989c9193c6c3 Mon Sep 17 00:00:00 2001 From: royreiss Date: Fri, 9 Dec 2016 15:06:44 -0500 Subject: [PATCH 3/4] Revised boolean check --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 9160d11..c6576cd 100644 --- a/index.js +++ b/index.js @@ -48,7 +48,7 @@ ArrayParser.prototype.newEntry = function (includeEmpty) { if(entry === 'false'){ entry = false; } - if (entry !== null && typeof(entry) !== 'boolean') entry = this.transform(entry) + if (entry !== null && typeof entry !== 'boolean') entry = this.transform(entry) this.entries.push(entry) this.recorded = [] } From 23ba034b2a1210e3c932289312fecf539d4751b3 Mon Sep 17 00:00:00 2001 From: royreiss Date: Fri, 9 Dec 2016 16:01:52 -0500 Subject: [PATCH 4/4] Correct boolean check spacing --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index c6576cd..bc54883 100644 --- a/index.js +++ b/index.js @@ -45,8 +45,8 @@ ArrayParser.prototype.newEntry = function (includeEmpty) { if (entry === 'true') { entry = true } - if(entry === 'false'){ - entry = false; + if (entry === 'false') { + entry = false } if (entry !== null && typeof entry !== 'boolean') entry = this.transform(entry) this.entries.push(entry)