@guillaume-docquier/tools-ts 2.1.0 → 2.2.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 +96 -0
- package/dist/Range.d.ts +110 -0
- package/dist/Range.js +153 -0
- package/dist/Range.js.map +1 -0
- package/dist/entry.tools-ts.d.ts +1 -0
- package/dist/entry.tools-ts.js +1 -0
- package/dist/entry.tools-ts.js.map +1 -1
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -1,3 +1,99 @@
|
|
|
1
1
|
# tools-ts
|
|
2
2
|
|
|
3
3
|
A collection of small typescript tools published to npm
|
|
4
|
+
|
|
5
|
+
## Exported Tools Overview
|
|
6
|
+
|
|
7
|
+
This package is a grab bag of focused TypeScript utilities. Use this README as the
|
|
8
|
+
orientation layer: it tells you which tool to reach for and when. The individual
|
|
9
|
+
modules contain the deeper API examples and implementation notes.
|
|
10
|
+
|
|
11
|
+
### Error Handling And Assertions
|
|
12
|
+
|
|
13
|
+
Use these tools when code needs to distinguish expected failures from broken
|
|
14
|
+
program assumptions.
|
|
15
|
+
|
|
16
|
+
| Export | What it is | Use it when |
|
|
17
|
+
| ------------------------------ | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
18
|
+
| `Result`, `Success`, `Failure` | A typed success/failure return shape plus helper constructors and guards. | You want expected failures to be returned and handled explicitly instead of thrown. Prefer this for recoverable application outcomes. |
|
|
19
|
+
| `Result.tryCatch` | A wrapper that converts thrown or rejected non-fatal errors into `Failure`. | You are calling code that may throw, especially third-party APIs, and want to bring it back into the `Result` flow. |
|
|
20
|
+
| `Assert` | Runtime assertion helpers that throw `AssertionError` and narrow TypeScript types. | TypeScript cannot express an invariant strongly enough, or test code needs a clear fatal assertion. |
|
|
21
|
+
| `AssertionError` | A fatal error for violated assumptions, with structured context. | A program invariant is broken and continuing would hide a bug or corrupt later state. Usually use `Assert` unless you need a custom assertion. |
|
|
22
|
+
| `FatalError` | Base fatal error class with an `isFatal` flag and structured context. | An error should crash or escape normal expected-error handling. Extend this for domain-specific fatal errors. |
|
|
23
|
+
| `Rethrow` | Helpers for catch blocks that should not swallow fatal errors. | You catch `unknown` but only intend to handle recoverable `Error` instances. |
|
|
24
|
+
| `NotImplementedError` | A fatal placeholder error with tracking context. | A code path intentionally exists before the feature is implemented, and the missing work should be traceable. |
|
|
25
|
+
| `isNodeJSError` | Type guard for Node-style `ErrnoException` properties on `Error`. | You need to inspect fields like `code`, `path`, `errno`, or `syscall` after catching a Node.js error. |
|
|
26
|
+
|
|
27
|
+
### Type And Value Guards
|
|
28
|
+
|
|
29
|
+
Use these tools at runtime boundaries: parsed JSON, environment variables,
|
|
30
|
+
external APIs, CLI input, local storage, or other unknown data.
|
|
31
|
+
|
|
32
|
+
| Export | What it is | Use it when |
|
|
33
|
+
| ------------ | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
|
34
|
+
| `TypeGuard` | Small runtime guards for primitives, arrays, records, integers, and enum members. | You need non-throwing checks that also narrow types. |
|
|
35
|
+
| `getEnumKey` | Looks up the enum key associated with a value. | You have an enum value and need the more descriptive key for display, logs, or diagnostics. |
|
|
36
|
+
| `asArray` | Normalizes a single value or array into an array. | An API accepts both `T` and `T[]`, but downstream logic should iterate uniformly. |
|
|
37
|
+
|
|
38
|
+
### Numeric Ranges
|
|
39
|
+
|
|
40
|
+
Use this tool when code needs a reusable, validated numeric interval instead of
|
|
41
|
+
duplicating min/max checks across call sites.
|
|
42
|
+
|
|
43
|
+
| Export | What it is | Use it when |
|
|
44
|
+
| ------- | ---------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
|
|
45
|
+
| `Range` | Helpers for creating, validating, comparing, and testing ranges. | You need finite integer or float intervals with inclusive minimums and configurable maximums. |
|
|
46
|
+
|
|
47
|
+
### Utility Types
|
|
48
|
+
|
|
49
|
+
These exports are type-only helpers for common TypeScript modeling problems.
|
|
50
|
+
|
|
51
|
+
| Export | What it is | Use it when |
|
|
52
|
+
| ------------------------------------------ | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
|
|
53
|
+
| `ConstructorType` | A type for class constructors. | A function accepts a class and later uses `new` or `instanceof` against it. |
|
|
54
|
+
| `EnumKeyType`, `EnumValueType`, `EnumType` | Broad shapes for enum-like objects. | You are writing generic utilities that operate on TypeScript enums or const-object enums. |
|
|
55
|
+
| `Enumify` | Converts a const object into a union of its values. | A project avoids TypeScript `enum` but wants enum-like ergonomics from `as const` objects. |
|
|
56
|
+
| `ValueOf` | Produces a union of an object's value types. | You need the values of a lookup object as a type. |
|
|
57
|
+
| `Prettify` | Re-expands an object type for easier editor hovers. | Intersections or mapped types are correct but hard to read in tooling. |
|
|
58
|
+
| `OmitOverUnion` | Applies `Omit` distributively across union members. | Native `Omit` collapses a discriminated union in a way that loses member-specific fields. |
|
|
59
|
+
| `PartialProperties` | Makes selected object properties partial, not the whole object. | Only nested property objects should become partial while the parent shape stays required. |
|
|
60
|
+
| `Mutable` | Removes `readonly` from selected properties. | You have a narrow, deliberate mutation need. Avoid this unless there is no cleaner model. |
|
|
61
|
+
|
|
62
|
+
### Logging
|
|
63
|
+
|
|
64
|
+
Use the logging tools when an application or library needs structured logs with
|
|
65
|
+
consistent context, scopes, formatting, and redaction.
|
|
66
|
+
|
|
67
|
+
| Export | What it is | Use it when |
|
|
68
|
+
| --------------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
69
|
+
| `Logger` | The package logger facade, backed by LogTape, with root configuration and child scoped loggers. | Application code needs to configure sinks/context, or library code needs a logger that can be configured later by the host app. |
|
|
70
|
+
| `createConsoleLogSink` | Console sink factory with production-oriented defaults. | You need a ready-to-use console sink with JSON lines, non-blocking writes, and secret redaction by default. |
|
|
71
|
+
| `jsonLineFormatter` | Structured one-record-per-line log formatter. | Logs are going to production systems, aggregators, or files where machine parsing matters. |
|
|
72
|
+
| `prettyConsoleFormatter` | Human-readable console formatter with expandable structured context. | Local development needs readable console output. |
|
|
73
|
+
| `RECOMMENDED_LOG_REDACTION` | Default field redaction rules for common secrets. | You want a baseline set of credential and sensitive-field protections for logs. |
|
|
74
|
+
| `LogSink` | Type alias for supported logging sinks. | You are typing sink integrations or custom sink factories. |
|
|
75
|
+
| `LogContext` | Type for user-provided structured log context. | You attach serializable context to log calls or logger instances. |
|
|
76
|
+
| `LoggerContext` | Type for the final context shape passed to sinks and formatters. | You are writing a formatter or sink and need the logger-reserved `scopes` field. |
|
|
77
|
+
| `LogContextProvider` | Interface for dynamic context providers. | Log context changes over time, such as the active user, request, tenant, or job. |
|
|
78
|
+
|
|
79
|
+
### Runtime Utilities
|
|
80
|
+
|
|
81
|
+
Use these small utilities to keep common asynchronous and callback patterns
|
|
82
|
+
consistent.
|
|
83
|
+
|
|
84
|
+
| Export | What it is | Use it when |
|
|
85
|
+
| ----------------- | ----------------------------- | ------------------------------------------------------------------------------- |
|
|
86
|
+
| `setTimeoutAsync` | Promise-based timeout helper. | You want `await`-friendly delays that work in browser and Node environments. |
|
|
87
|
+
| `debounce` | Creates a debounced callback. | A repeated event should trigger work only after calls have settled for a delay. |
|
|
88
|
+
| `noop` | Synchronous no-op function. | You need a safe default callback that intentionally does nothing. |
|
|
89
|
+
| `asyncNoop` | Asynchronous no-op function. | You need a safe default async callback or hook that resolves immediately. |
|
|
90
|
+
|
|
91
|
+
### Measurement
|
|
92
|
+
|
|
93
|
+
Use these helpers for lightweight operational visibility, not for rigorous
|
|
94
|
+
benchmarking.
|
|
95
|
+
|
|
96
|
+
| Export | What it is | Use it when |
|
|
97
|
+
| ----------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------ |
|
|
98
|
+
| `Measure.executionTime` | Wraps sync or async work and logs elapsed time. | You need quick timing instrumentation around a named operation. |
|
|
99
|
+
| `Measure.memoryUsage` | Logs process memory usage in megabytes. | You need a snapshot of Node.js process memory for diagnostics or runtime visibility. |
|
package/dist/Range.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Result } from "./Result.js";
|
|
2
|
+
/**
|
|
3
|
+
* A finite numeric interval with an inclusive minimum and either an inclusive or exclusive maximum.
|
|
4
|
+
* Use {@link Range.createMaxInclusive} and {@link Range.createMaxExclusive} factory methods to create valid ranges.
|
|
5
|
+
*/
|
|
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.createMaxInclusive} factory method 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";
|
|
16
|
+
/**
|
|
17
|
+
* The kind of numeric values accepted by the range.
|
|
18
|
+
*/
|
|
19
|
+
readonly numericType: TNumericType;
|
|
20
|
+
/**
|
|
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.createMaxExclusive} factory method to create valid ExclusiveRanges.
|
|
36
|
+
*/
|
|
37
|
+
export type ExclusiveRange<TNumericType extends NumericType> = {
|
|
38
|
+
/**
|
|
39
|
+
* Discriminator for ranges where the maximum value is excluded.
|
|
40
|
+
*/
|
|
41
|
+
readonly type: "MaxExclusive";
|
|
42
|
+
/**
|
|
43
|
+
* The kind of numeric values accepted by the range.
|
|
44
|
+
*/
|
|
45
|
+
readonly numericType: TNumericType;
|
|
46
|
+
/**
|
|
47
|
+
* The inclusive lower bound.
|
|
48
|
+
*/
|
|
49
|
+
readonly min: number;
|
|
50
|
+
/**
|
|
51
|
+
* The exclusive upper bound.
|
|
52
|
+
*/
|
|
53
|
+
readonly maxExclusive: number;
|
|
54
|
+
/**
|
|
55
|
+
* Optional outer range that this range must stay within.
|
|
56
|
+
*/
|
|
57
|
+
readonly limits?: Range<TNumericType>;
|
|
58
|
+
};
|
|
59
|
+
type NumericType = "float" | "integer";
|
|
60
|
+
/**
|
|
61
|
+
* Helpers for creating, validating, comparing, and narrowing numeric ranges.
|
|
62
|
+
*/
|
|
63
|
+
export declare const Range: {
|
|
64
|
+
/**
|
|
65
|
+
* Creates a range that includes its maximum value.
|
|
66
|
+
* The function returns a Failure if the Range parameters are invalid.
|
|
67
|
+
*
|
|
68
|
+
* @param range The range values, excluding the discriminator added by this function.
|
|
69
|
+
*/
|
|
70
|
+
createMaxInclusive: <TNumericType extends NumericType>(range: Omit<InclusiveRange<TNumericType>, "type">) => Result<InclusiveRange<TNumericType>, string>;
|
|
71
|
+
/**
|
|
72
|
+
* Creates a range that excludes its maximum value.
|
|
73
|
+
* The function returns a Failure if the Range parameters are invalid.
|
|
74
|
+
*
|
|
75
|
+
* @param range The range values, excluding the discriminator added by this function.
|
|
76
|
+
*/
|
|
77
|
+
createMaxExclusive: <TNumericType extends NumericType>(range: Omit<ExclusiveRange<TNumericType>, "type">) => Result<ExclusiveRange<TNumericType>, string>;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a new range with the same discriminator, numeric type, and limits as another range.
|
|
80
|
+
*
|
|
81
|
+
* @param fromRange The range to copy the shape from.
|
|
82
|
+
* @param withValues The replacement minimum and maximum values.
|
|
83
|
+
*/
|
|
84
|
+
from: <TRange extends Range<TNumericType>, TNumericType extends NumericType>(fromRange: TRange, withValues: {
|
|
85
|
+
min: number;
|
|
86
|
+
max: number;
|
|
87
|
+
}) => Result<TRange, string>;
|
|
88
|
+
/**
|
|
89
|
+
* Checks whether a Range is valid.
|
|
90
|
+
* This is only useful to run on untrusted input since the Range constructors already ensures the Range is valid.
|
|
91
|
+
*
|
|
92
|
+
* @param range The range to validate.
|
|
93
|
+
*/
|
|
94
|
+
validate: (range: Range) => string | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Checks whether a numeric value is inside the Range.
|
|
97
|
+
*
|
|
98
|
+
* @param range The range to test against.
|
|
99
|
+
* @param value The value to test.
|
|
100
|
+
*/
|
|
101
|
+
isWithin: (range: Range, value: number) => boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Checks whether two Ranges share at least one value.
|
|
104
|
+
*
|
|
105
|
+
* @param a The first range.
|
|
106
|
+
* @param b The second range.
|
|
107
|
+
*/
|
|
108
|
+
overlaps: <TNumericType extends NumericType>(a: Range<TNumericType>, b: Range<TNumericType>) => boolean;
|
|
109
|
+
};
|
|
110
|
+
export {};
|
package/dist/Range.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Result } from "./Result.js";
|
|
2
|
+
/**
|
|
3
|
+
* Helpers for creating, validating, comparing, and narrowing numeric ranges.
|
|
4
|
+
*/
|
|
5
|
+
export const Range = {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a range that includes its maximum value.
|
|
8
|
+
* The function returns a Failure if the Range parameters are invalid.
|
|
9
|
+
*
|
|
10
|
+
* @param range The range values, excluding the discriminator added by this function.
|
|
11
|
+
*/
|
|
12
|
+
createMaxInclusive: (range) => {
|
|
13
|
+
const inclusiveRange = {
|
|
14
|
+
...range,
|
|
15
|
+
type: "MaxInclusive",
|
|
16
|
+
};
|
|
17
|
+
const invalidReason = Range.validate(inclusiveRange);
|
|
18
|
+
if (invalidReason !== undefined) {
|
|
19
|
+
return Result.Failure(invalidReason);
|
|
20
|
+
}
|
|
21
|
+
return Result.Success(inclusiveRange);
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* Creates a range that excludes its maximum value.
|
|
25
|
+
* The function returns a Failure if the Range parameters are invalid.
|
|
26
|
+
*
|
|
27
|
+
* @param range The range values, excluding the discriminator added by this function.
|
|
28
|
+
*/
|
|
29
|
+
createMaxExclusive: (range) => {
|
|
30
|
+
const exclusiveRange = {
|
|
31
|
+
...range,
|
|
32
|
+
type: "MaxExclusive",
|
|
33
|
+
};
|
|
34
|
+
const invalidReason = Range.validate(exclusiveRange);
|
|
35
|
+
if (invalidReason !== undefined) {
|
|
36
|
+
return Result.Failure(invalidReason);
|
|
37
|
+
}
|
|
38
|
+
return Result.Success(exclusiveRange);
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new range with the same discriminator, numeric type, and limits as another range.
|
|
42
|
+
*
|
|
43
|
+
* @param fromRange The range to copy the shape from.
|
|
44
|
+
* @param withValues The replacement minimum and maximum values.
|
|
45
|
+
*/
|
|
46
|
+
from: (fromRange, withValues) => {
|
|
47
|
+
switch (fromRange.type) {
|
|
48
|
+
case "MaxExclusive":
|
|
49
|
+
return Range.createMaxExclusive({
|
|
50
|
+
numericType: fromRange.numericType,
|
|
51
|
+
min: withValues.min,
|
|
52
|
+
maxExclusive: withValues.max,
|
|
53
|
+
limits: fromRange.limits,
|
|
54
|
+
});
|
|
55
|
+
case "MaxInclusive":
|
|
56
|
+
return Range.createMaxInclusive({
|
|
57
|
+
numericType: fromRange.numericType,
|
|
58
|
+
min: withValues.min,
|
|
59
|
+
maxInclusive: withValues.max,
|
|
60
|
+
limits: fromRange.limits,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* Checks whether a Range is valid.
|
|
66
|
+
* This is only useful to run on untrusted input since the Range constructors already ensures the Range is valid.
|
|
67
|
+
*
|
|
68
|
+
* @param range The range to validate.
|
|
69
|
+
*/
|
|
70
|
+
validate: (range) => {
|
|
71
|
+
for (const rule of RANGE_VALIDATION_RULES) {
|
|
72
|
+
const reason = rule(range);
|
|
73
|
+
if (reason !== undefined) {
|
|
74
|
+
return reason;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
},
|
|
79
|
+
/**
|
|
80
|
+
* Checks whether a numeric value is inside the Range.
|
|
81
|
+
*
|
|
82
|
+
* @param range The range to test against.
|
|
83
|
+
* @param value The value to test.
|
|
84
|
+
*/
|
|
85
|
+
isWithin: (range, value) => {
|
|
86
|
+
if (value < range.min) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
switch (range.type) {
|
|
90
|
+
case "MaxExclusive":
|
|
91
|
+
return value < range.maxExclusive;
|
|
92
|
+
case "MaxInclusive":
|
|
93
|
+
return value <= range.maxInclusive;
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
/**
|
|
97
|
+
* Checks whether two Ranges share at least one value.
|
|
98
|
+
*
|
|
99
|
+
* @param a The first range.
|
|
100
|
+
* @param b The second range.
|
|
101
|
+
*/
|
|
102
|
+
overlaps: (a, b) => {
|
|
103
|
+
return Range.isWithin(a, b.min) || Range.isWithin(b, a.min);
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
const RANGE_VALIDATION_RULES = [
|
|
107
|
+
minIsFinite,
|
|
108
|
+
maxIsFinite,
|
|
109
|
+
minIsValidNumberType,
|
|
110
|
+
maxIsValidNumberType,
|
|
111
|
+
minIsSmallerThanMax,
|
|
112
|
+
limitsAreValid,
|
|
113
|
+
minIsWithinLimits,
|
|
114
|
+
maxIsWithinLimits,
|
|
115
|
+
];
|
|
116
|
+
function minIsFinite(range) {
|
|
117
|
+
return Number.isFinite(range.min) ? undefined : "Min must be a finite number";
|
|
118
|
+
}
|
|
119
|
+
function maxIsFinite(range) {
|
|
120
|
+
return Number.isFinite(getMax(range)) ? undefined : "Min must be a finite number";
|
|
121
|
+
}
|
|
122
|
+
function minIsValidNumberType(range) {
|
|
123
|
+
return range.numericType === "float" || Number.isInteger(range.min) ? undefined : `Min must be a ${range.numericType} number`;
|
|
124
|
+
}
|
|
125
|
+
function maxIsValidNumberType(range) {
|
|
126
|
+
return range.numericType === "float" || Number.isInteger(getMax(range)) ? undefined : `Max must be a ${range.numericType} number`;
|
|
127
|
+
}
|
|
128
|
+
function minIsSmallerThanMax(range) {
|
|
129
|
+
switch (range.type) {
|
|
130
|
+
case "MaxExclusive":
|
|
131
|
+
return range.min < range.maxExclusive ? undefined : "Min must be smaller than the exclusive max";
|
|
132
|
+
case "MaxInclusive":
|
|
133
|
+
return range.min <= range.maxInclusive ? undefined : "Min must be smaller or equal to the inclusive max";
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function limitsAreValid(range) {
|
|
137
|
+
return range.limits === undefined ? undefined : Range.validate(range.limits);
|
|
138
|
+
}
|
|
139
|
+
function minIsWithinLimits(range) {
|
|
140
|
+
return range.limits === undefined || Range.isWithin(range.limits, range.min) ? undefined : "Min must be within limits";
|
|
141
|
+
}
|
|
142
|
+
function maxIsWithinLimits(range) {
|
|
143
|
+
return range.limits === undefined || Range.isWithin(range.limits, getMax(range)) ? undefined : "Max must be within limits";
|
|
144
|
+
}
|
|
145
|
+
function getMax(range) {
|
|
146
|
+
switch (range.type) {
|
|
147
|
+
case "MaxExclusive":
|
|
148
|
+
return range.maxExclusive;
|
|
149
|
+
case "MaxInclusive":
|
|
150
|
+
return range.maxInclusive;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=Range.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Range.js","sourceRoot":"","sources":["../src/Range.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAwEpC;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB;;;;;OAKG;IACH,kBAAkB,EAAE,CAClB,KAAiD,EACH,EAAE;QAChD,MAAM,cAAc,GAAiC;YACnD,GAAG,KAAK;YACR,IAAI,EAAE,cAAc;SACrB,CAAA;QA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EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,2BAA2B,CAAA;AACxH,CAAC;AACD,SAAS,iBAAiB,CAAC,KAAyC;IAClE,OAAO,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,2BAA2B,CAAA;AAC5H,CAAC;AAED,SAAS,MAAM,CAAC,KAAY;IAC1B,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,cAAc;YACjB,OAAO,KAAK,CAAC,YAAY,CAAA;QAC3B,KAAK,cAAc;YACjB,OAAO,KAAK,CAAC,YAAY,CAAA;IAC7B,CAAC;AACH,CAAC"}
|
package/dist/entry.tools-ts.d.ts
CHANGED
|
@@ -9,6 +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 } from "./Range.js";
|
|
12
13
|
export { TypeGuard } from "./TypeGuard.js";
|
|
13
14
|
export { setTimeoutAsync } from "./setTimeoutAsync.js";
|
|
14
15
|
export { noop, asyncNoop } from "./noop.js";
|
package/dist/entry.tools-ts.js
CHANGED
|
@@ -8,6 +8,7 @@ export { asArray } from "./asArray.js";
|
|
|
8
8
|
export { Assert } from "./Assert.js";
|
|
9
9
|
export { Result } from "./Result.js";
|
|
10
10
|
export { Measure } from "./Measure.js";
|
|
11
|
+
export { Range } from "./Range.js";
|
|
11
12
|
export { TypeGuard } from "./TypeGuard.js";
|
|
12
13
|
export { setTimeoutAsync } from "./setTimeoutAsync.js";
|
|
13
14
|
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,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAA8B,MAAM,aAAa,CAAA;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,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"}
|
|
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,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAA8B,MAAM,aAAa,CAAA;AAChE,OAAO,EAAE,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": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "My personal collection of typescript tools",
|
|
5
5
|
"homepage": "https://github.com/Guillaume-Docquier/tools-ts",
|
|
6
6
|
"repository": {
|
|
@@ -47,30 +47,30 @@
|
|
|
47
47
|
"semi": false
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@logtape/logtape": "^2.
|
|
51
|
-
"@logtape/redaction": "^2.
|
|
50
|
+
"@logtape/logtape": "^2.1.1",
|
|
51
|
+
"@logtape/redaction": "^2.1.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@eslint/js": "^10.0.1",
|
|
55
55
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
56
|
-
"@semantic-release/github": "^12.0.
|
|
56
|
+
"@semantic-release/github": "^12.0.8",
|
|
57
57
|
"@semantic-release/npm": "^13.1.5",
|
|
58
|
-
"@semantic-release/release-notes-generator": "^14.1.
|
|
59
|
-
"@types/node": "^25.
|
|
60
|
-
"@vitest/coverage-v8": "^4.1.
|
|
61
|
-
"conventional-changelog-conventionalcommits": "^9.3.
|
|
62
|
-
"eslint": "^10.
|
|
58
|
+
"@semantic-release/release-notes-generator": "^14.1.1",
|
|
59
|
+
"@types/node": "^25.9.1",
|
|
60
|
+
"@vitest/coverage-v8": "^4.1.7",
|
|
61
|
+
"conventional-changelog-conventionalcommits": "^9.3.1",
|
|
62
|
+
"eslint": "^10.4.0",
|
|
63
63
|
"husky": "^9.1.7",
|
|
64
|
-
"jiti": "^2.
|
|
64
|
+
"jiti": "^2.7.0",
|
|
65
65
|
"lint-staged": "^16.4.0",
|
|
66
|
-
"prettier": "^3.8.
|
|
66
|
+
"prettier": "^3.8.3",
|
|
67
67
|
"semantic-release": "^25.0.3",
|
|
68
68
|
"sort-package-json": "^3.6.1",
|
|
69
|
-
"typescript": "
|
|
70
|
-
"typescript-eslint": "^8.
|
|
71
|
-
"vitest": "^4.1.
|
|
69
|
+
"typescript": "~6.0.3",
|
|
70
|
+
"typescript-eslint": "^8.59.4",
|
|
71
|
+
"vitest": "^4.1.7"
|
|
72
72
|
},
|
|
73
|
-
"packageManager": "pnpm@
|
|
73
|
+
"packageManager": "pnpm@11.3.0+sha512.2c403d6594527287672b1f7056343a1f7c3634036a67ffabfcc2b3d7595d843768f8787148d1b57cf7956c90606bbd192857c363af19e96d2d0ec9ec5741d215",
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public",
|
|
76
76
|
"provenance": true
|