diff --git a/lib/persistence.js b/lib/persistence.js index 4839693..538e523 100755 --- a/lib/persistence.js +++ b/lib/persistence.js @@ -156,7 +156,6 @@ class Persistence { treatRawData (rawData) { const data = rawData.split('\n') const dataById = {} - const tdata = [] const indexes = {} // Last line of every data file is usually blank so not really corrupt @@ -181,7 +180,7 @@ class Persistence { corruptItems / data.length > this.corruptAlertThreshold ) throw new Error(`More than ${Math.floor(100 * this.corruptAlertThreshold)}% of the data file is corrupt, the wrong beforeDeserialization hook may be used. Cautiously refusing to start NeDB to prevent dataloss`) - tdata.push(...Object.values(dataById)) + const tdata = Object.values(dataById) return { data: tdata, indexes: indexes } } @@ -192,7 +191,6 @@ class Persistence { */ treatRawStream (rawStream, cb) { const dataById = {} - const tdata = [] const indexes = {} // Last line of every data file is usually blank so not really corrupt @@ -224,11 +222,9 @@ class Persistence { return } - Object.keys(dataById).forEach(function (k) { - tdata.push(dataById[k]) - }) + const data = Object.values(dataById) - cb(null, { data: tdata, indexes: indexes }) + cb(null, { data, indexes: indexes }) }) lineStream.on('error', function (err) {