@tsed/core 8.18.1 → 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.
- package/lib/esm/decorators/storeFn.js +8 -4
- package/lib/esm/decorators/storeMerge.js +10 -0
- package/lib/esm/decorators/storeSet.js +10 -0
- package/lib/esm/errors/UnsupportedDecoratorType.js +8 -0
- package/lib/esm/types/DecoratorTypes.js +16 -0
- package/lib/esm/types/Env.js +8 -2
- package/lib/esm/types/Metadata.js +9 -0
- package/lib/esm/types/Store.js +14 -0
- package/lib/esm/types/Type.js +4 -2
- package/lib/esm/utils/AnyToPromise.js +20 -0
- package/lib/esm/utils/ancestorOf.js +17 -0
- package/lib/esm/utils/ancestorsOf.js +8 -2
- package/lib/esm/utils/catchError.js +12 -0
- package/lib/esm/utils/classOf.js +14 -7
- package/lib/esm/utils/cleanObject.js +7 -3
- package/lib/esm/utils/constructorOf.js +15 -4
- package/lib/esm/utils/createInstance.js +11 -0
- package/lib/esm/utils/decorateMethodsOf.js +11 -0
- package/lib/esm/utils/decoratorArgs.js +10 -0
- package/lib/esm/utils/decoratorTypeOf.js +11 -1
- package/lib/esm/utils/deepClone.js +7 -3
- package/lib/esm/utils/deepMerge.js +15 -0
- package/lib/esm/utils/descriptorOf.js +15 -4
- package/lib/esm/utils/getClassOrSymbol.js +8 -0
- package/lib/esm/utils/getConstructorArgNames.js +10 -0
- package/lib/esm/utils/getRandomId.js +8 -0
- package/lib/esm/utils/hasJsonMethod.js +6 -0
- package/lib/esm/utils/http/getHostInfoFromPort.js +9 -0
- package/lib/esm/utils/inheritedDescriptorOf.js +6 -0
- package/lib/esm/utils/isArray.js +8 -7
- package/lib/esm/utils/isArrowFn.js +6 -0
- package/lib/esm/utils/isBoolean.js +9 -2
- package/lib/esm/utils/isBuffer.js +10 -3
- package/lib/esm/utils/isClass.js +9 -0
- package/lib/esm/utils/isCollection.js +6 -3
- package/lib/esm/utils/isDate.js +3 -2
- package/lib/esm/utils/isEmpty.js +4 -3
- package/lib/esm/utils/isEnumerable.js +3 -2
- package/lib/esm/utils/isFunction.js +6 -0
- package/lib/esm/utils/isInheritedFrom.js +6 -0
- package/lib/esm/utils/isMomentObject.js +6 -0
- package/lib/esm/utils/isMongooseObject.js +13 -1
- package/lib/esm/utils/isNil.js +6 -0
- package/lib/esm/utils/isNumber.js +9 -2
- package/lib/esm/utils/isObject.js +6 -0
- package/lib/esm/utils/isObservable.js +6 -0
- package/lib/esm/utils/isPlainObject.js +9 -2
- package/lib/esm/utils/isPrimitive.js +14 -7
- package/lib/esm/utils/isPromise.js +4 -3
- package/lib/esm/utils/isProtectedKey.js +4 -2
- package/lib/esm/utils/isRegExp.js +6 -0
- package/lib/esm/utils/isSerializable.js +6 -0
- package/lib/esm/utils/isStream.js +6 -0
- package/lib/esm/utils/isString.js +10 -2
- package/lib/esm/utils/isSymbol.js +9 -1
- package/lib/esm/utils/methodsOf.js +4 -2
- package/lib/esm/utils/nameOf.js +12 -5
- package/lib/esm/utils/objectKeys.js +6 -0
- package/lib/esm/utils/primitiveOf.js +6 -0
- package/lib/esm/utils/prototypeOf.js +4 -3
- package/lib/esm/utils/setValue.js +20 -0
- package/lib/esm/utils/toMap.js +6 -0
- package/lib/esm/utils/toStringConstructor.js +10 -0
- package/lib/esm/utils/uniq.js +10 -1
- package/lib/esm/utils/useDecorators.js +6 -0
- package/lib/esm/utils/useMethodDecorators.js +12 -0
- package/lib/types/decorators/storeFn.d.ts +8 -4
- package/lib/types/decorators/storeMerge.d.ts +10 -0
- package/lib/types/decorators/storeSet.d.ts +10 -0
- package/lib/types/errors/UnsupportedDecoratorType.d.ts +8 -0
- package/lib/types/types/AnyDecorator.d.ts +10 -0
- package/lib/types/types/DecoratorParameters.d.ts +21 -0
- package/lib/types/types/DecoratorTypes.d.ts +16 -0
- package/lib/types/types/Env.d.ts +8 -2
- package/lib/types/types/Metadata.d.ts +9 -0
- package/lib/types/types/MetadataTypes.d.ts +12 -0
- package/lib/types/types/Relation.d.ts +8 -0
- package/lib/types/types/Store.d.ts +14 -0
- package/lib/types/types/Type.d.ts +14 -4
- package/lib/types/types/ValueOf.d.ts +10 -0
- package/lib/types/utils/AnyToPromise.d.ts +28 -0
- package/lib/types/utils/ancestorOf.d.ts +17 -0
- package/lib/types/utils/ancestorsOf.d.ts +8 -2
- package/lib/types/utils/catchError.d.ts +12 -0
- package/lib/types/utils/classOf.d.ts +14 -7
- package/lib/types/utils/cleanObject.d.ts +7 -3
- package/lib/types/utils/constructorOf.d.ts +15 -4
- package/lib/types/utils/createInstance.d.ts +11 -0
- package/lib/types/utils/decorateMethodsOf.d.ts +11 -0
- package/lib/types/utils/decoratorArgs.d.ts +10 -0
- package/lib/types/utils/decoratorTypeOf.d.ts +10 -0
- package/lib/types/utils/deepClone.d.ts +7 -3
- package/lib/types/utils/deepMerge.d.ts +30 -0
- package/lib/types/utils/descriptorOf.d.ts +15 -4
- package/lib/types/utils/getClassOrSymbol.d.ts +8 -0
- package/lib/types/utils/getConstructorArgNames.d.ts +10 -0
- package/lib/types/utils/getRandomId.d.ts +8 -0
- package/lib/types/utils/getValue.d.ts +7 -26
- package/lib/types/utils/hasJsonMethod.d.ts +6 -0
- package/lib/types/utils/http/getHostInfoFromPort.d.ts +15 -0
- package/lib/types/utils/inheritedDescriptorOf.d.ts +6 -0
- package/lib/types/utils/isArray.d.ts +8 -7
- package/lib/types/utils/isArrowFn.d.ts +6 -0
- package/lib/types/utils/isBoolean.d.ts +9 -2
- package/lib/types/utils/isBuffer.d.ts +10 -5
- package/lib/types/utils/isClass.d.ts +9 -0
- package/lib/types/utils/isCollection.d.ts +6 -3
- package/lib/types/utils/isDate.d.ts +3 -2
- package/lib/types/utils/isEmpty.d.ts +4 -3
- package/lib/types/utils/isEnumerable.d.ts +3 -2
- package/lib/types/utils/isFunction.d.ts +6 -0
- package/lib/types/utils/isInheritedFrom.d.ts +6 -0
- package/lib/types/utils/isMomentObject.d.ts +6 -0
- package/lib/types/utils/isMongooseObject.d.ts +13 -1
- package/lib/types/utils/isNil.d.ts +6 -0
- package/lib/types/utils/isNumber.d.ts +9 -2
- package/lib/types/utils/isObject.d.ts +6 -0
- package/lib/types/utils/isObservable.d.ts +8 -1
- package/lib/types/utils/isPlainObject.d.ts +9 -2
- package/lib/types/utils/isPrimitive.d.ts +14 -7
- package/lib/types/utils/isPromise.d.ts +4 -3
- package/lib/types/utils/isProtectedKey.d.ts +4 -2
- package/lib/types/utils/isRegExp.d.ts +6 -0
- package/lib/types/utils/isSerializable.d.ts +6 -0
- package/lib/types/utils/isStream.d.ts +6 -0
- package/lib/types/utils/isString.d.ts +10 -2
- package/lib/types/utils/isSymbol.d.ts +9 -1
- package/lib/types/utils/methodsOf.d.ts +4 -2
- package/lib/types/utils/nameOf.d.ts +12 -5
- package/lib/types/utils/objectKeys.d.ts +6 -0
- package/lib/types/utils/primitiveOf.d.ts +6 -0
- package/lib/types/utils/prototypeOf.d.ts +4 -3
- package/lib/types/utils/setValue.d.ts +20 -0
- package/lib/types/utils/toMap.d.ts +18 -0
- package/lib/types/utils/toStringConstructor.d.ts +10 -0
- package/lib/types/utils/uniq.d.ts +10 -1
- package/lib/types/utils/useDecorators.d.ts +6 -0
- package/lib/types/utils/useMethodDecorators.d.ts +12 -0
- package/package.json +5 -5
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @
|
|
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
|
}
|
package/lib/esm/utils/isClass.js
CHANGED
|
@@ -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
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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) ||
|
package/lib/esm/utils/isDate.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Checks if a value is the Date constructor or a valid Date instance.
|
|
2
3
|
*
|
|
3
|
-
* @
|
|
4
|
-
* @
|
|
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));
|
package/lib/esm/utils/isEmpty.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { isNil } from "./isNil.js";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
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
|
-
* @
|
|
6
|
-
* @
|
|
6
|
+
* @public
|
|
7
|
+
* @since v7.0.0
|
|
7
8
|
*/
|
|
8
9
|
export function isEnumerable(obj, key) {
|
|
9
10
|
const klass = classOf(obj);
|
|
@@ -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,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
|
}
|
package/lib/esm/utils/isNil.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Checks if a value is a number primitive.
|
|
2
3
|
*
|
|
3
|
-
* @
|
|
4
|
-
* @
|
|
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,12 +1,19 @@
|
|
|
1
1
|
import { classOf } from "./classOf.js";
|
|
2
2
|
/**
|
|
3
|
+
* Checks if a value is the Object constructor.
|
|
3
4
|
*
|
|
4
|
-
* @
|
|
5
|
-
* @
|
|
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
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
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
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* @
|
|
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
|
-
*
|
|
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
|
-
*
|
|
3
|
-
*
|
|
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);
|
|
@@ -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,10 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
*
|
|
7
|
-
*
|
|
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();
|
package/lib/esm/utils/nameOf.js
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
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
|
-
*
|
|
10
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
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) => {
|
package/lib/esm/utils/toMap.js
CHANGED
|
@@ -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");
|
package/lib/esm/utils/uniq.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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,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
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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;
|