Skip to content

Commit

Permalink
Merge pull request #4 from ndragun92/version/1.1.2
Browse files Browse the repository at this point in the history
chore: Update generateKey function to accept objects
  • Loading branch information
ndragun92 authored Mar 11, 2024
2 parents e156dec + 9e5b6e5 commit dba2e79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 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.1",
"version": "1.1.2",
"description": "A Node.js package providing efficient caching using the file system for storage.",
"type": "module",
"main": "./dist/file-sys-cache.cjs",
Expand Down
5 changes: 3 additions & 2 deletions src/utils/index.util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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)
export const generateKey = (payload: object, hash: THashOptions = 'sha256', encoding: TBinaryToTextEncoding = 'hex'): string => {
const data = JSON.stringify(payload)
return createHash(hash).update(data).digest(encoding)
}

0 comments on commit dba2e79

Please sign in to comment.