{"id":15821565,"url":"https://github.com/alan-agius4/speedy-require-cache","last_synced_at":"2025-07-12T17:33:46.484Z","repository":{"id":57161930,"uuid":"86696433","full_name":"alan-agius4/speedy-require-cache","owner":"alan-agius4","description":"Speeding up Node by caching the location of modules and files","archived":false,"fork":false,"pushed_at":"2017-05-16T20:34:02.000Z","size":36,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-02T17:01:39.635Z","etag":null,"topics":["boot","cache","fast","fastboot","module","modules","node","performance","require"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/alan-agius4.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-30T11:46:33.000Z","updated_at":"2019-07-20T23:45:12.000Z","dependencies_parsed_at":"2022-09-09T23:22:14.421Z","dependency_job_id":null,"html_url":"https://github.com/alan-agius4/speedy-require-cache","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/alan-agius4/speedy-require-cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alan-agius4%2Fspeedy-require-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alan-agius4%2Fspeedy-require-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alan-agius4%2Fspeedy-require-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alan-agius4%2Fspeedy-require-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alan-agius4","download_url":"https://codeload.github.com/alan-agius4/speedy-require-cache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alan-agius4%2Fspeedy-require-cache/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265025557,"owners_count":23699770,"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":["boot","cache","fast","fastboot","module","modules","node","performance","require"],"created_at":"2024-10-05T07:40:20.864Z","updated_at":"2025-07-12T17:33:46.450Z","avatar_url":"https://github.com/alan-agius4.png","language":"TypeScript","readme":"# @speedy/require-cache\n[![CircleCI](https://circleci.com/gh/alan-agius4/speedy-require-cache.svg?style=shield)](https://circleci.com/gh/alan-agius4/speedy-require-cache)\n[![npm version](https://img.shields.io/npm/v/@speedy/require-cache.svg)](https://www.npmjs.com/package/@speedy/require-cache)\n[![Dependency Status](https://img.shields.io/david/alan-agius4/speedy-require-cache.svg?style=flat-square)](https://david-dm.org/alan-agius4/speedy-require-cache)\n[![devDependency Status](https://img.shields.io/david/dev/alan-agius4/speedy-require-cache.svg?style=flat-square)](https://david-dm.org/alan-agius4/speedy-require-cache?type=dev)\n\nSpeed up Node load time by caching resolved module paths to avoid module resolution and refetching each time the application is loaded.\n\nThe first time the application loads, resolved file paths are saved in the file system.\n\nThis modules patches the `_resolveFilename` method of Node `module`, caching the files it finds in order to improve Node loading performance.\n\nThis is inspired by [fast-boot](https://www.npmjs.com/package/fast-boot).\n\n***Benchmark results***\n\n| Library   | Uncached    | Cached     | Efficient | Duration    |\n|-----------|-------------|------------|-----------|-------------|\n| tslint    | 128.268 ms  | 82.189 ms  | 35.923 %  | -46.078 ms  |\n| fs-extra  | 0.229 ms    | 0.236 ms   | -2.991 %  | 0.007 ms    |\n| shelljs   | 59.767 ms   | 32.028 ms  | 46.412 %  | -27.739 ms  |\n| stylelint | 1492.165 ms | 687.323 ms | 53.938 %  | -804.842 ms |\n| postcss   | 71.924 ms   | 45.183 ms  | 37.179 %  | -26.74 ms   |\n| yargs     | 97.382 ms   | 27.751 ms  | 71.503 %  | -69.632 ms  |\n| eslint    | 359.556 ms  | 292.274 ms | 18.712 %  | -67.282 ms  |\n\nBenchmark mark done on a `Windows 7 64 Bit`, `i7-5500U CPU @ 2.40Ghz` and `16GB RAM`.\n\n## Getting Started\n\n### Installation\n\n```\nnpm install @speedy/require-cache --save\n```\n\n### Usage\n\n```js\nimport { RequireCache } from \"@speedy/require-cache\";\nnew RequireCache().start();\n\nimport * as stylelint from \"stylelint\";\nimport * as _ from \"lodash\";\n```\n\n### Interfaces\n\n#### CacheOptions\n| Name          | Description                                                                                                                                                                                                                                                                                                 | Type                |\n|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------|\n| cacheKiller   | Used to invalidate the cache. By default it's set the version of `package.json`.\u003cbr\u003e\u003cbr\u003eNormally one will pass the application version number assuming that a different version or a Unix timestamp when the cache should expire.\u003cbr\u003e\u003cbr\u003estring: 'package.json' version: `1.0.0`\u003cbr\u003enumber: Unix timestamp: `1490873027` | `number` | `string` |\n| cacheFilePath | Alternate cache file location. Default: `./.cache/speedy-require-cache.json`                                                                                                                                                                                                                                | `string`            |\n readOnlyMode   | When in `ReadOnly` mode. Any changes will be discharged once process is terminated. Default: `false`                                                                                                                                                                                                        | `boolean`          |\n\n#### CacheStats\n| Name      | Description                                                                                         | Type     |\n|-----------|-----------------------------------------------------------------------------------------------------|----------|\n| cacheHit  | Number of modules who's locations were found in the cache                                           | `number` |\n| cacheMiss | Number of modules who's locations were not found in the cache and were added to the cache           | `number` |\n| notCached | Number of modules not to be cached - either not in `node_modules` folder or `process.cwd()`         | `number` |\n\n### Methods and Properties\n\n#### new RequireCache([options]: Partial\\\u003cCacheOptions\\\u003e) ⇒ `RequireCache`\nCreates an instance of RequireCache.\n\n#### requireCache.isEnabled : \u003ccode\u003eboolean\u003c/code\u003e\nWhether or not the cache is currently enabled.\n\n**Read only**: true\n\n#### requireCache.stats : \u003ccode\u003eCacheStats\u003c/code\u003e\nCaching effectiveness statistics.\n\n**Read only**: true\n\nStart caching of module locations.\n\n#### requireCache.stop()\nStop caching of the modules locations.\n\n#### requireCache.reset()\nDeletes the cache file.\n\n#### requireCache.save()\nSaves cached paths to file.\n\n## Benchmark Yourself\n\nIf you'd like to run the benchmark yourself. Clone the Git repository and install all the dependencies executing the following commands in your terminal:\n\n```\nnpm install\nnpm run benchmark-install\n```\n\nTo benchmark run:\n```\nnpm run benchmark\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falan-agius4%2Fspeedy-require-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falan-agius4%2Fspeedy-require-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falan-agius4%2Fspeedy-require-cache/lists"}