@tsed/core 8.18.2 → 8.19.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.
Files changed (139) hide show
  1. package/lib/esm/decorators/storeFn.js +8 -4
  2. package/lib/esm/decorators/storeMerge.js +10 -0
  3. package/lib/esm/decorators/storeSet.js +10 -0
  4. package/lib/esm/errors/UnsupportedDecoratorType.js +8 -0
  5. package/lib/esm/types/DecoratorTypes.js +16 -0
  6. package/lib/esm/types/Env.js +8 -2
  7. package/lib/esm/types/Metadata.js +9 -0
  8. package/lib/esm/types/Store.js +14 -0
  9. package/lib/esm/types/Type.js +4 -2
  10. package/lib/esm/utils/AnyToPromise.js +20 -0
  11. package/lib/esm/utils/ancestorOf.js +17 -0
  12. package/lib/esm/utils/ancestorsOf.js +8 -2
  13. package/lib/esm/utils/catchError.js +12 -0
  14. package/lib/esm/utils/classOf.js +14 -7
  15. package/lib/esm/utils/cleanObject.js +7 -3
  16. package/lib/esm/utils/constructorOf.js +15 -4
  17. package/lib/esm/utils/createInstance.js +11 -0
  18. package/lib/esm/utils/decorateMethodsOf.js +11 -0
  19. package/lib/esm/utils/decoratorArgs.js +10 -0
  20. package/lib/esm/utils/decoratorTypeOf.js +11 -1
  21. package/lib/esm/utils/deepClone.js +7 -3
  22. package/lib/esm/utils/deepMerge.js +15 -0
  23. package/lib/esm/utils/descriptorOf.js +15 -4
  24. package/lib/esm/utils/getClassOrSymbol.js +8 -0
  25. package/lib/esm/utils/getConstructorArgNames.js +10 -0
  26. package/lib/esm/utils/getRandomId.js +8 -0
  27. package/lib/esm/utils/hasJsonMethod.js +6 -0
  28. package/lib/esm/utils/http/getHostInfoFromPort.js +9 -0
  29. package/lib/esm/utils/inheritedDescriptorOf.js +6 -0
  30. package/lib/esm/utils/isArray.js +8 -7
  31. package/lib/esm/utils/isArrowFn.js +6 -0
  32. package/lib/esm/utils/isBoolean.js +9 -2
  33. package/lib/esm/utils/isBuffer.js +10 -3
  34. package/lib/esm/utils/isClass.js +9 -0
  35. package/lib/esm/utils/isCollection.js +6 -3
  36. package/lib/esm/utils/isDate.js +3 -2
  37. package/lib/esm/utils/isEmpty.js +4 -3
  38. package/lib/esm/utils/isEnumerable.js +3 -2
  39. package/lib/esm/utils/isFunction.js +6 -0
  40. package/lib/esm/utils/isInheritedFrom.js +6 -0
  41. package/lib/esm/utils/isMomentObject.js +6 -0
  42. package/lib/esm/utils/isMongooseObject.js +13 -1
  43. package/lib/esm/utils/isNil.js +6 -0
  44. package/lib/esm/utils/isNumber.js +9 -2
  45. package/lib/esm/utils/isObject.js +6 -0
  46. package/lib/esm/utils/isObservable.js +6 -0
  47. package/lib/esm/utils/isPlainObject.js +9 -2
  48. package/lib/esm/utils/isPrimitive.js +14 -7
  49. package/lib/esm/utils/isPromise.js +4 -3
  50. package/lib/esm/utils/isProtectedKey.js +4 -2
  51. package/lib/esm/utils/isRegExp.js +6 -0
  52. package/lib/esm/utils/isSerializable.js +6 -0
  53. package/lib/esm/utils/isStream.js +6 -0
  54. package/lib/esm/utils/isString.js +10 -2
  55. package/lib/esm/utils/isSymbol.js +9 -1
  56. package/lib/esm/utils/methodsOf.js +4 -2
  57. package/lib/esm/utils/nameOf.js +12 -5
  58. package/lib/esm/utils/objectKeys.js +6 -0
  59. package/lib/esm/utils/primitiveOf.js +6 -0
  60. package/lib/esm/utils/prototypeOf.js +4 -3
  61. package/lib/esm/utils/setValue.js +20 -0
  62. package/lib/esm/utils/toMap.js +6 -0
  63. package/lib/esm/utils/toStringConstructor.js +10 -0
  64. package/lib/esm/utils/uniq.js +10 -1
  65. package/lib/esm/utils/useDecorators.js +6 -0
  66. package/lib/esm/utils/useMethodDecorators.js +12 -0
  67. package/lib/types/decorators/storeFn.d.ts +8 -4
  68. package/lib/types/decorators/storeMerge.d.ts +10 -0
  69. package/lib/types/decorators/storeSet.d.ts +10 -0
  70. package/lib/types/errors/UnsupportedDecoratorType.d.ts +8 -0
  71. package/lib/types/types/AnyDecorator.d.ts +10 -0
  72. package/lib/types/types/DecoratorParameters.d.ts +21 -0
  73. package/lib/types/types/DecoratorTypes.d.ts +16 -0
  74. package/lib/types/types/Env.d.ts +8 -2
  75. package/lib/types/types/Metadata.d.ts +9 -0
  76. package/lib/types/types/MetadataTypes.d.ts +12 -0
  77. package/lib/types/types/Relation.d.ts +8 -0
  78. package/lib/types/types/Store.d.ts +14 -0
  79. package/lib/types/types/Type.d.ts +14 -4
  80. package/lib/types/types/ValueOf.d.ts +10 -0
  81. package/lib/types/utils/AnyToPromise.d.ts +28 -0
  82. package/lib/types/utils/ancestorOf.d.ts +17 -0
  83. package/lib/types/utils/ancestorsOf.d.ts +8 -2
  84. package/lib/types/utils/catchError.d.ts +12 -0
  85. package/lib/types/utils/classOf.d.ts +14 -7
  86. package/lib/types/utils/cleanObject.d.ts +7 -3
  87. package/lib/types/utils/constructorOf.d.ts +15 -4
  88. package/lib/types/utils/createInstance.d.ts +11 -0
  89. package/lib/types/utils/decorateMethodsOf.d.ts +11 -0
  90. package/lib/types/utils/decoratorArgs.d.ts +10 -0
  91. package/lib/types/utils/decoratorTypeOf.d.ts +10 -0
  92. package/lib/types/utils/deepClone.d.ts +7 -3
  93. package/lib/types/utils/deepMerge.d.ts +30 -0
  94. package/lib/types/utils/descriptorOf.d.ts +15 -4
  95. package/lib/types/utils/getClassOrSymbol.d.ts +8 -0
  96. package/lib/types/utils/getConstructorArgNames.d.ts +10 -0
  97. package/lib/types/utils/getRandomId.d.ts +8 -0
  98. package/lib/types/utils/getValue.d.ts +7 -26
  99. package/lib/types/utils/hasJsonMethod.d.ts +6 -0
  100. package/lib/types/utils/http/getHostInfoFromPort.d.ts +15 -0
  101. package/lib/types/utils/inheritedDescriptorOf.d.ts +6 -0
  102. package/lib/types/utils/isArray.d.ts +8 -7
  103. package/lib/types/utils/isArrowFn.d.ts +6 -0
  104. package/lib/types/utils/isBoolean.d.ts +9 -2
  105. package/lib/types/utils/isBuffer.d.ts +10 -5
  106. package/lib/types/utils/isClass.d.ts +9 -0
  107. package/lib/types/utils/isCollection.d.ts +6 -3
  108. package/lib/types/utils/isDate.d.ts +3 -2
  109. package/lib/types/utils/isEmpty.d.ts +4 -3
  110. package/lib/types/utils/isEnumerable.d.ts +3 -2
  111. package/lib/types/utils/isFunction.d.ts +6 -0
  112. package/lib/types/utils/isInheritedFrom.d.ts +6 -0
  113. package/lib/types/utils/isMomentObject.d.ts +6 -0
  114. package/lib/types/utils/isMongooseObject.d.ts +13 -1
  115. package/lib/types/utils/isNil.d.ts +6 -0
  116. package/lib/types/utils/isNumber.d.ts +9 -2
  117. package/lib/types/utils/isObject.d.ts +6 -0
  118. package/lib/types/utils/isObservable.d.ts +8 -1
  119. package/lib/types/utils/isPlainObject.d.ts +9 -2
  120. package/lib/types/utils/isPrimitive.d.ts +14 -7
  121. package/lib/types/utils/isPromise.d.ts +4 -3
  122. package/lib/types/utils/isProtectedKey.d.ts +4 -2
  123. package/lib/types/utils/isRegExp.d.ts +6 -0
  124. package/lib/types/utils/isSerializable.d.ts +6 -0
  125. package/lib/types/utils/isStream.d.ts +6 -0
  126. package/lib/types/utils/isString.d.ts +10 -2
  127. package/lib/types/utils/isSymbol.d.ts +9 -1
  128. package/lib/types/utils/methodsOf.d.ts +4 -2
  129. package/lib/types/utils/nameOf.d.ts +12 -5
  130. package/lib/types/utils/objectKeys.d.ts +6 -0
  131. package/lib/types/utils/primitiveOf.d.ts +6 -0
  132. package/lib/types/utils/prototypeOf.d.ts +4 -3
  133. package/lib/types/utils/setValue.d.ts +20 -0
  134. package/lib/types/utils/toMap.d.ts +18 -0
  135. package/lib/types/utils/toStringConstructor.d.ts +10 -0
  136. package/lib/types/utils/uniq.d.ts +10 -1
  137. package/lib/types/utils/useDecorators.d.ts +6 -0
  138. package/lib/types/utils/useMethodDecorators.d.ts +12 -0
  139. package/package.json +5 -5
@@ -1,7 +1,8 @@
1
1
  /**
2
- * Tests to see if the object is Buffer
3
- * @param target
4
- * @returns {boolean}
2
+ * Checks if a value is a Buffer or Uint8Array instance.
3
+ *
4
+ * @public
5
+ * @since v7.0.0
5
6
  */
6
7
  export function isBuffer(target) {
7
8
  // is Class
@@ -10,6 +11,12 @@ export function isBuffer(target) {
10
11
  }
11
12
  return isUint8Array(target);
12
13
  }
14
+ /**
15
+ * Checks if a value is the Uint8Array constructor or a Uint8Array instance.
16
+ *
17
+ * @public
18
+ * @since v7.0.0
19
+ */
13
20
  export function isUint8Array(target) {
14
21
  return !!(target && (target === Uint8Array || target instanceof Uint8Array));
15
22
  }
@@ -6,6 +6,15 @@ import { isClassObject } from "./isPlainObject.js";
6
6
  import { isPrimitiveOrPrimitiveClass } from "./isPrimitive.js";
7
7
  import { isPromise } from "./isPromise.js";
8
8
  import { isSymbol } from "./isSymbol.js";
9
+ /**
10
+ * Determines whether a given value represents a class (constructor function).
11
+ *
12
+ * This helper filters out common non-class values such as primitives, symbols,
13
+ * plain objects, dates, promises, arrays, buffers, and arrow functions.
14
+ *
15
+ * @public
16
+ * @since v7.0.0
17
+ */
9
18
  export function isClass(target) {
10
19
  if (!target) {
11
20
  return false;
@@ -1,8 +1,11 @@
1
1
  import { isArrayOrArrayClass } from "./isArray.js";
2
2
  /**
3
- * Return true if the target.
4
- * @param target
5
- * @returns {boolean}
3
+ * Determines whether a value is a collection type (Array, Map, Set, WeakMap, WeakSet).
4
+ *
5
+ * Checks both the constructor itself and instances of these collection types.
6
+ *
7
+ * @public
8
+ * @since v7.0.0
6
9
  */
7
10
  export function isCollection(target) {
8
11
  return (isArrayOrArrayClass(target) ||
@@ -1,7 +1,8 @@
1
1
  /**
2
+ * Checks if a value is the Date constructor or a valid Date instance.
2
3
  *
3
- * @param target
4
- * @returns {boolean}
4
+ * @public
5
+ * @since v7.0.0
5
6
  */
6
7
  export function isDate(target) {
7
8
  return target === Date || (target instanceof Date && !isNaN(+target));
@@ -1,8 +1,9 @@
1
1
  import { isNil } from "./isNil.js";
2
2
  /**
3
- * Return true if the value is an empty string, null or undefined.
4
- * @param value
5
- * @returns {boolean}
3
+ * Checks if a value is an empty string, null, or undefined.
4
+ *
5
+ * @public
6
+ * @since v7.0.0
6
7
  */
7
8
  export function isEmpty(value) {
8
9
  return value === "" || isNil(value);
@@ -1,9 +1,10 @@
1
1
  import { classOf } from "./classOf.js";
2
2
  import { inheritedDescriptorOf } from "./inheritedDescriptorOf.js";
3
3
  /**
4
+ * Checks if a property is enumerable on an object, considering its prototype chain.
4
5
  *
5
- * @param obj
6
- * @param key
6
+ * @public
7
+ * @since v7.0.0
7
8
  */
8
9
  export function isEnumerable(obj, key) {
9
10
  const klass = classOf(obj);
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Checks if a value is a function.
3
+ *
4
+ * @public
5
+ * @since v7.0.0
6
+ */
1
7
  export function isFunction(target) {
2
8
  return typeof target === "function";
3
9
  }
@@ -1,6 +1,12 @@
1
1
  import { ancestorOf } from "./ancestorOf.js";
2
2
  import { classOf } from "./classOf.js";
3
3
  import { nameOf } from "./nameOf.js";
4
+ /**
5
+ * Checks if a target class inherits from another class within a specified depth limit.
6
+ *
7
+ * @public
8
+ * @since v7.0.0
9
+ */
4
10
  export function isInheritedFrom(target, from, deep = 5) {
5
11
  if (!target || !from) {
6
12
  return false;
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Checks if an object is a Moment.js object by verifying the _isAMomentObject property.
3
+ *
4
+ * @public
5
+ * @since v7.0.0
6
+ */
1
7
  export function isMomentObject(obj) {
2
8
  return !!(obj && obj?._isAMomentObject);
3
9
  }
@@ -1,7 +1,19 @@
1
1
  import { hasJsonMethod } from "./hasJsonMethod.js";
2
+ /**
3
+ * Checks if an object is a MongoDB ObjectID by verifying the _bsontype property.
4
+ *
5
+ * @public
6
+ * @since v7.0.0
7
+ */
2
8
  export function isObjectID(obj) {
3
- return obj && obj._bsontype;
9
+ return !!(obj && obj._bsontype);
4
10
  }
11
+ /**
12
+ * Checks if an object is a Mongoose model or MongoDB ObjectID.
13
+ *
14
+ * @public
15
+ * @since v7.0.0
16
+ */
5
17
  export function isMongooseObject(obj) {
6
18
  return !!((hasJsonMethod(obj) && obj.$isMongooseModelPrototype) || isObjectID(obj));
7
19
  }
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Checks if a value is null or undefined.
3
+ *
4
+ * @public
5
+ * @since v7.0.0
6
+ */
1
7
  export function isNil(value) {
2
8
  return value === undefined || value === null;
3
9
  }
@@ -1,11 +1,18 @@
1
1
  /**
2
+ * Checks if a value is a number primitive.
2
3
  *
3
- * @param target
4
- * @returns {boolean}
4
+ * @public
5
+ * @since v7.0.0
5
6
  */
6
7
  export function isNumber(target) {
7
8
  return typeof target === "number";
8
9
  }
10
+ /**
11
+ * Checks if a value is a number primitive, Number object, or the Number constructor.
12
+ *
13
+ * @public
14
+ * @since v7.0.0
15
+ */
9
16
  export function isNumberOrNumberClass(target) {
10
17
  return typeof target === "number" || target instanceof Number || target === Number;
11
18
  }
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Checks if a value is an object type.
3
+ *
4
+ * @public
5
+ * @since v7.0.0
6
+ */
1
7
  export function isObject(target) {
2
8
  return typeof target === "object";
3
9
  }
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Checks if an object is an RxJS Observable by verifying lift and subscribe methods.
3
+ *
4
+ * @public
5
+ * @since v7.0.0
6
+ */
1
7
  export function isObservable(obj) {
2
8
  return !!obj && typeof obj.lift === "function" && typeof obj.subscribe === "function";
3
9
  }
@@ -1,12 +1,19 @@
1
1
  import { classOf } from "./classOf.js";
2
2
  /**
3
+ * Checks if a value is the Object constructor.
3
4
  *
4
- * @param target
5
- * @returns {boolean}
5
+ * @public
6
+ * @since v7.0.0
6
7
  */
7
8
  export function isClassObject(target) {
8
9
  return target === Object;
9
10
  }
11
+ /**
12
+ * Checks if a value is a plain object (not a class instance or constructor).
13
+ *
14
+ * @public
15
+ * @since v7.0.0
16
+ */
10
17
  export function isPlainObject(target) {
11
18
  return isClassObject(classOf(target)) && target !== Object;
12
19
  }
@@ -2,22 +2,29 @@ import { isBoolean, isBooleanOrBooleanClass } from "./isBoolean.js";
2
2
  import { isNumber, isNumberOrNumberClass } from "./isNumber.js";
3
3
  import { isString, isStringOrStringClass } from "./isString.js";
4
4
  /**
5
- * Return true if the given obj is a primitive.
6
- * @param target
7
- * @returns {boolean}
8
- * @ignore
5
+ * Checks if a value is a primitive or primitive class constructor (String, Number, Boolean).
6
+ *
7
+ * @public
8
+ * @since v7.0.0
9
9
  */
10
10
  export function isPrimitiveOrPrimitiveClass(target) {
11
11
  return isStringOrStringClass(target) || isNumberOrNumberClass(target) || isBooleanOrBooleanClass(target);
12
12
  }
13
13
  /**
14
- * Return true if the given obj is a primitive.
15
- * @param target
16
- * @returns {boolean}
14
+ * Checks if a value is a primitive type (string, number, or boolean).
15
+ *
16
+ * @public
17
+ * @since v7.0.0
17
18
  */
18
19
  export function isPrimitive(target) {
19
20
  return isString(target) || isNumber(target) || isBoolean(target);
20
21
  }
22
+ /**
23
+ * Checks if a value is a primitive class constructor (String, Number, or Boolean).
24
+ *
25
+ * @public
26
+ * @since v7.0.0
27
+ */
21
28
  export function isPrimitiveClass(target) {
22
29
  return [String, Number, Boolean].includes(target);
23
30
  }
@@ -1,8 +1,9 @@
1
1
  /**
2
- * Tests to see if the object is an ES2015 (ES6) Promise
2
+ * Checks if a value is a Promise by verifying the then method exists and it's not an Observable.
3
+ *
4
+ * @public
5
+ * @since v7.0.0
3
6
  * @see {@link https://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects}
4
- * @param target
5
- * @returns {boolean}
6
7
  */
7
8
  export function isPromise(target) {
8
9
  return (target === Promise ||
@@ -1,6 +1,8 @@
1
1
  /**
2
- * Prevent prototype pollution vulnerability
3
- * @param key
2
+ * Checks if a key is a protected property name to prevent prototype pollution vulnerabilities.
3
+ *
4
+ * @public
5
+ * @since v7.0.0
4
6
  */
5
7
  export function isProtectedKey(key) {
6
8
  return ["__proto__", "constructor", "prototype"].includes(key);
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Checks if a value is a RegExp instance.
3
+ *
4
+ * @public
5
+ * @since v7.0.0
6
+ */
1
7
  export function isRegExp(target) {
2
8
  return target instanceof RegExp;
3
9
  }
@@ -3,6 +3,12 @@ import { isNil } from "./isNil.js";
3
3
  import { isNumber } from "./isNumber.js";
4
4
  import { isStream } from "./isStream.js";
5
5
  import { isString } from "./isString.js";
6
+ /**
7
+ * Checks if data requires serialization by excluding buffers, streams, and primitive types.
8
+ *
9
+ * @public
10
+ * @since v7.0.0
11
+ */
6
12
  export function isSerializable(data) {
7
13
  return !(Buffer.isBuffer(data) || isStream(data) || isBoolean(data) || isNumber(data) || isString(data) || isNil(data));
8
14
  }
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Checks if an object is a Node.js stream by verifying the pipe method exists.
3
+ *
4
+ * @public
5
+ * @since v7.0.0
6
+ */
1
7
  export function isStream(obj) {
2
8
  return obj !== null && typeof obj === "object" && typeof obj.pipe === "function";
3
9
  }
@@ -1,10 +1,18 @@
1
1
  /**
2
- * @param target
3
- * @returns {boolean}
2
+ * Checks if a value is a string primitive.
3
+ *
4
+ * @public
5
+ * @since v7.0.0
4
6
  */
5
7
  export function isString(target) {
6
8
  return typeof target === "string";
7
9
  }
10
+ /**
11
+ * Checks if a value is a string primitive, String object, or the String constructor.
12
+ *
13
+ * @public
14
+ * @since v7.0.0
15
+ */
8
16
  export function isStringOrStringClass(target) {
9
17
  return typeof target === "string" || target instanceof String || target === String;
10
18
  }
@@ -1,10 +1,18 @@
1
1
  /**
2
+ * Checks if a value is a symbol primitive.
2
3
  *
3
- * @param target
4
+ * @public
5
+ * @since v7.0.0
4
6
  */
5
7
  export function isSymbol(target) {
6
8
  return typeof target === "symbol";
7
9
  }
10
+ /**
11
+ * Checks if a value is a symbol primitive, Symbol object, or the Symbol constructor.
12
+ *
13
+ * @public
14
+ * @since v7.0.0
15
+ */
8
16
  export function isSymbolOrSymbolClass(target) {
9
17
  return typeof target === "symbol" || target instanceof Symbol || target === Symbol;
10
18
  }
@@ -3,8 +3,10 @@ import { classOf } from "./classOf.js";
3
3
  import { isSymbol } from "./isSymbol.js";
4
4
  import { prototypeOf } from "./prototypeOf.js";
5
5
  /**
6
- * Return all methods for a given class.
7
- * @param target
6
+ * Returns all methods for a given class by traversing its prototype chain.
7
+ *
8
+ * @public
9
+ * @since v7.0.0
8
10
  */
9
11
  export function methodsOf(target) {
10
12
  const methods = new Map();
@@ -1,17 +1,24 @@
1
1
  /**
2
- * Get the provide name.
3
- * @param targetClass
2
+ * Gets the name of a class from a constructor function or instance.
3
+ *
4
+ * @public
5
+ * @since v7.0.0
4
6
  */
5
7
  export function nameOfClass(targetClass) {
6
8
  return typeof targetClass === "function" ? targetClass.name : targetClass.constructor.name;
7
9
  }
8
10
  /**
9
- * Get symbol name.
10
- * @param sym
11
+ * Extracts the name from a symbol by removing the Symbol() wrapper.
12
+ *
13
+ * @public
14
+ * @since v7.0.0
11
15
  */
12
16
  export const nameOfSymbol = (sym) => sym.toString().replace("Symbol(", "").replace(")", "");
13
17
  /**
14
- * Get object name
18
+ * Gets the name of any object including symbols, functions, and classes.
19
+ *
20
+ * @public
21
+ * @since v7.0.0
15
22
  */
16
23
  export function nameOf(obj) {
17
24
  switch (typeof obj) {
@@ -1,4 +1,10 @@
1
1
  import { isProtectedKey } from "./isProtectedKey.js";
2
+ /**
3
+ * Returns object keys excluding protected keys like constructor and prototype.
4
+ *
5
+ * @public
6
+ * @since v7.0.0
7
+ */
2
8
  export function objectKeys(obj) {
3
9
  return Object.keys(obj).filter((key) => !isProtectedKey(key));
4
10
  }
@@ -1,6 +1,12 @@
1
1
  import { isBooleanOrBooleanClass } from "./isBoolean.js";
2
2
  import { isNumberOrNumberClass } from "./isNumber.js";
3
3
  import { isStringOrStringClass } from "./isString.js";
4
+ /**
5
+ * Determines the primitive type name for a given target value or class.
6
+ *
7
+ * @public
8
+ * @since v7.0.0
9
+ */
4
10
  export function primitiveOf(target) {
5
11
  if (isStringOrStringClass(target)) {
6
12
  return "string";
@@ -1,8 +1,9 @@
1
1
  import { classOf } from "./classOf.js";
2
2
  /**
3
- * Return the prototype of the given class.
4
- * @param target
5
- * @returns {any}
3
+ * Returns the prototype of a given class or instance.
4
+ *
5
+ * @public
6
+ * @since v7.0.0
6
7
  */
7
8
  export function prototypeOf(target) {
8
9
  return classOf(target) === target ? target.prototype : target;
@@ -1,4 +1,24 @@
1
1
  import { isProtectedKey } from "./isProtectedKey.js";
2
+ /**
3
+ * Sets a value on an object using a dot-notation expression path.
4
+ *
5
+ * Supports both plain objects and Map-like objects (with `.set()`, `.get()`, `.has()` methods).
6
+ * Automatically creates intermediate objects as needed. Protected keys (`__proto__`, `constructor`, `prototype`) are ignored for security.
7
+ *
8
+ * ```typescript
9
+ * const obj = {};
10
+ * setValue(obj, "user.name", "John");
11
+ * // obj is now { user: { name: "John" } }
12
+ * ```
13
+ *
14
+ * @param scope - The target object or Map to set the value on
15
+ * @param expression - Dot-notation path to the property (e.g., "user.profile.name")
16
+ * @param value - The value to set at the specified path
17
+ * @param separator - Path separator character (default: ".")
18
+ * @returns void
19
+ * @public
20
+ * @since v7.0.0
21
+ */
2
22
  export function setValue(scope, expression, value, separator = ".") {
3
23
  const keys = expression.split(separator);
4
24
  const setValue = (key, add) => {
@@ -11,6 +11,12 @@ function createIdentityFn(keyOrFn) {
11
11
  }
12
12
  return keyOrFn;
13
13
  }
14
+ /**
15
+ * Converts an array or object to a Map using a key extraction strategy.
16
+ *
17
+ * @public
18
+ * @since v7.0.0
19
+ */
14
20
  export function toMap(input, keyOrFn) {
15
21
  if (isArray(input)) {
16
22
  const identity = createIdentityFn(keyOrFn || "id");
@@ -1,4 +1,14 @@
1
1
  import { constructorOf } from "./constructorOf.js";
2
+ /**
3
+ * Returns the textual signature of a class/instance constructor.
4
+ *
5
+ * Example output: `constructor(id: string, name?: string)`.
6
+ * Useful for debugging and documentation generation.
7
+ *
8
+ * @param target Instance or constructor.
9
+ * @returns The constructor signature as a string.
10
+ * @public
11
+ */
2
12
  export function toStringConstructor(target) {
3
13
  const ctr = constructorOf(target);
4
14
  const strings = ctr.toString().split("\n");
@@ -1,9 +1,18 @@
1
1
  /**
2
- * @param list
2
+ * Returns a new array with duplicate values removed.
3
+ *
4
+ * @public
5
+ * @since v7.0.0
3
6
  */
4
7
  export function uniq(list) {
5
8
  return Array.from(new Set(list).values());
6
9
  }
10
+ /**
11
+ * Returns a new array with duplicate objects removed based on a specified property key.
12
+ *
13
+ * @public
14
+ * @since v7.0.0
15
+ */
7
16
  export function uniqBy(list, key = "id") {
8
17
  const map = new Map();
9
18
  list.forEach((item) => {
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Combines multiple decorators into a single decorator function.
3
+ *
4
+ * @public
5
+ * @since v7.0.0
6
+ */
1
7
  export function useDecorators(...decorators) {
2
8
  return (...args) => {
3
9
  const isMethod = typeof args[2] === "object";
@@ -1,7 +1,19 @@
1
1
  import { descriptorOf } from "./descriptorOf.js";
2
+ /**
3
+ * Wraps a decorator to ensure it receives the proper method descriptor.
4
+ *
5
+ * @public
6
+ * @since v7.0.0
7
+ */
2
8
  export function useMethodDecorator(decorator) {
3
9
  return (target, propertyKey) => decorator(target, propertyKey, descriptorOf(target, propertyKey));
4
10
  }
11
+ /**
12
+ * Combines multiple method decorators into a single decorator with proper descriptor handling.
13
+ *
14
+ * @public
15
+ * @since v7.0.0
16
+ */
5
17
  export function useMethodDecorators(...decorators) {
6
18
  return (target, propertyKey) => {
7
19
  decorators.filter(Boolean).forEach((decorator) => decorator(target, propertyKey, descriptorOf(target, propertyKey)));
@@ -1,9 +1,13 @@
1
1
  import { DecoratorParameters } from "../types/DecoratorParameters.js";
2
2
  import { Store } from "../types/Store.js";
3
3
  /**
4
- * Create a store correctly configured from the parameters given by the decorator.
5
- * The `fn` can return a decorator that will be initialized with the parameters (target, propertyKey, descriptor).
6
- * @param {(store: Store, parameters: DecoratorParameters) => void} fn
7
- * @returns {Function}
4
+ * Creates a decorator factory that initializes a Store from decorator parameters and invokes a callback.
5
+ *
6
+ * The callback receives both the Store instance and the original decorator parameters.
7
+ * If the callback returns a function, that function is invoked with the same decorator parameters.
8
+ *
9
+ * @public
10
+ * @since v7.0.0
11
+ * @see Store
8
12
  */
9
13
  export declare function StoreFn(fn: (store: Store, parameters: DecoratorParameters) => void): Function;
@@ -1 +1,11 @@
1
+ /**
2
+ * Creates a decorator that merges a key-value pair into the target's Store metadata.
3
+ *
4
+ * Uses {@link Store.merge} internally to deep-merge the provided value with existing metadata.
5
+ *
6
+ * @public
7
+ * @since v7.0.0
8
+ * @see StoreFn
9
+ * @see Store
10
+ */
1
11
  export declare function StoreMerge(key: any, value: any): Function;
@@ -1 +1,11 @@
1
+ /**
2
+ * Creates a decorator that sets a key-value pair in the target's Store metadata.
3
+ *
4
+ * Uses {@link Store.set} internally to directly set the provided value (no merging).
5
+ *
6
+ * @public
7
+ * @since v7.0.0
8
+ * @see StoreFn
9
+ * @see Store
10
+ */
1
11
  export declare function StoreSet(key: any, value: any): Function;
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Error thrown when a decorator is used in an unsupported location or context.
3
+ *
4
+ * Provides a descriptive message indicating where the decorator was applied and why it's invalid.
5
+ *
6
+ * @public
7
+ * @since v7.0.0
8
+ */
1
9
  export declare class UnsupportedDecoratorType extends Error {
2
10
  name: "UNSUPPORTED_DECORATOR_TYPE";
3
11
  constructor(decorator: any, args: any[]);
@@ -1 +1,11 @@
1
+ /**
2
+ * Utility union representing any decorator type supported by TypeScript.
3
+ *
4
+ * Used by Ts.ED to type APIs that accept class, method, property or parameter
5
+ * decorators. This type is handy when a helper must remain generic with regard
6
+ * to the decorated target.
7
+ *
8
+ * @public
9
+ * @since 8.0.0
10
+ */
1
11
  export type AnyDecorator = any | ClassDecorator | MethodDecorator | PropertyDescriptor | ParameterDecorator;