{"id":17238025,"url":"https://github.com/jsantell/cache-per-frame","last_synced_at":"2025-06-21T08:08:04.401Z","repository":{"id":57192480,"uuid":"104786281","full_name":"jsantell/cache-per-frame","owner":"jsantell","description":"Cache the result of a function once per frame","archived":false,"fork":false,"pushed_at":"2017-09-25T19:53:08.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-03T21:11:48.608Z","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/jsantell.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":"2017-09-25T18:24:22.000Z","updated_at":"2018-11-16T19:42:17.000Z","dependencies_parsed_at":"2022-08-24T03:10:32.409Z","dependency_job_id":null,"html_url":"https://github.com/jsantell/cache-per-frame","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jsantell/cache-per-frame","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsantell%2Fcache-per-frame","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsantell%2Fcache-per-frame/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsantell%2Fcache-per-frame/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsantell%2Fcache-per-frame/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsantell","download_url":"https://codeload.github.com/jsantell/cache-per-frame/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsantell%2Fcache-per-frame/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261088356,"owners_count":23107683,"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":"2024-10-15T05:44:25.829Z","updated_at":"2025-06-21T08:07:59.385Z","avatar_url":"https://github.com/jsantell.png","language":"JavaScript","readme":"# cache-per-frame\n\n[![Build Status](http://img.shields.io/travis/jsantell/cache-per-frame.svg?style=flat-square)](https://travis-ci.org/jsantell/cache-per-frame)\n[![Build Status](http://img.shields.io/npm/v/cache-per-frame.svg?style=flat-square)](https://www.npmjs.org/package/cache-per-frame)\n[![Build Status](http://img.shields.io/npm/dt/cache-per-frame.svg?style=flat-square)](https://www.npmjs.org/package/cache-per-frame)\n[![Build Status](http://img.shields.io/npm/l/cache-per-frame.svg?style=flat-square)](https://www.npmjs.org/package/cache-per-frame)\n\nCache the result of a function once per frame. Built for `VRDisplay.getFrameData(frameData)`\nwhen working with several third party modules that call this once per frame. Does **not**\nmemoize via arguments, but only uses the arguments from the first call to the wrapped\nfunction per frame.\n\n## Install \u0026 Usage\n\nUse the browser-ready bundle at [dist/cache-per-frame.js]:\n\n```html\n\u003cscript src='cache-per-frame.js'\u003e\u003c/script\u003e\n\u003cscript\u003e\nvar nativeGetFrameData = VRDisplay.prototype.getFrameData;\nVRDisplay.prototype.getFrameData = cachePerFrame(function (fd) {\n  return nativeGetFrameData.call(this, fd);\n});\n\u003c/script\u003e\n```\n\nOr install via npm/yarn:\n\n`$ npm install cache-per-frame --save`\n\n```js\nconst cachePerFrame = require('cache-per-frame');\n\nvar nativeGetFrameData = VRDisplay.prototype.getFrameData;\nVRDisplay.prototype.getFrameData = cachePerFrame(function (fd) {\n  return nativeGetFrameData.call(this, fd);\n});\n```\n\n## API\n\nThe root module is a function `cachePerFrame(fn)` that takes a function `fn` and returns\na new wrapped form of that function that is throttled per frame. This wrapped function\nalso has two additional methods for stopping and starting the throttling. By default,\nthe wrapped function is already started.\n\n### wrappedFn.stop()\n\nStop throttling the function calls once per frame.\n\n### wrappedFn.start()\n\nStart throttling the function calls once per frame.\n\n## License\n\nApache License Version 2.0 (see [LICENSE])\n\n[LICENSE]: LICENSE\n[dist/cache-per-frame.js]: dist/cache-per-frame.js\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsantell%2Fcache-per-frame","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsantell%2Fcache-per-frame","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsantell%2Fcache-per-frame/lists"}