@carno.js/core 0.2.3
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/LICENSE +674 -0
- package/dist/Carno.d.ts +65 -0
- package/dist/Carno.js +307 -0
- package/dist/Cheetah.d.ts +65 -0
- package/dist/Cheetah.js +307 -0
- package/dist/cache/bento-cache.driver.d.ts +13 -0
- package/dist/cache/bento-cache.driver.js +55 -0
- package/dist/cache/cache.service.d.ts +8 -0
- package/dist/cache/cache.service.js +6 -0
- package/dist/commons/decorators/Injectable.decorator.d.ts +20 -0
- package/dist/commons/decorators/Injectable.decorator.js +33 -0
- package/dist/commons/decorators/controller.decorator.d.ts +8 -0
- package/dist/commons/decorators/controller.decorator.js +22 -0
- package/dist/commons/decorators/http.decorators.d.ts +13 -0
- package/dist/commons/decorators/http.decorators.js +44 -0
- package/dist/commons/decorators/index.d.ts +5 -0
- package/dist/commons/decorators/index.js +21 -0
- package/dist/commons/decorators/inject.decorator.d.ts +1 -0
- package/dist/commons/decorators/inject.decorator.js +5 -0
- package/dist/commons/decorators/middleware.decorator.d.ts +2 -0
- package/dist/commons/decorators/middleware.decorator.js +30 -0
- package/dist/commons/decorators/service.decorator.d.ts +2 -0
- package/dist/commons/decorators/service.decorator.js +7 -0
- package/dist/commons/http-code.enum.d.ts +50 -0
- package/dist/commons/http-code.enum.js +54 -0
- package/dist/commons/index.d.ts +3 -0
- package/dist/commons/index.js +19 -0
- package/dist/commons/registries/ProviderControl.d.ts +77 -0
- package/dist/commons/registries/ProviderControl.js +112 -0
- package/dist/commons/registries/ProviderRegistry.d.ts +7 -0
- package/dist/commons/registries/ProviderRegistry.js +20 -0
- package/dist/constants.d.ts +7 -0
- package/dist/constants.js +10 -0
- package/dist/container/ContainerConfiguration.d.ts +45 -0
- package/dist/container/ContainerConfiguration.js +121 -0
- package/dist/container/DependencyResolver.d.ts +18 -0
- package/dist/container/DependencyResolver.js +81 -0
- package/dist/container/InjectorService.d.ts +34 -0
- package/dist/container/InjectorService.js +157 -0
- package/dist/container/MethodInvoker.d.ts +17 -0
- package/dist/container/MethodInvoker.js +69 -0
- package/dist/container/RouteResolver.d.ts +27 -0
- package/dist/container/RouteResolver.js +173 -0
- package/dist/container/container.d.ts +41 -0
- package/dist/container/container.js +71 -0
- package/dist/container/createContainer.d.ts +3 -0
- package/dist/container/createContainer.js +12 -0
- package/dist/container/createInjector.d.ts +2 -0
- package/dist/container/createInjector.js +7 -0
- package/dist/container/index.d.ts +6 -0
- package/dist/container/index.js +22 -0
- package/dist/container/middleware.resolver.d.ts +9 -0
- package/dist/container/middleware.resolver.js +35 -0
- package/dist/default-routes-carno.d.ts +3 -0
- package/dist/default-routes-carno.js +29 -0
- package/dist/default-routes-cheetah.d.ts +3 -0
- package/dist/default-routes-cheetah.js +29 -0
- package/dist/domain/CarnoClosure.d.ts +1 -0
- package/dist/domain/CarnoClosure.js +2 -0
- package/dist/domain/CarnoMiddleware.d.ts +5 -0
- package/dist/domain/CarnoMiddleware.js +2 -0
- package/dist/domain/CheetahClosure.d.ts +1 -0
- package/dist/domain/CheetahClosure.js +2 -0
- package/dist/domain/CheetahMiddleware.d.ts +5 -0
- package/dist/domain/CheetahMiddleware.js +2 -0
- package/dist/domain/Context.d.ts +26 -0
- package/dist/domain/Context.js +107 -0
- package/dist/domain/LocalsContainer.d.ts +4 -0
- package/dist/domain/LocalsContainer.js +10 -0
- package/dist/domain/Metadata.d.ts +449 -0
- package/dist/domain/Metadata.js +511 -0
- package/dist/domain/cors-config.d.ts +12 -0
- package/dist/domain/cors-config.js +18 -0
- package/dist/domain/http-method.d.ts +7 -0
- package/dist/domain/http-method.js +11 -0
- package/dist/domain/index.d.ts +10 -0
- package/dist/domain/index.js +26 -0
- package/dist/domain/provider-scope.d.ts +5 -0
- package/dist/domain/provider-scope.js +9 -0
- package/dist/domain/provider-type.d.ts +6 -0
- package/dist/domain/provider-type.js +10 -0
- package/dist/domain/provider.d.ts +37 -0
- package/dist/domain/provider.js +70 -0
- package/dist/events/hooks.decorator.d.ts +3 -0
- package/dist/events/hooks.decorator.js +29 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.js +18 -0
- package/dist/events/on-event.d.ts +13 -0
- package/dist/events/on-event.js +11 -0
- package/dist/exceptions/HttpException.d.ts +9 -0
- package/dist/exceptions/HttpException.js +26 -0
- package/dist/exceptions/index.d.ts +1 -0
- package/dist/exceptions/index.js +17 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +32 -0
- package/dist/route/Matcher.d.ts +16 -0
- package/dist/route/Matcher.js +48 -0
- package/dist/route/RouteExecutor.d.ts +13 -0
- package/dist/route/RouteExecutor.js +70 -0
- package/dist/route/memoirist.d.ts +25 -0
- package/dist/route/memoirist.js +250 -0
- package/dist/services/logger.service.d.ts +23 -0
- package/dist/services/logger.service.js +54 -0
- package/dist/services/request-logger.service.d.ts +15 -0
- package/dist/services/request-logger.service.js +50 -0
- package/dist/testing/core-testing.d.ts +24 -0
- package/dist/testing/core-testing.js +98 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +17 -0
- package/dist/utils/ancestorOf.d.ts +2 -0
- package/dist/utils/ancestorOf.js +10 -0
- package/dist/utils/ancestorsOf.d.ts +6 -0
- package/dist/utils/ancestorsOf.js +20 -0
- package/dist/utils/classOf.d.ts +13 -0
- package/dist/utils/classOf.js +21 -0
- package/dist/utils/cleanObject.d.ts +6 -0
- package/dist/utils/cleanObject.js +22 -0
- package/dist/utils/constructorOf.d.ts +11 -0
- package/dist/utils/constructorOf.js +18 -0
- package/dist/utils/createInstance.d.ts +1 -0
- package/dist/utils/createInstance.js +7 -0
- package/dist/utils/decoratorTypeOf.d.ts +11 -0
- package/dist/utils/decoratorTypeOf.js +32 -0
- package/dist/utils/deepClone.d.ts +6 -0
- package/dist/utils/deepClone.js +63 -0
- package/dist/utils/deepMerge.d.ts +9 -0
- package/dist/utils/deepMerge.js +62 -0
- package/dist/utils/descriptorOf.d.ts +8 -0
- package/dist/utils/descriptorOf.js +16 -0
- package/dist/utils/getClassOrSymbol.d.ts +1 -0
- package/dist/utils/getClassOrSymbol.js +8 -0
- package/dist/utils/getConstructorArgNames.d.ts +1 -0
- package/dist/utils/getConstructorArgNames.js +12 -0
- package/dist/utils/getMethodArgTypes.d.ts +1 -0
- package/dist/utils/getMethodArgTypes.js +9 -0
- package/dist/utils/getValue.d.ts +32 -0
- package/dist/utils/getValue.js +47 -0
- package/dist/utils/hasJsonMethod.d.ts +1 -0
- package/dist/utils/hasJsonMethod.js +6 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/index.js +31 -0
- package/dist/utils/isArray.d.ts +13 -0
- package/dist/utils/isArray.js +21 -0
- package/dist/utils/isArrowFn.d.ts +1 -0
- package/dist/utils/isArrowFn.js +7 -0
- package/dist/utils/isBoolean.d.ts +7 -0
- package/dist/utils/isBoolean.js +15 -0
- package/dist/utils/isBuffer.d.ts +7 -0
- package/dist/utils/isBuffer.js +19 -0
- package/dist/utils/isClass.d.ts +1 -0
- package/dist/utils/isClass.js +26 -0
- package/dist/utils/isClassValidator.d.ts +6 -0
- package/dist/utils/isClassValidator.js +13 -0
- package/dist/utils/isCollection.d.ts +6 -0
- package/dist/utils/isCollection.js +20 -0
- package/dist/utils/isDate.d.ts +6 -0
- package/dist/utils/isDate.js +11 -0
- package/dist/utils/isEmpty.d.ts +6 -0
- package/dist/utils/isEmpty.js +12 -0
- package/dist/utils/isFunction.d.ts +1 -0
- package/dist/utils/isFunction.js +6 -0
- package/dist/utils/isInheritedFrom.d.ts +1 -0
- package/dist/utils/isInheritedFrom.js +24 -0
- package/dist/utils/isMomentObject.d.ts +1 -0
- package/dist/utils/isMomentObject.js +6 -0
- package/dist/utils/isMongooseObject.d.ts +2 -0
- package/dist/utils/isMongooseObject.js +11 -0
- package/dist/utils/isNil.d.ts +1 -0
- package/dist/utils/isNil.js +6 -0
- package/dist/utils/isNumber.d.ts +7 -0
- package/dist/utils/isNumber.js +15 -0
- package/dist/utils/isObject.d.ts +1 -0
- package/dist/utils/isObject.js +6 -0
- package/dist/utils/isObservable.d.ts +1 -0
- package/dist/utils/isObservable.js +6 -0
- package/dist/utils/isPlainObject.d.ts +7 -0
- package/dist/utils/isPlainObject.js +16 -0
- package/dist/utils/isPrimitive.d.ts +14 -0
- package/dist/utils/isPrimitive.js +28 -0
- package/dist/utils/isPrimitiveType.d.ts +1 -0
- package/dist/utils/isPrimitiveType.js +11 -0
- package/dist/utils/isPromise.d.ts +7 -0
- package/dist/utils/isPromise.js +14 -0
- package/dist/utils/isProtectedKey.d.ts +5 -0
- package/dist/utils/isProtectedKey.js +10 -0
- package/dist/utils/isRegExp.d.ts +1 -0
- package/dist/utils/isRegExp.js +6 -0
- package/dist/utils/isRequestScope.d.ts +11 -0
- package/dist/utils/isRequestScope.js +23 -0
- package/dist/utils/isSerializable.d.ts +1 -0
- package/dist/utils/isSerializable.js +11 -0
- package/dist/utils/isStream.d.ts +1 -0
- package/dist/utils/isStream.js +6 -0
- package/dist/utils/isString.d.ts +6 -0
- package/dist/utils/isString.js +14 -0
- package/dist/utils/isSymbol.d.ts +6 -0
- package/dist/utils/isSymbol.js +14 -0
- package/dist/utils/methodsOf.d.ts +9 -0
- package/dist/utils/methodsOf.js +24 -0
- package/dist/utils/nameOf.d.ts +14 -0
- package/dist/utils/nameOf.js +31 -0
- package/dist/utils/objectKeys.d.ts +1 -0
- package/dist/utils/objectKeys.js +7 -0
- package/dist/utils/primitiveOf.d.ts +1 -0
- package/dist/utils/primitiveOf.js +18 -0
- package/dist/utils/prototypeOf.d.ts +6 -0
- package/dist/utils/prototypeOf.js +12 -0
- package/dist/utils/setValue.d.ts +1 -0
- package/dist/utils/setValue.js +32 -0
- package/dist/utils/toMap.d.ts +3 -0
- package/dist/utils/toMap.js +34 -0
- package/dist/utils/toStringConstructor.d.ts +1 -0
- package/dist/utils/toStringConstructor.js +10 -0
- package/package.json +55 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isInheritedFrom = isInheritedFrom;
|
|
4
|
+
const classOf_1 = require("./classOf");
|
|
5
|
+
const ancestorOf_1 = require("./ancestorOf");
|
|
6
|
+
const nameOf_1 = require("./nameOf");
|
|
7
|
+
function isInheritedFrom(target, from, deep = 5) {
|
|
8
|
+
if (!target || !from) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
target = (0, classOf_1.classOf)(target);
|
|
12
|
+
from = (0, classOf_1.classOf)(from);
|
|
13
|
+
while ((0, nameOf_1.nameOf)(target) !== "") {
|
|
14
|
+
if (!deep) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (target === from) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
target = (0, ancestorOf_1.ancestorOf)(target);
|
|
21
|
+
deep--;
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isMomentObject(obj: any): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isObjectID = isObjectID;
|
|
4
|
+
exports.isMongooseObject = isMongooseObject;
|
|
5
|
+
const hasJsonMethod_1 = require("./hasJsonMethod");
|
|
6
|
+
function isObjectID(obj) {
|
|
7
|
+
return obj && obj._bsontype;
|
|
8
|
+
}
|
|
9
|
+
function isMongooseObject(obj) {
|
|
10
|
+
return !!(((0, hasJsonMethod_1.hasJsonMethod)(obj) && obj.$isMongooseModelPrototype) || isObjectID(obj));
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isNil(value: any): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNumber = isNumber;
|
|
4
|
+
exports.isNumberOrNumberClass = isNumberOrNumberClass;
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param target
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
function isNumber(target) {
|
|
11
|
+
return typeof target === "number";
|
|
12
|
+
}
|
|
13
|
+
function isNumberOrNumberClass(target) {
|
|
14
|
+
return typeof target === "number" || target instanceof Number || target === Number;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isObject(target: any): target is object;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isObservable<T>(obj: any): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isClassObject = isClassObject;
|
|
4
|
+
exports.isPlainObject = isPlainObject;
|
|
5
|
+
const classOf_1 = require("./classOf");
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param target
|
|
9
|
+
* @returns {boolean}
|
|
10
|
+
*/
|
|
11
|
+
function isClassObject(target) {
|
|
12
|
+
return target === Object;
|
|
13
|
+
}
|
|
14
|
+
function isPlainObject(target) {
|
|
15
|
+
return isClassObject((0, classOf_1.classOf)(target)) && target !== Object;
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return true if the given obj is a primitive.
|
|
3
|
+
* @param target
|
|
4
|
+
* @returns {boolean}
|
|
5
|
+
* @ignore
|
|
6
|
+
*/
|
|
7
|
+
export declare function isPrimitiveOrPrimitiveClass(target: any): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Return true if the given obj is a primitive.
|
|
10
|
+
* @param target
|
|
11
|
+
* @returns {boolean}
|
|
12
|
+
*/
|
|
13
|
+
export declare function isPrimitive(target: any): boolean;
|
|
14
|
+
export declare function isPrimitiveClass(target: any): boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPrimitiveOrPrimitiveClass = isPrimitiveOrPrimitiveClass;
|
|
4
|
+
exports.isPrimitive = isPrimitive;
|
|
5
|
+
exports.isPrimitiveClass = isPrimitiveClass;
|
|
6
|
+
const isBoolean_1 = require("./isBoolean");
|
|
7
|
+
const isNumber_1 = require("./isNumber");
|
|
8
|
+
const isString_1 = require("./isString");
|
|
9
|
+
/**
|
|
10
|
+
* Return true if the given obj is a primitive.
|
|
11
|
+
* @param target
|
|
12
|
+
* @returns {boolean}
|
|
13
|
+
* @ignore
|
|
14
|
+
*/
|
|
15
|
+
function isPrimitiveOrPrimitiveClass(target) {
|
|
16
|
+
return (0, isString_1.isStringOrStringClass)(target) || (0, isNumber_1.isNumberOrNumberClass)(target) || (0, isBoolean_1.isBooleanOrBooleanClass)(target);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Return true if the given obj is a primitive.
|
|
20
|
+
* @param target
|
|
21
|
+
* @returns {boolean}
|
|
22
|
+
*/
|
|
23
|
+
function isPrimitive(target) {
|
|
24
|
+
return (0, isString_1.isString)(target) || (0, isNumber_1.isNumber)(target) || (0, isBoolean_1.isBoolean)(target);
|
|
25
|
+
}
|
|
26
|
+
function isPrimitiveClass(target) {
|
|
27
|
+
return [String, Number, Boolean].includes(target);
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isPrimitiveType(type: any): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPrimitiveType = isPrimitiveType;
|
|
4
|
+
function isPrimitiveType(type) {
|
|
5
|
+
return (type === String ||
|
|
6
|
+
type === Number ||
|
|
7
|
+
type === Boolean ||
|
|
8
|
+
type === Symbol ||
|
|
9
|
+
type === undefined ||
|
|
10
|
+
type === null);
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests to see if the object is an ES2015 (ES6) Promise
|
|
3
|
+
* @see {@link https://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects}
|
|
4
|
+
* @param target
|
|
5
|
+
* @returns {boolean}
|
|
6
|
+
*/
|
|
7
|
+
export declare function isPromise<T = any>(target: any): target is Promise<T>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPromise = isPromise;
|
|
4
|
+
/**
|
|
5
|
+
* Tests to see if the object is an ES2015 (ES6) Promise
|
|
6
|
+
* @see {@link https://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects}
|
|
7
|
+
* @param target
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
function isPromise(target) {
|
|
11
|
+
return (target === Promise ||
|
|
12
|
+
target instanceof Promise ||
|
|
13
|
+
(!!target && typeof target.subscribe !== "function" && typeof target.then === "function"));
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isProtectedKey = isProtectedKey;
|
|
4
|
+
/**
|
|
5
|
+
* Prevent prototype pollution vulnerability
|
|
6
|
+
* @param key
|
|
7
|
+
*/
|
|
8
|
+
function isProtectedKey(key) {
|
|
9
|
+
return ["__proto__", "constructor", "prototype"].includes(key);
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isRegExp(target: any): target is RegExp;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TokenProvider } from "../commons";
|
|
2
|
+
import { InjectorService } from "../container";
|
|
3
|
+
import { Provider } from "../domain";
|
|
4
|
+
/**
|
|
5
|
+
* Check if the provider is a request scope or have some dependency that is a request scope
|
|
6
|
+
|
|
7
|
+
* @param provider
|
|
8
|
+
* @param deps
|
|
9
|
+
* @param injector
|
|
10
|
+
*/
|
|
11
|
+
export declare function isRequestScope(provider: Provider, deps: TokenProvider[], injector: InjectorService): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isRequestScope = isRequestScope;
|
|
4
|
+
const domain_1 = require("../domain");
|
|
5
|
+
/**
|
|
6
|
+
* Check if the provider is a request scope or have some dependency that is a request scope
|
|
7
|
+
|
|
8
|
+
* @param provider
|
|
9
|
+
* @param deps
|
|
10
|
+
* @param injector
|
|
11
|
+
*/
|
|
12
|
+
function isRequestScope(provider, deps, injector) {
|
|
13
|
+
if (provider.scope === 'request')
|
|
14
|
+
return true;
|
|
15
|
+
if (deps.length === 0)
|
|
16
|
+
return false;
|
|
17
|
+
return deps.some(dep => {
|
|
18
|
+
const depProvider = injector.get(dep);
|
|
19
|
+
if (!depProvider)
|
|
20
|
+
return false;
|
|
21
|
+
return depProvider.scope === domain_1.ProviderScope.REQUEST;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isSerializable(data: any): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSerializable = isSerializable;
|
|
4
|
+
const isStream_1 = require("./isStream");
|
|
5
|
+
const isBoolean_1 = require("./isBoolean");
|
|
6
|
+
const isNumber_1 = require("./isNumber");
|
|
7
|
+
const isString_1 = require("./isString");
|
|
8
|
+
const isNil_1 = require("./isNil");
|
|
9
|
+
function isSerializable(data) {
|
|
10
|
+
return !(Buffer.isBuffer(data) || (0, isStream_1.isStream)(data) || (0, isBoolean_1.isBoolean)(data) || (0, isNumber_1.isNumber)(data) || (0, isString_1.isString)(data) || (0, isNil_1.isNil)(data));
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isStream(obj: any): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isString = isString;
|
|
4
|
+
exports.isStringOrStringClass = isStringOrStringClass;
|
|
5
|
+
/**
|
|
6
|
+
* @param target
|
|
7
|
+
* @returns {boolean}
|
|
8
|
+
*/
|
|
9
|
+
function isString(target) {
|
|
10
|
+
return typeof target === "string";
|
|
11
|
+
}
|
|
12
|
+
function isStringOrStringClass(target) {
|
|
13
|
+
return typeof target === "string" || target instanceof String || target === String;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSymbol = isSymbol;
|
|
4
|
+
exports.isSymbolOrSymbolClass = isSymbolOrSymbolClass;
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param target
|
|
8
|
+
*/
|
|
9
|
+
function isSymbol(target) {
|
|
10
|
+
return typeof target === "symbol";
|
|
11
|
+
}
|
|
12
|
+
function isSymbolOrSymbolClass(target) {
|
|
13
|
+
return typeof target === "symbol" || target instanceof Symbol || target === Symbol;
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.methodsOf = methodsOf;
|
|
4
|
+
const classOf_1 = require("./classOf");
|
|
5
|
+
const ancestorsOf_1 = require("./ancestorsOf");
|
|
6
|
+
const prototypeOf_1 = require("./prototypeOf");
|
|
7
|
+
/**
|
|
8
|
+
* Return all methods for a given class.
|
|
9
|
+
* @param target
|
|
10
|
+
*/
|
|
11
|
+
function methodsOf(target) {
|
|
12
|
+
const methods = new Map();
|
|
13
|
+
target = (0, classOf_1.classOf)(target);
|
|
14
|
+
(0, ancestorsOf_1.ancestorsOf)(target).forEach((target) => {
|
|
15
|
+
const keys = Reflect.ownKeys((0, prototypeOf_1.prototypeOf)(target));
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
keys.forEach((propertyKey) => {
|
|
18
|
+
if (propertyKey !== "constructor") {
|
|
19
|
+
methods.set(propertyKey, { target, propertyKey });
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
return Array.from(methods.values());
|
|
24
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the provide name.
|
|
3
|
+
* @param targetClass
|
|
4
|
+
*/
|
|
5
|
+
export declare function nameOfClass(targetClass: any): string;
|
|
6
|
+
/**
|
|
7
|
+
* Get symbol name.
|
|
8
|
+
* @param sym
|
|
9
|
+
*/
|
|
10
|
+
export declare const nameOfSymbol: (sym: symbol) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Get object name
|
|
13
|
+
*/
|
|
14
|
+
export declare function nameOf(obj: any): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nameOfSymbol = void 0;
|
|
4
|
+
exports.nameOfClass = nameOfClass;
|
|
5
|
+
exports.nameOf = nameOf;
|
|
6
|
+
/**
|
|
7
|
+
* Get the provide name.
|
|
8
|
+
* @param targetClass
|
|
9
|
+
*/
|
|
10
|
+
function nameOfClass(targetClass) {
|
|
11
|
+
return typeof targetClass === "function" ? targetClass.name : targetClass.constructor.name;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get symbol name.
|
|
15
|
+
* @param sym
|
|
16
|
+
*/
|
|
17
|
+
const nameOfSymbol = (sym) => sym.toString().replace("Symbol(", "").replace(")", "");
|
|
18
|
+
exports.nameOfSymbol = nameOfSymbol;
|
|
19
|
+
/**
|
|
20
|
+
* Get object name
|
|
21
|
+
*/
|
|
22
|
+
function nameOf(obj) {
|
|
23
|
+
switch (typeof obj) {
|
|
24
|
+
default:
|
|
25
|
+
return "" + obj;
|
|
26
|
+
case "symbol":
|
|
27
|
+
return (0, exports.nameOfSymbol)(obj);
|
|
28
|
+
case "function":
|
|
29
|
+
return nameOfClass(obj);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function objectKeys(obj: any): string[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objectKeys = objectKeys;
|
|
4
|
+
const isProtectedKey_1 = require("./isProtectedKey");
|
|
5
|
+
function objectKeys(obj) {
|
|
6
|
+
return Object.keys(obj).filter((key) => !(0, isProtectedKey_1.isProtectedKey)(key));
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function primitiveOf(target: any): "string" | "number" | "boolean" | "any";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.primitiveOf = primitiveOf;
|
|
4
|
+
const isBoolean_1 = require("./isBoolean");
|
|
5
|
+
const isNumber_1 = require("./isNumber");
|
|
6
|
+
const isString_1 = require("./isString");
|
|
7
|
+
function primitiveOf(target) {
|
|
8
|
+
if ((0, isString_1.isStringOrStringClass)(target)) {
|
|
9
|
+
return "string";
|
|
10
|
+
}
|
|
11
|
+
if ((0, isNumber_1.isNumberOrNumberClass)(target)) {
|
|
12
|
+
return "number";
|
|
13
|
+
}
|
|
14
|
+
if ((0, isBoolean_1.isBooleanOrBooleanClass)(target)) {
|
|
15
|
+
return "boolean";
|
|
16
|
+
}
|
|
17
|
+
return "any";
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prototypeOf = prototypeOf;
|
|
4
|
+
const classOf_1 = require("./classOf");
|
|
5
|
+
/**
|
|
6
|
+
* Return the prototype of the given class.
|
|
7
|
+
* @param target
|
|
8
|
+
* @returns {any}
|
|
9
|
+
*/
|
|
10
|
+
function prototypeOf(target) {
|
|
11
|
+
return (0, classOf_1.classOf)(target) === target ? target.prototype : target;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setValue(scope: any, expression: string, value: any, separator?: string): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setValue = setValue;
|
|
4
|
+
const isProtectedKey_1 = require("./isProtectedKey");
|
|
5
|
+
function setValue(scope, expression, value, separator = ".") {
|
|
6
|
+
const keys = expression.split(separator);
|
|
7
|
+
const setValue = (key, add) => {
|
|
8
|
+
if ((0, isProtectedKey_1.isProtectedKey)(key)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (add) {
|
|
12
|
+
if (typeof scope.set === "function") {
|
|
13
|
+
scope.set(key, value);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
scope[key] = value;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (typeof scope.set === "function") {
|
|
21
|
+
if (!scope.has(key)) {
|
|
22
|
+
scope.set(key, {});
|
|
23
|
+
}
|
|
24
|
+
scope = scope.get(key);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
scope = scope[key] = scope[key] || {};
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
};
|
|
31
|
+
while (setValue(keys.shift(), !keys.length)) { }
|
|
32
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type ToMapIdentityCB<V> = (item: V, index: string | number) => string | string[];
|
|
2
|
+
export type ToMapIdentity<V> = string | ToMapIdentityCB<V>;
|
|
3
|
+
export declare function toMap<K extends keyof any = any, V = any>(input: Record<K, V> | V[], keyOrFn?: ToMapIdentity<V>): Map<K, V>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toMap = toMap;
|
|
4
|
+
const isArray_1 = require("./isArray");
|
|
5
|
+
const isString_1 = require("./isString");
|
|
6
|
+
function createIdentityFn(keyOrFn) {
|
|
7
|
+
if (!keyOrFn) {
|
|
8
|
+
return (v, k) => String(k);
|
|
9
|
+
}
|
|
10
|
+
if ((0, isString_1.isString)(keyOrFn)) {
|
|
11
|
+
return (item) => {
|
|
12
|
+
return item[keyOrFn];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
return keyOrFn;
|
|
16
|
+
}
|
|
17
|
+
function toMap(input, keyOrFn) {
|
|
18
|
+
if ((0, isArray_1.isArray)(input)) {
|
|
19
|
+
const identity = createIdentityFn(keyOrFn || "id");
|
|
20
|
+
return input.reduce((map, value, index) => {
|
|
21
|
+
const ids = [].concat(identity(value, index));
|
|
22
|
+
ids.forEach((id) => {
|
|
23
|
+
const item = map.get(id);
|
|
24
|
+
value = item?.merge?.(value) || value;
|
|
25
|
+
map.set(id, value);
|
|
26
|
+
});
|
|
27
|
+
return map;
|
|
28
|
+
}, new Map());
|
|
29
|
+
}
|
|
30
|
+
const identity = createIdentityFn(keyOrFn);
|
|
31
|
+
return Object.entries(input).reduce((map, [key, value]) => {
|
|
32
|
+
return map.set(identity(value, key), value);
|
|
33
|
+
}, new Map());
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toStringConstructor(target: any): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toStringConstructor = toStringConstructor;
|
|
4
|
+
const constructorOf_1 = require("./constructorOf");
|
|
5
|
+
function toStringConstructor(target) {
|
|
6
|
+
const ctr = (0, constructorOf_1.constructorOf)(target);
|
|
7
|
+
const strings = ctr.toString().split("\n");
|
|
8
|
+
const ctrString = strings.find((s) => s.indexOf("constructor(") > -1) || "constructor()";
|
|
9
|
+
return `${ctrString.replace("{", "").trim()}`;
|
|
10
|
+
}
|