@jonloucks/contracts-ts 1.3.0 → 2.0.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.
- package/README.md +69 -21
- package/api/AutoClose.d.ts +2 -2
- package/api/AutoClose.d.ts.map +1 -1
- package/api/AutoClose.js +15 -23
- package/api/AutoClose.js.map +1 -1
- package/api/AutoCloseFactory.d.ts +3 -3
- package/api/AutoCloseFactory.d.ts.map +1 -1
- package/api/AutoCloseFactory.js +5 -9
- package/api/AutoCloseFactory.js.map +1 -1
- package/api/AutoOpen.js +3 -6
- package/api/AutoOpen.js.map +1 -1
- package/api/BasicContract.js +6 -11
- package/api/BasicContract.js.map +1 -1
- package/api/BindStrategy.js +4 -9
- package/api/BindStrategy.js.map +1 -1
- package/api/Contract.js +3 -6
- package/api/Contract.js.map +1 -1
- package/api/ContractException.js +5 -10
- package/api/ContractException.js.map +1 -1
- package/api/ContractFactory.js +3 -6
- package/api/ContractFactory.js.map +1 -1
- package/api/Contracts.d.ts +1 -1
- package/api/Contracts.d.ts.map +1 -1
- package/api/Contracts.js +4 -7
- package/api/Contracts.js.map +1 -1
- package/api/ContractsFactory.js +3 -6
- package/api/ContractsFactory.js.map +1 -1
- package/api/Convenience.d.ts +21 -16
- package/api/Convenience.d.ts.map +1 -1
- package/api/Convenience.js +17 -35
- package/api/Convenience.js.map +1 -1
- package/api/Open.d.ts.map +1 -1
- package/api/Open.js +9 -13
- package/api/Open.js.map +1 -1
- package/api/Promisor.d.ts +9 -5
- package/api/Promisor.d.ts.map +1 -1
- package/api/Promisor.js +18 -23
- package/api/Promisor.js.map +1 -1
- package/api/PromisorFactory.d.ts +3 -2
- package/api/PromisorFactory.d.ts.map +1 -1
- package/api/PromisorFactory.js +5 -9
- package/api/PromisorFactory.js.map +1 -1
- package/api/RatifiedContract.js +11 -16
- package/api/RatifiedContract.js.map +1 -1
- package/api/Repository.d.ts +2 -2
- package/api/Repository.d.ts.map +1 -1
- package/api/Repository.js +4 -7
- package/api/Repository.js.map +1 -1
- package/api/RepositoryFactory.js +5 -9
- package/api/RepositoryFactory.js.map +1 -1
- package/api/Types.d.ts +0 -24
- package/api/Types.d.ts.map +1 -1
- package/api/Types.js +13 -62
- package/api/Types.js.map +1 -1
- package/auxiliary/AtomicBoolean.js +3 -6
- package/auxiliary/AtomicBoolean.js.map +1 -1
- package/auxiliary/AtomicBooleanFactory.js +5 -9
- package/auxiliary/AtomicBooleanFactory.js.map +1 -1
- package/auxiliary/AtomicInteger.js +3 -6
- package/auxiliary/AtomicInteger.js.map +1 -1
- package/auxiliary/AtomicIntegerFactory.js +5 -9
- package/auxiliary/AtomicIntegerFactory.js.map +1 -1
- package/auxiliary/AtomicReference.js +3 -6
- package/auxiliary/AtomicReference.js.map +1 -1
- package/auxiliary/AtomicReferenceFactory.js +5 -9
- package/auxiliary/AtomicReferenceFactory.js.map +1 -1
- package/auxiliary/Checks.js +23 -36
- package/auxiliary/Checks.js.map +1 -1
- package/auxiliary/Consumer.js +7 -12
- package/auxiliary/Consumer.js.map +1 -1
- package/auxiliary/Convenience.d.ts +10 -6
- package/auxiliary/Convenience.d.ts.map +1 -1
- package/auxiliary/Convenience.js +17 -19
- package/auxiliary/Convenience.js.map +1 -1
- package/auxiliary/IdempotenState.d.ts +1 -1
- package/auxiliary/IdempotenState.d.ts.map +1 -1
- package/auxiliary/IdempotenState.js +2 -5
- package/auxiliary/IdempotenState.js.map +1 -1
- package/auxiliary/Idempotent.js +3 -6
- package/auxiliary/Idempotent.js.map +1 -1
- package/auxiliary/IdempotentFactory.js +5 -9
- package/auxiliary/IdempotentFactory.js.map +1 -1
- package/auxiliary/IllegalArgumentException.js +4 -8
- package/auxiliary/IllegalArgumentException.js.map +1 -1
- package/auxiliary/IllegalStateException.js +4 -8
- package/auxiliary/IllegalStateException.js.map +1 -1
- package/auxiliary/Predicate.js +9 -15
- package/auxiliary/Predicate.js.map +1 -1
- package/auxiliary/Supplier.js +10 -16
- package/auxiliary/Supplier.js.map +1 -1
- package/auxiliary/Transform.js +11 -18
- package/auxiliary/Transform.js.map +1 -1
- package/auxiliary/Validate.js +12 -15
- package/auxiliary/Validate.js.map +1 -1
- package/impl/AtomicBoolean.impl.js +1 -4
- package/impl/AtomicBoolean.impl.js.map +1 -1
- package/impl/AtomicBooleanFactory.impl.js +3 -6
- package/impl/AtomicBooleanFactory.impl.js.map +1 -1
- package/impl/AtomicInteger.impl.js +1 -4
- package/impl/AtomicInteger.impl.js.map +1 -1
- package/impl/AtomicIntegerFactory.impl.js +3 -6
- package/impl/AtomicIntegerFactory.impl.js.map +1 -1
- package/impl/AtomicReference.impl.js +2 -7
- package/impl/AtomicReference.impl.js.map +1 -1
- package/impl/AtomicReferenceFactory.impl.js +3 -6
- package/impl/AtomicReferenceFactory.impl.js.map +1 -1
- package/impl/AutoCloseFactory.impl.d.ts +0 -3
- package/impl/AutoCloseFactory.impl.d.ts.map +1 -1
- package/impl/AutoCloseFactory.impl.js +7 -10
- package/impl/AutoCloseFactory.impl.js.map +1 -1
- package/impl/AutoCloseMany.impl.d.ts +0 -2
- package/impl/AutoCloseMany.impl.d.ts.map +1 -1
- package/impl/AutoCloseMany.impl.js +5 -8
- package/impl/AutoCloseMany.impl.js.map +1 -1
- package/impl/AutoCloseOne.impl.d.ts.map +1 -1
- package/impl/AutoCloseOne.impl.js +8 -11
- package/impl/AutoCloseOne.impl.js.map +1 -1
- package/impl/ContractFactory.impl.js +7 -11
- package/impl/ContractFactory.impl.js.map +1 -1
- package/impl/Contracts.impl.d.ts.map +1 -1
- package/impl/Contracts.impl.js +38 -41
- package/impl/Contracts.impl.js.map +1 -1
- package/impl/ContractsFactory.impl.js +28 -32
- package/impl/ContractsFactory.impl.js.map +1 -1
- package/impl/ContractsWrapper.impl.js +3 -6
- package/impl/ContractsWrapper.impl.js.map +1 -1
- package/impl/Events.d.ts +1 -2
- package/impl/Events.d.ts.map +1 -1
- package/impl/Events.impl.d.ts +1 -2
- package/impl/Events.impl.d.ts.map +1 -1
- package/impl/Events.impl.js +6 -9
- package/impl/Events.impl.js.map +1 -1
- package/impl/Events.js +1 -2
- package/impl/Events.js.map +1 -1
- package/impl/ExtractorPromisor.impl.d.ts +2 -1
- package/impl/ExtractorPromisor.impl.d.ts.map +1 -1
- package/impl/ExtractorPromisor.impl.js +6 -9
- package/impl/ExtractorPromisor.impl.js.map +1 -1
- package/impl/Idempotent.impl.js +10 -13
- package/impl/Idempotent.impl.js.map +1 -1
- package/impl/IdempotentFactory.impl.js +5 -8
- package/impl/IdempotentFactory.impl.js.map +1 -1
- package/impl/Internal.impl.js +5 -8
- package/impl/Internal.impl.js.map +1 -1
- package/impl/LifeCyclePromisor.impl.js +19 -22
- package/impl/LifeCyclePromisor.impl.js.map +1 -1
- package/impl/Policy.d.ts +0 -1
- package/impl/Policy.d.ts.map +1 -1
- package/impl/Policy.impl.d.ts +1 -3
- package/impl/Policy.impl.d.ts.map +1 -1
- package/impl/Policy.impl.js +7 -10
- package/impl/Policy.impl.js.map +1 -1
- package/impl/Policy.js +1 -2
- package/impl/PromisorFactory.impl.d.ts.map +1 -1
- package/impl/PromisorFactory.impl.js +11 -14
- package/impl/PromisorFactory.impl.js.map +1 -1
- package/impl/Repository.impl.d.ts.map +1 -1
- package/impl/Repository.impl.js +19 -22
- package/impl/Repository.impl.js.map +1 -1
- package/impl/RepositoryFactory.impl.js +3 -6
- package/impl/RepositoryFactory.impl.js.map +1 -1
- package/impl/SingletonPromisor.impl.js +7 -10
- package/impl/SingletonPromisor.impl.js.map +1 -1
- package/impl/Storage.impl.js +3 -7
- package/impl/Storage.impl.js.map +1 -1
- package/impl/ValuePromisor.impl.js +1 -4
- package/impl/ValuePromisor.impl.js.map +1 -1
- package/index.d.ts +8 -20
- package/index.d.ts.map +1 -1
- package/index.js +10 -38
- package/index.js.map +1 -1
- package/package.json +10 -14
- package/version.js +2 -5
- package/version.js.map +1 -1
- package/auxiliary/Functional.d.ts +0 -9
- package/auxiliary/Functional.d.ts.map +0 -1
- package/auxiliary/Functional.js +0 -23
- package/auxiliary/Functional.js.map +0 -1
package/auxiliary/Consumer.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Consumer.ts
|
|
4
3
|
* Candidate for inclusion in api-ts
|
|
5
4
|
* Defines a Consumer type that can consume values of type T.
|
|
6
5
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.fromType = fromType;
|
|
10
|
-
exports.check = check;
|
|
11
|
-
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
12
|
-
const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
6
|
+
import { guardFunctions } from "@jonloucks/contracts-ts/api/Types";
|
|
7
|
+
import { presentCheck } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
13
8
|
/**
|
|
14
9
|
* Duck type guard check for Consumer
|
|
15
10
|
*
|
|
@@ -17,8 +12,8 @@ const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
|
17
12
|
* @param <T> the type of value consumed
|
|
18
13
|
* @returns true if instance is a Consumer, false otherwise
|
|
19
14
|
*/
|
|
20
|
-
function guard(instance) {
|
|
21
|
-
return
|
|
15
|
+
export function guard(instance) {
|
|
16
|
+
return guardFunctions(instance, 'consume');
|
|
22
17
|
}
|
|
23
18
|
/**
|
|
24
19
|
* Convert a Type to a Consumer
|
|
@@ -27,7 +22,7 @@ function guard(instance) {
|
|
|
27
22
|
* @param <T> the type of value consumed
|
|
28
23
|
* @returns a Consumer that consumes values of type T
|
|
29
24
|
*/
|
|
30
|
-
function fromType(type) {
|
|
25
|
+
export function fromType(type) {
|
|
31
26
|
if (guard(type)) {
|
|
32
27
|
return type;
|
|
33
28
|
}
|
|
@@ -44,7 +39,7 @@ function fromType(type) {
|
|
|
44
39
|
* @return the consumer if present
|
|
45
40
|
* @throws IllegalArgumentException if the consumer is not present
|
|
46
41
|
*/
|
|
47
|
-
function check(consumer) {
|
|
48
|
-
return
|
|
42
|
+
export function check(consumer) {
|
|
43
|
+
return presentCheck(consumer, "Consumer must be present.");
|
|
49
44
|
}
|
|
50
45
|
//# sourceMappingURL=Consumer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Consumer.js","sourceRoot":"","sources":["../../src/auxiliary/Consumer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Consumer.js","sourceRoot":"","sources":["../../src/auxiliary/Consumer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAgB,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAiBxE;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAI,QAAiB;IACxC,OAAO,cAAc,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAI,IAAa;IACvC,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,CAAC;QACN,OAAO;YACL,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAI,QAAiB;IACxC,OAAO,YAAY,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
2
|
-
import { AtomicBoolean } from "@jonloucks/contracts-ts/auxiliary/AtomicBoolean";
|
|
3
|
-
import { AtomicReference } from "@jonloucks/contracts-ts/auxiliary/AtomicReference";
|
|
4
|
-
import { AtomicInteger } from "@jonloucks/contracts-ts/auxiliary/AtomicInteger";
|
|
5
|
-
import { Idempotent, Config as IdempotentConfig } from "@jonloucks/contracts-ts/auxiliary/Idempotent";
|
|
6
|
-
export { AtomicBoolean, AtomicReference, AtomicInteger, RequiredType, Idempotent, IdempotentConfig };
|
|
7
1
|
/**
|
|
8
2
|
* @module Convenience
|
|
9
3
|
* @description
|
|
@@ -17,6 +11,15 @@ export { AtomicBoolean, AtomicReference, AtomicInteger, RequiredType, Idempotent
|
|
|
17
11
|
* import from this module. Instead, they should import directly from the
|
|
18
12
|
* source modules of the auxiliary types.
|
|
19
13
|
*/
|
|
14
|
+
import { RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
15
|
+
import { AtomicBoolean } from "@jonloucks/contracts-ts/auxiliary/AtomicBoolean";
|
|
16
|
+
import { AtomicReference } from "@jonloucks/contracts-ts/auxiliary/AtomicReference";
|
|
17
|
+
import { AtomicInteger } from "@jonloucks/contracts-ts/auxiliary/AtomicInteger";
|
|
18
|
+
import { Idempotent, Config as IdempotentConfig } from "@jonloucks/contracts-ts/auxiliary/Idempotent";
|
|
19
|
+
export { type Consumer, type Method as ConsumerFunction, type Type as ConsumerType, guard as consumerGuard, fromType as consumerFromType, check as consumerCheck } from "@jonloucks/contracts-ts/auxiliary/Consumer";
|
|
20
|
+
export { type Predicate, type Method as PredicateFunction, type Type as PredicateType, guard as predicateGuard, fromType as predicateFromType, check as predicateCheck, toValue as predicateToValue } from "@jonloucks/contracts-ts/auxiliary/Predicate";
|
|
21
|
+
export { type Supplier, type Method as SupplierFunction, type Type as SupplierType, guard as supplierGuard, fromType as supplierFromType, check as supplierCheck, toValue as supplierToValue } from "@jonloucks/contracts-ts/auxiliary/Supplier";
|
|
22
|
+
export { type Transform, type Method as TransformFunction, type Type as TransformType, guard as transformGuard, fromType as transformFromType, check as transformCheck, toValue as transformToValue } from "@jonloucks/contracts-ts/auxiliary/Transform";
|
|
20
23
|
/**
|
|
21
24
|
* Create an AtomicBoolean via the shared global CONTRACTS instance.
|
|
22
25
|
*
|
|
@@ -45,4 +48,5 @@ export declare function createAtomicInteger(initialValue?: number): RequiredType
|
|
|
45
48
|
* @returns the Idempotent instance
|
|
46
49
|
*/
|
|
47
50
|
export declare function createIdempotent(config: IdempotentConfig): RequiredType<Idempotent>;
|
|
51
|
+
export { type AtomicBoolean, type AtomicReference, type AtomicInteger, type RequiredType, type Idempotent, type IdempotentConfig };
|
|
48
52
|
//# sourceMappingURL=Convenience.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Convenience.d.ts","sourceRoot":"","sources":["../../src/auxiliary/Convenience.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAMjE,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAEtG,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"Convenience.d.ts","sourceRoot":"","sources":["../../src/auxiliary/Convenience.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAMjE,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAEtG,OAAO,EACL,KAAK,QAAQ,EAAE,KAAK,MAAM,IAAI,gBAAgB,EAAE,KAAK,IAAI,IAAI,YAAY,EACzE,KAAK,IAAI,aAAa,EAAE,QAAQ,IAAI,gBAAgB,EAAE,KAAK,IAAI,aAAa,EAC7E,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EACL,KAAK,SAAS,EAAE,KAAK,MAAM,IAAI,iBAAiB,EAAE,KAAK,IAAI,IAAI,aAAa,EAC5E,KAAK,IAAI,cAAc,EAAE,QAAQ,IAAI,iBAAiB,EAAE,KAAK,IAAI,cAAc,EAAE,OAAO,IAAI,gBAAgB,EAC7G,MAAM,6CAA6C,CAAC;AAErD,OAAO,EACL,KAAK,QAAQ,EAAE,KAAK,MAAM,IAAI,gBAAgB,EAAE,KAAK,IAAI,IAAI,YAAY,EACzE,KAAK,IAAI,aAAa,EAAE,QAAQ,IAAI,gBAAgB,EAAE,KAAK,IAAI,aAAa,EAAE,OAAO,IAAI,eAAe,EACzG,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EACL,KAAK,SAAS,EAAE,KAAK,MAAM,IAAI,iBAAiB,EAAE,KAAK,IAAI,IAAI,aAAa,EAC1E,KAAK,IAAI,cAAc,EAAE,QAAQ,IAAI,iBAAiB,EAAE,KAAK,IAAI,cAAc,EAAE,OAAO,IAAI,gBAAgB,EAC/G,MAAM,6CAA6C,CAAC;AAErD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,YAAY,CAAC,aAAa,CAAC,CAEvF;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAE3F;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,aAAa,CAAC,CAEtF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,YAAY,CAAC,UAAU,CAAC,CAEnF;AAED,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACtB,CAAC"}
|
package/auxiliary/Convenience.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAtomicBoolean = createAtomicBoolean;
|
|
4
|
-
exports.createAtomicReference = createAtomicReference;
|
|
5
|
-
exports.createAtomicInteger = createAtomicInteger;
|
|
6
|
-
exports.createIdempotent = createIdempotent;
|
|
7
|
-
const contracts_ts_1 = require("@jonloucks/contracts-ts");
|
|
8
|
-
const AtomicBooleanFactory_1 = require("@jonloucks/contracts-ts/auxiliary/AtomicBooleanFactory");
|
|
9
|
-
const AtomicReferenceFactory_1 = require("@jonloucks/contracts-ts/auxiliary/AtomicReferenceFactory");
|
|
10
|
-
const AtomicIntegerFactory_1 = require("@jonloucks/contracts-ts/auxiliary/AtomicIntegerFactory");
|
|
11
|
-
const IdempotentFactory_1 = require("@jonloucks/contracts-ts/auxiliary/IdempotentFactory");
|
|
12
1
|
/**
|
|
13
2
|
* @module Convenience
|
|
14
3
|
* @description
|
|
@@ -22,14 +11,23 @@ const IdempotentFactory_1 = require("@jonloucks/contracts-ts/auxiliary/Idempoten
|
|
|
22
11
|
* import from this module. Instead, they should import directly from the
|
|
23
12
|
* source modules of the auxiliary types.
|
|
24
13
|
*/
|
|
14
|
+
import { CONTRACTS } from "@jonloucks/contracts-ts";
|
|
15
|
+
import { CONTRACT as BOOLEAN_FACTORY } from "@jonloucks/contracts-ts/auxiliary/AtomicBooleanFactory";
|
|
16
|
+
import { CONTRACT as REFERENCE_FACTORY } from "@jonloucks/contracts-ts/auxiliary/AtomicReferenceFactory";
|
|
17
|
+
import { CONTRACT as INTEGER_FACTORY } from "@jonloucks/contracts-ts/auxiliary/AtomicIntegerFactory";
|
|
18
|
+
import { CONTRACT as IDEMPOTENT_FACTORY } from "@jonloucks/contracts-ts/auxiliary/IdempotentFactory";
|
|
19
|
+
export { guard as consumerGuard, fromType as consumerFromType, check as consumerCheck } from "@jonloucks/contracts-ts/auxiliary/Consumer";
|
|
20
|
+
export { guard as predicateGuard, fromType as predicateFromType, check as predicateCheck, toValue as predicateToValue } from "@jonloucks/contracts-ts/auxiliary/Predicate";
|
|
21
|
+
export { guard as supplierGuard, fromType as supplierFromType, check as supplierCheck, toValue as supplierToValue } from "@jonloucks/contracts-ts/auxiliary/Supplier";
|
|
22
|
+
export { guard as transformGuard, fromType as transformFromType, check as transformCheck, toValue as transformToValue } from "@jonloucks/contracts-ts/auxiliary/Transform";
|
|
25
23
|
/**
|
|
26
24
|
* Create an AtomicBoolean via the shared global CONTRACTS instance.
|
|
27
25
|
*
|
|
28
26
|
* @param initialValue the initial boolean value
|
|
29
27
|
* @returns the AtomicBoolean instance
|
|
30
28
|
*/
|
|
31
|
-
function createAtomicBoolean(initialValue) {
|
|
32
|
-
return
|
|
29
|
+
export function createAtomicBoolean(initialValue) {
|
|
30
|
+
return CONTRACTS.enforce(BOOLEAN_FACTORY).createAtomicBoolean(initialValue);
|
|
33
31
|
}
|
|
34
32
|
/**
|
|
35
33
|
* Create an AtomicReference via the shared global CONTRACTS instance.
|
|
@@ -37,8 +35,8 @@ function createAtomicBoolean(initialValue) {
|
|
|
37
35
|
* @param initialValue the initial reference value
|
|
38
36
|
* @returns the AtomicReference instance
|
|
39
37
|
*/
|
|
40
|
-
function createAtomicReference(initialValue) {
|
|
41
|
-
return
|
|
38
|
+
export function createAtomicReference(initialValue) {
|
|
39
|
+
return CONTRACTS.enforce(REFERENCE_FACTORY).createAtomicReference(initialValue);
|
|
42
40
|
}
|
|
43
41
|
/**
|
|
44
42
|
* Create an AtomicInteger via the shared global CONTRACTS instance.
|
|
@@ -46,8 +44,8 @@ function createAtomicReference(initialValue) {
|
|
|
46
44
|
* @param initialValue the initial integer value
|
|
47
45
|
* @returns the AtomicInteger instance
|
|
48
46
|
*/
|
|
49
|
-
function createAtomicInteger(initialValue) {
|
|
50
|
-
return
|
|
47
|
+
export function createAtomicInteger(initialValue) {
|
|
48
|
+
return CONTRACTS.enforce(INTEGER_FACTORY).createAtomicInteger(initialValue);
|
|
51
49
|
}
|
|
52
50
|
/**
|
|
53
51
|
* Create an Idempotent via the shared global CONTRACTS instance.
|
|
@@ -55,7 +53,7 @@ function createAtomicInteger(initialValue) {
|
|
|
55
53
|
* @param config the idempotent configuration
|
|
56
54
|
* @returns the Idempotent instance
|
|
57
55
|
*/
|
|
58
|
-
function createIdempotent(config) {
|
|
59
|
-
return
|
|
56
|
+
export function createIdempotent(config) {
|
|
57
|
+
return CONTRACTS.enforce(IDEMPOTENT_FACTORY).createIdempotent(config);
|
|
60
58
|
}
|
|
61
59
|
//# sourceMappingURL=Convenience.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Convenience.js","sourceRoot":"","sources":["../../src/auxiliary/Convenience.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Convenience.js","sourceRoot":"","sources":["../../src/auxiliary/Convenience.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,wDAAwD,CAAC;AACrG,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,0DAA0D,CAAC;AACzG,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,wDAAwD,CAAC;AACrG,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AAMrG,OAAO,EAEL,KAAK,IAAI,aAAa,EAAE,QAAQ,IAAI,gBAAgB,EAAE,KAAK,IAAI,aAAa,EAC7E,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAEL,KAAK,IAAI,cAAc,EAAE,QAAQ,IAAI,iBAAiB,EAAE,KAAK,IAAI,cAAc,EAAE,OAAO,IAAI,gBAAgB,EAC7G,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAEL,KAAK,IAAI,aAAa,EAAE,QAAQ,IAAI,gBAAgB,EAAE,KAAK,IAAI,aAAa,EAAE,OAAO,IAAI,eAAe,EACzG,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAEH,KAAK,IAAI,cAAc,EAAE,QAAQ,IAAI,iBAAiB,EAAE,KAAK,IAAI,cAAc,EAAE,OAAO,IAAI,gBAAgB,EAC/G,MAAM,6CAA6C,CAAC;AAErD;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,YAAsB;IACxD,OAAO,SAAS,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAI,YAAgB;IACvD,OAAO,SAAS,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;AAClF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,YAAqB;IACvD,OAAO,SAAS,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAwB;IACvD,OAAO,SAAS,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -5,7 +5,7 @@ export declare const STATES: readonly ["OPENABLE", "OPENING", "OPENED", "CLOSING
|
|
|
5
5
|
/** The possible states of an Idempotent */
|
|
6
6
|
export type State = typeof STATES[number];
|
|
7
7
|
/** The IdempotentState type */
|
|
8
|
-
export { State as IdempotentState };
|
|
8
|
+
export { type State as IdempotentState };
|
|
9
9
|
/** The starting state for an Idempotent */
|
|
10
10
|
export declare const START_STATE: State;
|
|
11
11
|
//# sourceMappingURL=IdempotenState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdempotenState.d.ts","sourceRoot":"","sources":["../../src/auxiliary/IdempotenState.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,MAAM,8EAA+E,CAAC;AAEnG,2CAA2C;AAC3C,MAAM,MAAM,KAAK,GAAG,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;AAE1C,+BAA+B;AAC/B,OAAO,EAAE,KAAK,IAAI,eAAe,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"IdempotenState.d.ts","sourceRoot":"","sources":["../../src/auxiliary/IdempotenState.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,MAAM,8EAA+E,CAAC;AAEnG,2CAA2C;AAC3C,MAAM,MAAM,KAAK,GAAG,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;AAE1C,+BAA+B;AAC/B,OAAO,EAAE,KAAK,KAAK,IAAI,eAAe,EAAE,CAAC;AAEzC,2CAA2C;AAC3C,eAAO,MAAM,WAAW,EAAE,KAAkB,CAAC"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.START_STATE = exports.STATES = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* The possible states of an Idempotent
|
|
6
3
|
*/
|
|
7
|
-
|
|
4
|
+
export const STATES = ['OPENABLE', 'OPENING', 'OPENED', 'CLOSING', 'CLOSED', 'DESTROYED'];
|
|
8
5
|
/** The starting state for an Idempotent */
|
|
9
|
-
|
|
6
|
+
export const START_STATE = 'OPENABLE';
|
|
10
7
|
//# sourceMappingURL=IdempotenState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdempotenState.js","sourceRoot":"","sources":["../../src/auxiliary/IdempotenState.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IdempotenState.js","sourceRoot":"","sources":["../../src/auxiliary/IdempotenState.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAU,CAAC;AAQnG,2CAA2C;AAC3C,MAAM,CAAC,MAAM,WAAW,GAAU,UAAU,CAAC"}
|
package/auxiliary/Idempotent.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.guard = guard;
|
|
4
|
-
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
1
|
+
import { guardFunctions } from "@jonloucks/contracts-ts/api/Types";
|
|
5
2
|
/**
|
|
6
3
|
* Determine if an instance implements Idempotent
|
|
7
4
|
*
|
|
8
5
|
* @param instance the instance to check
|
|
9
6
|
* @returns true if the instance implements Idempotent
|
|
10
7
|
*/
|
|
11
|
-
function guard(instance) {
|
|
12
|
-
return
|
|
8
|
+
export function guard(instance) {
|
|
9
|
+
return guardFunctions(instance, 'getState', 'open', 'isOpen');
|
|
13
10
|
}
|
|
14
11
|
//# sourceMappingURL=Idempotent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Idempotent.js","sourceRoot":"","sources":["../../src/auxiliary/Idempotent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Idempotent.js","sourceRoot":"","sources":["../../src/auxiliary/Idempotent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAgB,MAAM,mCAAmC,CAAC;AAkCjF;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,QAAiB;IACrC,OAAO,cAAc,CAAC,QAAQ,EAC5B,UAAU,EACV,MAAM,EACN,QAAQ,CACT,CAAC;AACJ,CAAC"}
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.CONTRACT = void 0;
|
|
4
|
-
exports.guard = guard;
|
|
5
|
-
const RatifiedContract_1 = require("@jonloucks/contracts-ts/api/RatifiedContract");
|
|
6
|
-
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
1
|
+
import { create as createContract } from "@jonloucks/contracts-ts/api/RatifiedContract";
|
|
2
|
+
import { guardFunctions } from "@jonloucks/contracts-ts/api/Types";
|
|
7
3
|
/**
|
|
8
4
|
* Determine if the given instance is a IdempotentFactory
|
|
9
5
|
*
|
|
10
6
|
* @param instance the instance to check
|
|
11
7
|
* @return true if the instance is a IdempotentFactory
|
|
12
8
|
*/
|
|
13
|
-
function guard(instance) {
|
|
14
|
-
return
|
|
9
|
+
export function guard(instance) {
|
|
10
|
+
return guardFunctions(instance, 'createIdempotent');
|
|
15
11
|
}
|
|
16
12
|
/**
|
|
17
13
|
* Contract for IdempotentFactory
|
|
18
14
|
*/
|
|
19
|
-
|
|
15
|
+
export const CONTRACT = createContract({
|
|
20
16
|
name: "IdempotentFactory",
|
|
21
17
|
test: guard
|
|
22
18
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdempotentFactory.js","sourceRoot":"","sources":["../../src/auxiliary/IdempotentFactory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IdempotentFactory.js","sourceRoot":"","sources":["../../src/auxiliary/IdempotentFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAExF,OAAO,EAAgB,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAkBjF;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,QAAiB;IACrC,OAAO,cAAc,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;AACtD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAgC,cAAc,CAAC;IAClE,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,KAAK;CACZ,CAAC,CAAC"}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IllegalArgumentException = void 0;
|
|
4
|
-
const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
1
|
+
import { messageCheck, used } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
5
2
|
/**
|
|
6
3
|
* Exception thrown when an illegal argument is provided.
|
|
7
4
|
* Note: This can not extend ContractException due to circular dependency.
|
|
8
5
|
*/
|
|
9
|
-
class IllegalArgumentException extends Error {
|
|
6
|
+
export class IllegalArgumentException extends Error {
|
|
10
7
|
constructor(message, thrown = null) {
|
|
11
8
|
// super(messageCheck(message), thrown || undefined);
|
|
12
|
-
super(
|
|
13
|
-
|
|
9
|
+
super(messageCheck(message));
|
|
10
|
+
used(thrown);
|
|
14
11
|
this.name = "IllegalArgumentException";
|
|
15
12
|
Object.setPrototypeOf(this, IllegalArgumentException.prototype);
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
|
-
exports.IllegalArgumentException = IllegalArgumentException;
|
|
19
15
|
//# sourceMappingURL=IllegalArgumentException.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IllegalArgumentException.js","sourceRoot":"","sources":["../../src/auxiliary/IllegalArgumentException.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IllegalArgumentException.js","sourceRoot":"","sources":["../../src/auxiliary/IllegalArgumentException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAE9E;;;GAGG;AACH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD,YAAY,OAAe,EAAE,SAAuB,IAAI;QACtD,qDAAqD;QACrD,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAAA;IACjE,CAAC;CACF"}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IllegalStateException = void 0;
|
|
4
|
-
const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
1
|
+
import { messageCheck, used } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
5
2
|
/**
|
|
6
3
|
* Exception thrown when an operation is invoked at an illegal or inappropriate time.
|
|
7
4
|
* Note: This can not extend ContractException due to circular dependency.
|
|
8
5
|
*/
|
|
9
|
-
class IllegalStateException extends Error {
|
|
6
|
+
export class IllegalStateException extends Error {
|
|
10
7
|
constructor(message, thrown = null) {
|
|
11
8
|
// super(messageCheck(message), thrown || undefined);
|
|
12
|
-
super(
|
|
13
|
-
|
|
9
|
+
super(messageCheck(message));
|
|
10
|
+
used(thrown);
|
|
14
11
|
this.name = "IllegalStateException";
|
|
15
12
|
Object.setPrototypeOf(this, IllegalStateException.prototype);
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
|
-
exports.IllegalStateException = IllegalStateException;
|
|
19
15
|
//# sourceMappingURL=IllegalStateException.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IllegalStateException.js","sourceRoot":"","sources":["../../src/auxiliary/IllegalStateException.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IllegalStateException.js","sourceRoot":"","sources":["../../src/auxiliary/IllegalStateException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAE9E;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAe,EAAE,SAAuB,IAAI;QACtD,qDAAqD;QACrD,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAA;IAC9D,CAAC;CACF"}
|
package/auxiliary/Predicate.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Predicate.ts
|
|
4
3
|
*
|
|
5
4
|
* Defines a Predicate type that can test values of type T.
|
|
6
5
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.fromType = fromType;
|
|
10
|
-
exports.toValue = toValue;
|
|
11
|
-
exports.check = check;
|
|
12
|
-
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
13
|
-
const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
6
|
+
import { guardFunctions } from "@jonloucks/contracts-ts/api/Types";
|
|
7
|
+
import { presentCheck, used } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
14
8
|
/**
|
|
15
9
|
* Duck type guard check for Predicate
|
|
16
10
|
*
|
|
@@ -18,8 +12,8 @@ const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
|
18
12
|
* @param <T> the type of value tested
|
|
19
13
|
* @returns true if instance is a Predicate, false otherwise
|
|
20
14
|
*/
|
|
21
|
-
function guard(instance) {
|
|
22
|
-
return
|
|
15
|
+
export function guard(instance) {
|
|
16
|
+
return guardFunctions(instance, 'test');
|
|
23
17
|
}
|
|
24
18
|
/**
|
|
25
19
|
* Convert a Type to a Predicate
|
|
@@ -28,14 +22,14 @@ function guard(instance) {
|
|
|
28
22
|
* @param <T> the type of value tested
|
|
29
23
|
* @returns a Predicate that tests values of type T
|
|
30
24
|
*/
|
|
31
|
-
function fromType(type) {
|
|
25
|
+
export function fromType(type) {
|
|
32
26
|
if (guard(type)) {
|
|
33
27
|
return type;
|
|
34
28
|
}
|
|
35
29
|
else if (typeof type === 'boolean') {
|
|
36
30
|
return {
|
|
37
31
|
test: (value) => {
|
|
38
|
-
|
|
32
|
+
used(value);
|
|
39
33
|
return type;
|
|
40
34
|
}
|
|
41
35
|
};
|
|
@@ -54,7 +48,7 @@ function fromType(type) {
|
|
|
54
48
|
* @param <T> the type of value tested
|
|
55
49
|
* @returns true if the value satisfies the Predicate, false otherwise
|
|
56
50
|
*/
|
|
57
|
-
function toValue(type, value) {
|
|
51
|
+
export function toValue(type, value) {
|
|
58
52
|
if (guard(type)) {
|
|
59
53
|
return type.test(value);
|
|
60
54
|
}
|
|
@@ -72,7 +66,7 @@ function toValue(type, value) {
|
|
|
72
66
|
* @return the predicate if present
|
|
73
67
|
* @throws IllegalArgumentException if the predicate is not present
|
|
74
68
|
*/
|
|
75
|
-
function check(predicate) {
|
|
76
|
-
return
|
|
69
|
+
export function check(predicate) {
|
|
70
|
+
return presentCheck(predicate, "Predicate must be present.");
|
|
77
71
|
}
|
|
78
72
|
//# sourceMappingURL=Predicate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Predicate.js","sourceRoot":"","sources":["../../src/auxiliary/Predicate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Predicate.js","sourceRoot":"","sources":["../../src/auxiliary/Predicate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAA8B,MAAM,mCAAmC,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAiB9E;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAI,QAAiB;IACxC,OAAO,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAI,IAAa;IACvC,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,IAAI,OAAO,IAAI,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO;YACL,IAAI,EAAE,CAAC,KAAQ,EAAY,EAAE;gBAC3B,IAAI,CAAC,KAAK,CAAC,CAAC;gBACZ,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO;YACL,IAAI,EAAE,IAAI;SACX,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CAAI,IAAa,EAAE,KAAQ;IAChD,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;SAAM,IAAI,OAAO,IAAI,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAI,SAAgC;IACvD,OAAO,YAAY,CAAC,SAAS,EAAE,4BAA4B,CAAC,CAAC;AAC/D,CAAC"}
|
package/auxiliary/Supplier.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Supplier.ts
|
|
4
3
|
* Defines a Supplier type that can supply values of type T.
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
exports.fromType = fromType;
|
|
9
|
-
exports.toValue = toValue;
|
|
10
|
-
exports.check = check;
|
|
11
|
-
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
12
|
-
const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
5
|
+
import { guardFunctions, isFunction } from "@jonloucks/contracts-ts/api/Types";
|
|
6
|
+
import { presentCheck } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
13
7
|
/**
|
|
14
8
|
* Duck type guard check for Supplier
|
|
15
9
|
*
|
|
@@ -17,8 +11,8 @@ const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
|
17
11
|
* @param <T> the type of value supplied
|
|
18
12
|
* @returns true if instance is a Supplier, false otherwise
|
|
19
13
|
*/
|
|
20
|
-
function guard(instance) {
|
|
21
|
-
return
|
|
14
|
+
export function guard(instance) {
|
|
15
|
+
return guardFunctions(instance, 'supply');
|
|
22
16
|
}
|
|
23
17
|
/**
|
|
24
18
|
* Convert a Type to a Supplier
|
|
@@ -26,11 +20,11 @@ function guard(instance) {
|
|
|
26
20
|
* @param <T> the type of value supplied
|
|
27
21
|
* @returns a Supplier that supplies values of type T
|
|
28
22
|
*/
|
|
29
|
-
function fromType(type) {
|
|
23
|
+
export function fromType(type) {
|
|
30
24
|
if (guard(type)) {
|
|
31
25
|
return type;
|
|
32
26
|
}
|
|
33
|
-
else if (
|
|
27
|
+
else if (isFunction(type)) {
|
|
34
28
|
return {
|
|
35
29
|
supply: type
|
|
36
30
|
};
|
|
@@ -48,11 +42,11 @@ function fromType(type) {
|
|
|
48
42
|
* @param <T> the type of value supplied
|
|
49
43
|
* @returns the value supplied by the Supplier Type
|
|
50
44
|
*/
|
|
51
|
-
function toValue(type) {
|
|
45
|
+
export function toValue(type) {
|
|
52
46
|
if (guard(type)) {
|
|
53
47
|
return type.supply();
|
|
54
48
|
}
|
|
55
|
-
else if (
|
|
49
|
+
else if (isFunction(type)) {
|
|
56
50
|
return type();
|
|
57
51
|
}
|
|
58
52
|
else {
|
|
@@ -66,7 +60,7 @@ function toValue(type) {
|
|
|
66
60
|
* @return the supplier if present
|
|
67
61
|
* @throws IllegalArgumentException if the supplier is not present
|
|
68
62
|
*/
|
|
69
|
-
function check(supplier) {
|
|
70
|
-
return
|
|
63
|
+
export function check(supplier) {
|
|
64
|
+
return presentCheck(supplier, "Supplier must be present.");
|
|
71
65
|
}
|
|
72
66
|
//# sourceMappingURL=Supplier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Supplier.js","sourceRoot":"","sources":["../../src/auxiliary/Supplier.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Supplier.js","sourceRoot":"","sources":["../../src/auxiliary/Supplier.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,UAAU,EAAgB,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAiBxE;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAI,QAAiB;IACxC,OAAO,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAI,IAAa;IACvC,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO;YACL,MAAM,EAAE,IAAI;SACb,CAAA;IACH,CAAC;SAAM,CAAC;QACN,OAAO;YACL,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI;SACnB,CAAA;IACH,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAI,IAAa;IACtC,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;SAAM,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAI,QAAiB;IACxC,OAAO,YAAY,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAC;AAC7D,CAAC"}
|
package/auxiliary/Transform.js
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Transform.ts
|
|
4
3
|
*
|
|
5
4
|
* Defines a Transform type that can transform values of type I to type O.
|
|
6
5
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.guardMethod = guardMethod;
|
|
10
|
-
exports.fromType = fromType;
|
|
11
|
-
exports.toValue = toValue;
|
|
12
|
-
exports.check = check;
|
|
13
|
-
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
14
|
-
const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
6
|
+
import { guardFunctions, isFunctionWithArity } from "@jonloucks/contracts-ts/api/Types";
|
|
7
|
+
import { presentCheck, used } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
15
8
|
/**
|
|
16
9
|
* Check if a value is a Transform
|
|
17
10
|
*
|
|
18
11
|
* @param transform the value to check
|
|
19
12
|
* @returns true if the value is a Transform, false otherwise
|
|
20
13
|
*/
|
|
21
|
-
function guard(transform) {
|
|
22
|
-
return
|
|
14
|
+
export function guard(transform) {
|
|
15
|
+
return guardFunctions(transform, 'transform');
|
|
23
16
|
}
|
|
24
17
|
/**
|
|
25
18
|
* Check if a value is a function with arity 1
|
|
@@ -27,8 +20,8 @@ function guard(transform) {
|
|
|
27
20
|
* @param transform the value to check
|
|
28
21
|
* @returns true if the value is a function with arity 1, false otherwise
|
|
29
22
|
*/
|
|
30
|
-
function guardMethod(transform) {
|
|
31
|
-
return
|
|
23
|
+
export function guardMethod(transform) {
|
|
24
|
+
return isFunctionWithArity(transform, 1);
|
|
32
25
|
}
|
|
33
26
|
/**
|
|
34
27
|
* Convert a TransformType to a Transform
|
|
@@ -36,7 +29,7 @@ function guardMethod(transform) {
|
|
|
36
29
|
* @param transform the TransformType to convert
|
|
37
30
|
* @returns the Transform
|
|
38
31
|
*/
|
|
39
|
-
function fromType(transform) {
|
|
32
|
+
export function fromType(transform) {
|
|
40
33
|
if (guard(transform)) {
|
|
41
34
|
return transform;
|
|
42
35
|
}
|
|
@@ -46,7 +39,7 @@ function fromType(transform) {
|
|
|
46
39
|
else {
|
|
47
40
|
return {
|
|
48
41
|
transform: (input) => {
|
|
49
|
-
|
|
42
|
+
used(input);
|
|
50
43
|
return transform;
|
|
51
44
|
},
|
|
52
45
|
};
|
|
@@ -59,7 +52,7 @@ function fromType(transform) {
|
|
|
59
52
|
* @param <T> the type of value supplied
|
|
60
53
|
* @returns the value supplied by the Transform Type
|
|
61
54
|
*/
|
|
62
|
-
function toValue(type, input) {
|
|
55
|
+
export function toValue(type, input) {
|
|
63
56
|
if (guard(type)) {
|
|
64
57
|
return type.transform(input);
|
|
65
58
|
}
|
|
@@ -77,7 +70,7 @@ function toValue(type, input) {
|
|
|
77
70
|
* @return the transform if present
|
|
78
71
|
* @throws IllegalArgumentException if the transform is not present
|
|
79
72
|
*/
|
|
80
|
-
function check(transform) {
|
|
81
|
-
return
|
|
73
|
+
export function check(transform) {
|
|
74
|
+
return presentCheck(transform, "Transform must be present.");
|
|
82
75
|
}
|
|
83
76
|
//# sourceMappingURL=Transform.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transform.js","sourceRoot":"","sources":["../../src/auxiliary/Transform.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Transform.js","sourceRoot":"","sources":["../../src/auxiliary/Transform.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAgB,MAAM,mCAAmC,CAAC;AACtG,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AA0B9E;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAO,SAAkB;IAC5C,OAAO,cAAc,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAChD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAO,SAAkB;IAClD,OAAO,mBAAmB,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAO,SAAqB;IAClD,IAAI,KAAK,CAAO,SAAS,CAAC,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAC;IACnB,CAAC;SAAM,IAAI,WAAW,CAAO,SAAS,CAAC,EAAE,CAAC;QACxC,OAAO,EAAE,SAAS,EAAE,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,OAAO;YACL,SAAS,EAAE,CAAC,KAAQ,EAAK,EAAE;gBACzB,IAAI,CAAC,KAAK,CAAC,CAAC;gBACZ,OAAO,SAAc,CAAC;YACxB,CAAC;SACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAM,IAAe,EAAE,KAAQ;IACpD,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;SAAM,IAAI,WAAW,CAAM,IAAI,CAAC,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,uCAAuC;IAC7D,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC,CAAC,mCAAmC;IAClD,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAM,SAAoB;IAC7C,OAAO,YAAY,CAAC,SAAS,EAAE,4BAA4B,CAAC,CAAC;AAC/D,CAAC"}
|