@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.
Files changed (214) hide show
  1. package/LICENSE +674 -0
  2. package/dist/Carno.d.ts +65 -0
  3. package/dist/Carno.js +307 -0
  4. package/dist/Cheetah.d.ts +65 -0
  5. package/dist/Cheetah.js +307 -0
  6. package/dist/cache/bento-cache.driver.d.ts +13 -0
  7. package/dist/cache/bento-cache.driver.js +55 -0
  8. package/dist/cache/cache.service.d.ts +8 -0
  9. package/dist/cache/cache.service.js +6 -0
  10. package/dist/commons/decorators/Injectable.decorator.d.ts +20 -0
  11. package/dist/commons/decorators/Injectable.decorator.js +33 -0
  12. package/dist/commons/decorators/controller.decorator.d.ts +8 -0
  13. package/dist/commons/decorators/controller.decorator.js +22 -0
  14. package/dist/commons/decorators/http.decorators.d.ts +13 -0
  15. package/dist/commons/decorators/http.decorators.js +44 -0
  16. package/dist/commons/decorators/index.d.ts +5 -0
  17. package/dist/commons/decorators/index.js +21 -0
  18. package/dist/commons/decorators/inject.decorator.d.ts +1 -0
  19. package/dist/commons/decorators/inject.decorator.js +5 -0
  20. package/dist/commons/decorators/middleware.decorator.d.ts +2 -0
  21. package/dist/commons/decorators/middleware.decorator.js +30 -0
  22. package/dist/commons/decorators/service.decorator.d.ts +2 -0
  23. package/dist/commons/decorators/service.decorator.js +7 -0
  24. package/dist/commons/http-code.enum.d.ts +50 -0
  25. package/dist/commons/http-code.enum.js +54 -0
  26. package/dist/commons/index.d.ts +3 -0
  27. package/dist/commons/index.js +19 -0
  28. package/dist/commons/registries/ProviderControl.d.ts +77 -0
  29. package/dist/commons/registries/ProviderControl.js +112 -0
  30. package/dist/commons/registries/ProviderRegistry.d.ts +7 -0
  31. package/dist/commons/registries/ProviderRegistry.js +20 -0
  32. package/dist/constants.d.ts +7 -0
  33. package/dist/constants.js +10 -0
  34. package/dist/container/ContainerConfiguration.d.ts +45 -0
  35. package/dist/container/ContainerConfiguration.js +121 -0
  36. package/dist/container/DependencyResolver.d.ts +18 -0
  37. package/dist/container/DependencyResolver.js +81 -0
  38. package/dist/container/InjectorService.d.ts +34 -0
  39. package/dist/container/InjectorService.js +157 -0
  40. package/dist/container/MethodInvoker.d.ts +17 -0
  41. package/dist/container/MethodInvoker.js +69 -0
  42. package/dist/container/RouteResolver.d.ts +27 -0
  43. package/dist/container/RouteResolver.js +173 -0
  44. package/dist/container/container.d.ts +41 -0
  45. package/dist/container/container.js +71 -0
  46. package/dist/container/createContainer.d.ts +3 -0
  47. package/dist/container/createContainer.js +12 -0
  48. package/dist/container/createInjector.d.ts +2 -0
  49. package/dist/container/createInjector.js +7 -0
  50. package/dist/container/index.d.ts +6 -0
  51. package/dist/container/index.js +22 -0
  52. package/dist/container/middleware.resolver.d.ts +9 -0
  53. package/dist/container/middleware.resolver.js +35 -0
  54. package/dist/default-routes-carno.d.ts +3 -0
  55. package/dist/default-routes-carno.js +29 -0
  56. package/dist/default-routes-cheetah.d.ts +3 -0
  57. package/dist/default-routes-cheetah.js +29 -0
  58. package/dist/domain/CarnoClosure.d.ts +1 -0
  59. package/dist/domain/CarnoClosure.js +2 -0
  60. package/dist/domain/CarnoMiddleware.d.ts +5 -0
  61. package/dist/domain/CarnoMiddleware.js +2 -0
  62. package/dist/domain/CheetahClosure.d.ts +1 -0
  63. package/dist/domain/CheetahClosure.js +2 -0
  64. package/dist/domain/CheetahMiddleware.d.ts +5 -0
  65. package/dist/domain/CheetahMiddleware.js +2 -0
  66. package/dist/domain/Context.d.ts +26 -0
  67. package/dist/domain/Context.js +107 -0
  68. package/dist/domain/LocalsContainer.d.ts +4 -0
  69. package/dist/domain/LocalsContainer.js +10 -0
  70. package/dist/domain/Metadata.d.ts +449 -0
  71. package/dist/domain/Metadata.js +511 -0
  72. package/dist/domain/cors-config.d.ts +12 -0
  73. package/dist/domain/cors-config.js +18 -0
  74. package/dist/domain/http-method.d.ts +7 -0
  75. package/dist/domain/http-method.js +11 -0
  76. package/dist/domain/index.d.ts +10 -0
  77. package/dist/domain/index.js +26 -0
  78. package/dist/domain/provider-scope.d.ts +5 -0
  79. package/dist/domain/provider-scope.js +9 -0
  80. package/dist/domain/provider-type.d.ts +6 -0
  81. package/dist/domain/provider-type.js +10 -0
  82. package/dist/domain/provider.d.ts +37 -0
  83. package/dist/domain/provider.js +70 -0
  84. package/dist/events/hooks.decorator.d.ts +3 -0
  85. package/dist/events/hooks.decorator.js +29 -0
  86. package/dist/events/index.d.ts +2 -0
  87. package/dist/events/index.js +18 -0
  88. package/dist/events/on-event.d.ts +13 -0
  89. package/dist/events/on-event.js +11 -0
  90. package/dist/exceptions/HttpException.d.ts +9 -0
  91. package/dist/exceptions/HttpException.js +26 -0
  92. package/dist/exceptions/index.d.ts +1 -0
  93. package/dist/exceptions/index.js +17 -0
  94. package/dist/index.d.ts +16 -0
  95. package/dist/index.js +32 -0
  96. package/dist/route/Matcher.d.ts +16 -0
  97. package/dist/route/Matcher.js +48 -0
  98. package/dist/route/RouteExecutor.d.ts +13 -0
  99. package/dist/route/RouteExecutor.js +70 -0
  100. package/dist/route/memoirist.d.ts +25 -0
  101. package/dist/route/memoirist.js +250 -0
  102. package/dist/services/logger.service.d.ts +23 -0
  103. package/dist/services/logger.service.js +54 -0
  104. package/dist/services/request-logger.service.d.ts +15 -0
  105. package/dist/services/request-logger.service.js +50 -0
  106. package/dist/testing/core-testing.d.ts +24 -0
  107. package/dist/testing/core-testing.js +98 -0
  108. package/dist/testing/index.d.ts +1 -0
  109. package/dist/testing/index.js +17 -0
  110. package/dist/utils/ancestorOf.d.ts +2 -0
  111. package/dist/utils/ancestorOf.js +10 -0
  112. package/dist/utils/ancestorsOf.d.ts +6 -0
  113. package/dist/utils/ancestorsOf.js +20 -0
  114. package/dist/utils/classOf.d.ts +13 -0
  115. package/dist/utils/classOf.js +21 -0
  116. package/dist/utils/cleanObject.d.ts +6 -0
  117. package/dist/utils/cleanObject.js +22 -0
  118. package/dist/utils/constructorOf.d.ts +11 -0
  119. package/dist/utils/constructorOf.js +18 -0
  120. package/dist/utils/createInstance.d.ts +1 -0
  121. package/dist/utils/createInstance.js +7 -0
  122. package/dist/utils/decoratorTypeOf.d.ts +11 -0
  123. package/dist/utils/decoratorTypeOf.js +32 -0
  124. package/dist/utils/deepClone.d.ts +6 -0
  125. package/dist/utils/deepClone.js +63 -0
  126. package/dist/utils/deepMerge.d.ts +9 -0
  127. package/dist/utils/deepMerge.js +62 -0
  128. package/dist/utils/descriptorOf.d.ts +8 -0
  129. package/dist/utils/descriptorOf.js +16 -0
  130. package/dist/utils/getClassOrSymbol.d.ts +1 -0
  131. package/dist/utils/getClassOrSymbol.js +8 -0
  132. package/dist/utils/getConstructorArgNames.d.ts +1 -0
  133. package/dist/utils/getConstructorArgNames.js +12 -0
  134. package/dist/utils/getMethodArgTypes.d.ts +1 -0
  135. package/dist/utils/getMethodArgTypes.js +9 -0
  136. package/dist/utils/getValue.d.ts +32 -0
  137. package/dist/utils/getValue.js +47 -0
  138. package/dist/utils/hasJsonMethod.d.ts +1 -0
  139. package/dist/utils/hasJsonMethod.js +6 -0
  140. package/dist/utils/index.d.ts +15 -0
  141. package/dist/utils/index.js +31 -0
  142. package/dist/utils/isArray.d.ts +13 -0
  143. package/dist/utils/isArray.js +21 -0
  144. package/dist/utils/isArrowFn.d.ts +1 -0
  145. package/dist/utils/isArrowFn.js +7 -0
  146. package/dist/utils/isBoolean.d.ts +7 -0
  147. package/dist/utils/isBoolean.js +15 -0
  148. package/dist/utils/isBuffer.d.ts +7 -0
  149. package/dist/utils/isBuffer.js +19 -0
  150. package/dist/utils/isClass.d.ts +1 -0
  151. package/dist/utils/isClass.js +26 -0
  152. package/dist/utils/isClassValidator.d.ts +6 -0
  153. package/dist/utils/isClassValidator.js +13 -0
  154. package/dist/utils/isCollection.d.ts +6 -0
  155. package/dist/utils/isCollection.js +20 -0
  156. package/dist/utils/isDate.d.ts +6 -0
  157. package/dist/utils/isDate.js +11 -0
  158. package/dist/utils/isEmpty.d.ts +6 -0
  159. package/dist/utils/isEmpty.js +12 -0
  160. package/dist/utils/isFunction.d.ts +1 -0
  161. package/dist/utils/isFunction.js +6 -0
  162. package/dist/utils/isInheritedFrom.d.ts +1 -0
  163. package/dist/utils/isInheritedFrom.js +24 -0
  164. package/dist/utils/isMomentObject.d.ts +1 -0
  165. package/dist/utils/isMomentObject.js +6 -0
  166. package/dist/utils/isMongooseObject.d.ts +2 -0
  167. package/dist/utils/isMongooseObject.js +11 -0
  168. package/dist/utils/isNil.d.ts +1 -0
  169. package/dist/utils/isNil.js +6 -0
  170. package/dist/utils/isNumber.d.ts +7 -0
  171. package/dist/utils/isNumber.js +15 -0
  172. package/dist/utils/isObject.d.ts +1 -0
  173. package/dist/utils/isObject.js +6 -0
  174. package/dist/utils/isObservable.d.ts +1 -0
  175. package/dist/utils/isObservable.js +6 -0
  176. package/dist/utils/isPlainObject.d.ts +7 -0
  177. package/dist/utils/isPlainObject.js +16 -0
  178. package/dist/utils/isPrimitive.d.ts +14 -0
  179. package/dist/utils/isPrimitive.js +28 -0
  180. package/dist/utils/isPrimitiveType.d.ts +1 -0
  181. package/dist/utils/isPrimitiveType.js +11 -0
  182. package/dist/utils/isPromise.d.ts +7 -0
  183. package/dist/utils/isPromise.js +14 -0
  184. package/dist/utils/isProtectedKey.d.ts +5 -0
  185. package/dist/utils/isProtectedKey.js +10 -0
  186. package/dist/utils/isRegExp.d.ts +1 -0
  187. package/dist/utils/isRegExp.js +6 -0
  188. package/dist/utils/isRequestScope.d.ts +11 -0
  189. package/dist/utils/isRequestScope.js +23 -0
  190. package/dist/utils/isSerializable.d.ts +1 -0
  191. package/dist/utils/isSerializable.js +11 -0
  192. package/dist/utils/isStream.d.ts +1 -0
  193. package/dist/utils/isStream.js +6 -0
  194. package/dist/utils/isString.d.ts +6 -0
  195. package/dist/utils/isString.js +14 -0
  196. package/dist/utils/isSymbol.d.ts +6 -0
  197. package/dist/utils/isSymbol.js +14 -0
  198. package/dist/utils/methodsOf.d.ts +9 -0
  199. package/dist/utils/methodsOf.js +24 -0
  200. package/dist/utils/nameOf.d.ts +14 -0
  201. package/dist/utils/nameOf.js +31 -0
  202. package/dist/utils/objectKeys.d.ts +1 -0
  203. package/dist/utils/objectKeys.js +7 -0
  204. package/dist/utils/primitiveOf.d.ts +1 -0
  205. package/dist/utils/primitiveOf.js +18 -0
  206. package/dist/utils/prototypeOf.d.ts +6 -0
  207. package/dist/utils/prototypeOf.js +12 -0
  208. package/dist/utils/setValue.d.ts +1 -0
  209. package/dist/utils/setValue.js +32 -0
  210. package/dist/utils/toMap.d.ts +3 -0
  211. package/dist/utils/toMap.js +34 -0
  212. package/dist/utils/toStringConstructor.d.ts +1 -0
  213. package/dist/utils/toStringConstructor.js +10 -0
  214. 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,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMomentObject = isMomentObject;
4
+ function isMomentObject(obj) {
5
+ return !!(obj && obj?._isAMomentObject);
6
+ }
@@ -0,0 +1,2 @@
1
+ export declare function isObjectID(obj: any): any;
2
+ export declare function isMongooseObject(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,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNil = isNil;
4
+ function isNil(value) {
5
+ return value === undefined || value === null;
6
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ *
3
+ * @param target
4
+ * @returns {boolean}
5
+ */
6
+ export declare function isNumber(target: any): target is number;
7
+ export declare function isNumberOrNumberClass(target: any): target is number;
@@ -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,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isObject = isObject;
4
+ function isObject(target) {
5
+ return typeof target === "object";
6
+ }
@@ -0,0 +1 @@
1
+ export declare function isObservable<T>(obj: any): boolean;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isObservable = isObservable;
4
+ function isObservable(obj) {
5
+ return !!obj && typeof obj.lift === "function" && typeof obj.subscribe === "function";
6
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ *
3
+ * @param target
4
+ * @returns {boolean}
5
+ */
6
+ export declare function isClassObject(target: any): target is Object;
7
+ export declare function isPlainObject(target: 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,5 @@
1
+ /**
2
+ * Prevent prototype pollution vulnerability
3
+ * @param key
4
+ */
5
+ export declare function isProtectedKey(key: string): boolean;
@@ -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,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isRegExp = isRegExp;
4
+ function isRegExp(target) {
5
+ return target instanceof RegExp;
6
+ }
@@ -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,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isStream = isStream;
4
+ function isStream(obj) {
5
+ return obj !== null && typeof obj === "object" && typeof obj.pipe === "function";
6
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @param target
3
+ * @returns {boolean}
4
+ */
5
+ export declare function isString(target: any): target is string;
6
+ export declare function isStringOrStringClass(target: any): target is string;
@@ -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,6 @@
1
+ /**
2
+ *
3
+ * @param target
4
+ */
5
+ export declare function isSymbol(target: any): target is symbol;
6
+ export declare function isSymbolOrSymbolClass(target: any): target is symbol;
@@ -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,9 @@
1
+ import { Type } from "../commons";
2
+ /**
3
+ * Return all methods for a given class.
4
+ * @param target
5
+ */
6
+ export declare function methodsOf(target: any): {
7
+ target: Type;
8
+ propertyKey: string;
9
+ }[];
@@ -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,6 @@
1
+ /**
2
+ * Return the prototype of the given class.
3
+ * @param target
4
+ * @returns {any}
5
+ */
6
+ export declare function prototypeOf(target: any): any;
@@ -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
+ }