{"id":24938580,"url":"https://github.com/korkje/memz","last_synced_at":"2026-04-24T23:31:58.515Z","repository":{"id":213000273,"uuid":"730786513","full_name":"korkje/memz","owner":"korkje","description":"Memoize helper","archived":false,"fork":false,"pushed_at":"2025-01-31T15:26:09.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-16T14:17:38.817Z","etag":null,"topics":["deno","memoize","typescript"],"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/korkje.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","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,"zenodo":null}},"created_at":"2023-12-12T17:07:22.000Z","updated_at":"2025-01-31T15:25:45.000Z","dependencies_parsed_at":"2024-06-11T22:46:14.762Z","dependency_job_id":"b0ba06b3-199b-4091-81d0-ac250394d312","html_url":"https://github.com/korkje/memz","commit_stats":null,"previous_names":["korkje/memz"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/korkje/memz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korkje%2Fmemz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korkje%2Fmemz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korkje%2Fmemz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korkje%2Fmemz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/korkje","download_url":"https://codeload.github.com/korkje/memz/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korkje%2Fmemz/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32245054,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["deno","memoize","typescript"],"created_at":"2025-02-02T17:58:56.156Z","updated_at":"2026-04-24T23:31:58.499Z","avatar_url":"https://github.com/korkje.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# memz [![JSR](https://jsr.io/badges/@korkje/memz)](https://jsr.io/@korkje/memz)\n\nWrap any function with a cache.\n\n```ts\nimport memoize from \"jsr:@korkje/memz\";\n\nconst add = memoize((a: number, b: number) =\u003e a + b);\n```\n\nRecursion:\n\n```ts\nconst fib = memoize((n: number): number =\u003e {\n    if (n \u003c 2) {\n        return n;\n    }\n\n    return fib(n - 2) + fib(n - 1);\n});\n```\n\nInitial cache:\n\n```ts\n// Start with 2 and 1, i.e. create the Lucas sequence.\nconst cache = { \"[0]\": 2, \"[1]\": 1 };\nconst fib = memoize(\n    (n: number): number =\u003e fib(n - 2) + fib(n - 1),\n    { cache },\n);\n```\n\nBy default, cache keys are arguments serialized to JSON, hence the `\"[0]\"` and `\"[1]\"` keys above.\n\nCustom cache keys:\n\n```ts\nconst fib = memoize(\n    (n: number): number =\u003e fib(n - 2) + fib(n - 1),\n    { keyFn: n =\u003e n },\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkorkje%2Fmemz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkorkje%2Fmemz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkorkje%2Fmemz/lists"}