Skip to content

Commit

Permalink
node-cache - making default export work correctly (#921)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredwray authored Dec 3, 2024
1 parent 53d0628 commit 20e5734
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
12 changes: 11 additions & 1 deletion packages/node-cache/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ npm install @cacheable/node-cache --save
# Basic Usage

```javascript
import {NodeCache} from '@cacheable/node-cache';
import NodeCache from '@cacheable/node-cache';

const cache = new NodeCache();
cache.set('foo', 'bar');
Expand All @@ -50,6 +50,16 @@ cache.del('foo'); // true
cache.set('bar', 'baz', '35m'); // 35 minutes using shorthand
```

# NodeCache Not Default Export

```javascript
import {NodeCache} from '@cacheable/node-cache';

const cache = new NodeCache();
cache.set('foo', 'bar');
cache.get('foo'); // 'bar'
```

# Advanced Usage

```javascript
Expand Down
3 changes: 2 additions & 1 deletion packages/node-cache/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export type NodeCacheStats = {
vsize: number;
};

export default class NodeCache extends Hookified {
export class NodeCache extends Hookified {
public readonly options: NodeCacheOptions = {
// eslint-disable-next-line @typescript-eslint/naming-convention
stdTTL: 0,
Expand Down Expand Up @@ -464,3 +464,4 @@ export default class NodeCache extends Hookified {
}

export {NodeCacheStore, type NodeCacheStoreOptions} from './store.js';
export default NodeCache;
11 changes: 11 additions & 0 deletions packages/node-cache/test/export.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {describe, test, expect} from 'vitest';
import {NodeCache} from '../src/index.js';

const cache = new NodeCache({checkperiod: 0});

describe('NodeCache', () => {
test('should create a new instance of NodeCache', () => {
const cache = new NodeCache({checkperiod: 0});
expect(cache).toBeInstanceOf(NodeCache);
});
});

0 comments on commit 20e5734

Please sign in to comment.