@travetto/cache 7.0.0-rc.0 → 7.0.0-rc.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/decorator.ts +8 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/cache",
3
- "version": "7.0.0-rc.0",
3
+ "version": "7.0.0-rc.1",
4
4
  "description": "Caching functionality with decorators for declarative use.",
5
5
  "keywords": [
6
6
  "typescript",
package/src/decorator.ts CHANGED
@@ -21,15 +21,15 @@ export function Cache<F extends string, U extends Record<F, CacheService>>(
21
21
  config = cfg;
22
22
  }
23
23
  }
24
- const dec = function <R extends Promise<unknown>>(target: U & CacheAware, propertyKey: string, _descriptor: MethodDescriptor<R>): void {
24
+ const dec = function <R extends Promise<unknown>>(target: U & CacheAware, propertyKey: string, descriptor: MethodDescriptor<R>): void {
25
25
  config.keySpace ??= `${target.constructor.name}.${propertyKey}`;
26
26
  (target[CacheConfigSymbol] ??= {})[propertyKey] = config;
27
- const handler = _descriptor.value!.bind(castTo(target));
27
+ const handler = descriptor.value!;
28
28
  // Allows for DI to run, as the service will not be bound until after the decorator is run
29
- _descriptor.value = castTo(function (this: typeof target) {
29
+ descriptor.value = castTo(function (this: typeof target) {
30
30
  return this[field].cache(this, propertyKey, handler, [...arguments]);
31
31
  });
32
- Object.defineProperty(_descriptor.value, 'name', { value: propertyKey, writable: false });
32
+ Object.defineProperty(descriptor.value, 'name', { value: propertyKey, writable: false });
33
33
  };
34
34
  return castTo(dec);
35
35
  }
@@ -42,14 +42,14 @@ export function Cache<F extends string, U extends Record<F, CacheService>>(
42
42
  * @kind decorator
43
43
  */
44
44
  export function EvictCache<F extends string, U extends Record<F, CacheService>>(field: F, config: CoreCacheConfig = {}) {
45
- return function <R extends Promise<unknown>>(target: U & CacheAware, propertyKey: string, _descriptor: MethodDescriptor<R>): void {
45
+ return function <R extends Promise<unknown>>(target: U & CacheAware, propertyKey: string, descriptor: MethodDescriptor<R>): void {
46
46
  config.keySpace ??= `${target.constructor.name}.${propertyKey}`;
47
47
  (target[EvictConfigSymbol] ??= {})[propertyKey] = config;
48
- const handler = _descriptor.value!.bind(castTo(target));
48
+ const handler = descriptor.value!;
49
49
  // Allows for DI to run, as the service will not be bound until after the decorator is run
50
- _descriptor.value = castTo(function (this: typeof target) {
50
+ descriptor.value = castTo(function (this: typeof target) {
51
51
  return this[field].evict(this, propertyKey, handler, [...arguments]);
52
52
  });
53
- Object.defineProperty(_descriptor.value, 'name', { value: propertyKey, writable: false });
53
+ Object.defineProperty(descriptor.value, 'name', { value: propertyKey, writable: false });
54
54
  };
55
55
  }