Skip to content

Commit

Permalink
fix: pass constructor options to parent (#5)
Browse files Browse the repository at this point in the history
This will make the KeyvLruManagedTtl parent aware of the options.
  • Loading branch information
e0ipso committed Aug 30, 2019
1 parent 9372867 commit 2df4b81
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/KeyvLru.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

import type { MapInterface } from '../flow/types/MapInterface';

export type KeyvLruOptions = {
max: number,
notify?: boolean,
ttl?: number,
expire?: number,
};

const lru = require('tiny-lru');
const EventEmitter = require('events');

Expand All @@ -13,14 +20,7 @@ class KeyvLru extends EventEmitter implements MapInterface {
cache: Object;
defaultTtl: ?number;

constructor(
options: {
max: number,
notify?: boolean,
ttl?: number,
expire?: number,
} = { max: 500 }
) {
constructor(options: KeyvLruOptions = { max: 500 }) {
super();
this.defaultTtl = options.ttl;
this.cache = lru(
Expand Down
11 changes: 3 additions & 8 deletions src/KeyvLruManagedTtl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow

import type { ExpirableItem } from '../flow/types/ExpirableItem';
import type { KeyvLruOptions } from './KeyvLru';

const lru = require('tiny-lru');
const KeyvLru = require('./KeyvLru');
Expand All @@ -21,14 +22,8 @@ class KeyvLruManagedTtl<T> extends KeyvLru {
cache: Object;
defaultTtl: ?number;

constructor(
options: {
max: number,
notify?: boolean,
ttl?: number,
} = { max: 500 }
) {
super();
constructor(options: KeyvLruOptions = { max: 500 }) {
super(options);
this.cache = lru(options.max, options.notify);
}

Expand Down

0 comments on commit 2df4b81

Please sign in to comment.