@thisisagile/easy 15.21.0 → 15.21.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/dist/types/Parser.d.ts +4 -5
- package/dist/types/Parser.js +5 -15
- package/dist/types/Parser.js.map +1 -1
- package/dist/types/Parser.mjs +6 -16
- package/dist/types/Parser.mjs.map +1 -1
- package/package.json +2 -2
- package/src/types/Parser.ts +10 -16
package/dist/types/Parser.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { Get } from './Get';
|
|
1
|
+
import { Get, Predicate } from './Get';
|
|
2
2
|
import { Constructor } from './Constructor';
|
|
3
3
|
export declare class Parser<T, V> {
|
|
4
4
|
protected value: T;
|
|
5
|
-
protected
|
|
6
|
-
protected alt: Get<V, T>;
|
|
7
|
-
readonly valid: boolean;
|
|
5
|
+
protected valid: boolean;
|
|
8
6
|
if: {
|
|
7
|
+
equals: (pred?: Predicate<T>) => this;
|
|
9
8
|
empty: <U>(pred?: Get<U, T> | undefined) => this;
|
|
10
9
|
defined: <U_1>(pred?: Get<U_1, T> | undefined) => this;
|
|
11
10
|
valid: <U_2>(pred?: Get<U_2, T> | undefined) => this;
|
|
@@ -28,7 +27,7 @@ export declare class Parser<T, V> {
|
|
|
28
27
|
};
|
|
29
28
|
};
|
|
30
29
|
};
|
|
31
|
-
constructor(value: T,
|
|
30
|
+
constructor(value: T, valid?: boolean);
|
|
32
31
|
protected evaluate<U>(meta: Get<boolean>, pred?: Get<U, T>): this;
|
|
33
32
|
protected evaluateNot<U>(meta: Get<boolean>, pred?: Get<U, T>): this;
|
|
34
33
|
}
|
package/dist/types/Parser.js
CHANGED
|
@@ -24,15 +24,15 @@ module.exports = __toCommonJS(Parser_exports);
|
|
|
24
24
|
var import_Get = require("./Get");
|
|
25
25
|
var import_Is = require("./Is");
|
|
26
26
|
var import_validation = require("../validation");
|
|
27
|
+
var import_Constructor = require("./Constructor");
|
|
27
28
|
var import_Array = require("./Array");
|
|
28
29
|
class Parser {
|
|
29
|
-
constructor(value,
|
|
30
|
+
constructor(value, valid = true) {
|
|
30
31
|
this.value = value;
|
|
31
|
-
this.f = f;
|
|
32
|
-
this.alt = alt;
|
|
33
32
|
this.valid = valid;
|
|
34
33
|
}
|
|
35
34
|
if = {
|
|
35
|
+
equals: (pred) => this.evaluate(import_Is.isTrue, pred),
|
|
36
36
|
empty: (pred) => this.evaluate(import_Is.isEmpty, pred),
|
|
37
37
|
defined: (pred) => this.evaluate(import_Is.isDefined, pred),
|
|
38
38
|
valid: (pred) => this.evaluate(import_validation.isValid, pred),
|
|
@@ -56,20 +56,10 @@ class Parser {
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
evaluate(meta, pred) {
|
|
59
|
-
return
|
|
60
|
-
this.value,
|
|
61
|
-
this.f,
|
|
62
|
-
this.alt,
|
|
63
|
-
(0, import_Get.ofGet)(meta, pred ? (0, import_Get.ofGet)(pred, this.value) : this.value)
|
|
64
|
-
);
|
|
59
|
+
return (0, import_Constructor.on)(this, (t) => t.valid = (0, import_Get.ofGet)(meta, pred ? (0, import_Get.ofGet)(pred, this.value) : this.value));
|
|
65
60
|
}
|
|
66
61
|
evaluateNot(meta, pred) {
|
|
67
|
-
return
|
|
68
|
-
this.value,
|
|
69
|
-
this.f,
|
|
70
|
-
this.alt,
|
|
71
|
-
!(0, import_Get.ofGet)(meta, pred ? (0, import_Get.ofGet)(pred, this.value) : this.value)
|
|
72
|
-
);
|
|
62
|
+
return (0, import_Constructor.on)(this, (t) => t.valid = !(0, import_Get.ofGet)(meta, pred ? (0, import_Get.ofGet)(pred, this.value) : this.value));
|
|
73
63
|
}
|
|
74
64
|
}
|
|
75
65
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/types/Parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/Parser.ts"],"sourcesContent":["import { Get, ofGet } from './Get';\nimport { isDefined, isEmpty, isIn, isObject, isString } from './Is';\nimport { isValid } from '../validation';\nimport { Constructor } from './Constructor';\nimport { toArray } from './Array';\n\nexport class Parser<T, V> {\n if = {\n empty: <U>(pred?: Get<U, T>): this => this.evaluate(isEmpty, pred),\n defined: <U>(pred?: Get<U, T>): this => this.evaluate(isDefined, pred),\n valid: <U>(pred?: Get<U, T>): this => this.evaluate(isValid, pred),\n in: (...items: T[]): this => this.evaluate(() => isIn(this.value, toArray(...items))),\n is: {\n object: <U>(pred?: Get<U, T>): this => this.evaluate(isObject, pred),\n string: <U>(pred?: Get<U, T>): this => this.evaluate(isString, pred),\n instance: <U>(c: Constructor<U>, pred?: Get<U, T>): this => this.evaluate(() => this.value instanceof c, pred),\n },\n not: {\n empty: <U>(pred?: Get<U, T>): this => this.evaluateNot(isEmpty, pred),\n defined: <U>(pred?: Get<U, T>): this => this.evaluateNot(isDefined, pred),\n valid: <U>(pred?: Get<U, T>): this => this.evaluateNot(isValid, pred),\n isObject: <U>(pred?: Get<U, T>): this => this.evaluateNot(isObject, pred),\n in: (...items: T[]): this => this.evaluate(() => !isIn(this.value, toArray(...items))),\n is: {\n object: <U>(pred?: Get<U, T>): this => this.evaluateNot(isObject, pred),\n string: <U>(pred?: Get<U, T>): this => this.evaluateNot(isString, pred),\n instance: <U>(c: Constructor<U>, pred?: Get<U, T>): this => this.evaluate(() => !(this.value instanceof c), pred),\n },\n },\n };\n\n constructor(protected value: T
|
|
1
|
+
{"version":3,"sources":["../../src/types/Parser.ts"],"sourcesContent":["import { Get, ofGet, Predicate } from './Get';\nimport { isDefined, isEmpty, isIn, isObject, isString, isTrue } from './Is';\nimport { isValid } from '../validation';\nimport { Constructor, on } from './Constructor';\nimport { toArray } from './Array';\n\nexport class Parser<T, V> {\n if = {\n equals: (pred?: Predicate<T>): this => this.evaluate(isTrue, pred),\n empty: <U>(pred?: Get<U, T>): this => this.evaluate(isEmpty, pred),\n defined: <U>(pred?: Get<U, T>): this => this.evaluate(isDefined, pred),\n valid: <U>(pred?: Get<U, T>): this => this.evaluate(isValid, pred),\n in: (...items: T[]): this => this.evaluate(() => isIn(this.value, toArray(...items))),\n is: {\n object: <U>(pred?: Get<U, T>): this => this.evaluate(isObject, pred),\n string: <U>(pred?: Get<U, T>): this => this.evaluate(isString, pred),\n instance: <U>(c: Constructor<U>, pred?: Get<U, T>): this => this.evaluate(() => this.value instanceof c, pred),\n },\n not: {\n empty: <U>(pred?: Get<U, T>): this => this.evaluateNot(isEmpty, pred),\n defined: <U>(pred?: Get<U, T>): this => this.evaluateNot(isDefined, pred),\n valid: <U>(pred?: Get<U, T>): this => this.evaluateNot(isValid, pred),\n isObject: <U>(pred?: Get<U, T>): this => this.evaluateNot(isObject, pred),\n in: (...items: T[]): this => this.evaluate(() => !isIn(this.value, toArray(...items))),\n is: {\n object: <U>(pred?: Get<U, T>): this => this.evaluateNot(isObject, pred),\n string: <U>(pred?: Get<U, T>): this => this.evaluateNot(isString, pred),\n instance: <U>(c: Constructor<U>, pred?: Get<U, T>): this => this.evaluate(() => !(this.value instanceof c), pred),\n },\n },\n };\n\n constructor(\n protected value: T,\n protected valid = true\n ) {}\n\n protected evaluate<U>(meta: Get<boolean>, pred?: Get<U, T>): this {\n return on(this, t => (t.valid = ofGet(meta, pred ? ofGet(pred, this.value) : this.value)));\n }\n\n protected evaluateNot<U>(meta: Get<boolean>, pred?: Get<U, T>): this {\n return on(this, t => (t.valid = !ofGet(meta, pred ? ofGet(pred, this.value) : this.value)));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAsC;AACtC,gBAAqE;AACrE,wBAAwB;AACxB,yBAAgC;AAChC,mBAAwB;AAEjB,MAAM,OAAa;AAAA,EA0BxB,YACY,OACA,QAAQ,MAClB;AAFU;AACA;AAAA,EACT;AAAA,EA5BH,KAAK;AAAA,IACH,QAAQ,CAAC,SAA8B,KAAK,SAAS,kBAAQ,IAAI;AAAA,IACjE,OAAO,CAAI,SAA2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;AAAA,EAEU,YAAe,MAAoB,MAAwB;AACnE,eAAO,uBAAG,MAAM,OAAM,EAAE,QAAQ,KAAC,kBAAM,MAAM,WAAO,kBAAM,MAAM,KAAK,KAAK,IAAI,KAAK,KAAK,CAAE;AAAA,EAC5F;AACF;","names":[]}
|
package/dist/types/Parser.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import "../chunk-4N72FQFX.mjs";
|
|
2
2
|
import { ofGet } from "./Get";
|
|
3
|
-
import { isDefined, isEmpty, isIn, isObject, isString } from "./Is";
|
|
3
|
+
import { isDefined, isEmpty, isIn, isObject, isString, isTrue } from "./Is";
|
|
4
4
|
import { isValid } from "../validation";
|
|
5
|
+
import { on } from "./Constructor";
|
|
5
6
|
import { toArray } from "./Array";
|
|
6
7
|
class Parser {
|
|
7
|
-
constructor(value,
|
|
8
|
+
constructor(value, valid = true) {
|
|
8
9
|
this.value = value;
|
|
9
|
-
this.f = f;
|
|
10
|
-
this.alt = alt;
|
|
11
10
|
this.valid = valid;
|
|
12
11
|
}
|
|
13
12
|
if = {
|
|
13
|
+
equals: (pred) => this.evaluate(isTrue, pred),
|
|
14
14
|
empty: (pred) => this.evaluate(isEmpty, pred),
|
|
15
15
|
defined: (pred) => this.evaluate(isDefined, pred),
|
|
16
16
|
valid: (pred) => this.evaluate(isValid, pred),
|
|
@@ -34,20 +34,10 @@ class Parser {
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
evaluate(meta, pred) {
|
|
37
|
-
return
|
|
38
|
-
this.value,
|
|
39
|
-
this.f,
|
|
40
|
-
this.alt,
|
|
41
|
-
ofGet(meta, pred ? ofGet(pred, this.value) : this.value)
|
|
42
|
-
);
|
|
37
|
+
return on(this, (t) => t.valid = ofGet(meta, pred ? ofGet(pred, this.value) : this.value));
|
|
43
38
|
}
|
|
44
39
|
evaluateNot(meta, pred) {
|
|
45
|
-
return
|
|
46
|
-
this.value,
|
|
47
|
-
this.f,
|
|
48
|
-
this.alt,
|
|
49
|
-
!ofGet(meta, pred ? ofGet(pred, this.value) : this.value)
|
|
50
|
-
);
|
|
40
|
+
return on(this, (t) => t.valid = !ofGet(meta, pred ? ofGet(pred, this.value) : this.value));
|
|
51
41
|
}
|
|
52
42
|
}
|
|
53
43
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/Parser.ts"],"sourcesContent":["import { Get, ofGet } from './Get';\nimport { isDefined, isEmpty, isIn, isObject, isString } from './Is';\nimport { isValid } from '../validation';\nimport { Constructor } from './Constructor';\nimport { toArray } from './Array';\n\nexport class Parser<T, V> {\n if = {\n empty: <U>(pred?: Get<U, T>): this => this.evaluate(isEmpty, pred),\n defined: <U>(pred?: Get<U, T>): this => this.evaluate(isDefined, pred),\n valid: <U>(pred?: Get<U, T>): this => this.evaluate(isValid, pred),\n in: (...items: T[]): this => this.evaluate(() => isIn(this.value, toArray(...items))),\n is: {\n object: <U>(pred?: Get<U, T>): this => this.evaluate(isObject, pred),\n string: <U>(pred?: Get<U, T>): this => this.evaluate(isString, pred),\n instance: <U>(c: Constructor<U>, pred?: Get<U, T>): this => this.evaluate(() => this.value instanceof c, pred),\n },\n not: {\n empty: <U>(pred?: Get<U, T>): this => this.evaluateNot(isEmpty, pred),\n defined: <U>(pred?: Get<U, T>): this => this.evaluateNot(isDefined, pred),\n valid: <U>(pred?: Get<U, T>): this => this.evaluateNot(isValid, pred),\n isObject: <U>(pred?: Get<U, T>): this => this.evaluateNot(isObject, pred),\n in: (...items: T[]): this => this.evaluate(() => !isIn(this.value, toArray(...items))),\n is: {\n object: <U>(pred?: Get<U, T>): this => this.evaluateNot(isObject, pred),\n string: <U>(pred?: Get<U, T>): this => this.evaluateNot(isString, pred),\n instance: <U>(c: Constructor<U>, pred?: Get<U, T>): this => this.evaluate(() => !(this.value instanceof c), pred),\n },\n },\n };\n\n constructor(protected value: T
|
|
1
|
+
{"version":3,"sources":["../../src/types/Parser.ts"],"sourcesContent":["import { Get, ofGet, Predicate } from './Get';\nimport { isDefined, isEmpty, isIn, isObject, isString, isTrue } from './Is';\nimport { isValid } from '../validation';\nimport { Constructor, on } from './Constructor';\nimport { toArray } from './Array';\n\nexport class Parser<T, V> {\n if = {\n equals: (pred?: Predicate<T>): this => this.evaluate(isTrue, pred),\n empty: <U>(pred?: Get<U, T>): this => this.evaluate(isEmpty, pred),\n defined: <U>(pred?: Get<U, T>): this => this.evaluate(isDefined, pred),\n valid: <U>(pred?: Get<U, T>): this => this.evaluate(isValid, pred),\n in: (...items: T[]): this => this.evaluate(() => isIn(this.value, toArray(...items))),\n is: {\n object: <U>(pred?: Get<U, T>): this => this.evaluate(isObject, pred),\n string: <U>(pred?: Get<U, T>): this => this.evaluate(isString, pred),\n instance: <U>(c: Constructor<U>, pred?: Get<U, T>): this => this.evaluate(() => this.value instanceof c, pred),\n },\n not: {\n empty: <U>(pred?: Get<U, T>): this => this.evaluateNot(isEmpty, pred),\n defined: <U>(pred?: Get<U, T>): this => this.evaluateNot(isDefined, pred),\n valid: <U>(pred?: Get<U, T>): this => this.evaluateNot(isValid, pred),\n isObject: <U>(pred?: Get<U, T>): this => this.evaluateNot(isObject, pred),\n in: (...items: T[]): this => this.evaluate(() => !isIn(this.value, toArray(...items))),\n is: {\n object: <U>(pred?: Get<U, T>): this => this.evaluateNot(isObject, pred),\n string: <U>(pred?: Get<U, T>): this => this.evaluateNot(isString, pred),\n instance: <U>(c: Constructor<U>, pred?: Get<U, T>): this => this.evaluate(() => !(this.value instanceof c), pred),\n },\n },\n };\n\n constructor(\n protected value: T,\n protected valid = true\n ) {}\n\n protected evaluate<U>(meta: Get<boolean>, pred?: Get<U, T>): this {\n return on(this, t => (t.valid = ofGet(meta, pred ? ofGet(pred, this.value) : this.value)));\n }\n\n protected evaluateNot<U>(meta: Get<boolean>, pred?: Get<U, T>): this {\n return on(this, t => (t.valid = !ofGet(meta, pred ? ofGet(pred, this.value) : this.value)));\n }\n}\n"],"mappings":";AAAA,SAAc,aAAw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E,UAAU,CAAI,GAAmB,SAA2B,KAAK,SAAS,MAAM,EAAE,KAAK,iBAAiB,IAAI,IAAI;AAAA,MAClH;AAAA,IACF;AAAA,EACF;AAAA,EAOU,SAAY,MAAoB,MAAwB;AAChE,WAAO,GAAG,MAAM,OAAM,EAAE,QAAQ,MAAM,MAAM,OAAO,MAAM,MAAM,KAAK,KAAK,IAAI,KAAK,KAAK,CAAE;AAAA,EAC3F;AAAA,EAEU,YAAe,MAAoB,MAAwB;AACnE,WAAO,GAAG,MAAM,OAAM,EAAE,QAAQ,CAAC,MAAM,MAAM,OAAO,MAAM,MAAM,KAAK,KAAK,IAAI,KAAK,KAAK,CAAE;AAAA,EAC5F;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy",
|
|
3
|
-
"version": "15.21.
|
|
3
|
+
"version": "15.21.2",
|
|
4
4
|
"description": "Straightforward library for building domain-driven microservice architectures",
|
|
5
5
|
"author": "Sander Hoogendoorn",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@thisisagile/easy-test": "15.21.
|
|
36
|
+
"@thisisagile/easy-test": "15.21.2",
|
|
37
37
|
"@types/form-urlencoded": "^4.4.0",
|
|
38
38
|
"@types/jsonwebtoken": "^9.0.6",
|
|
39
39
|
"@types/luxon": "3.4.2",
|
package/src/types/Parser.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { Get, ofGet } from './Get';
|
|
2
|
-
import { isDefined, isEmpty, isIn, isObject, isString } from './Is';
|
|
1
|
+
import { Get, ofGet, Predicate } from './Get';
|
|
2
|
+
import { isDefined, isEmpty, isIn, isObject, isString, isTrue } from './Is';
|
|
3
3
|
import { isValid } from '../validation';
|
|
4
|
-
import { Constructor } from './Constructor';
|
|
4
|
+
import { Constructor, on } from './Constructor';
|
|
5
5
|
import { toArray } from './Array';
|
|
6
6
|
|
|
7
7
|
export class Parser<T, V> {
|
|
8
8
|
if = {
|
|
9
|
+
equals: (pred?: Predicate<T>): this => this.evaluate(isTrue, pred),
|
|
9
10
|
empty: <U>(pred?: Get<U, T>): this => this.evaluate(isEmpty, pred),
|
|
10
11
|
defined: <U>(pred?: Get<U, T>): this => this.evaluate(isDefined, pred),
|
|
11
12
|
valid: <U>(pred?: Get<U, T>): this => this.evaluate(isValid, pred),
|
|
@@ -29,23 +30,16 @@ export class Parser<T, V> {
|
|
|
29
30
|
},
|
|
30
31
|
};
|
|
31
32
|
|
|
32
|
-
constructor(
|
|
33
|
+
constructor(
|
|
34
|
+
protected value: T,
|
|
35
|
+
protected valid = true
|
|
36
|
+
) {}
|
|
33
37
|
|
|
34
38
|
protected evaluate<U>(meta: Get<boolean>, pred?: Get<U, T>): this {
|
|
35
|
-
return
|
|
36
|
-
this.value,
|
|
37
|
-
this.f,
|
|
38
|
-
this.alt,
|
|
39
|
-
ofGet(meta, pred ? ofGet(pred, this.value) : this.value)
|
|
40
|
-
);
|
|
39
|
+
return on(this, t => (t.valid = ofGet(meta, pred ? ofGet(pred, this.value) : this.value)));
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
protected evaluateNot<U>(meta: Get<boolean>, pred?: Get<U, T>): this {
|
|
44
|
-
return
|
|
45
|
-
this.value,
|
|
46
|
-
this.f,
|
|
47
|
-
this.alt,
|
|
48
|
-
!ofGet(meta, pred ? ofGet(pred, this.value) : this.value)
|
|
49
|
-
);
|
|
43
|
+
return on(this, t => (t.valid = !ofGet(meta, pred ? ofGet(pred, this.value) : this.value)));
|
|
50
44
|
}
|
|
51
45
|
}
|