@jonloucks/contracts-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/api/Convenience.d.ts +87 -0
- package/api/Convenience.d.ts.map +1 -0
- package/api/Convenience.js +110 -0
- package/api/Convenience.js.map +1 -0
- package/api/PromisorFactory.d.ts +1 -1
- package/auxiliary/Convenience.d.ts +42 -0
- package/auxiliary/Convenience.d.ts.map +1 -0
- package/auxiliary/Convenience.js +50 -0
- package/auxiliary/Convenience.js.map +1 -0
- package/package.json +1 -1
- package/version.js +1 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { AutoClose, Contract, OptionalType, RequiredType } from "@jonloucks/contracts-ts";
|
|
2
|
+
import { PromisorType } from "@jonloucks/contracts-ts/api/Promisor";
|
|
3
|
+
import { BindStrategyType } from "@jonloucks/contracts-ts/api/BindStrategy";
|
|
4
|
+
import { Promisor } from "@jonloucks/contracts-ts/api/Promisor";
|
|
5
|
+
import { TransformType } from "@jonloucks/contracts-ts/api/Types";
|
|
6
|
+
/**
|
|
7
|
+
* @module Convenience
|
|
8
|
+
* @description
|
|
9
|
+
*
|
|
10
|
+
* This module provides convenience functions for creating types
|
|
11
|
+
* using the shared global CONTRACTS instance. For performance-sensitive
|
|
12
|
+
* applications, consider using factory instances directly to avoid the
|
|
13
|
+
* overhead of enforcing the factory contract on each creation.
|
|
14
|
+
*
|
|
15
|
+
* Internal Note: To avoid circular dependencies, other modules should not
|
|
16
|
+
* import from this module. Instead, they should import directly from the
|
|
17
|
+
* source modules of the types.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Claim a deliverable from a Contract via the shared global CONTRACTS instance.
|
|
21
|
+
*
|
|
22
|
+
* @param contract the Contract to claim from
|
|
23
|
+
* @returns the deliverable
|
|
24
|
+
*/
|
|
25
|
+
export declare function claim<T>(contract: RequiredType<Contract<T>>): OptionalType<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Enforce a deliverable from a Contract via the shared global CONTRACTS instance.
|
|
28
|
+
*
|
|
29
|
+
* @param contract the Contract to enforce from
|
|
30
|
+
* @returns the deliverable
|
|
31
|
+
*/
|
|
32
|
+
export declare function enforce<T>(contract: RequiredType<Contract<T>>): RequiredType<T>;
|
|
33
|
+
/**
|
|
34
|
+
* Bind a Promisor to a Contract via the shared global CONTRACTS instance.
|
|
35
|
+
*
|
|
36
|
+
* @param contract the Contract to bind to
|
|
37
|
+
* @param promisor the PromisorType to bind
|
|
38
|
+
* @param bindStrategy optional BindStrategyType
|
|
39
|
+
* @returns an AutoClose to manage the binding lifecycle
|
|
40
|
+
*/
|
|
41
|
+
export declare function bind<T>(contract: RequiredType<Contract<T>>, promisor: PromisorType<T>, bindStrategy?: BindStrategyType): RequiredType<AutoClose>;
|
|
42
|
+
/**
|
|
43
|
+
* Check if a Contract is bound via the shared global CONTRACTS instance.
|
|
44
|
+
*
|
|
45
|
+
* @param contract the Contract to check
|
|
46
|
+
* @returns true if the Contract is bound, false otherwise
|
|
47
|
+
*/
|
|
48
|
+
export declare function isBound<T>(contract: RequiredType<Contract<T>>): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a Promisor that returns the given value every time it is claimed.
|
|
51
|
+
*
|
|
52
|
+
* @param deliverable the value to return from the Promisor
|
|
53
|
+
* @return The new Promisor
|
|
54
|
+
* @param <T> the type of deliverable
|
|
55
|
+
*/
|
|
56
|
+
export declare function createValue<T>(deliverable: OptionalType<T>): RequiredType<Promisor<T>>;
|
|
57
|
+
/**
|
|
58
|
+
* Creates a Promisor that only calls the source Promisor once and then always
|
|
59
|
+
* returns that value.
|
|
60
|
+
* Note: increment and decrementUsage are relayed to the source promisor.
|
|
61
|
+
*
|
|
62
|
+
* @param promisor the source Promisor
|
|
63
|
+
* @return The new Promisor
|
|
64
|
+
* @param <T> the type of deliverable
|
|
65
|
+
*/
|
|
66
|
+
export declare function createSingleton<T>(promisor: PromisorType<T>): RequiredType<Promisor<T>>;
|
|
67
|
+
/**
|
|
68
|
+
* Reference counted, lazy loaded, with opt-in 'open' and 'close' invoked on deliverable.
|
|
69
|
+
* Note: increment and decrementUsage are relayed to the source promisor.
|
|
70
|
+
*
|
|
71
|
+
* @param promisor the source promisor
|
|
72
|
+
* @return the new Promisor
|
|
73
|
+
* @param <T> the type of deliverable
|
|
74
|
+
*/
|
|
75
|
+
export declare function createLifeCycle<T>(promisor: PromisorType<T>): RequiredType<Promisor<T>>;
|
|
76
|
+
/**
|
|
77
|
+
* Extract values from the deliverable of a source Promisor.
|
|
78
|
+
* Note: increment and decrementUsage are relayed to the source promisor.
|
|
79
|
+
*
|
|
80
|
+
* @param promisor the source promisor
|
|
81
|
+
* @param extractor the function that gets an object from the deliverable. For example Person => Age
|
|
82
|
+
* @return the new Promisor
|
|
83
|
+
* @param <T> the type of deliverable
|
|
84
|
+
* @param <R> the new Promisor deliverable type
|
|
85
|
+
*/
|
|
86
|
+
export declare function createExtractor<T, R>(promisor: PromisorType<T>, extractor: TransformType<T, R>): RequiredType<Promisor<R>>;
|
|
87
|
+
//# sourceMappingURL=Convenience.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Convenience.d.ts","sourceRoot":"","sources":["../../src/api/Convenience.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAa,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACrG,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAE5E,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE;;;;;;;;;;;;GAYG;AAEH;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAE7E;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAE/E;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,gBAAgB,GAAG,YAAY,CAAC,SAAS,CAAC,CAEhJ;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAEvE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAEtF;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAEvF;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAEvF;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAE1H"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.claim = claim;
|
|
4
|
+
exports.enforce = enforce;
|
|
5
|
+
exports.bind = bind;
|
|
6
|
+
exports.isBound = isBound;
|
|
7
|
+
exports.createValue = createValue;
|
|
8
|
+
exports.createSingleton = createSingleton;
|
|
9
|
+
exports.createLifeCycle = createLifeCycle;
|
|
10
|
+
exports.createExtractor = createExtractor;
|
|
11
|
+
const contracts_ts_1 = require("@jonloucks/contracts-ts");
|
|
12
|
+
const PromisorFactory_1 = require("@jonloucks/contracts-ts/api/PromisorFactory");
|
|
13
|
+
/**
|
|
14
|
+
* @module Convenience
|
|
15
|
+
* @description
|
|
16
|
+
*
|
|
17
|
+
* This module provides convenience functions for creating types
|
|
18
|
+
* using the shared global CONTRACTS instance. For performance-sensitive
|
|
19
|
+
* applications, consider using factory instances directly to avoid the
|
|
20
|
+
* overhead of enforcing the factory contract on each creation.
|
|
21
|
+
*
|
|
22
|
+
* Internal Note: To avoid circular dependencies, other modules should not
|
|
23
|
+
* import from this module. Instead, they should import directly from the
|
|
24
|
+
* source modules of the types.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Claim a deliverable from a Contract via the shared global CONTRACTS instance.
|
|
28
|
+
*
|
|
29
|
+
* @param contract the Contract to claim from
|
|
30
|
+
* @returns the deliverable
|
|
31
|
+
*/
|
|
32
|
+
function claim(contract) {
|
|
33
|
+
return contracts_ts_1.CONTRACTS.claim(contract);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Enforce a deliverable from a Contract via the shared global CONTRACTS instance.
|
|
37
|
+
*
|
|
38
|
+
* @param contract the Contract to enforce from
|
|
39
|
+
* @returns the deliverable
|
|
40
|
+
*/
|
|
41
|
+
function enforce(contract) {
|
|
42
|
+
return contracts_ts_1.CONTRACTS.enforce(contract);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Bind a Promisor to a Contract via the shared global CONTRACTS instance.
|
|
46
|
+
*
|
|
47
|
+
* @param contract the Contract to bind to
|
|
48
|
+
* @param promisor the PromisorType to bind
|
|
49
|
+
* @param bindStrategy optional BindStrategyType
|
|
50
|
+
* @returns an AutoClose to manage the binding lifecycle
|
|
51
|
+
*/
|
|
52
|
+
function bind(contract, promisor, bindStrategy) {
|
|
53
|
+
return contracts_ts_1.CONTRACTS.bind(contract, promisor, bindStrategy);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Check if a Contract is bound via the shared global CONTRACTS instance.
|
|
57
|
+
*
|
|
58
|
+
* @param contract the Contract to check
|
|
59
|
+
* @returns true if the Contract is bound, false otherwise
|
|
60
|
+
*/
|
|
61
|
+
function isBound(contract) {
|
|
62
|
+
return contracts_ts_1.CONTRACTS.isBound(contract);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Creates a Promisor that returns the given value every time it is claimed.
|
|
66
|
+
*
|
|
67
|
+
* @param deliverable the value to return from the Promisor
|
|
68
|
+
* @return The new Promisor
|
|
69
|
+
* @param <T> the type of deliverable
|
|
70
|
+
*/
|
|
71
|
+
function createValue(deliverable) {
|
|
72
|
+
return enforce(PromisorFactory_1.CONTRACT).createValue(deliverable);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Creates a Promisor that only calls the source Promisor once and then always
|
|
76
|
+
* returns that value.
|
|
77
|
+
* Note: increment and decrementUsage are relayed to the source promisor.
|
|
78
|
+
*
|
|
79
|
+
* @param promisor the source Promisor
|
|
80
|
+
* @return The new Promisor
|
|
81
|
+
* @param <T> the type of deliverable
|
|
82
|
+
*/
|
|
83
|
+
function createSingleton(promisor) {
|
|
84
|
+
return enforce(PromisorFactory_1.CONTRACT).createSingleton(promisor);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Reference counted, lazy loaded, with opt-in 'open' and 'close' invoked on deliverable.
|
|
88
|
+
* Note: increment and decrementUsage are relayed to the source promisor.
|
|
89
|
+
*
|
|
90
|
+
* @param promisor the source promisor
|
|
91
|
+
* @return the new Promisor
|
|
92
|
+
* @param <T> the type of deliverable
|
|
93
|
+
*/
|
|
94
|
+
function createLifeCycle(promisor) {
|
|
95
|
+
return enforce(PromisorFactory_1.CONTRACT).createLifeCycle(promisor);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Extract values from the deliverable of a source Promisor.
|
|
99
|
+
* Note: increment and decrementUsage are relayed to the source promisor.
|
|
100
|
+
*
|
|
101
|
+
* @param promisor the source promisor
|
|
102
|
+
* @param extractor the function that gets an object from the deliverable. For example Person => Age
|
|
103
|
+
* @return the new Promisor
|
|
104
|
+
* @param <T> the type of deliverable
|
|
105
|
+
* @param <R> the new Promisor deliverable type
|
|
106
|
+
*/
|
|
107
|
+
function createExtractor(promisor, extractor) {
|
|
108
|
+
return enforce(PromisorFactory_1.CONTRACT).createExtractor(promisor, extractor);
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=Convenience.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Convenience.js","sourceRoot":"","sources":["../../src/api/Convenience.ts"],"names":[],"mappings":";;AA2BA,sBAEC;AAQD,0BAEC;AAUD,oBAEC;AAQD,0BAEC;AASD,kCAEC;AAWD,0CAEC;AAUD,0CAEC;AAYD,0CAEC;AA/GD,0DAAqG;AAGrG,iFAA2F;AAI3F;;;;;;;;;;;;GAYG;AAEH;;;;;GAKG;AACH,SAAgB,KAAK,CAAI,QAAmC;IAC1D,OAAO,wBAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACnC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,OAAO,CAAI,QAAmC;IAC5D,OAAO,wBAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,IAAI,CAAI,QAAmC,EAAE,QAAyB,EAAE,YAA+B;IACrH,OAAO,wBAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;GAKG;AACH,SAAgB,OAAO,CAAI,QAAmC;IAC5D,OAAO,wBAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,WAAW,CAAI,WAA4B;IACzD,OAAO,OAAO,CAAC,0BAAgB,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;AAC5D,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAAI,QAAyB;IAC1D,OAAO,OAAO,CAAC,0BAAgB,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAI,QAAyB;IAC1D,OAAO,OAAO,CAAC,0BAAgB,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,eAAe,CAAO,QAAyB,EAAE,SAA8B;IAC7F,OAAO,OAAO,CAAC,0BAAgB,CAAC,CAAC,eAAe,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AACxE,CAAC"}
|
package/api/PromisorFactory.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export interface PromisorFactory {
|
|
|
33
33
|
*/
|
|
34
34
|
createLifeCycle<T>(promisor: PromisorType<T>): RequiredType<Promisor<T>>;
|
|
35
35
|
/**
|
|
36
|
-
* Extract
|
|
36
|
+
* Extract values from the deliverable of a source Promisor.
|
|
37
37
|
* Note: increment and decrementUsage are relayed to the source promisor.
|
|
38
38
|
*
|
|
39
39
|
* @param promisor the source promisor
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
export { AtomicBoolean } from "@jonloucks/contracts-ts/auxiliary/AtomicBoolean";
|
|
6
|
+
export { AtomicReference } from "@jonloucks/contracts-ts/auxiliary/AtomicReference";
|
|
7
|
+
export { AtomicInteger } from "@jonloucks/contracts-ts/auxiliary/AtomicInteger";
|
|
8
|
+
/**
|
|
9
|
+
* @module Convenience
|
|
10
|
+
* @description
|
|
11
|
+
*
|
|
12
|
+
* This module provides convenience functions for creating auxiliary types
|
|
13
|
+
* using the shared global CONTRACTS instance. For performance-sensitive
|
|
14
|
+
* applications, consider using factory instances directly to avoid the
|
|
15
|
+
* overhead of enforcing the factory contract on each creation.
|
|
16
|
+
*
|
|
17
|
+
* Internal Note: To avoid circular dependencies, other modules should not
|
|
18
|
+
* import from this module. Instead, they should import directly from the
|
|
19
|
+
* source modules of the auxiliary types.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Create an AtomicBoolean via the shared global CONTRACTS instance.
|
|
23
|
+
*
|
|
24
|
+
* @param initialValue the initial boolean value
|
|
25
|
+
* @returns the AtomicBoolean instance
|
|
26
|
+
*/
|
|
27
|
+
export declare function createAtomicBoolean(initialValue: boolean): RequiredType<AtomicBoolean>;
|
|
28
|
+
/**
|
|
29
|
+
* Create an AtomicReference via the shared global CONTRACTS instance.
|
|
30
|
+
*
|
|
31
|
+
* @param initialValue the initial reference value
|
|
32
|
+
* @returns the AtomicReference instance
|
|
33
|
+
*/
|
|
34
|
+
export declare function createAtomicReference<T>(initialValue: T): RequiredType<AtomicReference<T>>;
|
|
35
|
+
/**
|
|
36
|
+
* Create an AtomicInteger via the shared global CONTRACTS instance.
|
|
37
|
+
*
|
|
38
|
+
* @param initialValue the initial integer value
|
|
39
|
+
* @returns the AtomicInteger instance
|
|
40
|
+
*/
|
|
41
|
+
export declare function createAtomicInteger(initialValue: number): RequiredType<AtomicInteger>;
|
|
42
|
+
//# sourceMappingURL=Convenience.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Convenience.d.ts","sourceRoot":"","sources":["../../src/auxiliary/Convenience.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAKjE,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAEhF,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAEhF;;;;;;;;;;;;GAYG;AAEH;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,OAAO,GAAG,YAAY,CAAC,aAAa,CAAC,CAEtF;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAE1F;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,YAAY,CAAC,aAAa,CAAC,CAErF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAtomicBoolean = createAtomicBoolean;
|
|
4
|
+
exports.createAtomicReference = createAtomicReference;
|
|
5
|
+
exports.createAtomicInteger = createAtomicInteger;
|
|
6
|
+
const contracts_ts_1 = require("@jonloucks/contracts-ts");
|
|
7
|
+
const AtomicBooleanFactory_1 = require("@jonloucks/contracts-ts/auxiliary/AtomicBooleanFactory");
|
|
8
|
+
const AtomicReferenceFactory_1 = require("@jonloucks/contracts-ts/auxiliary/AtomicReferenceFactory");
|
|
9
|
+
const AtomicIntegerFactory_1 = require("@jonloucks/contracts-ts/auxiliary/AtomicIntegerFactory");
|
|
10
|
+
/**
|
|
11
|
+
* @module Convenience
|
|
12
|
+
* @description
|
|
13
|
+
*
|
|
14
|
+
* This module provides convenience functions for creating auxiliary types
|
|
15
|
+
* using the shared global CONTRACTS instance. For performance-sensitive
|
|
16
|
+
* applications, consider using factory instances directly to avoid the
|
|
17
|
+
* overhead of enforcing the factory contract on each creation.
|
|
18
|
+
*
|
|
19
|
+
* Internal Note: To avoid circular dependencies, other modules should not
|
|
20
|
+
* import from this module. Instead, they should import directly from the
|
|
21
|
+
* source modules of the auxiliary types.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Create an AtomicBoolean via the shared global CONTRACTS instance.
|
|
25
|
+
*
|
|
26
|
+
* @param initialValue the initial boolean value
|
|
27
|
+
* @returns the AtomicBoolean instance
|
|
28
|
+
*/
|
|
29
|
+
function createAtomicBoolean(initialValue) {
|
|
30
|
+
return contracts_ts_1.CONTRACTS.enforce(AtomicBooleanFactory_1.CONTRACT).createAtomicBoolean(initialValue);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create an AtomicReference via the shared global CONTRACTS instance.
|
|
34
|
+
*
|
|
35
|
+
* @param initialValue the initial reference value
|
|
36
|
+
* @returns the AtomicReference instance
|
|
37
|
+
*/
|
|
38
|
+
function createAtomicReference(initialValue) {
|
|
39
|
+
return contracts_ts_1.CONTRACTS.enforce(AtomicReferenceFactory_1.CONTRACT).createAtomicReference(initialValue);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create an AtomicInteger via the shared global CONTRACTS instance.
|
|
43
|
+
*
|
|
44
|
+
* @param initialValue the initial integer value
|
|
45
|
+
* @returns the AtomicInteger instance
|
|
46
|
+
*/
|
|
47
|
+
function createAtomicInteger(initialValue) {
|
|
48
|
+
return contracts_ts_1.CONTRACTS.enforce(AtomicIntegerFactory_1.CONTRACT).createAtomicInteger(initialValue);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=Convenience.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Convenience.js","sourceRoot":"","sources":["../../src/auxiliary/Convenience.ts"],"names":[],"mappings":";;AAiCA,kDAEC;AAQD,sDAEC;AAQD,kDAEC;AAtDD,0DAAoD;AACpD,iGAAqG;AACrG,qGAAyG;AACzG,iGAAqG;AASrG;;;;;;;;;;;;GAYG;AAEH;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,YAAqB;IACvD,OAAO,wBAAS,CAAC,OAAO,CAAC,+BAAe,CAAC,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAI,YAAe;IACtD,OAAO,wBAAS,CAAC,OAAO,CAAC,iCAAiB,CAAC,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;AAClF,CAAC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,YAAoB;IACtD,OAAO,wBAAS,CAAC,OAAO,CAAC,+BAAe,CAAC,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;AAC9E,CAAC"}
|
package/package.json
CHANGED
package/version.js
CHANGED
|
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VERSION = exports.NAME = void 0;
|
|
4
4
|
// generated file - do not edit
|
|
5
5
|
exports.NAME = "@jonloucks/contracts-ts";
|
|
6
|
-
exports.VERSION = "1.0.
|
|
6
|
+
exports.VERSION = "1.0.2";
|
|
7
7
|
//# sourceMappingURL=version.js.map
|