'use strict';

class Keyv {
	constructor(opts) {
		opts = opts || {};
		this.store = opts.store || new Map();
	}

	get(key) {
		return Promise.resolve(this.store.get(key)).then(data => {
			if (!data) {
				return undefined;
			}
			if (!this.store.ttlSupport && Date.now() > data.expires) {
				this.delete(key);
				return undefined;
			}
			return this.store.ttlSupport ? data : data.value;
		});
	}

	set(key, value, ttl) {
		let set;
		if (this.store.ttlSupport) {
			set = this.store.set(key, value, ttl);
		} else {
			const expires = (typeof ttl === 'number') ? (Date.now() + ttl) : undefined;
			const data = { value, expires };
			set = this.store.set(key, data);
		}
		return Promise.resolve(set).then(() => value);
	}

	delete(key) {
		return Promise.resolve(this.store.delete(key));
	}
}

module.exports = Keyv;

@@ -44,16 +44,21 @@
 ts) %7B%0A%09%09
+this.
 opts = o
@@ -79,16 +79,21 @@
 his.
+opts.
 store = 
 opts
@@ -88,16 +88,21 @@
 store = 
+this.
 opts.sto
@@ -160,24 +160,29 @@
 esolve(this.
+opts.
 store.get(ke
@@ -252,24 +252,29 @@
 %09%09if (!this.
+opts.
 store.ttlSup
@@ -370,24 +370,29 @@
 return this.
+opts.
 store.ttlSup
@@ -469,24 +469,29 @@
 %0A%09%09if (this.
+opts.
 store.ttlSup
@@ -504,32 +504,37 @@
 %7B%0A%09%09%09set = this.
+opts.
 store.set(key, v
@@ -681,24 +681,29 @@
 %09set = this.
+opts.
 store.set(ke
@@ -814,16 +814,21 @@
 ve(this.
+opts.
 store.de

Save all opts in this.opts