Skip to content

Commit

Permalink
Upgrade to level@8
Browse files Browse the repository at this point in the history
  • Loading branch information
fnogatz committed Sep 18, 2022
1 parent 8acd11a commit 03a8ce1
Show file tree
Hide file tree
Showing 3 changed files with 199 additions and 256 deletions.
11 changes: 6 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const toStamp = require('./util').toStamp

const { Transform } = require('readable-stream')
const { formatElapsed, getKey } = require('./util')

module.exports = Clocker

const path = require('path')

const level = require('level')
const { Transform } = require('readable-stream')
const { Level } = require('level')
const { EntryStream } = require('level-read-stream')
const mkdirp = require('mkdirp')
const parseTime = require('parse-messy-time')
const strftime = require('strftime')
Expand All @@ -25,7 +26,7 @@ function Clocker (options) {
}
mkdirp.sync(this.dir)

this.db = level(path.join(this.dir, 'db'), { valueEncoding: 'json' })
this.db = new Level(path.join(this.dir, 'db'), { valueEncoding: 'json' })
}

Clocker.RESERVED_DATA_ENTRIES = [
Expand Down Expand Up @@ -421,7 +422,7 @@ Clocker.prototype.dataStream = function (filter) {

const gt = filter.gt ? strftime('%F %T', getDate(filter.gt)) : ''
const lt = filter.lt ? strftime('%F %T', getDate(filter.lt)) : '~'
const s = this.db.createReadStream({
const s = new EntryStream(this.db, {
gt: 'time!' + gt,
lt: 'time!' + lt
})
Expand Down Expand Up @@ -484,7 +485,7 @@ Clocker.prototype.aggregate = function (by, filter, cb) {

Clocker.prototype._getLastRow = function (cb) {
let found = false
this.db.createReadStream({
new EntryStream(this.db, {
gt: 'time!',
lt: 'time!~',
limit: 1,
Expand Down
Loading

0 comments on commit 03a8ce1

Please sign in to comment.