{"id":22040185,"url":"https://github.com/ykforerlang/repure","last_synced_at":"2026-05-01T10:32:47.551Z","repository":{"id":83880536,"uuid":"124614723","full_name":"ykforerlang/repure","owner":"ykforerlang","description":"Memoized selector library for Redux","archived":false,"fork":false,"pushed_at":"2018-03-11T15:27:11.000Z","size":13,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T13:18:31.710Z","etag":null,"topics":["memoized-selectors","redux","reselect"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ykforerlang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-03-10T02:28:02.000Z","updated_at":"2018-08-03T08:03:06.000Z","dependencies_parsed_at":"2023-10-20T23:56:22.043Z","dependency_job_id":null,"html_url":"https://github.com/ykforerlang/repure","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ykforerlang/repure","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ykforerlang%2Frepure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ykforerlang%2Frepure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ykforerlang%2Frepure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ykforerlang%2Frepure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ykforerlang","download_url":"https://codeload.github.com/ykforerlang/repure/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ykforerlang%2Frepure/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32494270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"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":["memoized-selectors","redux","reselect"],"created_at":"2024-11-30T11:13:38.673Z","updated_at":"2026-05-01T10:32:47.510Z","avatar_url":"https://github.com/ykforerlang.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# repure\n[中文文档](./README_zh.md)\n\nA replacement for [reselect](https://github.com/reactjs/reselect.git) and providing a more simple, more natural way of writing.\nSame parameters will get same result, so the function which wrapped by `repure`  will cache the result. If the same parameter is transmitted next time, the cached results will be used.\n\n### Get Start\n**install** :`npm install repure`\n\n```javascript\nimport repure from 'repure'\n\nfunction f(a, b) {\n  console.log('invoke f, will takes 5 seconds')\n  return a + b\n}\n\nconst rf = repure(f)\n\nrf(1, 1) // takes 5 seconds\nrf(1, 1) // takes 0 seconds\nrf(1, 1) // takes 0 seconds\nrf(1, 1) // takes 0 seconds\nrf(2, 2) // takes 5 seconds\n\n```\n\n### API\nrepure provide 3 API: repureCreator(cacheSize, equalityCheck)， repure， repureOneCacheCreator(equalityCheck)\n\n#### repureCreator(cacheSize, equalityCheck)\nthe result of repureCreator is a **repure** and the wrapped functions could cache **cacheSize** results.\nwe will use **equalityCheck** to compare whether or not the parameters are equal.\n\nDefault equalityCheck：\n```javascript\nfunction defaultEqualityCheck(a, b) {\n    return a === b\n}\n```\n\nAnother common equalityCheck is  shallowEqual: `import { shallowEqual } from 'repure'`\n\n\n#### repure\nIn most cases, you should use this method. cacheSize = 1 and equalityCheck is  `===`. the same with `createSelector` provided by [reselct](https://github.com/reactjs/reselect.git)\n\n####  repureOneCacheCreator(equalityCheck)\nrepureOneCacheCreator is optimized version of repureCreator when cacheSize is 1.\n\n\n\nAlso provide a method of batch operation： batchRepure(obj, repure)\n```javascript\nimport * as fobj from './xx' // file export func\n\nconst fobj2 = batchRepure(obj, repure)\n```\n\n### Composing\n```javascript\nfunction f(a, b) {\n    ...\n}\nconst rf = repure(f)\n\nfunction g(a, b, c){\n    const r = rf(a, b)\n    return r * c\n}\nconst rg = repure(g)\n\nrg(1, 1, 2)\nrg(1, 1, 2)\nrg(1, 1, 3)\n```\n\n \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fykforerlang%2Frepure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fykforerlang%2Frepure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fykforerlang%2Frepure/lists"}