@raindrops-on-roses/number-clamp 0.0.1
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 +59 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/package.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @raindrops-on-roses/clamp
|
|
2
|
+
|
|
3
|
+
`clamp` utility from [raindrops-on-roses](https://www.npmjs.com/package/raindrops-on-roses).
|
|
4
|
+
|
|
5
|
+
Constrains a numeric value between a minimum and maximum bound.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @raindrops-on-roses/clamp
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { clamp } from "@raindrops-on-roses/clamp";
|
|
17
|
+
|
|
18
|
+
clamp(5, 0, 10); // 5
|
|
19
|
+
clamp(-5, 0, 10); // 0
|
|
20
|
+
clamp(15, 0, 10); // 10
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## API
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
clamp(value: number, min: number, max: number): number
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Parameters
|
|
30
|
+
|
|
31
|
+
- `value` — The value to clamp.
|
|
32
|
+
- `min` — The minimum value.
|
|
33
|
+
- `max` — The maximum value.
|
|
34
|
+
|
|
35
|
+
### Returns
|
|
36
|
+
|
|
37
|
+
The clamped value, between `min` and `max`.
|
|
38
|
+
|
|
39
|
+
## With the complete library
|
|
40
|
+
|
|
41
|
+
You can also install the complete `raindrops-on-roses` package:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
npm install raindrops-on-roses
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
and import `clamp` from the umbrella package:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { clamp } from "raindrops-on-roses";
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Lore
|
|
54
|
+
|
|
55
|
+
Procrustes is an innkeeper who forces his guests to sleep in a magical bed whose size fits no one. Either it is too short, in which case Procrustes cuts off whatever parts of the traveler stick out; or it is too long, in which case the innkeeper stretches the limbs of those who lie in it until they match the size of the bed.
|
|
56
|
+
|
|
57
|
+
## Repository
|
|
58
|
+
|
|
59
|
+
[graphieros/raindrops-on-roses](https://github.com/graphieros/raindrops-on-roses)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clamps a numeric value between a minimum and maximum bound.
|
|
3
|
+
*
|
|
4
|
+
* ---
|
|
5
|
+
*
|
|
6
|
+
* @param value - The value to clamp
|
|
7
|
+
* @param min - The minimum value
|
|
8
|
+
* @param max - The maximum value
|
|
9
|
+
* @returns The clamped value, between `min` and `max`
|
|
10
|
+
*
|
|
11
|
+
* ---
|
|
12
|
+
*
|
|
13
|
+
* Lore:
|
|
14
|
+
* Procrustes is an innkeeper who forces his guests to sleep in a magical bed whose size fits no one. Either it is too short, in which case Procrustes cuts off whatever parts of the traveler stick out; or it is too long, in which case the innkeeper stretches the limbs of those who lie in it until they match the size of the bed.
|
|
15
|
+
*/
|
|
16
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAErE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Clamps a numeric value between a minimum and maximum bound.\n *\n * ---\n *\n * @param value - The value to clamp\n * @param min - The minimum value\n * @param max - The maximum value\n * @returns The clamped value, between `min` and `max`\n *\n * ---\n *\n * Lore:\n * Procrustes is an innkeeper who forces his guests to sleep in a magical bed whose size fits no one. Either it is too short, in which case Procrustes cuts off whatever parts of the traveler stick out; or it is too long, in which case the innkeeper stretches the limbs of those who lie in it until they match the size of the bed.\n */\nexport function clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n"],"mappings":";AAeA,SAAgB,EAAM,GAAe,GAAa,GAAqB;CACrE,OAAO,KAAK,IAAI,KAAK,IAAI,GAAO,CAAG,GAAG,CAAG;AAC3C"}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@raindrops-on-roses/number-clamp",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "vite build && tsc -p tsconfig.json"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/graphieros/raindrops-on-roses.git",
|
|
25
|
+
"directory": "packages/number-clamp"
|
|
26
|
+
}
|
|
27
|
+
}
|