{"id":16485887,"url":"https://github.com/fabsrc/re-mem","last_synced_at":"2026-06-08T18:31:04.647Z","repository":{"id":42700853,"uuid":"303493202","full_name":"fabsrc/re-mem","owner":"fabsrc","description":"🧠 Memoization with stale-while-revalidate and stale-if-error","archived":false,"fork":false,"pushed_at":"2023-10-19T10:43:57.000Z","size":176,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-01T00:12:12.459Z","etag":null,"topics":["hacktoberfest","memoization","swr"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fabsrc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-12T19:29:46.000Z","updated_at":"2023-07-09T09:40:44.000Z","dependencies_parsed_at":"2025-01-11T14:43:50.065Z","dependency_job_id":"09a43b66-a336-472e-a610-668bd683dbe6","html_url":"https://github.com/fabsrc/re-mem","commit_stats":{"total_commits":24,"total_committers":3,"mean_commits":8.0,"dds":0.125,"last_synced_commit":"1cfe301f2a6697be95da2105757ba574b8656119"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/fabsrc/re-mem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabsrc%2Fre-mem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabsrc%2Fre-mem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabsrc%2Fre-mem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabsrc%2Fre-mem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fabsrc","download_url":"https://codeload.github.com/fabsrc/re-mem/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabsrc%2Fre-mem/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34075950,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","memoization","swr"],"created_at":"2024-10-11T13:27:38.256Z","updated_at":"2026-06-08T18:31:04.625Z","avatar_url":"https://github.com/fabsrc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# re-mem\n\n\u003e Fork of [mem](https://github.com/sindresorhus/mem/) with \"staleWhileRevalidate\" and \"staleIfError\"\n\n![Node.js CI](https://github.com/fabsrc/re-mem/workflows/Node.js%20CI/badge.svg)\n\n## Install\n\n```shell\nnpm install -S @fabsrc/re-mem\n```\n\n## Usage\n\n```js\nimport reMem from \"@fabsrc/re-mem\"\n\nfunction getData(id) {\n  return Promise.resolve(`Data: ${id}`)\n}\nconst getDataMemoized = reMem(getData, {\n  maxAge: 1000,\n  staleWhileRevalidate: 10000,\n  staleIfError: 20000\n})\n\ngetDataMemoized(123)\n  .then(console.log)\n  .catch(console.error)\n```\n\n### Options\n\n- `cacheKey` Function that returns a cache key based on arguments passed to a function. By default the first argument is used as cache key\n- `cache` Custom cache to store data in. (Default: `new Map()`)\n- `cachePromiseRejection` Boolean flag wether to cache rejected Promises or not (Default: `false`)\n- `maxAge` Time in ms to return the cached promise (Default: `Infinity`)\n- `staleWhileRevalidate` Time in ms to return stale data while revalidating the data in the background. The time starts after `maxAge` runs out.\n- `staleIfError` Time in ms to return stale data if original promise rejects with an error.\n\n## Development\n\n### Testing\n\n```shell\nnpm test\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabsrc%2Fre-mem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabsrc%2Fre-mem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabsrc%2Fre-mem/lists"}