npm.io
1.0.0 • Published 3 years ago

cache-key

Licence
MIT
Version
1.0.0
Deps
0
Size
6 kB
Vulns
0
Weekly
0
Stars
1

cache-key

create stable cache keys from complex objects

Install

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.

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"}]'

Keywords