{"id":15067801,"url":"https://github.com/r3dst0rm/easy-memoize","last_synced_at":"2025-07-06T17:06:12.465Z","repository":{"id":35061868,"uuid":"202194053","full_name":"R3DST0RM/easy-memoize","owner":"R3DST0RM","description":"Memoization in JS should be made easy. easy-memoize will help you with it!","archived":false,"fork":false,"pushed_at":"2025-07-02T23:58:11.000Z","size":559,"stargazers_count":3,"open_issues_count":8,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-03T00:30:02.222Z","etag":null,"topics":["javascript","memoize","react","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/easy-memoize","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/R3DST0RM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2019-08-13T17:36:04.000Z","updated_at":"2023-01-06T18:05:15.000Z","dependencies_parsed_at":"2024-01-21T00:24:18.750Z","dependency_job_id":"7888c2e2-144f-4767-bc2e-e6e0d95e5b96","html_url":"https://github.com/R3DST0RM/easy-memoize","commit_stats":{"total_commits":148,"total_committers":6,"mean_commits":"24.666666666666668","dds":0.5472972972972974,"last_synced_commit":"a6f2d968733f230e842e2954f0a825a5e846872a"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/R3DST0RM/easy-memoize","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R3DST0RM%2Feasy-memoize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R3DST0RM%2Feasy-memoize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R3DST0RM%2Feasy-memoize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R3DST0RM%2Feasy-memoize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/R3DST0RM","download_url":"https://codeload.github.com/R3DST0RM/easy-memoize/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R3DST0RM%2Feasy-memoize/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263940263,"owners_count":23533009,"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","react","typescript"],"created_at":"2024-09-25T01:27:28.337Z","updated_at":"2025-07-06T17:06:12.449Z","avatar_url":"https://github.com/R3DST0RM.png","language":"TypeScript","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=dominik.schwarzbauer%40googlemail.com"],"categories":[],"sub_categories":[],"readme":"# easy-memoize\n[![Build Status](https://github.com/R3DST0RM/easy-memoize/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/R3DST0RM/easy-memoize/actions/workflows/build.yml/badge.svg?branch=master)\n[![Coverage Status](https://coveralls.io/repos/github/R3DST0RM/easy-memoize/badge.svg?branch=master)](https://coveralls.io/github/R3DST0RM/easy-memoize?branch=master)\n\nMemoization is a simple thing and should be made easy to implement. The library `easy-memoize` will help you with it.\nFor an enhanced documentation please visit the wiki pages.\n\n# Installation\n\nThe package can be installed using `npm` or `yarn`. For example:\n\n```bash\nnpm install --save easy-memoize\n```\n\n# Usage\n\nThe usage of this library is as easy as 1, 2, 3.\nJust wrap it around your called function and pass in the arguments, like you normally would.\n\n```javascript\nimport easyMemo from \"easy-memoize\";\n\n/* ... */\n\n// On first call calculates the result of 1 * 2, if this code ever gets called again, the cached result will be returned.\neasyMemo((a, b) =\u003e a * b, [])(1, 2); // returns: 2\n\n// It returns the same object if the dependency is the same ( === safe)\neasyMemo((value) =\u003e ({ value, randomProp: \"abc\" }), [])(\"R3DST0RM\"); // returns: { value: \"R3DST0RM\", randomProp: \"abc\" }\n```\n\n## Memoize Signature\n\nThe memoize function receives two input params, the function to memoize as well as an array of dependencies. When those dependencies change,\nthe function will be executed again otherwise a cached result will be returned.\n\nE.g: `easyMemo(() =\u003e { return anotherFunction() }, [anotherFunction])`\n\nIf `anotherFunction` changes, the memoized function will be executed again.\n\n## Memoize Limits\n\nThe standard cache size of one function is at 10. Means, 10 results will be cached. \nIf a function exceeds this limit, the oldest results will be removed.\n\nUsing `overrideMaxCacheSize(num: Number)` allows you to override this default behavior.\n\n# How it works\n\nThe memoization is done by storing the function and its arguments. If one of it changes, the function will be executed again.\n\nLet's assume there is a function called: `heavyCalculation` with the following implementation:\n\n```javascript\nconst fibonacci = (num) =\u003e num \u003c= 1 ? 1 : fibonacci(num - 1) + fibonacci(num - 2);\n\nconst heavyCalculation = () =\u003e fibonacci(40);\n```\n\nThe bet is, you would not want it to run again and again everytime the result is needed, just once, until something changes.\n\nUsing easy-memoize, this would be achieved wrapping `heavyCalculation` with the memoize function:\n\n```javascript\nconst easyHeavyCalculation = easyMemo(heavyCalculation, []) // returns a new memoized function\n\n// By running easyHeavyCalculation(); a cached value will be returned if it gets executed a second time\nconsole.log(easyHeavyCalculation());\nconsole.log(easyHeavyCalculation()); // returns cached value\n```\n\n# Motivation\n\nAs motivation served the `useCallback` function from React.\nWhere it is possible to memoize a function call based on it's dependencies.\n\nTherefore this library strives to be as efficient as possible while maintain the easiness of `useCallback`.\n\n# Contribute\n\nYour contribution is highly wanted. If there is a feature or issue you want to work an feel free to submit a PR.\n\n# Browser Support\n\nWe care about browser support. Therefore this library has support for Internet Explorer 11\n\n![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) |\n--- | --- | --- | --- | --- | --- |\nLatest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |\n\n# Donate\n\nIf you like this library and would like to support this work feel free to donate here:\n\n[![paypal](https://www.paypalobjects.com/en_US/DK/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=dominik.schwarzbauer%40googlemail.com)\n\n# License\n\nLicensed under MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr3dst0rm%2Feasy-memoize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr3dst0rm%2Feasy-memoize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr3dst0rm%2Feasy-memoize/lists"}