Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

level-ttl

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

level-ttl - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

16

level-ttl.js

@@ -1,4 +0,4 @@

const after = require('after')
, xtend = require('xtend')
, sublevel = require('level-sublevel')
const after = require('after')
, xtend = require('xtend')
, spaces = require('level-spaces')

@@ -220,10 +220,12 @@ , DEFAULT_FREQUENCY = 10000

// backwards compatibility
if (!options.namespace && options.sublevel)
options.namespace = options.sublevel
options = xtend({
methodPrefix : ''
, sublevel : 'ttl'
, namespace : 'ttl'
, checkFrequency : DEFAULT_FREQUENCY
}, options)
var sdb = typeof db.sublevels == 'object' ? db : sublevel(db)
db._ttl = {

@@ -234,3 +236,3 @@ put : db.put.bind(db)

, close : db.close.bind(db)
, sub : sdb.sublevel(options.sublevel)
, sub : spaces(db, options.namespace)
}

@@ -237,0 +239,0 @@

@@ -9,3 +9,3 @@ {

],
"version": "1.0.1",
"version": "2.0.0",
"homepage": "https://github.com/rvagg/node-level-ttl",

@@ -18,2 +18,3 @@ "authors": [

"levelup",
"level",
"ttl",

@@ -29,5 +30,5 @@ "whoa dude!"

"after": ">=0.8.1 <0.9.0-0",
"level-sublevel": ">=5.2.0 <5.3.0-0",
"level-spaces": ">=1.0.1 <1.1.0-0",
"list-stream": ">=1.0.0 <1.1.0-0",
"xtend": ">=2.1.1 <2.2.0-0"
"xtend": ">=4.0.0 <4.1.0-0"
},

@@ -34,0 +35,0 @@ "peerDependencies": {},

@@ -5,3 +5,4 @@ # Level TTL [![Build Status](https://secure.travis-ci.org/rvagg/node-level-ttl.png)](http://travis-ci.org/rvagg/node-level-ttl)

[![NPM](https://nodei.co/npm/level-ttl.png?downloads)](https://nodei.co/npm/level-ttl/)
[![NPM](https://nodei.co/npm/level-ttl.png?downloads=true&downloadRank=true)](https://nodei.co/npm/level-ttl/)
[![NPM](https://nodei.co/npm-dl/level-ttl.png?months=6&height=3)](https://nodei.co/npm/level-ttl/)

@@ -8,0 +9,0 @@ **Add a `'ttl'` (time-to-live) option to LevelUP for `put()` and `batch()`**

const test = require('tape')
, rimraf = require('rimraf')
, levelup = require('level')
, sublevel = require('level-sublevel')
, listStream = require('list-stream')

@@ -88,4 +87,4 @@ , ttl = require('./')

ts++
contains(t, arr, /!ttl!\d{13}!bar/, 'bar')
contains(t, arr, '!ttl!bar', /\d{13}/)
contains(t, arr, /\xffttl\xff\d{13}!bar/, 'bar')
contains(t, arr, '\xffttl\xffbar', /\d{13}/)
contains(t, arr, 'bar', 'barvalue')

@@ -118,14 +117,14 @@ contains(t, arr, 'foo', 'foovalue')

contains(t, arr, 'bar1', 'barvalue1')
contains(t, arr, /^!ttl!\d{13}!bar1$/, 'bar1')
contains(t, arr, '!ttl!bar1', /^\d{13}$/)
contains(t, arr, /^\xffttl\xff\d{13}!bar1$/, 'bar1')
contains(t, arr, '\xffttl\xffbar1', /^\d{13}$/)
}
if (keys >= 2) {
contains(t, arr, 'bar2', 'barvalue2')
contains(t, arr, /^!ttl!\d{13}!bar2$/, 'bar2')
contains(t, arr, '!ttl!bar2', /^\d{13}$/)
contains(t, arr, /^\xffttl\xff\d{13}!bar2$/, 'bar2')
contains(t, arr, '\xffttl\xffbar2', /^\d{13}$/)
}
if (keys >= 3) {
contains(t, arr, 'bar3', 'barvalue3')
contains(t, arr, /^!ttl!\d{13}!bar3$/, 'bar3')
contains(t, arr, '!ttl!bar3', /^\d{13}$/)
contains(t, arr, /^\xffttl\xff\d{13}!bar3$/, 'bar3')
contains(t, arr, '\xffttl\xffbar3', /^\d{13}$/)
}

@@ -159,19 +158,19 @@ })

contains(t, arr, 'bar1', 'barvalue1')
contains(t, arr, /^!ttl!\d{13}!bar1$/, 'bar1')
contains(t, arr, '!ttl!bar1', /^\d{13}$/)
contains(t, arr, /^\xffttl\xff\d{13}!bar1$/, 'bar1')
contains(t, arr, '\xffttl\xffbar1', /^\d{13}$/)
}
if (keys >= 2) {
contains(t, arr, 'bar2', 'barvalue2')
contains(t, arr, /^!ttl!\d{13}!bar2$/, 'bar2')
contains(t, arr, '!ttl!bar2', /^\d{13}$/)
contains(t, arr, /^\xffttl\xff\d{13}!bar2$/, 'bar2')
contains(t, arr, '\xffttl\xffbar2', /^\d{13}$/)
}
if (keys >= 3) {
contains(t, arr, 'bar3', 'barvalue3')
contains(t, arr, /^!ttl!\d{13}!bar3$/, 'bar3')
contains(t, arr, '!ttl!bar3', /^\d{13}$/)
contains(t, arr, /^\xffttl\xff\d{13}!bar3$/, 'bar3')
contains(t, arr, '\xffttl\xffbar3', /^\d{13}$/)
}
if (keys >= 3) {
contains(t, arr, 'bar4', 'barvalue4')
contains(t, arr, /^!ttl!\d{13}!bar4$/, 'bar4')
contains(t, arr, '!ttl!bar4', /^\d{13}$/)
contains(t, arr, /^\xffttl\xff\d{13}!bar4$/, 'bar4')
contains(t, arr, '\xffttl\xffbar4', /^\d{13}$/)
}

@@ -217,4 +216,4 @@ })

contains(t, arr, 'foo', 'foovalue')
contains(t, arr, /!ttl!\d{13}!bar/, 'bar')
contains(t, arr, '!ttl!bar', /\d{13}/)
contains(t, arr, /\xffttl\xff\d{13}!bar/, 'bar')
contains(t, arr, '\xffttl\xffbar', /\d{13}/)
})

@@ -257,4 +256,4 @@ }, delay)

contains(t, arr, 'foo', 'foovalue')
contains(t, arr, /!ttl!\d{13}!bar/, 'bar')
contains(t, arr, '!ttl!bar', /\d{13}/)
contains(t, arr, /\xffttl\xff\d{13}!bar/, 'bar')
contains(t, arr, '\xffttl\xffbar', /\d{13}/)
})

@@ -299,4 +298,4 @@ }, delay)

contains(t, arr, 'foo', 'foovalue')
contains(t, arr, /!ttl!\d{13}!bar/, 'bar')
contains(t, arr, '!ttl!bar', /\d{13}/)
contains(t, arr, /\xffttl\xff\d{13}!bar/, 'bar')
contains(t, arr, '\xffttl\xffbar', /\d{13}/)
}

@@ -341,4 +340,4 @@ })

contains(t, arr, 'foo', '{"v":"foovalue"}')
contains(t, arr, /!ttl!\d{13}!bar/, 'bar')
contains(t, arr, '!ttl!bar', /\d{13}/)
contains(t, arr, /\xffttl\xff\d{13}!bar/, 'bar')
contains(t, arr, '\xffttl\xffbar', /\d{13}/)
}

@@ -416,26 +415,1 @@ }, { valueEncoding: 'utf8' })

})
test('Stopping a ttl-db based on a sublevel-db', function (t) {
var location = '__ttl-' + Math.random()
fixtape(t)
levelup(location, {}, function (err, levelDb) {
t.notOk(err, 'no error on open()')
var ttlDb = ttl(sublevel(levelDb).sublevel('my-sublevel'))
ttlDb.put('foo', 'bar', function(err) {
t.notOk(err, 'no error on put()')
ttlDb.get('foo', function(err, value) {
t.notOk(err, 'no error on get()')
t.equal(value, 'bar', 'same value returned')
levelDb.close()
ttlDb.stop()
t.end()
})
})
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc