From 790562c45ffe4358770d50ba17496cb403681ae9 Mon Sep 17 00:00:00 2001 From: Anatoly Pashin Date: Tue, 25 Feb 2014 11:12:34 +1100 Subject: [PATCH] fixed setAutocompactionInterval interval arg if interval is undefined, then it's bigger than 5000 Test case in Chrome console: ``` > var interval undefined > (interval < 5000) false ``` --- lib/persistence.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/persistence.js b/lib/persistence.js index a7fe72d..32d8368 100644 --- a/lib/persistence.js +++ b/lib/persistence.js @@ -155,14 +155,16 @@ Persistence.prototype.compactDatafile = function () { * @param {Number} interval in milliseconds, with an enforced minimum of 5 seconds */ Persistence.prototype.setAutocompactionInterval = function (interval) { - var self = this; + var self = this + , minInterval = 5000 + , realInterval = Math.max(interval||0, minInterval) + ; - if (interval < 5000) { interval = 5000; } this.stopAutocompaction(); this.autocompactionIntervalId = setInterval(function () { self.compactDatafile(); - }, interval); + }, realInterval); };