cacheable 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,7 +1,5 @@
1
- import { WrapFunctionOptions, GetOrSetKey, GetOrSetFunctionOptions } from '@cacheable/memoize';
2
- export { GetOrSetFunctionOptions, GetOrSetKey, GetOrSetOptions, WrapOptions, WrapSyncOptions, getOrSet, wrap, wrapSync } from '@cacheable/memoize';
3
- import { Stats, CacheableItem, HashAlgorithm } from '@cacheable/utils';
4
- export { CacheableItem, Stats as CacheableStats, HashAlgorithm, calculateTtlFromExpiration, getCascadingTtl, hash, shorthandToMilliseconds, shorthandToTime } from '@cacheable/utils';
1
+ import { Stats, CacheableItem, WrapFunctionOptions, GetOrSetKey, GetOrSetFunctionOptions, HashAlgorithm } from '@cacheable/utils';
2
+ export { CacheableItem, Stats as CacheableStats, GetOrSetFunctionOptions, GetOrSetKey, GetOrSetOptions, HashAlgorithm, WrapOptions, WrapSyncOptions, calculateTtlFromExpiration, getCascadingTtl, getOrSet, hash, shorthandToMilliseconds, shorthandToTime, wrap, wrapSync } from '@cacheable/utils';
5
3
  import { Hookified, HookifiedOptions } from 'hookified';
6
4
  import { Keyv, KeyvStoreAdapter, StoredDataRaw } from 'keyv';
7
5
  export { Keyv, KeyvHooks, KeyvOptions, KeyvStoreAdapter } from 'keyv';
@@ -408,14 +406,24 @@ declare class Cacheable extends Hookified {
408
406
  */
409
407
  getOrSet<T>(key: GetOrSetKey, function_: () => Promise<T>, options?: GetOrSetFunctionOptions): Promise<T | undefined>;
410
408
  /**
411
- * Will hash an object using the specified algorithm. The default algorithm is 'sha256'.
409
+ * Will hash an object asynchronously using the specified cryptographic algorithm.
410
+ * Use this for cryptographic algorithms (SHA-256, SHA-384, SHA-512).
411
+ * For non-cryptographic algorithms, use hashSync() for better performance.
412
412
  * @param {any} object the object to hash
413
- * @param {string} algorithm the hash algorithm to use. The default is 'sha256'
413
+ * @param {string} algorithm the hash algorithm to use. The default is 'SHA-256'
414
+ * @returns {Promise<string>} the hash of the object
415
+ */
416
+ hash(object: any, algorithm?: HashAlgorithm): Promise<string>;
417
+ /**
418
+ * Will hash an object synchronously using the specified non-cryptographic algorithm.
419
+ * Use this for non-cryptographic algorithms (DJB2, FNV1, MURMER, CRC32).
420
+ * For cryptographic algorithms, use hash() instead.
421
+ * @param {any} object the object to hash
422
+ * @param {string} algorithm the hash algorithm to use. The default is 'djb2'
414
423
  * @returns {string} the hash of the object
415
424
  */
416
- hash(object: any, algorithm?: HashAlgorithm): string;
425
+ hashSync(object: any, algorithm?: HashAlgorithm): string;
417
426
  private setManyKeyv;
418
- private hasManyKeyv;
419
427
  /**
420
428
  * Processes a single key from secondary store for getRaw operation
421
429
  * @param primary - the primary store to use
package/dist/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- import { WrapFunctionOptions, GetOrSetKey, GetOrSetFunctionOptions } from '@cacheable/memoize';
2
- export { GetOrSetFunctionOptions, GetOrSetKey, GetOrSetOptions, WrapOptions, WrapSyncOptions, getOrSet, wrap, wrapSync } from '@cacheable/memoize';
3
- import { Stats, CacheableItem, HashAlgorithm } from '@cacheable/utils';
4
- export { CacheableItem, Stats as CacheableStats, HashAlgorithm, calculateTtlFromExpiration, getCascadingTtl, hash, shorthandToMilliseconds, shorthandToTime } from '@cacheable/utils';
1
+ import { Stats, CacheableItem, WrapFunctionOptions, GetOrSetKey, GetOrSetFunctionOptions, HashAlgorithm } from '@cacheable/utils';
2
+ export { CacheableItem, Stats as CacheableStats, GetOrSetFunctionOptions, GetOrSetKey, GetOrSetOptions, HashAlgorithm, WrapOptions, WrapSyncOptions, calculateTtlFromExpiration, getCascadingTtl, getOrSet, hash, shorthandToMilliseconds, shorthandToTime, wrap, wrapSync } from '@cacheable/utils';
5
3
  import { Hookified, HookifiedOptions } from 'hookified';
6
4
  import { Keyv, KeyvStoreAdapter, StoredDataRaw } from 'keyv';
7
5
  export { Keyv, KeyvHooks, KeyvOptions, KeyvStoreAdapter } from 'keyv';
@@ -408,14 +406,24 @@ declare class Cacheable extends Hookified {
408
406
  */
409
407
  getOrSet<T>(key: GetOrSetKey, function_: () => Promise<T>, options?: GetOrSetFunctionOptions): Promise<T | undefined>;
410
408
  /**
411
- * Will hash an object using the specified algorithm. The default algorithm is 'sha256'.
409
+ * Will hash an object asynchronously using the specified cryptographic algorithm.
410
+ * Use this for cryptographic algorithms (SHA-256, SHA-384, SHA-512).
411
+ * For non-cryptographic algorithms, use hashSync() for better performance.
412
412
  * @param {any} object the object to hash
413
- * @param {string} algorithm the hash algorithm to use. The default is 'sha256'
413
+ * @param {string} algorithm the hash algorithm to use. The default is 'SHA-256'
414
+ * @returns {Promise<string>} the hash of the object
415
+ */
416
+ hash(object: any, algorithm?: HashAlgorithm): Promise<string>;
417
+ /**
418
+ * Will hash an object synchronously using the specified non-cryptographic algorithm.
419
+ * Use this for non-cryptographic algorithms (DJB2, FNV1, MURMER, CRC32).
420
+ * For cryptographic algorithms, use hash() instead.
421
+ * @param {any} object the object to hash
422
+ * @param {string} algorithm the hash algorithm to use. The default is 'djb2'
414
423
  * @returns {string} the hash of the object
415
424
  */
416
- hash(object: any, algorithm?: HashAlgorithm): string;
425
+ hashSync(object: any, algorithm?: HashAlgorithm): string;
417
426
  private setManyKeyv;
418
- private hasManyKeyv;
419
427
  /**
420
428
  * Processes a single key from secondary store for getRaw operation
421
429
  * @param primary - the primary store to use