{"id":19312100,"url":"https://github.com/bigcommerce/memoize-js","last_synced_at":"2025-04-22T15:31:50.151Z","repository":{"id":35081193,"uuid":"203709754","full_name":"bigcommerce/memoize-js","owner":"bigcommerce","description":"A JavaScript library for memoizing the result of a pure function","archived":false,"fork":false,"pushed_at":"2024-10-13T09:27:56.000Z","size":394,"stargazers_count":3,"open_issues_count":6,"forks_count":3,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-11-01T14:40:24.487Z","etag":null,"topics":["javascript","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/bigcommerce.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2019-08-22T03:46:07.000Z","updated_at":"2024-02-06T20:12:38.000Z","dependencies_parsed_at":"2023-01-15T13:26:09.723Z","dependency_job_id":"25e05dfe-b735-4744-b96b-70dc81d54d60","html_url":"https://github.com/bigcommerce/memoize-js","commit_stats":{"total_commits":29,"total_committers":4,"mean_commits":7.25,"dds":0.3448275862068966,"last_synced_commit":"a14accfd31d516a841e576df3d8f3d1c8485549c"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigcommerce%2Fmemoize-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigcommerce%2Fmemoize-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigcommerce%2Fmemoize-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigcommerce%2Fmemoize-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bigcommerce","download_url":"https://codeload.github.com/bigcommerce/memoize-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223900372,"owners_count":17222028,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["javascript","memoize","typescript"],"created_at":"2024-11-10T00:32:51.357Z","updated_at":"2024-11-10T00:32:51.707Z","avatar_url":"https://github.com/bigcommerce.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @bigcommerce/memoize\n\n[![CircleCI](https://circleci.com/gh/bigcommerce/memoize-js.svg?style=svg)](https://circleci.com/gh/bigcommerce/memoize-js)\n\nThis library can be used to memoize the result of a pure function. \n\nUnlike the default `memoize` function provided by Lodash, it can be applied to functions that accept multiple non-primitive arguments. It can also be configured to expire its cache after certain number of unique calls. By default, it compares object-based arguments shallowly; but it can be configured to compare arguments strictly or deeply depending on your usage requirement.\n\n\n## Install\n\nYou can install this library using [npm](https://www.npmjs.com/get-npm).\n\n```sh\nnpm install --save @bigcommerce/memoize\n```\n\n\n## Usage\n\nTo memoize a function:\n\n```ts\nfunction fn(a, b) {\n    return { a, b };\n}\n\nconst memoizedFn = memoize(fn);\nconst result = memoizedFn({ message: 'hello' }, { message: 'world' });\nconst result2 = memoizedFn({ message: 'hello' }, { message: 'world' });\n\nexpect(result).toBe(result2);\n```\n\nTo set a limit on the cache size:\n\n```ts\nfunction fn(a, b) {\n    return { a, b };\n}\n\nconst memoizedFn = memoize(fn, { maxSize: 1 });\nconst result = memoizedFn({ message: 'hello' }, { message: 'world' });\n\n// This call will expire the cache of the previous call because it is called with a different set of arguments\nconst result2 = memoizedFn({ message: 'hello' }, { message: 'foobar' });\nconst result3 = memoizedFn({ message: 'hello' }, { message: 'world' });\n\nexpect(result3).not.toBe(result);\n```\n\nThere is a convenience method for setting the cache size to one:\n\n```ts\nconst memoizedFn = memoizeOne(fn);\n```\n\nTo use a different argument comparison function:\n\n```ts\nconst memoizedFn = memoize(fn, { \n    isEqual: (a, b) =\u003e a === b,\n});\n```\n\n\n## Contribution\n\nTo release:\n\n```sh\nnpm run release\n```\n\nTo see other available commands:\n\n```sh\nnpm run\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigcommerce%2Fmemoize-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbigcommerce%2Fmemoize-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigcommerce%2Fmemoize-js/lists"}