ts-ioc-container 53.0.0 → 54.0.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/cjm/utils/once.js CHANGED
@@ -1,11 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.once = void 0;
4
- const once = (target, propertyKey, descriptor) => {
4
+ const once = ({ onRepeat } = {}) => (target, propertyKey, descriptor) => {
5
5
  const originalMethod = descriptor.value;
6
6
  const cacheMap = new WeakMap();
7
+ let index = 0;
7
8
  descriptor.value = function (...args) {
9
+ index++;
8
10
  if (cacheMap.has(this)) {
11
+ onRepeat?.({ index: index - 1, args });
9
12
  return cacheMap.get(this);
10
13
  }
11
14
  const result = originalMethod.apply(this, args);
package/esm/utils/once.js CHANGED
@@ -1,8 +1,11 @@
1
- export const once = (target, propertyKey, descriptor) => {
1
+ export const once = ({ onRepeat } = {}) => (target, propertyKey, descriptor) => {
2
2
  const originalMethod = descriptor.value;
3
3
  const cacheMap = new WeakMap();
4
+ let index = 0;
4
5
  descriptor.value = function (...args) {
6
+ index++;
5
7
  if (cacheMap.has(this)) {
8
+ onRepeat?.({ index: index - 1, args });
6
9
  return cacheMap.get(this);
7
10
  }
8
11
  const result = originalMethod.apply(this, args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-ioc-container",
3
- "version": "53.0.0",
3
+ "version": "54.0.0",
4
4
  "description": "Fast, lightweight TypeScript dependency injection container with a clean API, scoped lifecycles, decorators, tokens, hooks, lazy injection, customizable providers, and no global container objects.",
5
5
  "workspaces": [
6
6
  "docs"
@@ -1 +1,8 @@
1
- export declare const once: MethodDecorator;
1
+ type RepeatOptions = {
2
+ index: number;
3
+ args: unknown[];
4
+ };
5
+ export declare const once: ({ onRepeat }?: {
6
+ onRepeat?: (options: RepeatOptions) => void;
7
+ }) => MethodDecorator;
8
+ export {};