Comparing version 1.0.1 to 2.0.0
@@ -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()`** |
74
test.js
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() | ||
}) | ||
}) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72
27426
576
+ Addedabstract-leveldown@0.12.41.0.0(transitive)
+ Addedbl@0.8.2(transitive)
+ Addeddeferred-leveldown@0.2.0(transitive)
+ Addederrno@0.1.8(transitive)
+ Addedexternr@1.0.0(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedlevel-spaces@1.0.1(transitive)
+ Addedlevel-updown@1.0.1(transitive)
+ Addedlevelup@0.18.6(transitive)
+ Addedprr@0.0.01.0.1(transitive)
+ Addedreadable-stream@1.0.34(transitive)
+ Addedsemver@2.3.2(transitive)
+ Addedxtend@3.0.0(transitive)
- Removedlevel-sublevel@>=5.2.0 <5.3.0-0
- Removedclone@0.1.19(transitive)
- Removedforeach@2.0.6(transitive)
- Removedindexof@0.0.1(transitive)
- Removedis@0.2.7(transitive)
- Removedis-object@0.1.2(transitive)
- Removedlevel-fix-range@2.0.0(transitive)
- Removedlevel-hooks@4.5.0(transitive)
- Removedlevel-sublevel@5.2.3(transitive)
- Removedobject-keys@0.2.00.4.0(transitive)
- Removedstring-range@1.2.2(transitive)
- Removedxtend@2.0.62.1.2(transitive)
Updatedxtend@>=4.0.0 <4.1.0-0