Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pass constructor options to parent #5

Merged
merged 2 commits into from
Aug 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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