@guillaume-docquier/tools-ts 6.6.0 → 6.7.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 CHANGED
@@ -35,14 +35,15 @@ external APIs, CLI input, local storage, or other unknown data.
35
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
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
37
 
38
- ### Numeric Ranges
38
+ ### Numeric Utilities
39
39
 
40
- Use this tool when code needs a reusable, validated numeric interval instead of
41
- duplicating min/max checks across call sites.
40
+ Use these tools when code needs reusable numeric operations or validated
41
+ intervals.
42
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. |
43
+ | Export | What it is | Use it when |
44
+ | -------- | ---------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
45
+ | `Scalar` | Helpers for scalar number operations. | You need to constrain a number to an inclusive minimum and maximum. |
46
+ | `Range` | Helpers for creating, validating, comparing, and testing ranges. | You need finite integer or float intervals with inclusive minimums and configurable maximums. |
46
47
 
47
48
  ### Sorting
48
49
 
@@ -0,0 +1,7 @@
1
+ export declare const Scalar: {
2
+ /**
3
+ * Restricts a number to the inclusive range between min and max.
4
+ * It will not validate that min < max.
5
+ */
6
+ clamp: (value: number, min: number, max: number) => number;
7
+ };
package/dist/Scalar.js ADDED
@@ -0,0 +1,10 @@
1
+ export const Scalar = {
2
+ /**
3
+ * Restricts a number to the inclusive range between min and max.
4
+ * It will not validate that min < max.
5
+ */
6
+ clamp: (value, min, max) => {
7
+ return Math.min(Math.max(value, min), max);
8
+ },
9
+ };
10
+ //# sourceMappingURL=Scalar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Scalar.js","sourceRoot":"","sources":["../src/Scalar.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB;;;OAGG;IACH,KAAK,EAAE,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW,EAAU,EAAE;QACzD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;IAC5C,CAAC;CACF,CAAA"}
@@ -11,6 +11,7 @@ export { Assert } from "./Assert.js";
11
11
  export { Result, type Success, type Failure } from "./Result.js";
12
12
  export { Profile } from "./Profile.js";
13
13
  export { Range } from "./Range.js";
14
+ export { Scalar } from "./Scalar.js";
14
15
  export { TypeGuard } from "./TypeGuard.js";
15
16
  export { setTimeoutAsync } from "./setTimeoutAsync.js";
16
17
  export { noop, asyncNoop } from "./noop.js";
@@ -10,6 +10,7 @@ export { Assert } from "./Assert.js";
10
10
  export { Result } from "./Result.js";
11
11
  export { Profile } from "./Profile.js";
12
12
  export { Range } from "./Range.js";
13
+ export { Scalar } from "./Scalar.js";
13
14
  export { TypeGuard } from "./TypeGuard.js";
14
15
  export { setTimeoutAsync } from "./setTimeoutAsync.js";
15
16
  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,c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kCAAkC,CAAA;AAKvE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,SAAS,EAA4B,MAAM,cAAc,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,OAAO,EAAW,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAY,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAgB,OAAO,EAAE,MAAM,YAAY,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guillaume-docquier/tools-ts",
3
- "version": "6.6.0",
3
+ "version": "6.7.0",
4
4
  "description": "My personal collection of typescript tools",
5
5
  "homepage": "https://github.com/Guillaume-Docquier/tools-ts",
6
6
  "license": "MIT",