Skip to content

Commit

Permalink
💨 Use the new way of importing node's EventEmitter (#73)
Browse files Browse the repository at this point in the history
Node changed the name of the library from `events` to `node:events` with
v16. It still has backward compatibilities it seems, but importing the
cachette library failed on one occasion: the result was that the
CacheInstance was not resolved as an EventEmitter.

The `package.json` node version is already at `>=18`, so this should be
fine.
  • Loading branch information
erykwarren authored Jul 14, 2023
1 parent 9c4587b commit fe6e29b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
54 changes: 27 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/lib/CacheClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export abstract class CacheClient {
const buildKeyArgs = (args: any[]) => args
.filter(x =>
typeof x !== 'object' ||
// If the arg is an object, we check that it's not a instance of a class
// If the arg is an object, we check that it's not an instance of a class
(typeof x === 'object' && (x?.constructor.name === 'Object' || x?.constructor.name === 'Array')) ||
// typeof null === object, then we need to have another condition to accept null as well
x === null
Expand Down Expand Up @@ -95,7 +95,7 @@ export abstract class CacheClient {
};
}

// We *do* want an loosely-typed `Function` here, by nature of the library
// We *do* want a loosely-typed `Function` here, by nature of the library
// eslint-disable-next-line @typescript-eslint/ban-types
public getUncachedFunction(functionName: string): Function {
if (this[`${functionName}NoCache`]) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/CacheInstance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as EventEmitter from 'events';
import { EventEmitter } from 'node:events';

export type CachableValue = any;
export type FetchingFunction = () => Promise<CachableValue>;
Expand Down

0 comments on commit fe6e29b

Please sign in to comment.