Skip to content

Commit 414dc39

Browse files
committed
more refactoring
1 parent 7c593c6 commit 414dc39

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

lib/csv-2-json.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var addNestedKey = function (key, value, doc) {
3838
nestedKeys = key.split('.'), // Array of all keys and sub keys for the document
3939
finalKey = nestedKeys.pop(); // Retrieve the last sub key.
4040
_.each(nestedKeys, function (nestedKey) {
41-
if (keyExists(nestedKey, trackerDocument)) { // This nestedKey already exists, use an existing doc
41+
if (trackerDocument[nestedKey]) { // This nestedKey already exists, use an existing doc
4242
trackerDocument = trackerDocument[nestedKey]; // Update the trackerDocument to use the existing document
4343
} else {
4444
trackerDocument[nestedKey] = {}; // Add document at the current subKey
@@ -49,11 +49,6 @@ var addNestedKey = function (key, value, doc) {
4949
return subDocumentRoot; // Return the document with the nested document structure setup
5050
};
5151

52-
// Helper function to check if the given key already exists in the given document
53-
var keyExists = function (key, doc) {
54-
return (!_.isUndefined(doc[key])); // If the key doesn't exist, then the type is 'undefined'
55-
};
56-
5752
/**
5853
* Does the given value represent an array?
5954
* @param value
@@ -125,18 +120,6 @@ var convertCSV = function (lines, callback) {
125120
return _.filter(jsonDocs, function (doc) { return doc !== false; }); // Return all non 'falsey' values to filter blank lines
126121
};
127122

128-
/**
129-
* Validates the input provided to csv2json.
130-
* Only returns (undefined) if no errors are found
131-
* @param opts Object options object
132-
* @param data String csv string
133-
* @param callback Function callback function
134-
* @returns {*}
135-
*/
136-
var checkErrors = function (opts, data, callback){
137-
138-
};
139-
140123
module.exports = {
141124

142125
/**

0 commit comments

Comments
 (0)