https://github.com/smeijer/cache-key
create stable cache keys from complex objects
https://github.com/smeijer/cache-key
Last synced: 2 months ago
JSON representation
create stable cache keys from complex objects
- Host: GitHub
- URL: https://github.com/smeijer/cache-key
- Owner: smeijer
- License: mit
- Created: 2023-07-12T13:47:31.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-13T13:06:06.000Z (almost 2 years ago)
- Last Synced: 2025-02-17T06:35:24.010Z (2 months ago)
- Language: TypeScript
- Size: 60.5 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license
Awesome Lists containing this project
README
# cache-key
> create stable cache keys from complex objects
## Install
```sh
npm install cache-key
```## Usage
Just pass an array of values to `hashCacheKey` and it will return a stable hash. The order of items in the array is untouched. The keys of objects are sorted alphabetically.
```js
import { hashCacheKey } from 'cache-key';hashCacheKey(['users', { id: 1, name: 'person' }]);
//=> '["users",{"id":1,name:"person"}]'hashCacheKey(['users', { name: 'person', id: 1 }]);
//=> '["users",{"id":1,name:"person"}]'
```