Skip to content

Commit

Permalink
Merge pull request #3 from ndragun92/version/1.1.1
Browse files Browse the repository at this point in the history
feat: Add generateKey function and update package version
  • Loading branch information
ndragun92 committed Mar 11, 2024
2 parents 0347322 + f566b62 commit e156dec
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "file-sys-cache",
"version": "1.1.0",
"version": "1.1.1",
"description": "A Node.js package providing efficient caching using the file system for storage.",
"type": "module",
"main": "./dist/file-sys-cache.cjs",
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// eslint-disable-next-line import/no-named-default
import { default as FileSysCache } from './lib/file-sys-cache'
import { generateKey } from './utils/index.util.ts'
import type { THashOptions } from './types/index.type'

export { type THashOptions, FileSysCache }
export { type THashOptions, FileSysCache, generateKey }
1 change: 1 addition & 0 deletions src/lib/file-sys-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export default class FileSysCache {
}
if (this.enableMonitoring) {
monitoring.count.success.invalidate++
this.log()
}
} catch (_) {
if (this.enableMonitoring) {
Expand Down
6 changes: 6 additions & 0 deletions src/utils/index.util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { createHash } from 'node:crypto'
import { type TBinaryToTextEncoding, type THashOptions } from '../types/index.type.ts'

export const generateKey = (value: string, hash: THashOptions = 'sha256', encoding: TBinaryToTextEncoding = 'hex'): string => {
return createHash(hash).update(value).digest(encoding)
}

0 comments on commit e156dec

Please sign in to comment.