@ptolemy2002/js-math-utils 2.0.0 → 2.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 +17 -11
- package/dist/index.d.ts +1 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,14 @@ import { functionName } from '@ptolemy2002/js-math-utils';
|
|
|
9
9
|
const { functionName } = require('@ptolemy2002/js-math-utils');
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
+
## Type Reference
|
|
13
|
+
```typescript
|
|
14
|
+
type ClampOptions = {
|
|
15
|
+
min?: number;
|
|
16
|
+
max?: number;
|
|
17
|
+
};
|
|
18
|
+
```
|
|
19
|
+
|
|
12
20
|
## Functions
|
|
13
21
|
The following functions are available in the library:
|
|
14
22
|
|
|
@@ -17,27 +25,25 @@ The following functions are available in the library:
|
|
|
17
25
|
Clamps a number between a minimum and maximum value.
|
|
18
26
|
|
|
19
27
|
#### Parameters
|
|
20
|
-
- `value` (
|
|
21
|
-
- `
|
|
22
|
-
- `
|
|
28
|
+
- `value` (`number`): The value to be clamped.
|
|
29
|
+
- `args` - An object containing the following properties:
|
|
30
|
+
- `min` (`number?`): The minimum value. If not specified, the value is not clamped on the minimum side.
|
|
31
|
+
- `max` (`number?`): The maximum value. If not specified, the value is not clamped on the maximum side.
|
|
23
32
|
|
|
24
33
|
#### Returns
|
|
25
|
-
|
|
34
|
+
`number` - The clamped value.
|
|
26
35
|
|
|
27
36
|
### wrapNumber
|
|
28
37
|
#### Description
|
|
29
38
|
Wraps a number between a minimum and maximum value, non-inclusive on the maximum side (so `min - 1` gets converted to `max - 1` and `max` gets converted to `min`).
|
|
30
39
|
|
|
31
40
|
#### Parameters
|
|
32
|
-
- `n` (
|
|
33
|
-
- `min` (
|
|
34
|
-
- `max` (
|
|
41
|
+
- `n` (`number`): The number to be wrapped.
|
|
42
|
+
- `min` (`number`): The minimum value.
|
|
43
|
+
- `max` (`number`): The maximum value.
|
|
35
44
|
|
|
36
45
|
#### Returns
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
## Meta
|
|
40
|
-
This is a React Library Created by Ptolemy2002's [cra-template-react-library](https://www.npmjs.com/package/@ptolemy2002/cra-template-react-library) template in combination with [create-react-app](https://www.npmjs.com/package/create-react-app). However, it does not actually depend on React - it has been modified to work only with my own utility library. It contains methods of building and publishing your library to npm.
|
|
46
|
+
`number` - The wrapped value.
|
|
41
47
|
|
|
42
48
|
## Peer Dependencies
|
|
43
49
|
This project does not have any peer dependencies (they are all bundled with the library), so it should work out of the box.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
type ClampOptions = {
|
|
1
|
+
export type ClampOptions = {
|
|
2
2
|
min?: number;
|
|
3
3
|
max?: number;
|
|
4
4
|
};
|
|
5
5
|
export declare function clamp(value: number, { min, max }?: ClampOptions): number;
|
|
6
6
|
export declare function wrapNumber(n: number, min: number, max: number): number;
|
|
7
|
-
export {};
|