{"id":28509855,"url":"https://github.com/choojs/nanocache","last_synced_at":"2025-07-03T01:31:17.669Z","repository":{"id":57101685,"uuid":"116042112","full_name":"choojs/nanocache","owner":"choojs","description":"Cache Nanocomponents.","archived":false,"fork":false,"pushed_at":"2018-01-19T14:44:10.000Z","size":45,"stargazers_count":7,"open_issues_count":2,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-08T22:39:43.728Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/choojs.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}},"created_at":"2018-01-02T17:54:37.000Z","updated_at":"2020-10-22T11:57:07.000Z","dependencies_parsed_at":"2022-08-20T22:40:53.315Z","dependency_job_id":null,"html_url":"https://github.com/choojs/nanocache","commit_stats":null,"previous_names":["yoshuawuyts/nanocache"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/choojs/nanocache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanocache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanocache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanocache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanocache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/choojs","download_url":"https://codeload.github.com/choojs/nanocache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanocache/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263243615,"owners_count":23436336,"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":[],"created_at":"2025-06-08T22:37:31.096Z","updated_at":"2025-07-03T01:31:17.654Z","avatar_url":"https://github.com/choojs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nanocache\n[![npm version][2]][3] [![build status][4]][5]\n[![downloads][8]][9] [![js-standard-style][10]][11]\n\nCache Nanocomponents.\n\n## Usage\n### my-component.js\n```js\nvar Component = require('choo/component')\nvar html = require('choo/html')\n\nmodule.exports = class Article extends Component {\n  static id (article) {\n    return `article-${article.id}`\n  }\n\n  createElement (article) {\n    return html`\n      \u003carticle\u003e\n        \u003ch2\u003e${article.title}\u003c/h2\u003e\n        \u003cp\u003e${article.body}\u003c/p\u003e\n      \u003c/article\u003e\n    `\n  }\n\n  update () {\n    return false\n  }\n}\n```\n\n### example.js\n```js\nvar myComponent = require('./my-component')\nvar Nanocache = require('nanocache')\n\nvar cache = new Nanocache()\ncache(myComponent)\n// =\u003e create a new instance of myComponent\n\ncache(myComponent)\n// =\u003e return cached instance of myComponent\n```\n\n## API\n### `cache = Nanocache()`\nCreate a new Nanocache instance.\n\n### `cache.render(Nanocomponent)`\nRender a Nanocomponent instance. It checks a static `id` method that\nreturns an id. If the id is not registered in the cache, it creates a new\ninstance and caches it. If the id already exists, it returns the cached\ninstance.\n\n### `cache.prune()`\nRemove all components from the cache that don't currently have a DOM node\nattached.\n\n## Installation\n```sh\n$ npm install @choojs/nanocache\n```\n\n## See Also\n- [choojs/nanocomponent](https://github.com/choojs/nanocomponent)\n\n## License\n[Apache-2.0](./LICENSE)\n\n[0]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square\n[1]: https://nodejs.org/api/documentation.html#documentation_stability_index\n[2]: https://img.shields.io/npm/v/@choojs/nanocache.svg?style=flat-square\n[3]: https://npmjs.org/package/@choojs/nanocache\n[4]: https://img.shields.io/travis/yoshuawuyts/nanocache/master.svg?style=flat-square\n[5]: https://travis-ci.org/yoshuawuyts/nanocache\n[6]: https://img.shields.io/codecov/c/github/yoshuawuyts/nanocache/master.svg?style=flat-square\n[7]: https://codecov.io/github/yoshuawuyts/nanocache\n[8]: http://img.shields.io/npm/dm/nanocache.svg?style=flat-square\n[9]: https://npmjs.org/package/nanocache\n[10]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\n[11]: https://github.com/feross/standard\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchoojs%2Fnanocache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchoojs%2Fnanocache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchoojs%2Fnanocache/lists"}