Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Custom "hash" function #40

Open
codemariner opened this issue Jul 28, 2023 · 0 comments
Open

Feature Request: Custom "hash" function #40

codemariner opened this issue Jul 28, 2023 · 0 comments

Comments

@codemariner
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant