keyv 4.0.1 → 4.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/keyv/src/index.js":{"path":"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/keyv/src/index.js","statementMap":{"0":{"start":{"line":3,"column":21},"end":{"line":3,"column":38}},"1":{"start":{"line":4,"column":14},"end":{"line":4,"column":36}},"2":{"start":{"line":6,"column":18},"end":{"line":22,"column":1}},"3":{"start":{"line":7,"column":18},"end":{"line":15,"column":2}},"4":{"start":{"line":16,"column":1},"end":{"line":19,"column":2}},"5":{"start":{"line":17,"column":18},"end":{"line":17,"column":66}},"6":{"start":{"line":18,"column":2},"end":{"line":18,"column":51}},"7":{"start":{"line":21,"column":1},"end":{"line":21,"column":18}},"8":{"start":{"line":26,"column":2},"end":{"line":26,"column":10}},"9":{"start":{"line":27,"column":2},"end":{"line":35,"column":4}},"10":{"start":{"line":37,"column":2},"end":{"line":40,"column":3}},"11":{"start":{"line":38,"column":26},"end":{"line":38,"column":54}},"12":{"start":{"line":39,"column":3},"end":{"line":39,"column":47}},"13":{"start":{"line":42,"column":2},"end":{"line":44,"column":3}},"14":{"start":{"line":43,"column":3},"end":{"line":43,"column":67}},"15":{"start":{"line":43,"column":40},"end":{"line":43,"column":65}},"16":{"start":{"line":46,"column":2},"end":{"line":46,"column":50}},"17":{"start":{"line":50,"column":2},"end":{"line":50,"column":41}},"18":{"start":{"line":54,"column":22},"end":{"line":54,"column":45}},"19":{"start":{"line":55,"column":20},"end":{"line":55,"column":29}},"20":{"start":{"line":56,"column":2},"end":{"line":70,"column":6}},"21":{"start":{"line":57,"column":15},"end":{"line":57,"column":37}},"22":{"start":{"line":58,"column":17},"end":{"line":58,"column":80}},"23":{"start":{"line":60,"column":4},"end":{"line":62,"column":5}},"24":{"start":{"line":61,"column":5},"end":{"line":61,"column":22}},"25":{"start":{"line":64,"column":4},"end":{"line":67,"column":5}},"26":{"start":{"line":65,"column":5},"end":{"line":65,"column":22}},"27":{"start":{"line":66,"column":5},"end":{"line":66,"column":22}},"28":{"start":{"line":69,"column":4},"end":{"line":69,"column":56}},"29":{"start":{"line":74,"column":22},"end":{"line":74,"column":45}},"30":{"start":{"line":75,"column":2},"end":{"line":77,"column":3}},"31":{"start":{"line":76,"column":3},"end":{"line":76,"column":23}},"32":{"start":{"line":79,"column":2},"end":{"line":81,"column":3}},"33":{"start":{"line":80,"column":3},"end":{"line":80,"column":19}},"34":{"start":{"line":83,"column":20},"end":{"line":83,"column":29}},"35":{"start":{"line":85,"column":2},"end":{"line":92,"column":21}},"36":{"start":{"line":87,"column":20},"end":{"line":87,"column":73}},"37":{"start":{"line":88,"column":4},"end":{"line":88,"column":31}},"38":{"start":{"line":89,"column":4},"end":{"line":89,"column":38}},"39":{"start":{"line":91,"column":18},"end":{"line":91,"column":52}},"40":{"start":{"line":92,"column":15},"end":{"line":92,"column":19}},"41":{"start":{"line":96,"column":22},"end":{"line":96,"column":45}},"42":{"start":{"line":97,"column":20},"end":{"line":97,"column":29}},"43":{"start":{"line":98,"column":2},"end":{"line":99,"column":42}},"44":{"start":{"line":99,"column":15},"end":{"line":99,"column":40}},"45":{"start":{"line":103,"column":20},"end":{"line":103,"column":29}},"46":{"start":{"line":104,"column":2},"end":{"line":105,"column":30}},"47":{"start":{"line":105,"column":15},"end":{"line":105,"column":28}},"48":{"start":{"line":109,"column":0},"end":{"line":109,"column":22}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":6,"column":18},"end":{"line":6,"column":19}},"loc":{"start":{"line":6,"column":29},"end":{"line":22,"column":1}},"line":6},"1":{"name":"(anonymous_1)","decl":{"start":{"line":25,"column":1},"end":{"line":25,"column":2}},"loc":{"start":{"line":25,"column":27},"end":{"line":47,"column":2}},"line":25},"2":{"name":"(anonymous_2)","decl":{"start":{"line":43,"column":31},"end":{"line":43,"column":32}},"loc":{"start":{"line":43,"column":40},"end":{"line":43,"column":65}},"line":43},"3":{"name":"(anonymous_3)","decl":{"start":{"line":49,"column":1},"end":{"line":49,"column":2}},"loc":{"start":{"line":49,"column":20},"end":{"line":51,"column":2}},"line":49},"4":{"name":"(anonymous_4)","decl":{"start":{"line":53,"column":1},"end":{"line":53,"column":2}},"loc":{"start":{"line":53,"column":19},"end":{"line":71,"column":2}},"line":53},"5":{"name":"(anonymous_5)","decl":{"start":{"line":57,"column":9},"end":{"line":57,"column":10}},"loc":{"start":{"line":57,"column":15},"end":{"line":57,"column":37}},"line":57},"6":{"name":"(anonymous_6)","decl":{"start":{"line":58,"column":9},"end":{"line":58,"column":10}},"loc":{"start":{"line":58,"column":17},"end":{"line":58,"column":80}},"line":58},"7":{"name":"(anonymous_7)","decl":{"start":{"line":59,"column":9},"end":{"line":59,"column":10}},"loc":{"start":{"line":59,"column":17},"end":{"line":70,"column":4}},"line":59},"8":{"name":"(anonymous_8)","decl":{"start":{"line":73,"column":1},"end":{"line":73,"column":2}},"loc":{"start":{"line":73,"column":22},"end":{"line":93,"column":2}},"line":73},"9":{"name":"(anonymous_9)","decl":{"start":{"line":86,"column":9},"end":{"line":86,"column":10}},"loc":{"start":{"line":86,"column":15},"end":{"line":90,"column":4}},"line":86},"10":{"name":"(anonymous_10)","decl":{"start":{"line":91,"column":9},"end":{"line":91,"column":10}},"loc":{"start":{"line":91,"column":18},"end":{"line":91,"column":52}},"line":91},"11":{"name":"(anonymous_11)","decl":{"start":{"line":92,"column":9},"end":{"line":92,"column":10}},"loc":{"start":{"line":92,"column":15},"end":{"line":92,"column":19}},"line":92},"12":{"name":"(anonymous_12)","decl":{"start":{"line":95,"column":1},"end":{"line":95,"column":2}},"loc":{"start":{"line":95,"column":13},"end":{"line":100,"column":2}},"line":95},"13":{"name":"(anonymous_13)","decl":{"start":{"line":99,"column":9},"end":{"line":99,"column":10}},"loc":{"start":{"line":99,"column":15},"end":{"line":99,"column":40}},"line":99},"14":{"name":"(anonymous_14)","decl":{"start":{"line":102,"column":1},"end":{"line":102,"column":2}},"loc":{"start":{"line":102,"column":9},"end":{"line":106,"column":2}},"line":102},"15":{"name":"(anonymous_15)","decl":{"start":{"line":105,"column":9},"end":{"line":105,"column":10}},"loc":{"start":{"line":105,"column":15},"end":{"line":105,"column":28}},"line":105}},"branchMap":{"0":{"loc":{"start":{"line":16,"column":1},"end":{"line":19,"column":2}},"type":"if","locations":[{"start":{"line":16,"column":1},"end":{"line":19,"column":2}},{"start":{"line":16,"column":1},"end":{"line":19,"column":2}}],"line":16},"1":{"loc":{"start":{"line":16,"column":5},"end":{"line":16,"column":35}},"type":"binary-expr","locations":[{"start":{"line":16,"column":5},"end":{"line":16,"column":20}},{"start":{"line":16,"column":24},"end":{"line":16,"column":35}}],"line":16},"2":{"loc":{"start":{"line":17,"column":18},"end":{"line":17,"column":66}},"type":"binary-expr","locations":[{"start":{"line":17,"column":18},"end":{"line":17,"column":33}},{"start":{"line":17,"column":37},"end":{"line":17,"column":66}}],"line":17},"3":{"loc":{"start":{"line":33,"column":3},"end":{"line":33,"column":44}},"type":"cond-expr","locations":[{"start":{"line":33,"column":31},"end":{"line":33,"column":38}},{"start":{"line":33,"column":41},"end":{"line":33,"column":44}}],"line":33},"4":{"loc":{"start":{"line":37,"column":2},"end":{"line":40,"column":3}},"type":"if","locations":[{"start":{"line":37,"column":2},"end":{"line":40,"column":3}},{"start":{"line":37,"column":2},"end":{"line":40,"column":3}}],"line":37},"5":{"loc":{"start":{"line":42,"column":2},"end":{"line":44,"column":3}},"type":"if","locations":[{"start":{"line":42,"column":2},"end":{"line":44,"column":3}},{"start":{"line":42,"column":2},"end":{"line":44,"column":3}}],"line":42},"6":{"loc":{"start":{"line":58,"column":17},"end":{"line":58,"column":80}},"type":"cond-expr","locations":[{"start":{"line":58,"column":46},"end":{"line":58,"column":73}},{"start":{"line":58,"column":76},"end":{"line":58,"column":80}}],"line":58},"7":{"loc":{"start":{"line":60,"column":4},"end":{"line":62,"column":5}},"type":"if","locations":[{"start":{"line":60,"column":4},"end":{"line":62,"column":5}},{"start":{"line":60,"column":4},"end":{"line":62,"column":5}}],"line":60},"8":{"loc":{"start":{"line":64,"column":4},"end":{"line":67,"column":5}},"type":"if","locations":[{"start":{"line":64,"column":4},"end":{"line":67,"column":5}},{"start":{"line":64,"column":4},"end":{"line":67,"column":5}}],"line":64},"9":{"loc":{"start":{"line":64,"column":8},"end":{"line":64,"column":69}},"type":"binary-expr","locations":[{"start":{"line":64,"column":8},"end":{"line":64,"column":40}},{"start":{"line":64,"column":44},"end":{"line":64,"column":69}}],"line":64},"10":{"loc":{"start":{"line":69,"column":11},"end":{"line":69,"column":55}},"type":"cond-expr","locations":[{"start":{"line":69,"column":38},"end":{"line":69,"column":42}},{"start":{"line":69,"column":45},"end":{"line":69,"column":55}}],"line":69},"11":{"loc":{"start":{"line":69,"column":12},"end":{"line":69,"column":34}},"type":"binary-expr","locations":[{"start":{"line":69,"column":12},"end":{"line":69,"column":19}},{"start":{"line":69,"column":23},"end":{"line":69,"column":34}}],"line":69},"12":{"loc":{"start":{"line":75,"column":2},"end":{"line":77,"column":3}},"type":"if","locations":[{"start":{"line":75,"column":2},"end":{"line":77,"column":3}},{"start":{"line":75,"column":2},"end":{"line":77,"column":3}}],"line":75},"13":{"loc":{"start":{"line":79,"column":2},"end":{"line":81,"column":3}},"type":"if","locations":[{"start":{"line":79,"column":2},"end":{"line":81,"column":3}},{"start":{"line":79,"column":2},"end":{"line":81,"column":3}}],"line":79},"14":{"loc":{"start":{"line":87,"column":20},"end":{"line":87,"column":73}},"type":"cond-expr","locations":[{"start":{"line":87,"column":49},"end":{"line":87,"column":65}},{"start":{"line":87,"column":69},"end":{"line":87,"column":73}}],"line":87}},"s":{"0":1,"1":1,"2":1,"3":3,"4":3,"5":2,"6":2,"7":1,"8":187,"9":187,"10":187,"11":3,"12":3,"13":187,"14":178,"15":1,"16":187,"17":92,"18":45,"19":45,"20":45,"21":45,"22":45,"23":45,"24":9,"25":36,"26":5,"27":5,"28":31,"29":37,"30":37,"31":32,"32":37,"33":1,"34":37,"35":37,"36":37,"37":37,"38":37,"39":37,"40":37,"41":10,"42":10,"43":10,"44":10,"45":155,"46":155,"47":155,"48":1},"f":{"0":3,"1":187,"2":1,"3":92,"4":45,"5":45,"6":45,"7":45,"8":37,"9":37,"10":37,"11":37,"12":10,"13":10,"14":155,"15":155},"b":{"0":[2,1],"1":[3,3],"2":[2,2],"3":[2,185],"4":[3,184],"5":[178,9],"6":[36,9],"7":[9,36],"8":[5,31],"9":[36,13],"10":[1,30],"11":[31,1],"12":[32,5],"13":[1,36],"14":[6,31]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"68d63c1da21bdd17ca5b4661ccb46d430a48aa3d","contentHash":"600469b33bfd3413852cfb4a0f6eb2248472b9c0ecd031c4b7ee54f59a8c8e2c"}}
@@ -0,0 +1 @@
1
+ {"parent":null,"pid":74271,"argv":["/Users/jaredwray/.nvm/versions/node/v16.13.1/bin/node","/Users/jaredwray/src/github.com/jaredwray/keyv/packages/keyv/node_modules/.bin/ava","--serial"],"execArgv":[],"cwd":"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/keyv","time":1641659048071,"ppid":74270,"coverageFilename":"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/keyv/.nyc_output/37411020-4142-4b08-b825-343ba2427bf7.json","externalId":"","uuid":"37411020-4142-4b08-b825-343ba2427bf7","files":[]}
@@ -0,0 +1 @@
1
+ {"parent":"37411020-4142-4b08-b825-343ba2427bf7","pid":74274,"argv":["/Users/jaredwray/.nvm/versions/node/v16.13.1/bin/node","/Users/jaredwray/src/github.com/jaredwray/keyv/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/keyv","time":1641659048289,"ppid":74271,"coverageFilename":"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/keyv/.nyc_output/cd79f2de-c8b8-4493-bc15-b2bde28efa4b.json","externalId":"","uuid":"cd79f2de-c8b8-4493-bc15-b2bde28efa4b","files":["/Users/jaredwray/src/github.com/jaredwray/keyv/packages/keyv/src/index.js"]}
@@ -0,0 +1 @@
1
+ {"processes":{"37411020-4142-4b08-b825-343ba2427bf7":{"parent":null,"children":["cd79f2de-c8b8-4493-bc15-b2bde28efa4b"]},"cd79f2de-c8b8-4493-bc15-b2bde28efa4b":{"parent":"37411020-4142-4b08-b825-343ba2427bf7","children":[]}},"files":{"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/keyv/src/index.js":["cd79f2de-c8b8-4493-bc15-b2bde28efa4b"]},"externalIds":{}}
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  <h1 align="center">
2
- <img width="250" src="https://rawgit.com/lukechilds/keyv/master/media/logo.svg" alt="keyv">
2
+ <img width="250" src="https://jaredwray.com/images/keyv.svg" alt="keyv">
3
3
  <br>
4
4
  <br>
5
5
  </h1>
6
6
 
7
7
  > Simple key-value storage with support for multiple backends
8
8
 
9
- [![Build Status](https://travis-ci.org/lukechilds/keyv.svg?branch=master)](https://travis-ci.org/lukechilds/keyv)
10
- [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv?branch=master)
9
+ [![build](https://github.com/jaredwray/keyv/actions/workflows/build.yaml/badge.svg)](https://github.com/jaredwray/keyv/actions/workflows/build.yaml)
10
+ [![codecov](https://codecov.io/gh/jaredwray/keyv/branch/master/graph/badge.svg?token=bRzR3RyOXZ)](https://codecov.io/gh/jaredwray/keyv)
11
11
  [![npm](https://img.shields.io/npm/dm/keyv.svg)](https://www.npmjs.com/package/keyv)
12
12
  [![npm](https://img.shields.io/npm/v/keyv.svg)](https://www.npmjs.com/package/keyv)
13
13
 
@@ -100,15 +100,15 @@ const keyv = new Keyv({ serialize: JSON.stringify, deserialize: JSON.parse });
100
100
 
101
101
  ## Official Storage Adapters
102
102
 
103
- The official storage adapters are covered by [over 150 integration tests](https://travis-ci.org/lukechilds/keyv/jobs/260418145) to guarantee consistent behaviour. They are lightweight, efficient wrappers over the DB clients making use of indexes and native TTLs where available.
103
+ The official storage adapters are covered by [over 150 integration tests](https://github.com/jaredwray/keyv/actions/workflows/build.yaml) to guarantee consistent behaviour. They are lightweight, efficient wrappers over the DB clients making use of indexes and native TTLs where available.
104
104
 
105
- Database | Adapter | Native TTL | Status
106
- ---|---|---|---
107
- Redis | [@keyv/redis](https://github.com/lukechilds/keyv-redis) | Yes | [![Build Status](https://travis-ci.org/lukechilds/keyv-redis.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-redis) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-redis/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-redis?branch=master)
108
- MongoDB | [@keyv/mongo](https://github.com/lukechilds/keyv-mongo) | Yes | [![Build Status](https://travis-ci.org/lukechilds/keyv-mongo.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-mongo) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-mongo/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-mongo?branch=master)
109
- SQLite | [@keyv/sqlite](https://github.com/lukechilds/keyv-sqlite) | No | [![Build Status](https://travis-ci.org/lukechilds/keyv-sqlite.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-sqlite) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-sqlite/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-sqlite?branch=master)
110
- PostgreSQL | [@keyv/postgres](https://github.com/lukechilds/keyv-postgres) | No | [![Build Status](https://travis-ci.org/lukechilds/keyv-postgres.svg?branch=master)](https://travis-ci.org/lukechildskeyv-postgreskeyv) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-postgres/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-postgres?branch=master)
111
- MySQL | [@keyv/mysql](https://github.com/lukechilds/keyv-mysql) | No | [![Build Status](https://travis-ci.org/lukechilds/keyv-mysql.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-mysql) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-mysql/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-mysql?branch=master)
105
+ Database | Adapter | Native TTL
106
+ ---|---|---
107
+ Redis | [@keyv/redis](https://github.com/jaredwray/keyv/tree/master/packages/redis) | Yes
108
+ MongoDB | [@keyv/mongo](https://github.com/jaredwray/keyv/tree/master/packages/mongo) | Yes
109
+ SQLite | [@keyv/sqlite](https://github.com/jaredwray/keyv/tree/master/packages/sqlite) | No
110
+ PostgreSQL | [@keyv/postgres](https://github.com/jaredwray/keyv/tree/master/packages/postgres) | No
111
+ MySQL | [@keyv/mysql](https://github.com/jaredwray/keyv/tree/master/packages/mysql) | No
112
112
 
113
113
  ## Third-party Storage Adapters
114
114
 
@@ -142,9 +142,12 @@ The following are third-party storage adapters compatible with Keyv:
142
142
  - [quick-lru](https://github.com/sindresorhus/quick-lru) - Simple "Least Recently Used" (LRU) cache
143
143
  - [keyv-file](https://github.com/zaaack/keyv-file) - File system storage adapter for Keyv
144
144
  - [keyv-dynamodb](https://www.npmjs.com/package/keyv-dynamodb) - DynamoDB storage adapter for Keyv
145
+ - [keyv-lru](https://www.npmjs.com/package/keyv-lru) - LRU storage adapter for Keyv
146
+ - [keyv-null](https://www.npmjs.com/package/keyv-null) - Null storage adapter for Keyv
145
147
  - [keyv-firestore ](https://github.com/goto-bus-stop/keyv-firestore) – Firebase Cloud Firestore adapter for Keyv
146
148
  - [keyv-mssql](https://github.com/pmorgan3/keyv-mssql) - Microsoft Sql Server adapter for Keyv
147
- - [keyv-memcache](https://github.com/jaredwray/keyv-memcache) - Memcache storage adapter for Keyv
149
+ - [keyv-memcache](https://github.com/jaredwray/keyv/tree/master/packages/memcache) - Memcache storage adapter for Keyv
150
+ - [keyv-azuretable](https://github.com/howlowck/keyv-azuretable) - Azure Table Storage/API adapter for Keyv
148
151
 
149
152
  ## Add Cache Support to your Module
150
153
 
@@ -285,4 +288,4 @@ Returns a promise which is resolved when the entries have been cleared.
285
288
 
286
289
  ## License
287
290
 
288
- MIT © Luke Childs
291
+ MIT © Jared Wray & Luke Childs
package/package.json CHANGED
@@ -1,19 +1,22 @@
1
1
  {
2
2
  "name": "keyv",
3
- "version": "4.0.1",
3
+ "version": "4.0.5",
4
4
  "description": "Simple key-value storage with support for multiple backends",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
7
- "test": "xo && nyc ava test/keyv.js",
8
- "test:full": "xo && nyc ava --serial",
9
- "coverage": "nyc report --reporter=text-lcov | coveralls"
7
+ "test": "xo && nyc ava --serial",
8
+ "coverage": "nyc report --reporter=text-lcov > coverage.lcov",
9
+ "clean": "rm -rf node_modules && rm -rf .nyc_output && rm -rf coverage.lcov && rm -rf ./test/testdb.sqlite"
10
10
  },
11
11
  "xo": {
12
- "extends": "xo-lukechilds"
12
+ "extends": "xo-lukechilds",
13
+ "rules": {
14
+ "unicorn/prefer-module": 0
15
+ }
13
16
  },
14
17
  "repository": {
15
18
  "type": "git",
16
- "url": "git+https://github.com/lukechilds/keyv.git"
19
+ "url": "git+https://github.com/jaredwray/keyv.git"
17
20
  },
18
21
  "keywords": [
19
22
  "key",
@@ -22,28 +25,28 @@
22
25
  "cache",
23
26
  "ttl"
24
27
  ],
25
- "author": "Luke Childs <lukechilds123@gmail.com> (http://lukechilds.co.uk)",
28
+ "author": "Jared Wray <me@jaredwray.com> (http://jaredwray.com)",
26
29
  "license": "MIT",
27
30
  "bugs": {
28
- "url": "https://github.com/lukechilds/keyv/issues"
31
+ "url": "https://github.com/jaredwray/keyv/issues"
29
32
  },
30
- "homepage": "https://github.com/lukechilds/keyv",
33
+ "homepage": "https://github.com/jaredwray/keyv",
31
34
  "dependencies": {
32
35
  "json-buffer": "3.0.1"
33
36
  },
34
37
  "devDependencies": {
35
- "ava": "^2.2.0",
36
- "coveralls": "^3.0.0",
37
- "eslint-config-xo-lukechilds": "^1.0.0",
38
38
  "@keyv/mongo": "*",
39
39
  "@keyv/mysql": "*",
40
40
  "@keyv/postgres": "*",
41
41
  "@keyv/redis": "*",
42
42
  "@keyv/sqlite": "*",
43
43
  "@keyv/test-suite": "*",
44
- "nyc": "^14.1.1",
44
+ "ava": "^3.15.0",
45
+ "eslint-config-xo-lukechilds": "^1.0.0",
46
+ "eslint-plugin-promise": "^5.1.1",
47
+ "nyc": "^15.1.0",
45
48
  "this": "^1.0.2",
46
49
  "timekeeper": "^2.0.0",
47
- "xo": "^0.25.3"
50
+ "xo": "^0.46.3"
48
51
  }
49
52
  }
package/src/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  const EventEmitter = require('events');
4
4
  const JSONB = require('json-buffer');
5
5
 
6
- const loadStore = opts => {
6
+ const loadStore = options => {
7
7
  const adapters = {
8
8
  redis: '@keyv/redis',
9
9
  mongodb: '@keyv/mongo',
@@ -11,36 +11,36 @@ const loadStore = opts => {
11
11
  sqlite: '@keyv/sqlite',
12
12
  postgresql: '@keyv/postgres',
13
13
  postgres: '@keyv/postgres',
14
- mysql: '@keyv/mysql'
14
+ mysql: '@keyv/mysql',
15
15
  };
16
- if (opts.adapter || opts.uri) {
17
- const adapter = opts.adapter || /^[^:]*/.exec(opts.uri)[0];
18
- return new (require(adapters[adapter]))(opts);
16
+ if (options.adapter || options.uri) {
17
+ const adapter = options.adapter || /^[^:]*/.exec(options.uri)[0];
18
+ return new (require(adapters[adapter]))(options);
19
19
  }
20
20
 
21
21
  return new Map();
22
22
  };
23
23
 
24
24
  class Keyv extends EventEmitter {
25
- constructor(uri, opts) {
25
+ constructor(uri, options) {
26
26
  super();
27
27
  this.opts = Object.assign(
28
28
  {
29
29
  namespace: 'keyv',
30
30
  serialize: JSONB.stringify,
31
- deserialize: JSONB.parse
31
+ deserialize: JSONB.parse,
32
32
  },
33
33
  (typeof uri === 'string') ? { uri } : uri,
34
- opts
34
+ options,
35
35
  );
36
36
 
37
37
  if (!this.opts.store) {
38
- const adapterOpts = Object.assign({}, this.opts);
39
- this.opts.store = loadStore(adapterOpts);
38
+ const adapterOptions = Object.assign({}, this.opts);
39
+ this.opts.store = loadStore(adapterOptions);
40
40
  }
41
41
 
42
42
  if (typeof this.opts.store.on === 'function') {
43
- this.opts.store.on('error', err => this.emit('error', err));
43
+ this.opts.store.on('error', error => this.emit('error', error));
44
44
  }
45
45
 
46
46
  this.opts.store.namespace = this.opts.namespace;
@@ -50,14 +50,12 @@ class Keyv extends EventEmitter {
50
50
  return `${this.opts.namespace}:${key}`;
51
51
  }
52
52
 
53
- get(key, opts) {
53
+ get(key, options) {
54
54
  const keyPrefixed = this._getKeyPrefix(key);
55
55
  const { store } = this.opts;
56
56
  return Promise.resolve()
57
57
  .then(() => store.get(keyPrefixed))
58
- .then(data => {
59
- return (typeof data === 'string') ? this.opts.deserialize(data) : data;
60
- })
58
+ .then(data => (typeof data === 'string') ? this.opts.deserialize(data) : data)
61
59
  .then(data => {
62
60
  if (data === undefined) {
63
61
  return undefined;
@@ -68,7 +66,7 @@ class Keyv extends EventEmitter {
68
66
  return undefined;
69
67
  }
70
68
 
71
- return (opts && opts.raw) ? data : data.value;
69
+ return (options && options.raw) ? data : data.value;
72
70
  });
73
71
  }
74
72
 
package/test/test.js ADDED
@@ -0,0 +1,132 @@
1
+ const test = require('ava');
2
+ const keyvTestSuite = require('@keyv/test-suite').default;
3
+ const { keyvOfficialTests } = require('@keyv/test-suite');
4
+ const Keyv = require('this');
5
+ const tk = require('timekeeper');
6
+ const KeyvSqlite = require('@keyv/sqlite');
7
+
8
+ keyvOfficialTests(test, Keyv, 'sqlite://test/testdb.sqlite', 'sqlite://non/existent/database.sqlite');
9
+
10
+ const store = () => new KeyvSqlite({ uri: 'sqlite://test/testdb.sqlite', busyTimeout: 3000 });
11
+ keyvTestSuite(test, Keyv, store);
12
+
13
+ test.serial('Keyv is a class', t => {
14
+ t.is(typeof Keyv, 'function');
15
+ t.throws(() => Keyv()); // eslint-disable-line new-cap
16
+ t.notThrows(() => new Keyv());
17
+ });
18
+
19
+ test.serial('Keyv accepts storage adapters', async t => {
20
+ const store = new Map();
21
+ const keyv = new Keyv({ store });
22
+ t.is(store.size, 0);
23
+ await keyv.set('foo', 'bar');
24
+ t.is(await keyv.get('foo'), 'bar');
25
+ t.is(store.size, 1);
26
+ });
27
+
28
+ test.serial('Keyv passes tll info to stores', async t => {
29
+ t.plan(1);
30
+ const store = new Map();
31
+ const storeSet = store.set;
32
+ store.set = (key, value, ttl) => {
33
+ t.is(ttl, 100);
34
+ storeSet.call(store, key, value, ttl);
35
+ };
36
+
37
+ const keyv = new Keyv({ store });
38
+ await keyv.set('foo', 'bar', 100);
39
+ });
40
+
41
+ test.serial('Keyv respects default tll option', async t => {
42
+ const store = new Map();
43
+ const keyv = new Keyv({ store, ttl: 100 });
44
+ await keyv.set('foo', 'bar');
45
+ t.is(await keyv.get('foo'), 'bar');
46
+ tk.freeze(Date.now() + 150);
47
+ t.is(await keyv.get('foo'), undefined);
48
+ t.is(store.size, 0);
49
+ tk.reset();
50
+ });
51
+
52
+ test.serial('.set(key, val, ttl) overwrites default tll option', async t => {
53
+ const startTime = Date.now();
54
+ tk.freeze(startTime);
55
+ const store = new Map();
56
+ const keyv = new Keyv({ store, ttl: 200 });
57
+ await keyv.set('foo', 'bar');
58
+ await keyv.set('fizz', 'buzz', 100);
59
+ await keyv.set('ping', 'pong', 300);
60
+ t.is(await keyv.get('foo'), 'bar');
61
+ t.is(await keyv.get('fizz'), 'buzz');
62
+ t.is(await keyv.get('ping'), 'pong');
63
+ tk.freeze(startTime + 150);
64
+ t.is(await keyv.get('foo'), 'bar');
65
+ t.is(await keyv.get('fizz'), undefined);
66
+ t.is(await keyv.get('ping'), 'pong');
67
+ tk.freeze(startTime + 250);
68
+ t.is(await keyv.get('foo'), undefined);
69
+ t.is(await keyv.get('ping'), 'pong');
70
+ tk.freeze(startTime + 350);
71
+ t.is(await keyv.get('ping'), undefined);
72
+ tk.reset();
73
+ });
74
+
75
+ test.serial('.set(key, val, ttl) where ttl is "0" overwrites default tll option and sets key to never expire', async t => {
76
+ const startTime = Date.now();
77
+ tk.freeze(startTime);
78
+ const store = new Map();
79
+ const keyv = new Keyv({ store, ttl: 200 });
80
+ await keyv.set('foo', 'bar', 0);
81
+ t.is(await keyv.get('foo'), 'bar');
82
+ tk.freeze(startTime + 250);
83
+ t.is(await keyv.get('foo'), 'bar');
84
+ tk.reset();
85
+ });
86
+
87
+ test.serial('.get(key, {raw: true}) returns the raw object instead of the value', async t => {
88
+ const store = new Map();
89
+ const keyv = new Keyv({ store });
90
+ await keyv.set('foo', 'bar');
91
+ const value = await keyv.get('foo');
92
+ const rawObject = await keyv.get('foo', { raw: true });
93
+ t.is(value, 'bar');
94
+ t.is(rawObject.value, 'bar');
95
+ });
96
+
97
+ test.serial('Keyv uses custom serializer when provided instead of json-buffer', async t => {
98
+ t.plan(3);
99
+ const store = new Map();
100
+ const serialize = data => {
101
+ t.pass();
102
+ return JSON.stringify(data);
103
+ };
104
+
105
+ const deserialize = data => {
106
+ t.pass();
107
+ return JSON.parse(data);
108
+ };
109
+
110
+ const keyv = new Keyv({ store, serialize, deserialize });
111
+ await keyv.set('foo', 'bar');
112
+ t.is(await keyv.get('foo'), 'bar');
113
+ });
114
+
115
+ test.serial('Keyv supports async serializer/deserializer', async t => {
116
+ t.plan(3);
117
+ const store = new Map();
118
+
119
+ const serialize = async data => {
120
+ t.pass();
121
+ return JSON.stringify(data);
122
+ };
123
+
124
+ const deserialize = async data => {
125
+ t.pass();
126
+ return JSON.parse(data);
127
+ };
128
+
129
+ const keyv = new Keyv({ store, serialize, deserialize });
130
+ await keyv.set('foo', 'bar');
131
+ t.is(await keyv.get('foo'), 'bar');
132
+ });
Binary file
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2017 Luke Childs
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.