@jonloucks/contracts-ts 1.2.3 → 1.4.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/api/Types.d.ts CHANGED
@@ -9,6 +9,10 @@ export type OptionalType<T> = T | null | undefined;
9
9
  * Type that is guaranteed to be non-null and non-undefined
10
10
  */
11
11
  export type RequiredType<T> = NonNullable<T>;
12
+ /**
13
+ * Type that can be undefined or a value of type T
14
+ */
15
+ export type UndefinedType<T> = T | undefined;
12
16
  /**
13
17
  * A function of unknown signature
14
18
  */
@@ -21,10 +25,12 @@ export interface Transform<I, O> {
21
25
  }
22
26
  /**
23
27
  * A function that transforms type I to type O
28
+ * @deprecated use @jonloucks/contracts-ts/auxiliary/Functional instead
24
29
  */
25
30
  export type TransformFunction<I, O> = (input: I) => O;
26
31
  /**
27
32
  * A transformation type that can be a Transform or a function from type I to type O
33
+ * @deprecated use @jonloucks/contracts-ts/auxiliary/Functional instead
28
34
  */
29
35
  export type TransformType<I, O> = Transform<I, O> | TransformFunction<I, O>;
30
36
  /**
@@ -121,6 +127,7 @@ export declare function hasFunction<T>(value: unknown, propertyName: string | sy
121
127
  *
122
128
  * @param transform the TransformType to convert
123
129
  * @returns the Transform
130
+ * @deprecated use @jonloucks/contracts-ts/auxiliary/Functional instead
124
131
  */
125
132
  export declare function typeToTransform<I, O>(transform: TransformType<I, O>): RequiredType<Transform<I, O>>;
126
133
  //# sourceMappingURL=Types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../src/api/Types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,eAAe,GAA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,CAAC,EAAE,CAAC,CAAC,CAAC,CASnG"}
package/api/Types.js CHANGED
@@ -163,9 +163,15 @@ function getPropertyDescriptor(instance, name) {
163
163
  }
164
164
  return undefined;
165
165
  }
166
+ /**
167
+ * @deprecated use @jonloucks/contracts-ts/auxiliary/Functional instead
168
+ */
166
169
  function guardTransform(transform) {
167
170
  return guardFunctions(transform, 'transform');
168
171
  }
172
+ /**
173
+ * @deprecated use @jonloucks/contracts-ts/auxiliary/Functional instead
174
+ */
169
175
  function guardTransformFunction(transform) {
170
176
  return isFunctionWithArity(transform, 1);
171
177
  }
@@ -174,6 +180,7 @@ function guardTransformFunction(transform) {
174
180
  *
175
181
  * @param transform the TransformType to convert
176
182
  * @returns the Transform
183
+ * @deprecated use @jonloucks/contracts-ts/auxiliary/Functional instead
177
184
  */
178
185
  function typeToTransform(transform) {
179
186
  const validTransformType = (0, Checks_1.presentCheck)(transform, "TransformType must be present.");
package/api/Types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Types.js","sourceRoot":"","sources":["../../src/api/Types.ts"],"names":[],"mappings":";AAAA;;GAEG;;AA2CH,8BAEC;AAQD,oCAEC;AAOD,gCAEC;AASD,kDAEC;AAOD,4BAEC;AAQD,4BAEC;AAOD,4BAEC;AAOD,4BAEC;AAOD,8BAEC;AAOD,4BAEC;AAOD,sCAEC;AAUD,wCAYC;AAUD,kCAYC;AA4BD,0CASC;AA1ND,qEAAwE;AACxE,yGAAsG;AAkCtG;;;;;GAKG;AACH,SAAgB,SAAS,CAAI,KAAc;IACzC,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAC/C,CAAC;AAED;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,KAAc;IACzC,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,SAAgB,UAAU,CAA4B,KAAc;IAClE,OAAO,SAAS,CAAC,KAAK,CAAC,IAA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AC9C,OAAO,cAAc,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,SAAS,sBAAsB,CAAO,SAAkB;IACtD,OAAO,mBAAmB,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,eAAe,CAAO,SAA8B;IAClE,MAAM,kBAAkB,GAAG,IAAA,qBAAY,EAAC,SAAS,EAAE,gCAAgC,CAAC,CAAC;IACrF,IAAI,cAAc,CAAO,kBAAkB,CAAC,EAAE,CAAC;QAC7C,OAAO,kBAAkB,CAAC;IAC5B,CAAC;SAAM,IAAI,sBAAsB,CAAO,kBAAkB,CAAC,EAAE,CAAC;QAC5D,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAC3C,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,mDAAwB,CAAC,sEAAsE,CAAC,CAAC;IAC7G,CAAC;AACH,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Consumer.ts
3
+ * Candidate for inclusion in api-ts
4
+ * Defines a Consumer type that can consume values of type T.
5
+ */
6
+ import { RequiredType } from "@jonloucks/contracts-ts/api/Types";
7
+ /**
8
+ * A method that consumes a value of type T
9
+ */
10
+ export type Method<T> = (value: T) => void;
11
+ /**
12
+ * A Consumer that consumes values of type T
13
+ */
14
+ export interface Consumer<T> {
15
+ consume(value: T): void;
16
+ }
17
+ /**
18
+ * A type that can be either a Method or a Consumer
19
+ */
20
+ export type Type<T> = Method<T> | Consumer<T>;
21
+ /**
22
+ * Duck type guard check for Consumer
23
+ *
24
+ * @param instance the instance to check
25
+ * @param <T> the type of value consumed
26
+ * @returns true if instance is a Consumer, false otherwise
27
+ */
28
+ export declare function guard<T>(instance: unknown): instance is RequiredType<Consumer<T>>;
29
+ /**
30
+ * Convert a Type to a Consumer
31
+ *
32
+ * @param type the type to convert
33
+ * @param <T> the type of value consumed
34
+ * @returns a Consumer that consumes values of type T
35
+ */
36
+ export declare function fromType<T>(type: Type<T>): RequiredType<Consumer<T>>;
37
+ /**
38
+ * Check that a Consumer is present
39
+ *
40
+ * @param consumer the consumer to check
41
+ * @return the consumer if present
42
+ * @throws IllegalArgumentException if the consumer is not present
43
+ */
44
+ export declare function check<T>(consumer: Type<T>): Type<T>;
45
+ //# sourceMappingURL=Consumer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Consumer.d.ts","sourceRoot":"","sources":["../../src/auxiliary/Consumer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAkB,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAGjF;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC;IAAI,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;CAAE;AAEzD;;GAEG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAEjF;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAQpE;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAEnD"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /**
3
+ * Consumer.ts
4
+ * Candidate for inclusion in api-ts
5
+ * Defines a Consumer type that can consume values of type T.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.guard = guard;
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");
13
+ /**
14
+ * Duck type guard check for Consumer
15
+ *
16
+ * @param instance the instance to check
17
+ * @param <T> the type of value consumed
18
+ * @returns true if instance is a Consumer, false otherwise
19
+ */
20
+ function guard(instance) {
21
+ return (0, Types_1.guardFunctions)(instance, 'consume');
22
+ }
23
+ /**
24
+ * Convert a Type to a Consumer
25
+ *
26
+ * @param type the type to convert
27
+ * @param <T> the type of value consumed
28
+ * @returns a Consumer that consumes values of type T
29
+ */
30
+ function fromType(type) {
31
+ if (guard(type)) {
32
+ return type;
33
+ }
34
+ else {
35
+ return {
36
+ consume: type
37
+ };
38
+ }
39
+ }
40
+ /**
41
+ * Check that a Consumer is present
42
+ *
43
+ * @param consumer the consumer to check
44
+ * @return the consumer if present
45
+ * @throws IllegalArgumentException if the consumer is not present
46
+ */
47
+ function check(consumer) {
48
+ return (0, Checks_1.presentCheck)(consumer, "Consumer must be present.");
49
+ }
50
+ //# sourceMappingURL=Consumer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Consumer.js","sourceRoot":"","sources":["../../src/auxiliary/Consumer.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AA2BH,sBAEC;AASD,4BAQC;AASD,sBAEC;AAvDD,6DAAiF;AACjF,qEAAwE;AAiBxE;;;;;;GAMG;AACH,SAAgB,KAAK,CAAI,QAAiB;IACxC,OAAO,IAAA,sBAAc,EAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,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,SAAgB,KAAK,CAAI,QAAiB;IACxC,OAAO,IAAA,qBAAY,EAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,9 @@
1
+ export type { Consumer, Method as ConsumerFunction, Type as ConsumerType } from "@jonloucks/contracts-ts/auxiliary/Consumer";
2
+ export { guard as consumerGuard, fromType as consumerFromType, check as consumerCheck } from "@jonloucks/contracts-ts/auxiliary/Consumer";
3
+ export type { Predicate, Method as PredicateFunction, Type as PredicateType } from "@jonloucks/contracts-ts/auxiliary/Predicate";
4
+ export { guard as predicateGuard, fromType as predicateFromType, check as predicateCheck, toValue as predicateToValue } from "@jonloucks/contracts-ts/auxiliary/Predicate";
5
+ export type { Supplier, Method as SupplierFunction, Type as SupplierType } from "@jonloucks/contracts-ts/auxiliary/Supplier";
6
+ export { guard as supplierGuard, fromType as supplierFromType, check as supplierCheck, toValue as supplierToValue } from "@jonloucks/contracts-ts/auxiliary/Supplier";
7
+ export type { Transform, Method as TransformFunction, Type as TransformType } from "@jonloucks/contracts-ts/auxiliary/Transform";
8
+ export { guard as transformGuard, fromType as transformFromType, check as transformCheck, toValue as transformToValue } from "@jonloucks/contracts-ts/auxiliary/Transform";
9
+ //# sourceMappingURL=Functional.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Functional.d.ts","sourceRoot":"","sources":["../../src/auxiliary/Functional.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,gBAAgB,EAAE,IAAI,IAAI,YAAY,EAAE,MACnE,4CAA4C,CAAC;AAEpD,OAAO,EAAE,KAAK,IAAI,aAAa,EAAE,QAAQ,IAAI,gBAAgB,EAAE,KAAK,IAAI,aAAa,EAAE,MAChF,4CAA4C,CAAC;AAEpD,YAAY,EAAE,SAAS,EAAE,MAAM,IAAI,iBAAiB,EAAE,IAAI,IAAI,aAAa,EAAE,MACtE,6CAA6C,CAAC;AAErD,OAAO,EAAE,KAAK,IAAI,cAAc,EAAE,QAAQ,IAAI,iBAAiB,EAAE,KAAK,IAAI,cAAc,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAChH,6CAA6C,CAAC;AAErD,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,gBAAgB,EAAE,IAAI,IAAI,YAAY,EAAE,MACnE,4CAA4C,CAAC;AAEpD,OAAO,EAAE,KAAK,IAAI,aAAa,EAAE,QAAQ,IAAI,gBAAgB,EAAE,KAAK,IAAI,aAAa,EAAE,OAAO,IAAI,eAAe,EAAE,MAC5G,4CAA4C,CAAC;AAEpD,YAAY,EAAE,SAAS,EAAE,MAAM,IAAI,iBAAiB,EAAE,IAAI,IAAI,aAAa,EAAE,MACtE,6CAA6C,CAAC;AAErD,OAAO,EAAE,KAAK,IAAI,cAAc,EAAE,QAAQ,IAAI,iBAAiB,EAAE,KAAK,IAAI,cAAc,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAChH,6CAA6C,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformToValue = exports.transformCheck = exports.transformFromType = exports.transformGuard = exports.supplierToValue = exports.supplierCheck = exports.supplierFromType = exports.supplierGuard = exports.predicateToValue = exports.predicateCheck = exports.predicateFromType = exports.predicateGuard = exports.consumerCheck = exports.consumerFromType = exports.consumerGuard = void 0;
4
+ var Consumer_1 = require("@jonloucks/contracts-ts/auxiliary/Consumer");
5
+ Object.defineProperty(exports, "consumerGuard", { enumerable: true, get: function () { return Consumer_1.guard; } });
6
+ Object.defineProperty(exports, "consumerFromType", { enumerable: true, get: function () { return Consumer_1.fromType; } });
7
+ Object.defineProperty(exports, "consumerCheck", { enumerable: true, get: function () { return Consumer_1.check; } });
8
+ var Predicate_1 = require("@jonloucks/contracts-ts/auxiliary/Predicate");
9
+ Object.defineProperty(exports, "predicateGuard", { enumerable: true, get: function () { return Predicate_1.guard; } });
10
+ Object.defineProperty(exports, "predicateFromType", { enumerable: true, get: function () { return Predicate_1.fromType; } });
11
+ Object.defineProperty(exports, "predicateCheck", { enumerable: true, get: function () { return Predicate_1.check; } });
12
+ Object.defineProperty(exports, "predicateToValue", { enumerable: true, get: function () { return Predicate_1.toValue; } });
13
+ var Supplier_1 = require("@jonloucks/contracts-ts/auxiliary/Supplier");
14
+ Object.defineProperty(exports, "supplierGuard", { enumerable: true, get: function () { return Supplier_1.guard; } });
15
+ Object.defineProperty(exports, "supplierFromType", { enumerable: true, get: function () { return Supplier_1.fromType; } });
16
+ Object.defineProperty(exports, "supplierCheck", { enumerable: true, get: function () { return Supplier_1.check; } });
17
+ Object.defineProperty(exports, "supplierToValue", { enumerable: true, get: function () { return Supplier_1.toValue; } });
18
+ var Transform_1 = require("@jonloucks/contracts-ts/auxiliary/Transform");
19
+ Object.defineProperty(exports, "transformGuard", { enumerable: true, get: function () { return Transform_1.guard; } });
20
+ Object.defineProperty(exports, "transformFromType", { enumerable: true, get: function () { return Transform_1.fromType; } });
21
+ Object.defineProperty(exports, "transformCheck", { enumerable: true, get: function () { return Transform_1.check; } });
22
+ Object.defineProperty(exports, "transformToValue", { enumerable: true, get: function () { return Transform_1.toValue; } });
23
+ //# sourceMappingURL=Functional.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Functional.js","sourceRoot":"","sources":["../../src/auxiliary/Functional.ts"],"names":[],"mappings":";;;AAIA,uEACoD;AAD3C,yGAAA,KAAK,OAAiB;AAAE,4GAAA,QAAQ,OAAoB;AAAE,yGAAA,KAAK,OAAiB;AAMrF,yEACqD;AAD5C,2GAAA,KAAK,OAAkB;AAAE,8GAAA,QAAQ,OAAqB;AAAE,2GAAA,KAAK,OAAkB;AAAE,6GAAA,OAAO,OAAoB;AAMrH,uEACoD;AAD3C,yGAAA,KAAK,OAAiB;AAAE,4GAAA,QAAQ,OAAoB;AAAE,yGAAA,KAAK,OAAiB;AAAE,2GAAA,OAAO,OAAmB;AAMjH,yEACqD;AAD5C,2GAAA,KAAK,OAAkB;AAAE,8GAAA,QAAQ,OAAqB;AAAE,2GAAA,KAAK,OAAkB;AAAE,6GAAA,OAAO,OAAoB"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Predicate.ts
3
+ *
4
+ * Defines a Predicate type that can test values of type T.
5
+ */
6
+ import { OptionalType, RequiredType } from "@jonloucks/contracts-ts/api/Types";
7
+ /**
8
+ * A method that tests a value of type T and returns a boolean
9
+ */
10
+ export type Method<T> = (value: T) => boolean;
11
+ /**
12
+ * A Predicate that tests values of type T
13
+ */
14
+ export interface Predicate<T> {
15
+ test(value: T): boolean;
16
+ }
17
+ /**
18
+ * A type that can be a Method, Predicate, or a boolean
19
+ */
20
+ export type Type<T> = Method<T> | Predicate<T> | boolean;
21
+ /**
22
+ * Duck type guard check for Predicate
23
+ *
24
+ * @param instance the instance to check
25
+ * @param <T> the type of value tested
26
+ * @returns true if instance is a Predicate, false otherwise
27
+ */
28
+ export declare function guard<T>(instance: unknown): instance is Predicate<T>;
29
+ /**
30
+ * Convert a Type to a Predicate
31
+ *
32
+ * @param type the type to convert
33
+ * @param <T> the type of value tested
34
+ * @returns a Predicate that tests values of type T
35
+ */
36
+ export declare function fromType<T>(type: Type<T>): Predicate<T>;
37
+ /**
38
+ * Test a value against a Predicate Type
39
+ *
40
+ * @param type the Predicate Type
41
+ * @param value the value to test
42
+ * @param <T> the type of value tested
43
+ * @returns true if the value satisfies the Predicate, false otherwise
44
+ */
45
+ export declare function toValue<T>(type: Type<T>, value: T): boolean;
46
+ /**
47
+ * Check that a predicate is present
48
+ *
49
+ * @param predicate the predicate to check
50
+ * @return the predicate if present
51
+ * @throws IllegalArgumentException if the predicate is not present
52
+ */
53
+ export declare function check<T>(predicate: OptionalType<Type<T>>): RequiredType<Type<T>>;
54
+ //# sourceMappingURL=Predicate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Predicate.d.ts","sourceRoot":"","sources":["../../src/auxiliary/Predicate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAkB,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAG/F;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC;IAAI,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC;CAAE;AAE1D;;GAEG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,SAAS,CAAC,CAAC,CAAC,CAEpE;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAevD;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAQ3D;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAEhF"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ /**
3
+ * Predicate.ts
4
+ *
5
+ * Defines a Predicate type that can test values of type T.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.guard = guard;
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");
14
+ /**
15
+ * Duck type guard check for Predicate
16
+ *
17
+ * @param instance the instance to check
18
+ * @param <T> the type of value tested
19
+ * @returns true if instance is a Predicate, false otherwise
20
+ */
21
+ function guard(instance) {
22
+ return (0, Types_1.guardFunctions)(instance, 'test');
23
+ }
24
+ /**
25
+ * Convert a Type to a Predicate
26
+ *
27
+ * @param type the type to convert
28
+ * @param <T> the type of value tested
29
+ * @returns a Predicate that tests values of type T
30
+ */
31
+ function fromType(type) {
32
+ if (guard(type)) {
33
+ return type;
34
+ }
35
+ else if (typeof type === 'boolean') {
36
+ return {
37
+ test: (value) => {
38
+ (0, Checks_1.used)(value);
39
+ return type;
40
+ }
41
+ };
42
+ }
43
+ else {
44
+ return {
45
+ test: type
46
+ };
47
+ }
48
+ }
49
+ /**
50
+ * Test a value against a Predicate Type
51
+ *
52
+ * @param type the Predicate Type
53
+ * @param value the value to test
54
+ * @param <T> the type of value tested
55
+ * @returns true if the value satisfies the Predicate, false otherwise
56
+ */
57
+ function toValue(type, value) {
58
+ if (guard(type)) {
59
+ return type.test(value);
60
+ }
61
+ else if (typeof type === 'boolean') {
62
+ return type;
63
+ }
64
+ else {
65
+ return type(value);
66
+ }
67
+ }
68
+ /**
69
+ * Check that a predicate is present
70
+ *
71
+ * @param predicate the predicate to check
72
+ * @return the predicate if present
73
+ * @throws IllegalArgumentException if the predicate is not present
74
+ */
75
+ function check(predicate) {
76
+ return (0, Checks_1.presentCheck)(predicate, "Predicate must be present.");
77
+ }
78
+ //# sourceMappingURL=Predicate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Predicate.js","sourceRoot":"","sources":["../../src/auxiliary/Predicate.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AA2BH,sBAEC;AASD,4BAeC;AAUD,0BAQC;AASD,sBAEC;AAhFD,6DAA+F;AAC/F,qEAA8E;AAiB9E;;;;;;GAMG;AACH,SAAgB,KAAK,CAAI,QAAiB;IACxC,OAAO,IAAA,sBAAc,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,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,IAAA,aAAI,EAAC,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,SAAgB,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,SAAgB,KAAK,CAAI,SAAgC;IACvD,OAAO,IAAA,qBAAY,EAAC,SAAS,EAAE,4BAA4B,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Supplier.ts
3
+ * Defines a Supplier type that can supply values of type T.
4
+ */
5
+ import { RequiredType } from "@jonloucks/contracts-ts/api/Types";
6
+ /**
7
+ * A method that supplies a value of type T
8
+ */
9
+ export type Method<T> = () => T;
10
+ /**
11
+ * A Supplier that supplies values of type T
12
+ */
13
+ export interface Supplier<T> {
14
+ supply(): T;
15
+ }
16
+ /**
17
+ * A type that can be a Method, Supplier, or a value of type T
18
+ */
19
+ export type Type<T> = Method<T> | Supplier<T> | T;
20
+ /**
21
+ * Duck type guard check for Supplier
22
+ *
23
+ * @param instance the instance to check
24
+ * @param <T> the type of value supplied
25
+ * @returns true if instance is a Supplier, false otherwise
26
+ */
27
+ export declare function guard<T>(instance: unknown): instance is RequiredType<Supplier<T>>;
28
+ /**
29
+ * Convert a Type to a Supplier
30
+ * @param type the type to convert
31
+ * @param <T> the type of value supplied
32
+ * @returns a Supplier that supplies values of type T
33
+ */
34
+ export declare function fromType<T>(type: Type<T>): RequiredType<Supplier<T>>;
35
+ /**
36
+ * Get the value from a Supplier Type
37
+ *
38
+ * @param type the Supplier Type
39
+ * @param <T> the type of value supplied
40
+ * @returns the value supplied by the Supplier Type
41
+ */
42
+ export declare function toValue<T>(type: Type<T>): T;
43
+ /**
44
+ * Check that a Supplier is present
45
+ *
46
+ * @param supplier the supplier to check
47
+ * @return the supplier if present
48
+ * @throws IllegalArgumentException if the supplier is not present
49
+ */
50
+ export declare function check<T>(supplier: Type<T>): Type<T>;
51
+ //# sourceMappingURL=Supplier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Supplier.d.ts","sourceRoot":"","sources":["../../src/auxiliary/Supplier.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA8B,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAG7F;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC;IAAI,MAAM,IAAI,CAAC,CAAC;CAAE;AAE7C;;GAEG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAElD;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAEjF;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAYpE;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAQ3C;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAEnD"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ /**
3
+ * Supplier.ts
4
+ * Defines a Supplier type that can supply values of type T.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.guard = guard;
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");
13
+ /**
14
+ * Duck type guard check for Supplier
15
+ *
16
+ * @param instance the instance to check
17
+ * @param <T> the type of value supplied
18
+ * @returns true if instance is a Supplier, false otherwise
19
+ */
20
+ function guard(instance) {
21
+ return (0, Types_1.guardFunctions)(instance, 'supply');
22
+ }
23
+ /**
24
+ * Convert a Type to a Supplier
25
+ * @param type the type to convert
26
+ * @param <T> the type of value supplied
27
+ * @returns a Supplier that supplies values of type T
28
+ */
29
+ function fromType(type) {
30
+ if (guard(type)) {
31
+ return type;
32
+ }
33
+ else if ((0, Types_1.isFunction)(type)) {
34
+ return {
35
+ supply: type
36
+ };
37
+ }
38
+ else {
39
+ return {
40
+ supply: () => type
41
+ };
42
+ }
43
+ }
44
+ /**
45
+ * Get the value from a Supplier Type
46
+ *
47
+ * @param type the Supplier Type
48
+ * @param <T> the type of value supplied
49
+ * @returns the value supplied by the Supplier Type
50
+ */
51
+ function toValue(type) {
52
+ if (guard(type)) {
53
+ return type.supply();
54
+ }
55
+ else if ((0, Types_1.isFunction)(type)) {
56
+ return type();
57
+ }
58
+ else {
59
+ return type;
60
+ }
61
+ }
62
+ /**
63
+ * Check that a Supplier is present
64
+ *
65
+ * @param supplier the supplier to check
66
+ * @return the supplier if present
67
+ * @throws IllegalArgumentException if the supplier is not present
68
+ */
69
+ function check(supplier) {
70
+ return (0, Checks_1.presentCheck)(supplier, "Supplier must be present.");
71
+ }
72
+ //# sourceMappingURL=Supplier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Supplier.js","sourceRoot":"","sources":["../../src/auxiliary/Supplier.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AA2BH,sBAEC;AAQD,4BAYC;AASD,0BAQC;AASD,sBAEC;AA3ED,6DAA6F;AAC7F,qEAAwE;AAiBxE;;;;;;GAMG;AACH,SAAgB,KAAK,CAAI,QAAiB;IACxC,OAAO,IAAA,sBAAc,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAI,IAAa;IACvC,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,IAAI,IAAA,kBAAU,EAAC,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,SAAgB,OAAO,CAAI,IAAa;IACtC,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;SAAM,IAAI,IAAA,kBAAU,EAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,KAAK,CAAI,QAAiB;IACxC,OAAO,IAAA,qBAAY,EAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Transform.ts
3
+ *
4
+ * Defines a Transform type that can transform values of type I to type O.
5
+ */
6
+ import { RequiredType } from "@jonloucks/contracts-ts/api/Types";
7
+ /**
8
+ * A function that transforms type I to type O
9
+ */
10
+ export type Method<I, O> = (input: I) => O;
11
+ /**
12
+ * A transformation from type I to type O
13
+ */
14
+ export interface Transform<I, O> {
15
+ /**
16
+ * Transform an input of type I to an output of type O
17
+ *
18
+ * @param input the input to transform
19
+ * @returns the transformed output
20
+ */
21
+ transform(input: I): O;
22
+ }
23
+ /**
24
+ * A transformation type that can be a Transform or a function from type I to type O
25
+ */
26
+ export type Type<I, O> = Transform<I, O> | Method<I, O> | O;
27
+ /**
28
+ * Check if a value is a Transform
29
+ *
30
+ * @param transform the value to check
31
+ * @returns true if the value is a Transform, false otherwise
32
+ */
33
+ export declare function guard<I, O>(transform: unknown): transform is Transform<I, O>;
34
+ /**
35
+ * Check if a value is a function with arity 1
36
+ *
37
+ * @param transform the value to check
38
+ * @returns true if the value is a function with arity 1, false otherwise
39
+ */
40
+ export declare function guardMethod<I, O>(transform: unknown): transform is Method<I, O>;
41
+ /**
42
+ * Convert a TransformType to a Transform
43
+ *
44
+ * @param transform the TransformType to convert
45
+ * @returns the Transform
46
+ */
47
+ export declare function fromType<I, O>(transform: Type<I, O>): RequiredType<Transform<I, O>>;
48
+ /**
49
+ * Get the value from a Transform Type
50
+ *
51
+ * @param type the Transform Type
52
+ * @param <T> the type of value supplied
53
+ * @returns the value supplied by the Transform Type
54
+ */
55
+ export declare function toValue<I, O>(type: Type<I, O>, input: I): O;
56
+ /**
57
+ * Check that a Transform is present
58
+ *
59
+ * @param transform the transform to check
60
+ * @return the transform if present
61
+ * @throws IllegalArgumentException if the transform is not present
62
+ */
63
+ export declare function check<I, O>(transform: Type<I, O>): Type<I, O>;
64
+ //# sourceMappingURL=Transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Transform.d.ts","sourceRoot":"","sources":["../../src/auxiliary/Transform.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAuC,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAGtG;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,EAAE,CAAC;IAE7B;;;;;OAKG;IACH,SAAS,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AAE5D;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,GAAG,SAAS,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAE5E;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,GAAG,SAAS,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAE/E;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAanF;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,EAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAQzD;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,EAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAC,CAAC,CAAC,CAE1D"}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ /**
3
+ * Transform.ts
4
+ *
5
+ * Defines a Transform type that can transform values of type I to type O.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.guard = guard;
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");
15
+ /**
16
+ * Check if a value is a Transform
17
+ *
18
+ * @param transform the value to check
19
+ * @returns true if the value is a Transform, false otherwise
20
+ */
21
+ function guard(transform) {
22
+ return (0, Types_1.guardFunctions)(transform, 'transform');
23
+ }
24
+ /**
25
+ * Check if a value is a function with arity 1
26
+ *
27
+ * @param transform the value to check
28
+ * @returns true if the value is a function with arity 1, false otherwise
29
+ */
30
+ function guardMethod(transform) {
31
+ return (0, Types_1.isFunctionWithArity)(transform, 1);
32
+ }
33
+ /**
34
+ * Convert a TransformType to a Transform
35
+ *
36
+ * @param transform the TransformType to convert
37
+ * @returns the Transform
38
+ */
39
+ function fromType(transform) {
40
+ if (guard(transform)) {
41
+ return transform;
42
+ }
43
+ else if (guardMethod(transform)) {
44
+ return { transform };
45
+ }
46
+ else {
47
+ return {
48
+ transform: (input) => {
49
+ (0, Checks_1.used)(input);
50
+ return transform;
51
+ },
52
+ };
53
+ }
54
+ }
55
+ /**
56
+ * Get the value from a Transform Type
57
+ *
58
+ * @param type the Transform Type
59
+ * @param <T> the type of value supplied
60
+ * @returns the value supplied by the Transform Type
61
+ */
62
+ function toValue(type, input) {
63
+ if (guard(type)) {
64
+ return type.transform(input);
65
+ }
66
+ else if (guardMethod(type)) {
67
+ return type(input); // type is a Method, call it with input
68
+ }
69
+ else {
70
+ return type; // type is a direct value of type O
71
+ }
72
+ }
73
+ /**
74
+ * Check that a Transform is present
75
+ *
76
+ * @param transform the transform to check
77
+ * @return the transform if present
78
+ * @throws IllegalArgumentException if the transform is not present
79
+ */
80
+ function check(transform) {
81
+ return (0, Checks_1.presentCheck)(transform, "Transform must be present.");
82
+ }
83
+ //# sourceMappingURL=Transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Transform.js","sourceRoot":"","sources":["../../src/auxiliary/Transform.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAmCH,sBAEC;AAQD,kCAEC;AAQD,4BAaC;AASD,0BAQC;AASD,sBAEC;AA9FD,6DAAsG;AACtG,qEAA8E;AA0B9E;;;;;GAKG;AACH,SAAgB,KAAK,CAAO,SAAkB;IAC5C,OAAO,IAAA,sBAAc,EAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAChD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,WAAW,CAAO,SAAkB;IAClD,OAAO,IAAA,2BAAmB,EAAC,SAAS,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;GAKG;AACH,SAAgB,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,IAAA,aAAI,EAAC,KAAK,CAAC,CAAC;gBACZ,OAAO,SAAc,CAAC;YACxB,CAAC;SACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,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,SAAgB,KAAK,CAAM,SAAoB;IAC7C,OAAO,IAAA,qBAAY,EAAC,SAAS,EAAE,4BAA4B,CAAC,CAAC;AAC/D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jonloucks/contracts-ts",
3
- "version": "1.2.3",
3
+ "version": "1.4.0",
4
4
  "description": "Typescript Dependency Contracts for dependency inversion",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -67,9 +67,10 @@
67
67
  "registry": "https://registry.npmjs.org/"
68
68
  },
69
69
  "devDependencies": {
70
+ "@jonloucks/badges-ts": "^0.1.0",
70
71
  "@types/jest": "^30.0.0",
71
- "@types/node": "^25.2.2",
72
- "@typescript-eslint/eslint-plugin": "^8.54.0",
72
+ "@types/node": "^25.2.3",
73
+ "@typescript-eslint/eslint-plugin": "^8.55.0",
73
74
  "@typescript-eslint/parser": "^8.53.1",
74
75
  "eslint": "^9.39.2",
75
76
  "jest": "^30.2.0",
@@ -77,8 +78,5 @@
77
78
  "ts-jest": "^29.4.6",
78
79
  "typedoc": "^0.28.15",
79
80
  "typescript": "^5.9.3"
80
- },
81
- "dependencies": {
82
- "@jonloucks/badges-ts": "^0.1.0"
83
81
  }
84
82
  }
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.2.3";
6
+ exports.VERSION = "1.4.0";
7
7
  //# sourceMappingURL=version.js.map