Skip to content
This repository has been archived by the owner on Jun 6, 2019. It is now read-only.

Commit

Permalink
Add memo-ization
Browse files Browse the repository at this point in the history
  • Loading branch information
mrose17 committed Apr 10, 2018
1 parent 7fc3746 commit fa335b8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,19 @@ Client.prototype.sync = function (callback) {
const self = this

const now = underscore.now()
let ballot, ballots, i, transaction, updateP
let ballot, ballots, i, memo, transaction, updateP

if (typeof callback !== 'function') throw new Error('sync missing callback parameter')

if (!self.state.properties) self.state.properties = {}
if ((self.state.reconcileStamp === null) || (isNaN(self.state.reconcileStamp))) {
// WHY: isNaN(null) === false
memo = { prevoiusStamp: self.state.reconcileStamp }
self.state.reconcileStamp = now + (14 * msecs.day)
memo.reconcileStamp = self.state.reconcileStamp
memo.reconcileDate = new Date(self.state.reconcileStamp)
self.memo('sync', memo)

self._log('sync', { reconcileStamp: self.state.reconcileStamp })
return self.setTimeUntilReconcile(self.state.reconcileStamp, callback)
}
Expand Down

0 comments on commit fa335b8

Please sign in to comment.