@thisisagile/easy 8.20.0 → 8.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,4 +5,8 @@ export declare class Weight extends Struct {
5
5
  readonly uow: UnitOfWeight;
6
6
  sizeInG: () => number;
7
7
  gte: (w: Weight) => boolean;
8
+ lte: (w: Weight) => boolean;
9
+ between: (lower: Weight, upper?: Weight) => boolean;
10
+ sum: (add: Weight) => Weight;
8
11
  }
12
+ export declare const weight: (value: number, uow?: UnitOfWeight | undefined) => Weight;
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Weight = void 0;
12
+ exports.weight = exports.Weight = void 0;
13
13
  const enums_1 = require("../enums");
14
14
  const validation_1 = require("../../validation");
15
15
  const Struct_1 = require("../Struct");
@@ -20,6 +20,9 @@ class Weight extends Struct_1.Struct {
20
20
  this.uow = enums_1.UnitOfWeight.byId(this.state.uow, enums_1.UnitOfWeight.G);
21
21
  this.sizeInG = () => this.value * this.uow.gMultiplier;
22
22
  this.gte = (w) => this.sizeInG() >= w.sizeInG();
23
+ this.lte = (w) => this.sizeInG() <= w.sizeInG();
24
+ this.between = (lower, upper = (0, exports.weight)(Number.MAX_VALUE, this.uow)) => this.gte(lower) && this.lte(upper);
25
+ this.sum = (add) => (0, exports.weight)((this.sizeInG() + add.sizeInG()) / this.uow.gMultiplier, this.uow);
23
26
  }
24
27
  }
25
28
  __decorate([
@@ -27,4 +30,6 @@ __decorate([
27
30
  __metadata("design:type", Number)
28
31
  ], Weight.prototype, "value", void 0);
29
32
  exports.Weight = Weight;
33
+ const weight = (value, uow) => new Weight({ value, uow });
34
+ exports.weight = weight;
30
35
  //# sourceMappingURL=Weight.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Weight.js","sourceRoot":"","sources":["../../../src/domain/structs/Weight.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAAwC;AACxC,iDAA4C;AAC5C,sCAAmC;AAEnC,MAAa,MAAO,SAAQ,eAAM;IAAlC;;QACuB,UAAK,GAAW,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QAC7C,QAAG,GAAiB,oBAAY,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,oBAAY,CAAC,CAAC,CAAC,CAAC;QAC/E,YAAO,GAAG,GAAW,EAAE,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;QAE1D,QAAG,GAAG,CAAC,CAAS,EAAW,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;IAC9D,CAAC;CAAA;AALa;IAAX,IAAA,qBAAQ,GAAE;;qCAA2C;AADxD,wBAMC"}
1
+ {"version":3,"file":"Weight.js","sourceRoot":"","sources":["../../../src/domain/structs/Weight.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAAwC;AACxC,iDAA4C;AAC5C,sCAAmC;AAEnC,MAAa,MAAO,SAAQ,eAAM;IAAlC;;QACuB,UAAK,GAAW,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QAC7C,QAAG,GAAiB,oBAAY,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,oBAAY,CAAC,CAAC,CAAC,CAAC;QAC/E,YAAO,GAAG,GAAW,EAAE,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;QAE1D,QAAG,GAAG,CAAC,CAAS,EAAW,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;QAE5D,QAAG,GAAG,CAAC,CAAS,EAAW,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;QAG5D,YAAO,GAAG,CAAC,KAAa,EAAE,KAAK,GAAG,IAAA,cAAM,EAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC5G,QAAG,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,IAAA,cAAM,EAAC,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3G,CAAC;CAAA;AAXa;IAAX,IAAA,qBAAQ,GAAE;;qCAA2C;AADxD,wBAYC;AAEM,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,GAAkB,EAAU,EAAE,CAAC,IAAI,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;AAAnF,QAAA,MAAM,UAA6E"}
@@ -0,0 +1,2 @@
1
+ import { Get } from './Get';
2
+ export declare const asNumber: (n: unknown, alt?: Get<number, any> | undefined) => number;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asNumber = void 0;
4
+ const Get_1 = require("./Get");
5
+ const Try_1 = require("./Try");
6
+ const Is_1 = require("./Is");
7
+ const Text_1 = require("./Text");
8
+ const asNumber = (n, alt) => (0, Try_1.tryTo)(() => (0, Text_1.asString)(n)).map(s => parseInt(s)).filter(n => (0, Is_1.isNumber)(n)).or((0, Get_1.ofGet)(alt) ?? NaN);
9
+ exports.asNumber = asNumber;
10
+ //# sourceMappingURL=Number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Number.js","sourceRoot":"","sources":["../../src/types/Number.ts"],"names":[],"mappings":";;;AAAA,+BAAmC;AACnC,+BAA8B;AAC9B,6BAAgC;AAChC,iCAAkC;AAE3B,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAE,GAAiB,EAAU,EAAE,CAAC,IAAA,WAAK,EAAC,GAAG,EAAE,CAAC,IAAA,eAAQ,EAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,aAAQ,EAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,WAAK,EAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;AAApJ,QAAA,QAAQ,YAA4I"}
@@ -17,6 +17,7 @@ export * from './Json';
17
17
  export * from './List';
18
18
  export * from './Message';
19
19
  export * from './Meta';
20
+ export * from './Number';
20
21
  export * from './Result';
21
22
  export * from './Results';
22
23
  export * from './Tag';
@@ -29,6 +29,7 @@ __exportStar(require("./Json"), exports);
29
29
  __exportStar(require("./List"), exports);
30
30
  __exportStar(require("./Message"), exports);
31
31
  __exportStar(require("./Meta"), exports);
32
+ __exportStar(require("./Number"), exports);
32
33
  __exportStar(require("./Result"), exports);
33
34
  __exportStar(require("./Results"), exports);
34
35
  __exportStar(require("./Tag"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAwB;AACxB,4CAA0B;AAC1B,gDAA8B;AAC9B,4CAA0B;AAC1B,yCAAuB;AACvB,gDAA8B;AAC9B,8CAA4B;AAC5B,yCAAuB;AACvB,4CAA0B;AAC1B,wCAAsB;AACtB,uCAAqB;AACrB,6CAA2B;AAC3B,uCAAqB;AACrB,wCAAsB;AACtB,2CAAyB;AACzB,yCAAuB;AACvB,yCAAuB;AACvB,4CAA0B;AAC1B,yCAAuB;AACvB,2CAAyB;AACzB,4CAA0B;AAC1B,wCAAsB;AACtB,6CAA2B;AAC3B,yCAAuB;AACvB,wCAAsB;AACtB,wCAAsB;AACtB,yCAAuB;AACvB,gDAA8B;AAC9B,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAwB;AACxB,4CAA0B;AAC1B,gDAA8B;AAC9B,4CAA0B;AAC1B,yCAAuB;AACvB,gDAA8B;AAC9B,8CAA4B;AAC5B,yCAAuB;AACvB,4CAA0B;AAC1B,wCAAsB;AACtB,uCAAqB;AACrB,6CAA2B;AAC3B,uCAAqB;AACrB,wCAAsB;AACtB,2CAAyB;AACzB,yCAAuB;AACvB,yCAAuB;AACvB,4CAA0B;AAC1B,yCAAuB;AACvB,2CAAyB;AACzB,2CAAyB;AACzB,4CAA0B;AAC1B,wCAAsB;AACtB,6CAA2B;AAC3B,yCAAuB;AACvB,wCAAsB;AACtB,wCAAsB;AACtB,yCAAuB;AACvB,gDAA8B;AAC9B,0CAAwB"}
@@ -1,5 +1,5 @@
1
1
  import { Id, Text } from '../types';
2
- export declare class Sentence {
2
+ export declare class Sentence implements Text {
3
3
  private sentence;
4
4
  constructor(word: Text, pre?: Sentence, sentence?: Text[]);
5
5
  toString(): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisisagile/easy",
3
- "version": "8.20.0",
3
+ "version": "8.23.0",
4
4
  "description": "Straightforward library for building domain-driven microservice architectures",
5
5
  "author": "Sander Hoogendoorn",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "devDependencies": {
34
- "@thisisagile/easy-test": "8.20.0",
34
+ "@thisisagile/easy-test": "8.23.0",
35
35
  "@types/form-urlencoded": "^4.4.0",
36
36
  "@types/jsonwebtoken": "^8.5.8",
37
37
  "@types/validator": "^13.7.0"
@@ -8,4 +8,12 @@ export class Weight extends Struct {
8
8
  sizeInG = (): number => this.value * this.uow.gMultiplier;
9
9
 
10
10
  gte = (w: Weight): boolean => this.sizeInG() >= w.sizeInG();
11
- }
11
+ // gt = (w: Weight): boolean => this.sizeInG() > w.sizeInG();
12
+ lte = (w: Weight): boolean => this.sizeInG() <= w.sizeInG();
13
+ // lt = (w: Weight): boolean => this.sizeInG() < w.sizeInG();
14
+
15
+ between = (lower: Weight, upper = weight(Number.MAX_VALUE, this.uow)) => this.gte(lower) && this.lte(upper);
16
+ sum = (add: Weight): Weight => weight((this.sizeInG() + add.sizeInG()) / this.uow.gMultiplier, this.uow);
17
+ }
18
+
19
+ export const weight = (value: number, uow?: UnitOfWeight): Weight => new Weight({ value, uow });
@@ -0,0 +1,6 @@
1
+ import { Get, ofGet } from './Get';
2
+ import { tryTo } from './Try';
3
+ import { isNumber } from './Is';
4
+ import { asString } from './Text';
5
+
6
+ export const asNumber = (n: unknown, alt?: Get<number>): number => tryTo(() => asString(n)).map(s => parseInt(s)).filter(n => isNumber(n)).or(ofGet(alt) ?? NaN);
@@ -17,6 +17,7 @@ export * from './Json';
17
17
  export * from './List';
18
18
  export * from './Message';
19
19
  export * from './Meta';
20
+ export * from './Number';
20
21
  export * from './Result';
21
22
  export * from './Results';
22
23
  export * from './Tag';
@@ -1,6 +1,6 @@
1
1
  import { Id, text, Text } from '../types';
2
2
 
3
- export class Sentence {
3
+ export class Sentence implements Text {
4
4
  constructor(word: Text, pre?: Sentence, private sentence: Text[] = (pre?.sentence ?? []).concat(word)) {}
5
5
 
6
6
  toString(): string {