@guillaume-docquier/tools-ts 3.0.2 → 4.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/dist/Range.d.ts CHANGED
@@ -1,118 +1,59 @@
1
1
  import { Result } from "./Result.js";
2
+ type NumericType = "float" | "integer";
3
+ type BoundType = "inclusive" | "exclusive";
2
4
  /**
3
5
  * A finite numeric interval with an inclusive minimum and either an inclusive or exclusive maximum.
4
6
  * Use the Range factory methods to create valid ranges.
5
7
  */
6
- export type Range<TNumericType extends NumericType = NumericType> = InclusiveRange<TNumericType> | ExclusiveRange<TNumericType>;
7
- /**
8
- * A finite numeric interval whose maximum value is included in the range.
9
- * Use the {@link Range.safeCreateMaxInclusive} or {@link Range.createMaxInclusive} factory methods to create valid InclusiveRanges.
10
- */
11
- export type InclusiveRange<TNumericType extends NumericType> = {
12
- /**
13
- * Discriminator for ranges where the maximum value is included.
14
- */
15
- readonly type: "MaxInclusive";
8
+ export type Range<TNumericType extends NumericType = NumericType, TBoundType extends BoundType = BoundType> = {
16
9
  /**
17
10
  * The kind of numeric values accepted by the range.
18
11
  */
19
12
  readonly numericType: TNumericType;
20
13
  /**
21
- * The inclusive lower bound.
22
- */
23
- readonly min: number;
24
- /**
25
- * The inclusive upper bound.
26
- */
27
- readonly maxInclusive: number;
28
- /**
29
- * Optional outer range that this range must stay within.
30
- */
31
- readonly limits?: Range<TNumericType>;
32
- };
33
- /**
34
- * A finite numeric interval whose maximum value is excluded from the range.
35
- * Use the {@link Range.safeCreateMaxExclusive} or {@link Range.createMaxExclusive} factory methods to create valid ExclusiveRanges.
36
- */
37
- export type ExclusiveRange<TNumericType extends NumericType> = {
38
- /**
39
- * Discriminator for ranges where the maximum value is excluded.
14
+ * Whether the max bound should be inclusive or exclusive.
40
15
  */
41
- readonly type: "MaxExclusive";
42
- /**
43
- * The kind of numeric values accepted by the range.
44
- */
45
- readonly numericType: TNumericType;
16
+ readonly maxBoundType: TBoundType;
46
17
  /**
47
18
  * The inclusive lower bound.
48
19
  */
49
20
  readonly min: number;
50
21
  /**
51
- * The exclusive upper bound.
52
- */
53
- readonly maxExclusive: number;
54
- /**
55
- * Optional outer range that this range must stay within.
22
+ * The inclusive upper bound.
56
23
  */
57
- readonly limits?: Range<TNumericType>;
24
+ readonly max: number;
58
25
  };
59
- type NumericType = "float" | "integer";
60
26
  /**
61
27
  * Helpers for creating, validating, comparing, and narrowing numeric ranges.
62
28
  */
63
29
  export declare const Range: {
64
30
  /**
65
- * Creates a range that includes its maximum value.
66
- * The function throws if the Range parameters are invalid. You should use this for trusted code only.
67
- *
68
- * @param data The range values, excluding the discriminator added by this function.
69
- */
70
- createMaxInclusive: <TNumericType extends NumericType>(data: Omit<InclusiveRange<TNumericType>, "type">) => InclusiveRange<TNumericType>;
71
- /**
72
- * Creates a range that includes its maximum value.
73
- * The function returns a Failure if the Range parameters are invalid.
74
- *
75
- * @param data The range values, excluding the discriminator added by this function.
76
- */
77
- safeCreateMaxInclusive: <TNumericType extends NumericType>(data: Omit<InclusiveRange<TNumericType>, "type">) => Result<InclusiveRange<TNumericType>, string>;
78
- /**
79
- * Creates a range that excludes its maximum value.
31
+ * Creates a range.
80
32
  * The function throws if the Range parameters are invalid. You should use this for trusted code only.
81
33
  *
82
- * @param data The range values, excluding the discriminator added by this function.
34
+ * @param data The range values.
83
35
  */
84
- createMaxExclusive: <TNumericType extends NumericType>(data: Omit<ExclusiveRange<TNumericType>, "type">) => ExclusiveRange<TNumericType>;
36
+ create: <TNumericType extends NumericType, TBoundType extends BoundType>(data: Range<TNumericType, TBoundType>) => Range<TNumericType, TBoundType>;
85
37
  /**
86
- * Creates a range that excludes its maximum value.
38
+ * Creates a range.
87
39
  * The function returns a Failure if the Range parameters are invalid.
88
40
  *
89
- * @param range The range values, excluding the discriminator added by this function.
41
+ * @param data The range values.
90
42
  */
91
- safeCreateMaxExclusive: <TNumericType extends NumericType>(range: Omit<ExclusiveRange<TNumericType>, "type">) => Result<ExclusiveRange<TNumericType>, string>;
43
+ safeCreate: <TNumericType extends NumericType, TBoundType extends BoundType>(data: Range<TNumericType, TBoundType>) => Result<Range<TNumericType, TBoundType>, string>;
92
44
  /**
93
- * Creates a new range with the same discriminator, numeric type, and limits as another range.
45
+ * Creates a new range from another one.
46
+ * When passing withValues, the min and max will replace that of the base range.
47
+ * When withValues is omitted, this returns a clone.
94
48
  *
95
49
  * @param fromRange The range to copy the shape from.
96
- * @param withValues The replacement minimum and maximum values.
50
+ * @param withValues The replacement minimum or maximum values.
97
51
  */
98
- from: <TRange extends Range<TNumericType>, TNumericType extends NumericType>(fromRange: TRange, withValues: {
99
- min: number;
100
- max: number;
101
- }) => Result<TRange, string>;
102
- /**
103
- * Checks whether a Range is valid.
104
- * This is only useful to run on untrusted input since the Range constructors already ensures the Range is valid.
105
- *
106
- * @param range The range to validate.
107
- */
108
- validate: (range: Range) => string | undefined;
109
- /**
110
- * Checks whether a numeric value is inside the Range.
111
- *
112
- * @param range The range to test against.
113
- * @param value The value to test.
114
- */
115
- isWithin: (range: Range, value: number) => boolean;
52
+ from: <TNumericType extends NumericType, TBoundType extends BoundType>(fromRange: Range<TNumericType, TBoundType>, withValues?: {
53
+ min?: number;
54
+ max?: number;
55
+ }) => Result<Range<TNumericType, TBoundType>, string>;
56
+ isWithin: typeof isWithin;
116
57
  /**
117
58
  * Checks whether two Ranges share at least one value.
118
59
  *
@@ -121,4 +62,18 @@ export declare const Range: {
121
62
  */
122
63
  overlaps: <TNumericType extends NumericType>(a: Range<TNumericType>, b: Range<TNumericType>) => boolean;
123
64
  };
65
+ /**
66
+ * Checks whether a Range is inside another Range.
67
+ *
68
+ * @param bounds The largest range.
69
+ * @param value The range to check.
70
+ */
71
+ declare function isWithin(bounds: Range, value: Range): boolean;
72
+ /**
73
+ * Checks whether a numeric value is inside the Range.
74
+ *
75
+ * @param bounds The range to test against.
76
+ * @param value The value to test.
77
+ */
78
+ declare function isWithin(bounds: Range, value: number): boolean;
124
79
  export {};
package/dist/Range.js CHANGED
@@ -1,121 +1,49 @@
1
1
  import { Result } from "./Result.js";
2
2
  import { Assert } from "./Assert.js";
3
+ import { TypeGuard } from "./TypeGuard.js";
3
4
  /**
4
5
  * Helpers for creating, validating, comparing, and narrowing numeric ranges.
5
6
  */
6
7
  export const Range = {
7
8
  /**
8
- * Creates a range that includes its maximum value.
9
+ * Creates a range.
9
10
  * The function throws if the Range parameters are invalid. You should use this for trusted code only.
10
11
  *
11
- * @param data The range values, excluding the discriminator added by this function.
12
+ * @param data The range values.
12
13
  */
13
- createMaxInclusive: (data) => {
14
- const rangeResult = Range.safeCreateMaxInclusive(data);
14
+ create: (data) => {
15
+ const rangeResult = Range.safeCreate(data);
15
16
  Assert.isSuccess(rangeResult);
16
17
  return rangeResult.value;
17
18
  },
18
19
  /**
19
- * Creates a range that includes its maximum value.
20
+ * Creates a range.
20
21
  * The function returns a Failure if the Range parameters are invalid.
21
22
  *
22
- * @param data The range values, excluding the discriminator added by this function.
23
+ * @param data The range values.
23
24
  */
24
- safeCreateMaxInclusive: (data) => {
25
- const inclusiveRange = {
26
- ...data,
27
- type: "MaxInclusive",
28
- };
29
- const invalidReason = Range.validate(inclusiveRange);
25
+ safeCreate: (data) => {
26
+ const invalidReason = validate(data);
30
27
  if (invalidReason !== undefined) {
31
28
  return Result.Failure(invalidReason);
32
29
  }
33
- return Result.Success(inclusiveRange);
34
- },
35
- /**
36
- * Creates a range that excludes its maximum value.
37
- * The function throws if the Range parameters are invalid. You should use this for trusted code only.
38
- *
39
- * @param data The range values, excluding the discriminator added by this function.
40
- */
41
- createMaxExclusive: (data) => {
42
- const rangeResult = Range.safeCreateMaxExclusive(data);
43
- Assert.isSuccess(rangeResult);
44
- return rangeResult.value;
30
+ return Result.Success(data);
45
31
  },
46
32
  /**
47
- * Creates a range that excludes its maximum value.
48
- * The function returns a Failure if the Range parameters are invalid.
49
- *
50
- * @param range The range values, excluding the discriminator added by this function.
51
- */
52
- safeCreateMaxExclusive: (range) => {
53
- const exclusiveRange = {
54
- ...range,
55
- type: "MaxExclusive",
56
- };
57
- const invalidReason = Range.validate(exclusiveRange);
58
- if (invalidReason !== undefined) {
59
- return Result.Failure(invalidReason);
60
- }
61
- return Result.Success(exclusiveRange);
62
- },
63
- /**
64
- * Creates a new range with the same discriminator, numeric type, and limits as another range.
33
+ * Creates a new range from another one.
34
+ * When passing withValues, the min and max will replace that of the base range.
35
+ * When withValues is omitted, this returns a clone.
65
36
  *
66
37
  * @param fromRange The range to copy the shape from.
67
- * @param withValues The replacement minimum and maximum values.
68
- */
69
- from: (fromRange, withValues) => {
70
- switch (fromRange.type) {
71
- case "MaxExclusive":
72
- return Range.safeCreateMaxExclusive({
73
- numericType: fromRange.numericType,
74
- min: withValues.min,
75
- maxExclusive: withValues.max,
76
- limits: fromRange.limits,
77
- });
78
- case "MaxInclusive":
79
- return Range.safeCreateMaxInclusive({
80
- numericType: fromRange.numericType,
81
- min: withValues.min,
82
- maxInclusive: withValues.max,
83
- limits: fromRange.limits,
84
- });
85
- }
86
- },
87
- /**
88
- * Checks whether a Range is valid.
89
- * This is only useful to run on untrusted input since the Range constructors already ensures the Range is valid.
90
- *
91
- * @param range The range to validate.
92
- */
93
- validate: (range) => {
94
- for (const rule of RANGE_VALIDATION_RULES) {
95
- const reason = rule(range);
96
- if (reason !== undefined) {
97
- return reason;
98
- }
99
- }
100
- return undefined;
101
- },
102
- /**
103
- * Checks whether a numeric value is inside the Range.
104
- *
105
- * @param range The range to test against.
106
- * @param value The value to test.
38
+ * @param withValues The replacement minimum or maximum values.
107
39
  */
108
- isWithin: (range, value) => {
109
- if (value < range.min) {
110
- return false;
111
- }
112
- switch (range.type) {
113
- case "MaxExclusive":
114
- return value < range.maxExclusive;
115
- case "MaxInclusive":
116
- return value <= range.maxInclusive;
117
- }
40
+ from: (fromRange, withValues = {}) => {
41
+ return Range.safeCreate({
42
+ ...fromRange,
43
+ ...withValues,
44
+ });
118
45
  },
46
+ isWithin,
119
47
  /**
120
48
  * Checks whether two Ranges share at least one value.
121
49
  *
@@ -126,51 +54,90 @@ export const Range = {
126
54
  return Range.isWithin(a, b.min) || Range.isWithin(b, a.min);
127
55
  },
128
56
  };
57
+ /**
58
+ * Checks whether a numeric value or Range is inside another Range.
59
+ *
60
+ * @param bounds The range to test against.
61
+ * @param value The value to test.
62
+ */
63
+ function isWithin(bounds, value) {
64
+ if (TypeGuard.isNumber(value)) {
65
+ if (value < bounds.min) {
66
+ return false;
67
+ }
68
+ if (value < bounds.max) {
69
+ return true;
70
+ }
71
+ if (value === bounds.max) {
72
+ return bounds.maxBoundType === "inclusive";
73
+ }
74
+ return false;
75
+ }
76
+ const normalizedBounds = normalizeUpperBound(bounds);
77
+ const normalizedValue = normalizeUpperBound(value);
78
+ if (value.min < bounds.min) {
79
+ return false;
80
+ }
81
+ if (normalizedValue.max < normalizedBounds.max) {
82
+ return true;
83
+ }
84
+ if (normalizedValue.max > normalizedBounds.max) {
85
+ return false;
86
+ }
87
+ return !(normalizedValue.boundType === "inclusive" && normalizedBounds.boundType === "exclusive");
88
+ }
89
+ function normalizeUpperBound(range) {
90
+ if (range.numericType === "integer" && range.maxBoundType === "exclusive") {
91
+ return {
92
+ max: range.max - 1,
93
+ boundType: "inclusive",
94
+ };
95
+ }
96
+ return {
97
+ max: range.max,
98
+ boundType: range.maxBoundType,
99
+ };
100
+ }
101
+ /**
102
+ * Checks whether a Range is valid.
103
+ * This is only useful to run on untrusted input since the Range constructors already ensures the Range is valid.
104
+ *
105
+ * @param range The range to validate.
106
+ */
107
+ function validate(range) {
108
+ for (const rule of RANGE_VALIDATION_RULES) {
109
+ const reason = rule(range);
110
+ if (reason !== undefined) {
111
+ return reason;
112
+ }
113
+ }
114
+ return undefined;
115
+ }
129
116
  const RANGE_VALIDATION_RULES = [
130
117
  minIsFinite,
131
118
  maxIsFinite,
132
- minIsValidNumberType,
133
- maxIsValidNumberType,
119
+ minIsValidNumericType,
120
+ maxIsValidNumericType,
134
121
  minIsSmallerThanMax,
135
- limitsAreValid,
136
- minIsWithinLimits,
137
- maxIsWithinLimits,
138
122
  ];
139
123
  function minIsFinite(range) {
140
124
  return Number.isFinite(range.min) ? undefined : "Min must be a finite number";
141
125
  }
142
126
  function maxIsFinite(range) {
143
- return Number.isFinite(getMax(range)) ? undefined : "Min must be a finite number";
127
+ return Number.isFinite(range.max) ? undefined : "Min must be a finite number";
144
128
  }
145
- function minIsValidNumberType(range) {
129
+ function minIsValidNumericType(range) {
146
130
  return range.numericType === "float" || Number.isInteger(range.min) ? undefined : `Min must be a ${range.numericType} number`;
147
131
  }
148
- function maxIsValidNumberType(range) {
149
- return range.numericType === "float" || Number.isInteger(getMax(range)) ? undefined : `Max must be a ${range.numericType} number`;
132
+ function maxIsValidNumericType(range) {
133
+ return range.numericType === "float" || Number.isInteger(range.max) ? undefined : `Max must be a ${range.numericType} number`;
150
134
  }
151
135
  function minIsSmallerThanMax(range) {
152
- switch (range.type) {
153
- case "MaxExclusive":
154
- return range.min < range.maxExclusive ? undefined : "Min must be smaller than the exclusive max";
155
- case "MaxInclusive":
156
- return range.min <= range.maxInclusive ? undefined : "Min must be smaller or equal to the inclusive max";
157
- }
158
- }
159
- function limitsAreValid(range) {
160
- return range.limits === undefined ? undefined : Range.validate(range.limits);
161
- }
162
- function minIsWithinLimits(range) {
163
- return range.limits === undefined || Range.isWithin(range.limits, range.min) ? undefined : "Min must be within limits";
164
- }
165
- function maxIsWithinLimits(range) {
166
- return range.limits === undefined || Range.isWithin(range.limits, getMax(range)) ? undefined : "Max must be within limits";
167
- }
168
- function getMax(range) {
169
- switch (range.type) {
170
- case "MaxExclusive":
171
- return range.maxExclusive;
172
- case "MaxInclusive":
173
- return range.maxInclusive;
136
+ switch (range.maxBoundType) {
137
+ case "exclusive":
138
+ return range.min < range.max ? undefined : "Min must be smaller than the exclusive max";
139
+ case "inclusive":
140
+ return range.min <= range.max ? undefined : "Min must be smaller or equal to the inclusive max";
174
141
  }
175
142
  }
176
143
  //# sourceMappingURL=Range.js.map
package/dist/Range.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Range.js","sourceRoot":"","sources":["../src/Range.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAwEpC;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB;;;;;OAKG;IACH,kBAAkB,EAAE,CAClB,IAAgD,EAClB,EAAE;QAChC,MAAM,WAAW,GAAG,KAAK,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAA;QACtD,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;QAE7B,OAAO,WAAW,CAAC,KAAK,CAAA;IAC1B,CAAC;IAED;;;;;OAKG;IACH,sBAAsB,EAAE,CACtB,IAAgD,EACF,EAAE;QAChD,MAAM,cAAc,GAAiC;YACnD,GAAG,IAAI;YACP,IAAI,EAAE,cAAc;SACrB,CAAA;QAED,MAAM,aAAa,GAAG,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAA;QACpD,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;QACtC,CAAC;QAED,OAAO,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IACvC,CAAC;IAED;;;;;OAKG;IACH,kBAAkB,EAAE,CAClB,IAAgD,EAClB,EAAE;QAChC,MAAM,WAAW,GAAG,KAAK,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAA;QACtD,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;QAE7B,OAAO,WAAW,CAAC,KAAK,CAAA;IAC1B,CAAC;IAED;;;;;OAKG;IACH,sBAAsB,EAAE,CACtB,KAAiD,EACH,EAAE;QAChD,MAAM,cAAc,GAAiC;YACnD,GAAG,KAAK;YACR,IAAI,EAAE,cAAc;SACrB,CAAA;QAED,M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M,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,KAAK,CAAC,WAAW,SAAS,CAAA;AAC/H,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAyC;IACpE,QAAQ,KAAK,CAAC,YAAY,EAAE,CAAC;QAC3B,KAAK,WAAW;YACd,OAAO,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,4CAA4C,CAAA;QACzF,KAAK,WAAW;YACd,OAAO,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,mDAAmD,CAAA;IACnG,CAAC;AACH,CAAC"}
@@ -9,7 +9,7 @@ export { asArray } from "./asArray.js";
9
9
  export { Assert } from "./Assert.js";
10
10
  export { Result, type Success, type Failure } from "./Result.js";
11
11
  export { Measure } from "./Measure.js";
12
- export { Range, type InclusiveRange, type ExclusiveRange } from "./Range.js";
12
+ export { Range } from "./Range.js";
13
13
  export { TypeGuard } from "./TypeGuard.js";
14
14
  export { setTimeoutAsync } from "./setTimeoutAsync.js";
15
15
  export { noop, asyncNoop } from "./noop.js";
@@ -1 +1 @@
1
- {"version":3,"file":"entry.tools-ts.js","sourceRoot":"","sources":["../src/entry.tools-ts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAI5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CA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,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAA;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAA;AAEtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AAKvE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guillaume-docquier/tools-ts",
3
- "version": "3.0.2",
3
+ "version": "4.0.0",
4
4
  "description": "My personal collection of typescript tools",
5
5
  "homepage": "https://github.com/Guillaume-Docquier/tools-ts",
6
6
  "repository": {