Skip to content

Commit

Permalink
#713 added array cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
itayw committed May 18, 2015
1 parent 66fa79a commit 3c9a4e5
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/dispatch/beacon.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,23 @@ var
var etl = {};
exports.etl = etl;

Array.prototype.clean = function(deleteValue) {
for (var i = 0; i < this.length; i++) {
if (!this[i]) {
this.splice(i, 1);
i--;
}
}
return this;
};

etl.verify = function (context, workspace, collection, documents, callback) {
var _document;
if (!Array.isArray(documents))
documents = [documents];

documents.clean();

var buildRowKey = function (obj) {
var key;
try {
Expand All @@ -55,11 +67,12 @@ etl.verify = function (context, workspace, collection, documents, callback) {
else {
doc.timestamp = new Date(doc.timestamp.value || doc.timestamp);
}
doc._key = buildRowKey(doc);
}
catch (ex) {
doc.timestamp = new Date();
return cb(ex);
}
doc._key = buildRowKey(doc);
return cb(null);
}, function (err) {
if (err)
Expand Down

0 comments on commit 3c9a4e5

Please sign in to comment.