Skip to content
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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ workflows:
jobs:
- node/test
- release/npm_and_github:
build_command: npm run build
context:
- org-global
- github-release
Expand Down
17 changes: 0 additions & 17 deletions .editorconfig

This file was deleted.

6 changes: 4 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"root": true,
"extends": ["5app", "prettier"],
"plugins": ["prettier"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier"],
"extends": ["5app", "plugin:@typescript-eslint/recommended", "prettier"],
"ignorePatterns": ["dist/"],
"rules": {
"prettier/prettier": "error"
}
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
.DS_Store
.nyc_output
.nyc_output
dist/
31 changes: 31 additions & 0 deletions example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* eslint-disable no-console */
import memoize from './src/index.js';

// Define a function which returns an object
type ProfileId = number;
interface Profile {
id: ProfileId;
name: string;
age: number;
}

async function getMyProfile(id: ProfileId): Promise<Profile> {
return {
id,
name: 'Andrew',
age: 100,
};
}

const memoProfile = memoize(getMyProfile, {
useCached(param) {
return param.timestamp ? param.timestamp > Date.now() : false;
},
getKey(param) {
return param[0];
},
});

const resp = await memoProfile(123);

console.log(resp?.id);
Loading