@thisisagile/easy 8.22.2 → 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.
@@ -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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisisagile/easy",
3
- "version": "8.22.2",
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.22.2",
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"
@@ -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';