file-system-cache icon indicating copy to clipboard operation
file-system-cache copied to clipboard

Feature Request: Custom "hash" function

Open codemariner opened this issue 1 year ago • 0 comments

I'm using file-system-cache to help store fixture data for tests. I'd like to be able to easily read the file system and see which file is for what data. Perhaps something like this:

interface HashFn {
    (...values:any[]):string
}

type FileSystemCacheOptions = {
    basePath?: string;
    ns?: any;
    ttl?: number;
    hash?: HashAlgorithm | HashFn;
    extension?: string;
};

//...

const cache = Cache({
    basePath: path.join(__dirname, 'cache'),
    ns: 'test-fixtures',
    hash: (...values:any[]) {
        return customizeFilename(values);
    }
})

for now, I'm just monkey patching the util#hash function.

codemariner avatar Jul 28 '23 18:07 codemariner