CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-lilconfig

A zero-dependency alternative to cosmiconfig for loading configuration files

89

1.21x
Overview
Eval results
Files

task.mdevals/scenario-10/

Configuration Cache Manager

Build a configuration file loader that efficiently manages caching of search and load operations. The system should maintain separate caches for search results and file loads, and provide methods to clear these caches individually or together.

Capabilities

Clear Search Cache

Clears only the search cache while preserving load cache.

  • After clearing search cache, a repeated search from the same directory should not return cached results @test
  • Clearing search cache does not affect previously cached loaded configurations @test

Clear Load Cache

Clears only the load cache while preserving search cache.

  • After clearing load cache, loading the same file again should re-read and re-parse the file @test
  • Clearing load cache does not affect previously cached search results @test

Clear All Caches

Clears both search and load caches completely.

  • After clearing all caches, both search and load operations should fetch fresh data @test
  • Clearing all caches is equivalent to clearing both search and load caches separately @test

Cache Identity Verification

Verify that cached results return the same object reference (identity equality).

  • Loading the same configuration file twice returns identical object references (same object in memory) @test
  • Searching from the same directory twice returns identical object references (same object in memory) @test

Implementation

@generates

API

/**
 * Creates a configuration explorer with caching capabilities
 * @param {string} name - The name to use for configuration file search
 * @param {Object} options - Configuration options
 * @param {boolean} [options.cache=true] - Enable or disable caching
 * @returns {Object} Explorer object with search, load, and cache management methods
 */
function createExplorer(name, options) {
  // Returns an object with the following methods:
  // - search(searchFrom?) - Search for config starting from a directory
  // - load(filepath) - Load a specific config file
  // - clearSearchCache() - Clear only the search cache
  // - clearLoadCache() - Clear only the load cache
  // - clearCaches() - Clear both caches
}

module.exports = { createExplorer };

Dependencies { .dependencies }

lilconfig { .dependency }

Provides configuration file discovery and loading with built-in caching support.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-lilconfig

tile.json