Comparing version 1.1.1 to 1.1.2
var parserMgr = require("./parserMgr.js"); | ||
var Parser = require("./parser"); | ||
var CSVError = require("./CSVError"); | ||
var numReg = /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/; | ||
/** | ||
@@ -110,3 +111,3 @@ * Convert lines of csv array into json | ||
var title = getTitle(head, i, param) | ||
if (flag === 'flat') { | ||
if (flag === 'flat' || param.flatKeys) { | ||
resultRow[title] = item | ||
@@ -199,3 +200,3 @@ } else { | ||
} | ||
if (!isNaN(trimed)) { | ||
if (numReg.test(trimed)) { | ||
return numberType | ||
@@ -202,0 +203,0 @@ } else if (trimed.length === 5 && trimed.toLowerCase() === "false" || trimed.length === 4 && trimed.toLowerCase() === "true") { |
@@ -21,3 +21,3 @@ { | ||
], | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"keywords": [ | ||
@@ -24,0 +24,0 @@ "csv", |
@@ -206,3 +206,3 @@ var Converter = require("../libs/core/Converter.js"); | ||
}) | ||
conv.on("end_parsed", function (res) { | ||
@@ -345,3 +345,13 @@ assert(res[0].Description.indexOf('THIN') > -1); | ||
}) | ||
it("should allow flatKey to change parse behaviour", function (done) { | ||
var conv = new Converter({ | ||
flatKeys:true | ||
}); | ||
conv.fromString("a.b,b.d,c.a\n1,2,3\n4,5,6").on("json", function (d) { | ||
assert(d["a.b"]) | ||
assert(d["b.d"]) | ||
assert(d["c.a"]) | ||
}) | ||
.on("end", done) | ||
}) | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
765559
11175