@helpers4/number 2.0.0-alpha.1 → 2.0.0-alpha.2

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
@@ -12,9 +12,9 @@ A set of helpers for working with URLs.
12
12
  [https://helpers4.js.org/number](https://helpers4.js.org/number)
13
13
 
14
14
  <!-- AUTOMATIC-METHODS -->
15
- - random
16
- - roundTo
17
15
  - clamp
16
+ - roundTo
17
+ - random
18
18
  <!-- /AUTOMATIC-METHODS -->
19
19
 
20
20
  ## See
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export * from './random';
2
- export * from './roundTo';
3
- export * from './clamp';
1
+ export declare function clamp(value: number, min: number, max: number): number;
2
+ export declare function roundTo(value: number, decimals: number): number;
3
+ export declare function randomBetween(min: number, max: number): number;
4
+ export declare function randomIntBetween(min: number, max: number): number;
package/lib/index.js CHANGED
@@ -1,4 +1,22 @@
1
- // helpers/number/index.ts
2
- export * from "./random";
3
- export * from "./roundTo";
4
- export * from "./clamp";
1
+ // helpers/number/clamp.ts
2
+ function clamp(value, min, max) {
3
+ return Math.min(Math.max(value, min), max);
4
+ }
5
+ // helpers/number/roundTo.ts
6
+ function roundTo(value, decimals) {
7
+ const multiplier = Math.pow(10, decimals);
8
+ return Math.round(value * multiplier) / multiplier;
9
+ }
10
+ // helpers/number/random.ts
11
+ function randomBetween(min, max) {
12
+ return Math.random() * (max - min) + min;
13
+ }
14
+ function randomIntBetween(min, max) {
15
+ return Math.floor(Math.random() * (max - min + 1)) + min;
16
+ }
17
+ export {
18
+ roundTo,
19
+ randomIntBetween,
20
+ randomBetween,
21
+ clamp
22
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helpers4/number",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-alpha.2",
4
4
  "description": "A set of helpers in TS/JS, compatible with tree-shaking, for number.",
5
5
  "author": "baxyz <baxy@etik.com>",
6
6
  "license": "AGPL-3.0",
@@ -20,9 +20,9 @@
20
20
  "keywords": [
21
21
  "helpers",
22
22
  "number",
23
- "random",
23
+ "clamp",
24
24
  "roundTo",
25
- "clamp"
25
+ "random"
26
26
  ],
27
27
  "files": [
28
28
  "lib/index.js",