From 9b102889f6e7a22c503e9fad69b29536eabdaa1b Mon Sep 17 00:00:00 2001 From: Ramya Ragupathy Date: Fri, 16 Feb 2018 16:33:26 +0530 Subject: [PATCH] null line reduction #1 --- index.js | 3 +-- src/parser.js | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index d460d46..f009d32 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,3 @@ -#!/usr/bin/env node const fs = require('fs') const parser = require('./src/parser.js') const fileName = process.argv[2] @@ -13,7 +12,7 @@ if (jsonStr === null) { } else if (jsonStr[1] !== '') { jsonStr[1] = jsonStr[1].trim() if (jsonStr[1] !== '') { - console.log(message[0], jsonStr[1]) + console.log(message[0]) } else { console.log(jsonStr[0]) } diff --git a/src/parser.js b/src/parser.js index 050c429..f354bd1 100644 --- a/src/parser.js +++ b/src/parser.js @@ -1,9 +1,7 @@ #!/usr/bin/env node const nullParser = (input) => { - let nullValue = input.slice(0, 4) - if (nullValue === 'null') { - input = input.slice(4, input.length) - return [null, input] + if (input.startsWith('null')) { + return [null, input.slice(4, input.length)] } else return null }