From e676c62de57ec41c501407c5af82c28ffe7ca935 Mon Sep 17 00:00:00 2001 From: archmoj Date: Fri, 25 Dec 2020 11:37:59 -0500 Subject: [PATCH] avoid function constructor --- src/dsv.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/dsv.js b/src/dsv.js index 17838fb..619175f 100644 --- a/src/dsv.js +++ b/src/dsv.js @@ -5,9 +5,13 @@ var EOL = {}, RETURN = 13; function objectConverter(columns) { - return new Function("d", "return {" + columns.map(function(name, i) { - return JSON.stringify(name) + ": d[" + i + "] || \"\""; - }).join(",") + "}"); + return function(d) { + var obj = {}; + for(var k = 0; k < columns.length; k++) { + obj[columns[k]] = d[k] || ""; + } + return obj; + }; } function customConverter(columns, f) {