querier-ts 1.0.1 → 1.0.2
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/README.md +1 -1
- package/lib/core/errors/index.d.ts +1 -0
- package/lib/core/errors/index.d.ts.map +1 -0
- package/lib/core/errors/index.js +2 -17
- package/lib/core/errors/index.js.map +1 -0
- package/lib/core/errors/invalid-argument-error.d.ts +1 -0
- package/lib/core/errors/invalid-argument-error.d.ts.map +1 -0
- package/lib/core/errors/invalid-argument-error.js +2 -5
- package/lib/core/errors/invalid-argument-error.js.map +1 -0
- package/lib/core/types/attribute-validation-function.d.ts +1 -0
- package/lib/core/types/attribute-validation-function.d.ts.map +1 -0
- package/lib/core/types/attribute-validation-function.js +2 -2
- package/lib/core/types/attribute-validation-function.js.map +1 -0
- package/lib/core/types/column-condition.d.ts +3 -2
- package/lib/core/types/column-condition.d.ts.map +1 -0
- package/lib/core/types/column-condition.js +2 -2
- package/lib/core/types/column-condition.js.map +1 -0
- package/lib/core/types/index.d.ts +1 -0
- package/lib/core/types/index.d.ts.map +1 -0
- package/lib/core/types/index.js +5 -20
- package/lib/core/types/index.js.map +1 -0
- package/lib/core/types/query-conditions-group-nullable.d.ts +2 -1
- package/lib/core/types/query-conditions-group-nullable.d.ts.map +1 -0
- package/lib/core/types/query-conditions-group-nullable.js +2 -2
- package/lib/core/types/query-conditions-group-nullable.js.map +1 -0
- package/lib/core/types/query-conditions-group.d.ts +2 -1
- package/lib/core/types/query-conditions-group.d.ts.map +1 -0
- package/lib/core/types/query-conditions-group.js +2 -2
- package/lib/core/types/query-conditions-group.js.map +1 -0
- package/lib/core/types/query-row-validator-initializer.d.ts +2 -1
- package/lib/core/types/query-row-validator-initializer.d.ts.map +1 -0
- package/lib/core/types/query-row-validator-initializer.js +2 -2
- package/lib/core/types/query-row-validator-initializer.js.map +1 -0
- package/lib/core/validation/decorators/index.d.ts +1 -0
- package/lib/core/validation/decorators/index.d.ts.map +1 -0
- package/lib/core/validation/decorators/index.js +2 -17
- package/lib/core/validation/decorators/index.js.map +1 -0
- package/lib/core/validation/decorators/number-validaton.d.ts +5 -36
- package/lib/core/validation/decorators/number-validaton.d.ts.map +1 -0
- package/lib/core/validation/decorators/number-validaton.js +86 -113
- package/lib/core/validation/decorators/number-validaton.js.map +1 -0
- package/lib/core/validation/index.d.ts +1 -0
- package/lib/core/validation/index.d.ts.map +1 -0
- package/lib/core/validation/index.js +2 -17
- package/lib/core/validation/index.js.map +1 -0
- package/lib/core/validation/query-row-validator.d.ts +2 -1
- package/lib/core/validation/query-row-validator.d.ts.map +1 -0
- package/lib/core/validation/query-row-validator.js +9 -12
- package/lib/core/validation/query-row-validator.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +2 -17
- package/lib/index.js.map +1 -0
- package/lib/query.d.ts +3 -2
- package/lib/query.d.ts.map +1 -0
- package/lib/query.js +20 -28
- package/lib/query.js.map +1 -0
- package/lib/utils/functions/generic/compare-arrays.d.ts +1 -0
- package/lib/utils/functions/generic/compare-arrays.d.ts.map +1 -0
- package/lib/utils/functions/generic/compare-arrays.js +3 -6
- package/lib/utils/functions/generic/compare-arrays.js.map +1 -0
- package/lib/utils/functions/generic/deep-equal.d.ts +1 -0
- package/lib/utils/functions/generic/deep-equal.d.ts.map +1 -0
- package/lib/utils/functions/generic/deep-equal.js +5 -8
- package/lib/utils/functions/generic/deep-equal.js.map +1 -0
- package/lib/utils/functions/generic/get-entries.d.ts +2 -5
- package/lib/utils/functions/generic/get-entries.d.ts.map +1 -0
- package/lib/utils/functions/generic/get-entries.js +3 -9
- package/lib/utils/functions/generic/get-entries.js.map +1 -0
- package/lib/utils/functions/generic/index.d.ts +1 -0
- package/lib/utils/functions/generic/index.d.ts.map +1 -0
- package/lib/utils/functions/generic/index.js +4 -19
- package/lib/utils/functions/generic/index.js.map +1 -0
- package/lib/utils/functions/sort/index.d.ts +1 -0
- package/lib/utils/functions/sort/index.d.ts.map +1 -0
- package/lib/utils/functions/sort/index.js +3 -18
- package/lib/utils/functions/sort/index.js.map +1 -0
- package/lib/utils/functions/sort/sort-by-properties.d.ts +2 -1
- package/lib/utils/functions/sort/sort-by-properties.d.ts.map +1 -0
- package/lib/utils/functions/sort/sort-by-properties.js +4 -7
- package/lib/utils/functions/sort/sort-by-properties.js.map +1 -0
- package/lib/utils/functions/sort/sort-by-property.d.ts +2 -1
- package/lib/utils/functions/sort/sort-by-property.d.ts.map +1 -0
- package/lib/utils/functions/sort/sort-by-property.js +2 -4
- package/lib/utils/functions/sort/sort-by-property.js.map +1 -0
- package/lib/utils/functions/type-guards/index.d.ts +1 -0
- package/lib/utils/functions/type-guards/index.d.ts.map +1 -0
- package/lib/utils/functions/type-guards/index.js +4 -19
- package/lib/utils/functions/type-guards/index.js.map +1 -0
- package/lib/utils/functions/type-guards/is-function.d.ts +1 -0
- package/lib/utils/functions/type-guards/is-function.d.ts.map +1 -0
- package/lib/utils/functions/type-guards/is-function.js +2 -5
- package/lib/utils/functions/type-guards/is-function.js.map +1 -0
- package/lib/utils/functions/type-guards/is-number.d.ts +1 -0
- package/lib/utils/functions/type-guards/is-number.d.ts.map +1 -0
- package/lib/utils/functions/type-guards/is-number.js +2 -5
- package/lib/utils/functions/type-guards/is-number.js.map +1 -0
- package/lib/utils/functions/type-guards/is-object.d.ts +1 -0
- package/lib/utils/functions/type-guards/is-object.d.ts.map +1 -0
- package/lib/utils/functions/type-guards/is-object.js +2 -5
- package/lib/utils/functions/type-guards/is-object.js.map +1 -0
- package/lib/utils/types/add-prefix-to-object.d.ts +1 -0
- package/lib/utils/types/add-prefix-to-object.d.ts.map +1 -0
- package/lib/utils/types/add-prefix-to-object.js +2 -2
- package/lib/utils/types/add-prefix-to-object.js.map +1 -0
- package/lib/utils/types/allowed-names.d.ts +2 -1
- package/lib/utils/types/allowed-names.d.ts.map +1 -0
- package/lib/utils/types/allowed-names.js +2 -2
- package/lib/utils/types/allowed-names.js.map +1 -0
- package/lib/utils/types/flag-excluded-type.d.ts +1 -0
- package/lib/utils/types/flag-excluded-type.d.ts.map +1 -0
- package/lib/utils/types/flag-excluded-type.js +2 -2
- package/lib/utils/types/flag-excluded-type.js.map +1 -0
- package/lib/utils/types/generic-object.d.ts +1 -0
- package/lib/utils/types/generic-object.d.ts.map +1 -0
- package/lib/utils/types/generic-object.js +2 -2
- package/lib/utils/types/generic-object.js.map +1 -0
- package/lib/utils/types/index.d.ts +1 -0
- package/lib/utils/types/index.d.ts.map +1 -0
- package/lib/utils/types/index.js +11 -26
- package/lib/utils/types/index.js.map +1 -0
- package/lib/utils/types/omit-type.d.ts +2 -1
- package/lib/utils/types/omit-type.d.ts.map +1 -0
- package/lib/utils/types/omit-type.js +2 -2
- package/lib/utils/types/omit-type.js.map +1 -0
- package/lib/utils/types/partial-of-properties.d.ts +2 -1
- package/lib/utils/types/partial-of-properties.d.ts.map +1 -0
- package/lib/utils/types/partial-of-properties.js +2 -2
- package/lib/utils/types/partial-of-properties.js.map +1 -0
- package/lib/utils/types/prop-of.d.ts +2 -1
- package/lib/utils/types/prop-of.d.ts.map +1 -0
- package/lib/utils/types/prop-of.js +2 -2
- package/lib/utils/types/prop-of.js.map +1 -0
- package/lib/utils/types/property-only.d.ts +2 -1
- package/lib/utils/types/property-only.d.ts.map +1 -0
- package/lib/utils/types/property-only.js +2 -2
- package/lib/utils/types/property-only.js.map +1 -0
- package/lib/utils/types/recursive-partial.d.ts +1 -0
- package/lib/utils/types/recursive-partial.d.ts.map +1 -0
- package/lib/utils/types/recursive-partial.js +2 -2
- package/lib/utils/types/recursive-partial.js.map +1 -0
- package/lib/utils/types/sort-function.d.ts +1 -0
- package/lib/utils/types/sort-function.d.ts.map +1 -0
- package/lib/utils/types/sort-function.js +2 -2
- package/lib/utils/types/sort-function.js.map +1 -0
- package/lib/utils/types/type.d.ts +1 -0
- package/lib/utils/types/type.d.ts.map +1 -0
- package/lib/utils/types/type.js +2 -2
- package/lib/utils/types/type.js.map +1 -0
- package/package.json +23 -16
- package/lib/base-object.d.ts +0 -6
- package/lib/base-object.js +0 -15
- package/lib/errors/index.d.ts +0 -2
- package/lib/errors/index.js +0 -5
- package/lib/errors/invalid-argument-error.d.ts +0 -10
- package/lib/errors/invalid-argument-error.js +0 -11
- package/lib/query-conditions-group-nullable.d.ts +0 -4
- package/lib/query-conditions-group-nullable.js +0 -2
- package/lib/query-conditions-group.d.ts +0 -4
- package/lib/query-conditions-group.js +0 -2
- package/lib/query-row-validator.d.ts +0 -72
- package/lib/query-row-validator.js +0 -85
- package/lib/utils/decorators/number-validaton.d.ts +0 -36
- package/lib/utils/decorators/number-validaton.js +0 -124
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.QueryRowValidator = void 0;
|
|
4
|
-
const generic_1 = require("../../utils/functions/generic");
|
|
5
|
-
const type_guards_1 = require("../../utils/functions/type-guards");
|
|
1
|
+
import { compareArrays, getEntries } from '../../utils/functions/generic';
|
|
2
|
+
import { isFunction, isObject } from '../../utils/functions/type-guards';
|
|
6
3
|
/**
|
|
7
4
|
* Validates a row in the query.
|
|
8
5
|
*/
|
|
9
|
-
class QueryRowValidator {
|
|
6
|
+
export class QueryRowValidator {
|
|
10
7
|
/**
|
|
11
8
|
* Initializes the validator.
|
|
12
9
|
*
|
|
@@ -34,7 +31,7 @@ class QueryRowValidator {
|
|
|
34
31
|
* @returns Validation result.
|
|
35
32
|
*/
|
|
36
33
|
validate() {
|
|
37
|
-
const conditionsEntries =
|
|
34
|
+
const conditionsEntries = getEntries(this.conditionsObject);
|
|
38
35
|
return conditionsEntries.every(([columnName, condition]) => this.validateColumnCondition(columnName, condition));
|
|
39
36
|
}
|
|
40
37
|
/**
|
|
@@ -51,16 +48,16 @@ class QueryRowValidator {
|
|
|
51
48
|
return true;
|
|
52
49
|
}
|
|
53
50
|
const cellValue = this.row[columnName];
|
|
54
|
-
if (
|
|
51
|
+
if (isFunction(condition)) {
|
|
55
52
|
return condition(cellValue);
|
|
56
53
|
}
|
|
57
54
|
if (Array.isArray(condition)) {
|
|
58
55
|
return Array.isArray(cellValue)
|
|
59
|
-
?
|
|
56
|
+
? compareArrays(cellValue, condition)
|
|
60
57
|
: false;
|
|
61
58
|
}
|
|
62
|
-
if (
|
|
63
|
-
return
|
|
59
|
+
if (isObject(condition)) {
|
|
60
|
+
return isObject(cellValue)
|
|
64
61
|
? this.validateInnerObject(cellValue, condition)
|
|
65
62
|
: false;
|
|
66
63
|
}
|
|
@@ -81,4 +78,4 @@ class QueryRowValidator {
|
|
|
81
78
|
});
|
|
82
79
|
}
|
|
83
80
|
}
|
|
84
|
-
|
|
81
|
+
//# sourceMappingURL=query-row-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-row-validator.js","sourceRoot":"","sources":["../../../src/core/validation/query-row-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAQzE;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAiB5B;;;;;OAKG;IACH,YAAoB,GAAM,EAAE,MAAuC;QACjE,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;QAChD,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CACb,GAAM,EACN,MAAuC;QAEvC,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAErD,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACK,QAAQ;QACd,MAAM,iBAAiB,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAA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,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./query"), exports);
|
|
1
|
+
export * from './query';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
package/lib/query.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { QueryConditionsGroup, QueryConditionsGroupNullable } from './core/types';
|
|
2
|
-
import { addPrefixToObject, PropertyOnly, PropOf } from './utils/types';
|
|
1
|
+
import type { QueryConditionsGroup, QueryConditionsGroupNullable } from './core/types';
|
|
2
|
+
import type { addPrefixToObject, PropertyOnly, PropOf } from './utils/types';
|
|
3
3
|
/**
|
|
4
4
|
* Allows filtering data from an array of objects.
|
|
5
5
|
*
|
|
@@ -208,3 +208,4 @@ export declare class Query<T extends object> {
|
|
|
208
208
|
*/
|
|
209
209
|
private validateRow;
|
|
210
210
|
}
|
|
211
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,4BAA4B,EAC7B,MAAM,cAAc,CAAC;AAKtB,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,MAAM,EAEP,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,qBAAa,KAAK,CAAC,CAAC,SAAS,MAAM;;IA0BjC;;;OAGG;IACH,OAAO,CAAC,gBAAgB,CAAkB;IAE1C;;;;OAIG;IACH,OAAO;IAIP;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;IAIlD;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI;IAM9C;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,GAAG,IAAI;IAMvE;;;;;;;;;;OAUG;IACH,WAAW,CAAC,SAAS,EAAE,4BAA4B,CAAC,CAAC,CAAC,GAAG,IAAI;IAQ7D;;;;;;;OAOG;IACH,OAAO,CACL,GAAG,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,iBAAiB,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,GACxE,IAAI;IAOP;;;;OAIG;IACH,KAAK,IAAI,MAAM;IAIf;;;;OAIG;IACH,MAAM,IAAI,OAAO;IAIjB;;;;OAIG;IACH,KAAK,IAAI,CAAC,GAAG,IAAI;IAMjB;;;;OAIG;IACH,IAAI,IAAI,CAAC,GAAG,IAAI;IAMhB;;;;OAIG;IACH,GAAG,IAAI,CAAC,EAAE;IAIV;;;;OAIG;IACH,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK;IAS9B;;;;OAIG;IACH,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;IAUxB;;;;;OAKG;IACH,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;IAQ1B;;;;;;;;;OASG;IAEH,IAAI,CAAkB,YAAY,EAAE,MAAM,GAAG,IAAI;IAMjD;;;;;;;;OAQG;IAEH,KAAK,CAAkB,KAAK,EAAE,MAAM,GAAG,IAAI;IAM3C;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAUtB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAUtB;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAUlB;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;CASpB"}
|
package/lib/query.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -20,12 +19,10 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
20
19
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
20
|
};
|
|
22
21
|
var _Query_rows, _Query_columns, _Query_startAt, _Query_limit, _Query_sortFunction;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const sort_1 = require("./utils/functions/sort");
|
|
28
|
-
const type_guards_1 = require("./utils/functions/type-guards");
|
|
22
|
+
import { QueryRowValidator } from './core/validation';
|
|
23
|
+
import { integer, min, validateNumbers } from './core/validation/decorators';
|
|
24
|
+
import { sortByProperties } from './utils/functions/sort';
|
|
25
|
+
import { isFunction } from './utils/functions/type-guards';
|
|
29
26
|
/**
|
|
30
27
|
* Allows filtering data from an array of objects.
|
|
31
28
|
*
|
|
@@ -72,7 +69,7 @@ const type_guards_1 = require("./utils/functions/type-guards");
|
|
|
72
69
|
* const numberOfUsers = Query.from(users).count();
|
|
73
70
|
* ```
|
|
74
71
|
*/
|
|
75
|
-
class Query {
|
|
72
|
+
export class Query {
|
|
76
73
|
/**
|
|
77
74
|
* Initializes the query.
|
|
78
75
|
*
|
|
@@ -98,7 +95,7 @@ class Query {
|
|
|
98
95
|
/**
|
|
99
96
|
* Function to order the results.
|
|
100
97
|
*/
|
|
101
|
-
_Query_sortFunction.set(this,
|
|
98
|
+
_Query_sortFunction.set(this, null);
|
|
102
99
|
/**
|
|
103
100
|
* Indicates whether conditions with `null` and `undefined` values should be
|
|
104
101
|
* skipped.
|
|
@@ -170,12 +167,7 @@ class Query {
|
|
|
170
167
|
* @returns Current query.
|
|
171
168
|
*/
|
|
172
169
|
orderBy(...columns) {
|
|
173
|
-
|
|
174
|
-
__classPrivateFieldSet(this, _Query_sortFunction, (0, sort_1.sortByProperties)(...columns), "f");
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
__classPrivateFieldSet(this, _Query_sortFunction, undefined, "f");
|
|
178
|
-
}
|
|
170
|
+
__classPrivateFieldSet(this, _Query_sortFunction, columns.length > 0 ? sortByProperties(...columns) : null, "f");
|
|
179
171
|
return this;
|
|
180
172
|
}
|
|
181
173
|
/**
|
|
@@ -201,7 +193,7 @@ class Query {
|
|
|
201
193
|
*/
|
|
202
194
|
first() {
|
|
203
195
|
const rows = this.getLimitedRows();
|
|
204
|
-
return rows.length ? rows[0] : null;
|
|
196
|
+
return rows.length > 0 ? rows[0] : null;
|
|
205
197
|
}
|
|
206
198
|
/**
|
|
207
199
|
* Returns the last result.
|
|
@@ -251,7 +243,7 @@ class Query {
|
|
|
251
243
|
* @returns Array with the values of all rows.
|
|
252
244
|
*/
|
|
253
245
|
values() {
|
|
254
|
-
return this.getLimitedRows().map((row) => __classPrivateFieldGet(this, _Query_columns, "f").length
|
|
246
|
+
return this.getLimitedRows().map((row) => __classPrivateFieldGet(this, _Query_columns, "f").length > 0
|
|
255
247
|
? __classPrivateFieldGet(this, _Query_columns, "f").map((column) => row[column])
|
|
256
248
|
: Object.values(row));
|
|
257
249
|
}
|
|
@@ -289,7 +281,7 @@ class Query {
|
|
|
289
281
|
*/
|
|
290
282
|
getLimitedRows() {
|
|
291
283
|
const rows = [...__classPrivateFieldGet(this, _Query_rows, "f")];
|
|
292
|
-
if (__classPrivateFieldGet(this, _Query_sortFunction, "f")) {
|
|
284
|
+
if (__classPrivateFieldGet(this, _Query_sortFunction, "f") !== null) {
|
|
293
285
|
rows.sort(__classPrivateFieldGet(this, _Query_sortFunction, "f"));
|
|
294
286
|
}
|
|
295
287
|
return rows.slice(__classPrivateFieldGet(this, _Query_startAt, "f")).slice(0, __classPrivateFieldGet(this, _Query_limit, "f"));
|
|
@@ -300,7 +292,7 @@ class Query {
|
|
|
300
292
|
* @returns The first column or `null`, if none is selected or there is no row.
|
|
301
293
|
*/
|
|
302
294
|
getFirstColumn() {
|
|
303
|
-
if (__classPrivateFieldGet(this, _Query_columns, "f").length) {
|
|
295
|
+
if (__classPrivateFieldGet(this, _Query_columns, "f").length > 0) {
|
|
304
296
|
return __classPrivateFieldGet(this, _Query_columns, "f")[0];
|
|
305
297
|
}
|
|
306
298
|
const firstObject = this.first();
|
|
@@ -312,7 +304,7 @@ class Query {
|
|
|
312
304
|
* @param condition Object or callback function.
|
|
313
305
|
*/
|
|
314
306
|
filterRows(condition) {
|
|
315
|
-
__classPrivateFieldSet(this, _Query_rows, __classPrivateFieldGet(this, _Query_rows, "f").filter((row) =>
|
|
307
|
+
__classPrivateFieldSet(this, _Query_rows, __classPrivateFieldGet(this, _Query_rows, "f").filter((row) => isFunction(condition)
|
|
316
308
|
? condition(row)
|
|
317
309
|
: this.validateRow(row, condition)), "f");
|
|
318
310
|
}
|
|
@@ -325,21 +317,21 @@ class Query {
|
|
|
325
317
|
* @returns {boolean} Validation result.
|
|
326
318
|
*/
|
|
327
319
|
validateRow(row, condition) {
|
|
328
|
-
return
|
|
320
|
+
return QueryRowValidator.validate(row, {
|
|
329
321
|
conditionsObject: condition,
|
|
330
322
|
ignoreNullValues: this.ignoreNullValues,
|
|
331
323
|
});
|
|
332
324
|
}
|
|
333
325
|
}
|
|
334
|
-
exports.Query = Query;
|
|
335
326
|
_Query_rows = new WeakMap(), _Query_columns = new WeakMap(), _Query_startAt = new WeakMap(), _Query_limit = new WeakMap(), _Query_sortFunction = new WeakMap();
|
|
336
327
|
__decorate([
|
|
337
|
-
|
|
338
|
-
__param(0,
|
|
339
|
-
__param(0,
|
|
328
|
+
validateNumbers,
|
|
329
|
+
__param(0, integer),
|
|
330
|
+
__param(0, min(0))
|
|
340
331
|
], Query.prototype, "skip", null);
|
|
341
332
|
__decorate([
|
|
342
|
-
|
|
343
|
-
__param(0,
|
|
344
|
-
__param(0,
|
|
333
|
+
validateNumbers,
|
|
334
|
+
__param(0, integer),
|
|
335
|
+
__param(0, min(0))
|
|
345
336
|
], Query.prototype, "limit", null);
|
|
337
|
+
//# sourceMappingURL=query.js.map
|
package/lib/query.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB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IAED;;;;OAIG;IACK,cAAc;QACpB,IAAI,uBAAA,IAAI,sBAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,OAAO,uBAAA,IAAI,sBAAS,CAAC,CAAC,CAAE,CAAC;QAC3B,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAEjC,OAAO,WAAW,CAAC,CAAC,CAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAe,CAAC,CAAC,CAAC,IAAI,CAAC;IACzE,CAAC;IAED;;;;OAIG;IACK,UAAU,CAChB,SAAkE;QAElE,uBAAA,IAAI,eAAS,uBAAA,IAAI,mBAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CACrC,UAAU,CAAsB,SAAS,CAAC;YACxC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC;YAChB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,SAAS,CAAC,CACrC,MAAA,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACK,WAAW,CACjB,GAAM,EACN,SAA0C;QAE1C,OAAO,iBAAiB,CAAC,QAAQ,CAAC,GAAG,EAAE;YACrC,gBAAgB,EAAE,SAAS;YAC3B,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;SACxC,CAAC,CAAC;IACL,CAAC;CACF;;AApFC;IADC,eAAe;IACV,WAAA,OAAO,CAAA;IAAE,WAAA,GAAG,CAAC,CAAC,CAAC,CAAA;iCAIpB;AAYD;IADC,eAAe;IACT,WAAA,OAAO,CAAA;IAAE,WAAA,GAAG,CAAC,CAAC,CAAC,CAAA;kCAIrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare-arrays.d.ts","sourceRoot":"","sources":["../../../../src/utils/functions/generic/compare-arrays.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,KAAG,OACc,CAAC"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const deep_equal_1 = require("./deep-equal");
|
|
5
|
-
const compareArrays = (a, b) => a.length === b.length && a.every((v, i) => (0, deep_equal_1.deepEqual)(v, b[i]));
|
|
6
|
-
exports.compareArrays = compareArrays;
|
|
1
|
+
import { deepEqual } from './deep-equal';
|
|
2
|
+
export const compareArrays = (a, b) => a.length === b.length && a.every((v, i) => deepEqual(v, b[i]));
|
|
3
|
+
//# sourceMappingURL=compare-arrays.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare-arrays.js","sourceRoot":"","sources":["../../../../src/utils/functions/generic/compare-arrays.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAI,CAAM,EAAE,CAAM,EAAW,EAAE,CAC1D,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-equal.d.ts","sourceRoot":"","sources":["../../../../src/utils/functions/generic/deep-equal.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,GAAI,GAAG,OAAO,EAAE,GAAG,OAAO,KAAG,OA4BlD,CAAC"}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.deepEqual = void 0;
|
|
4
|
-
const type_guards_1 = require("../type-guards");
|
|
5
|
-
const deepEqual = (a, b) => {
|
|
1
|
+
import { isObject } from '../type-guards';
|
|
2
|
+
export const deepEqual = (a, b) => {
|
|
6
3
|
if (a === b) {
|
|
7
4
|
return true;
|
|
8
5
|
}
|
|
9
|
-
if (!
|
|
6
|
+
if (!isObject(a) || !isObject(b)) {
|
|
10
7
|
return false;
|
|
11
8
|
}
|
|
12
9
|
if (Array.isArray(a) !== Array.isArray(b)) {
|
|
@@ -18,6 +15,6 @@ const deepEqual = (a, b) => {
|
|
|
18
15
|
return false;
|
|
19
16
|
}
|
|
20
17
|
return keysA.every((key) => Object.prototype.hasOwnProperty.call(b, key) &&
|
|
21
|
-
|
|
18
|
+
deepEqual(a[key], b[key]));
|
|
22
19
|
};
|
|
23
|
-
|
|
20
|
+
//# sourceMappingURL=deep-equal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-equal.js","sourceRoot":"","sources":["../../../../src/utils/functions/generic/deep-equal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAU,EAAE,CAAU,EAAW,EAAE;IAC3D,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE7B,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,KAAK,CAAC,KAAK,CAChB,CAAC,GAAG,EAAE,EAAE,CACN,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC;QAC5C,SAAS,CACN,CAA6B,CAAC,GAAG,CAAC,EAClC,CAA6B,CAAC,GAAG,CAAC,CACpC,CACJ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}[keyof T][];
|
|
4
|
-
export declare function getEntries<T extends Record<PropertyKey, unknown>>(obj: T): Entries<T>;
|
|
5
|
-
export {};
|
|
1
|
+
export declare function getEntries<T extends Record<PropertyKey, unknown>>(obj: T): [keyof T, T[keyof T]][];
|
|
2
|
+
//# sourceMappingURL=get-entries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-entries.d.ts","sourceRoot":"","sources":["../../../../src/utils/functions/generic/get-entries.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,EAC/D,GAAG,EAAE,CAAC,GACL,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAEzB"}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.
|
|
3
|
-
exports.getEntries = getEntries;
|
|
4
|
-
function getEntries(obj) {
|
|
5
|
-
const entries = [];
|
|
6
|
-
for (const key of Object.keys(obj)) {
|
|
7
|
-
entries.push([key, obj[key]]);
|
|
8
|
-
}
|
|
9
|
-
return entries;
|
|
1
|
+
export function getEntries(obj) {
|
|
2
|
+
return Object.entries(obj);
|
|
10
3
|
}
|
|
4
|
+
//# sourceMappingURL=get-entries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-entries.js","sourceRoot":"","sources":["../../../../src/utils/functions/generic/get-entries.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CACxB,GAAM;IAEN,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAA4B,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/functions/generic/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./compare-arrays"), exports);
|
|
18
|
-
__exportStar(require("./deep-equal"), exports);
|
|
19
|
-
__exportStar(require("./get-entries"), exports);
|
|
1
|
+
export * from './compare-arrays';
|
|
2
|
+
export * from './deep-equal';
|
|
3
|
+
export * from './get-entries';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/functions/generic/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/functions/sort/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./sort-by-properties"), exports);
|
|
18
|
-
__exportStar(require("./sort-by-property"), exports);
|
|
1
|
+
export * from './sort-by-properties';
|
|
2
|
+
export * from './sort-by-property';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/functions/sort/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { addPrefixToObject, PropertyOnly, PropOf, SortFunction } from '../../types';
|
|
1
|
+
import type { addPrefixToObject, PropertyOnly, PropOf, SortFunction } from '../../types';
|
|
2
2
|
export declare function sortByProperties<T extends object>(...props: (PropOf<T> | keyof addPrefixToObject<PropertyOnly<T>, '-'>)[]): SortFunction<T>;
|
|
3
|
+
//# sourceMappingURL=sort-by-properties.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort-by-properties.d.ts","sourceRoot":"","sources":["../../../../src/utils/functions/sort/sort-by-properties.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,MAAM,EACN,YAAY,EACb,MAAM,aAAa,CAAC;AAErB,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAC/C,GAAG,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,iBAAiB,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,GACtE,YAAY,CAAC,CAAC,CAAC,CAgBjB"}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.sortByProperties = sortByProperties;
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
function sortByProperties(...props) {
|
|
1
|
+
import { sortByProperty } from '.';
|
|
2
|
+
export function sortByProperties(...props) {
|
|
6
3
|
return (a, b) => {
|
|
7
4
|
if (props.length === 0) {
|
|
8
5
|
return 0;
|
|
9
6
|
}
|
|
10
|
-
let result = 0;
|
|
11
7
|
for (const prop of props) {
|
|
12
|
-
result =
|
|
8
|
+
const result = sortByProperty(prop)(a, b);
|
|
13
9
|
if (result !== 0) {
|
|
14
10
|
return result;
|
|
15
11
|
}
|
|
@@ -17,3 +13,4 @@ function sortByProperties(...props) {
|
|
|
17
13
|
return 0;
|
|
18
14
|
};
|
|
19
15
|
}
|
|
16
|
+
//# sourceMappingURL=sort-by-properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort-by-properties.js","sourceRoot":"","sources":["../../../../src/utils/functions/sort/sort-by-properties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,CAAC;AAQnC,MAAM,UAAU,gBAAgB,CAC9B,GAAG,KAAoE;IAEvE,OAAO,CAAC,CAAI,EAAE,CAAI,EAAU,EAAE;QAC5B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,MAAM,GAAG,cAAc,CAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAE7C,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC;gBACjB,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QAED,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { addPrefixToObject, PropertyOnly, PropOf, SortFunction } from '../../types';
|
|
1
|
+
import type { addPrefixToObject, PropertyOnly, PropOf, SortFunction } from '../../types';
|
|
2
2
|
export declare function sortByProperty<T extends object>(property: PropOf<T> | keyof addPrefixToObject<PropertyOnly<T>, '-'>): SortFunction<T>;
|
|
3
|
+
//# sourceMappingURL=sort-by-property.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort-by-property.d.ts","sourceRoot":"","sources":["../../../../src/utils/functions/sort/sort-by-property.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,MAAM,EACN,YAAY,EACb,MAAM,aAAa,CAAC;AAErB,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC7C,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,iBAAiB,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,GAClE,YAAY,CAAC,CAAC,CAAC,CAwBjB"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sortByProperty = sortByProperty;
|
|
4
|
-
function sortByProperty(property) {
|
|
1
|
+
export function sortByProperty(property) {
|
|
5
2
|
let sortOrder = 1;
|
|
6
3
|
let prop = property;
|
|
7
4
|
if (prop.startsWith('-')) {
|
|
@@ -25,3 +22,4 @@ function sortByProperty(property) {
|
|
|
25
22
|
return 0;
|
|
26
23
|
};
|
|
27
24
|
}
|
|
25
|
+
//# sourceMappingURL=sort-by-property.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort-by-property.js","sourceRoot":"","sources":["../../../../src/utils/functions/sort/sort-by-property.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,cAAc,CAC5B,QAAmE;IAEnE,IAAI,SAAS,GAAW,CAAC,CAAC;IAC1B,IAAI,IAAI,GAAG,QAAkB,CAAC;IAE9B,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,SAAS,GAAG,CAAC,CAAC,CAAC;QACf,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,GAAG,GAAG,IAAe,CAAC;IAE5B,OAAO,CAAC,CAAI,EAAE,CAAI,EAAU,EAAE;QAC5B,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACtB,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QAEtB,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI;YAAE,OAAO,CAAC,CAAC;QAC/C,IAAI,MAAM,IAAI,IAAI;YAAE,OAAO,CAAC,GAAG,SAAS,CAAC;QACzC,IAAI,MAAM,IAAI,IAAI;YAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;QAE1C,IAAI,MAAM,GAAG,MAAM;YAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;QAC3C,IAAI,MAAM,GAAG,MAAM;YAAE,OAAO,CAAC,GAAG,SAAS,CAAC;QAE1C,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/functions/type-guards/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./is-function"), exports);
|
|
18
|
-
__exportStar(require("./is-number"), exports);
|
|
19
|
-
__exportStar(require("./is-object"), exports);
|
|
1
|
+
export * from './is-function';
|
|
2
|
+
export * from './is-number';
|
|
3
|
+
export * from './is-object';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/functions/type-guards/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-function.d.ts","sourceRoot":"","sources":["../../../../src/utils/functions/type-guards/is-function.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,OAAO,OAAO,KAAG,KAAK,IAAI,CAC3B,CAAC"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isFunction = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Determines if the given value is a function.
|
|
6
3
|
*
|
|
@@ -8,5 +5,5 @@ exports.isFunction = void 0;
|
|
|
8
5
|
*
|
|
9
6
|
* @returns Validation result.
|
|
10
7
|
*/
|
|
11
|
-
const isFunction = (value) => typeof value === 'function';
|
|
12
|
-
|
|
8
|
+
export const isFunction = (value) => typeof value === 'function';
|
|
9
|
+
//# sourceMappingURL=is-function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-function.js","sourceRoot":"","sources":["../../../../src/utils/functions/type-guards/is-function.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAI,KAAc,EAAc,EAAE,CAC1D,OAAO,KAAK,KAAK,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-number.d.ts","sourceRoot":"","sources":["../../../../src/utils/functions/type-guards/is-number.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MACxB,CAAC"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNumber = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Determines if the given value is a number.
|
|
6
3
|
*
|
|
@@ -8,5 +5,5 @@ exports.isNumber = void 0;
|
|
|
8
5
|
*
|
|
9
6
|
* @returns Validation result.
|
|
10
7
|
*/
|
|
11
|
-
const isNumber = (value) => typeof value === 'number';
|
|
12
|
-
|
|
8
|
+
export const isNumber = (value) => typeof value === 'number';
|
|
9
|
+
//# sourceMappingURL=is-number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-number.js","sourceRoot":"","sources":["../../../../src/utils/functions/type-guards/is-number.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE,CAC1D,OAAO,KAAK,KAAK,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-object.d.ts","sourceRoot":"","sources":["../../../../src/utils/functions/type-guards/is-object.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MACN,CAAC"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isObject = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Determines if the given value is an object.
|
|
6
3
|
*
|
|
@@ -8,5 +5,5 @@ exports.isObject = void 0;
|
|
|
8
5
|
*
|
|
9
6
|
* @returns Validation result.
|
|
10
7
|
*/
|
|
11
|
-
const isObject = (value) => typeof value === 'object' && value !== null;
|
|
12
|
-
|
|
8
|
+
export const isObject = (value) => typeof value === 'object' && value !== null;
|
|
9
|
+
//# sourceMappingURL=is-object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-object.js","sourceRoot":"","sources":["../../../../src/utils/functions/type-guards/is-object.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE,CAC1D,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC"}
|