A zero-dependency alternative to cosmiconfig for loading configuration files
89
Build a configuration cache testing utility that demonstrates the performance benefits and control mechanisms of configuration file caching.
Create a module that helps developers test and benchmark configuration loading performance with different cache settings. The module should:
Provide a function benchmarkSearch(moduleName, searchPath, options) that:
firstSearchTime: time in milliseconds for the first searchsecondSearchTime: time in milliseconds for the second searchresult: the configuration result from the second searchcacheEnabled: boolean indicating whether caching was enabledProvide a function testCacheControl(moduleName, searchPath) that:
firstResult: result from the first searchsecondResult: result from the second searchresultsMatch: boolean indicating if both results have the same filepathProvide a function compareSearchCaching(moduleName, searchPath) that:
withCacheTime: time taken with cache enabledwithoutCacheTime: time taken with cache disabledresult: the configuration resultWhen benchmarkSearch is called with caching enabled, the second search should be faster than the first search @test
When benchmarkSearch is called with caching disabled, both searches should take similar amounts of time (difference < 5ms) @test
When testCacheControl is called, clearing caches should not affect the ability to find the same configuration file again @test
When compareSearchCaching is called, both cached and non-cached searches should return the same configuration filepath @test
@generates
/**
* Benchmarks search performance with specified cache settings
* @param {string} moduleName - Name of the configuration module to search for
* @param {string} searchPath - Directory path to start searching from
* @param {Object} options - Configuration options including cache setting
* @param {boolean} options.cache - Whether to enable caching
* @returns {Promise<Object>} Object with timing data and results
*/
export async function benchmarkSearch(moduleName, searchPath, options);
/**
* Tests cache control methods
* @param {string} moduleName - Name of the configuration module to search for
* @param {string} searchPath - Directory path to start searching from
* @returns {Promise<Object>} Object showing results before and after cache clearing
*/
export async function testCacheControl(moduleName, searchPath);
/**
* Compares search performance with and without caching
* @param {string} moduleName - Name of the configuration module to search for
* @param {string} searchPath - Directory path to start searching from
* @returns {Promise<Object>} Object with timing comparisons
*/
export async function compareSearchCaching(moduleName, searchPath);Provides configuration file search and loading with caching support.
Install with Tessl CLI
npx tessl i tessl/npm-lilconfigdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10