ts-number-lite 2.0.18 → 2.0.20

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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +22 -6
  3. package/package.json +5 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gaurang Mody
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ts-number-lite
2
2
 
3
- [![npm downloads](https://img.shields.io/npm/d18m/ts-number-lite.svg)](https://www.npmjs.com/package/ts-number-lite) [![npm version](https://img.shields.io/npm/v/ts-number-lite.svg)](https://www.npmjs.com/package/ts-number-lite)
3
+ [![npm downloads](https://img.shields.io/npm/dt/ts-number-lite.svg)](https://www.npmjs.com/package/ts-number-lite) [![npm version](https://img.shields.io/npm/v/ts-number-lite.svg)](https://www.npmjs.com/package/ts-number-lite) [![npm license](https://img.shields.io/npm/l/ts-number-lite.svg)](https://www.npmjs.com/package/ts-number-lite) [![npm types](https://img.shields.io/npm/types/ts-number-lite.svg)](https://www.npmjs.com/package/ts-number-lite) [![npm bundle size](https://img.shields.io/bundlephobia/minzip/ts-number-lite.svg)](https://bundlephobia.com/result?p=ts-number-lite)
4
4
 
5
5
  Lightweight, type-safe number utility library for web developers.
6
6
 
@@ -25,8 +25,6 @@ export class MyService {
25
25
  this.num.formatBytes(1048576); // '1 MB'
26
26
  this.num.formatPercent(0.756); // '75.6%'
27
27
  this.num.clamp(150, 0, 100); // 100
28
- this.num.round(3.14159, 2); // 3.14
29
- this.num.randomInt(1, 10); // random int 1-10
30
28
  }
31
29
  }
32
30
  ```
@@ -36,12 +34,30 @@ export class MyService {
36
34
  | Method | Description | Example |
37
35
  |--------|-------------|---------|
38
36
  | `formatCurrency` | Format as currency | `1234.56` → `'$1,234.56'` |
39
- | `formatBytes` | Format as bytes | `1048576` → `'1 MB'` |
37
+ | `formatBytes` | Format as bytes (KB, MB, etc) | `1048576` → `'1 MB'` |
40
38
  | `formatPercent` | Format as percent | `0.756` → `'75.6%'` |
41
39
  | `clamp` | Clamp value to range | `150, 0, 100` → `100` |
42
40
  | `round` | Round to decimals | `3.14159, 2` → `3.14` |
43
- | `randomInt` | Random integer | `1, 10` → random 1-10 |
41
+ | `randomInt` | Random integer in range | `1, 10` → `7` |
42
+ | `randomFloat` | Random float in range | `1.0, 5.0` → `3.14...` |
43
+ | `isEven` | Check if number is even | `2` → `true` |
44
+ | `isOdd` | Check if number is odd | `3` → `true` |
45
+ | `isPositive` | Check if number is positive | `5` → `true` |
46
+ | `isNegative` | Check if number is negative | `-5` → `true` |
47
+ | `isInteger` | Check if value is integer | `1.5` → `false` |
48
+ | `isNaN` | Check if value is NaN | `NaN` → `true` |
49
+ | `isFinite` | Check if value is finite | `Infinity` → `false` |
50
+ | `abs` | Absolute value | `-5` → `5` |
51
+ | `floor` | Floor value | `1.9` → `1` |
52
+ | `ceil` | Ceil value | `1.1` → `2` |
53
+ | `sqrt` | Square root | `9` → `3` |
54
+ | `pow` | Power of number | `2, 3` → `8` |
55
+ | `sum` | Sum multiple numbers | `1, 2, 3` → `6` |
56
+ | `avg` | Average multiple numbers | `1, 2, 3` → `2` |
57
+ | `min` | Minimum of numbers | `1, 2, 3` → `1` |
58
+ | `max` | Maximum of numbers | `1, 2, 3` → `3` |
59
+ | `range` | Create number range | `1, 5` → `[1, 2, 3, 4]` |
44
60
 
45
61
  ## License
46
62
 
47
- MIT
63
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-number-lite",
3
- "version": "2.0.18",
3
+ "version": "2.0.20",
4
4
  "description": "Lightweight, type-safe number utility library for web developers",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -13,7 +13,9 @@
13
13
  }
14
14
  },
15
15
  "files": [
16
- "dist"
16
+ "dist",
17
+ "LICENSE",
18
+ "README.md"
17
19
  ],
18
20
  "scripts": {
19
21
  "build": "tsc -p tsconfig.json"
@@ -25,7 +27,7 @@
25
27
  "helpers",
26
28
  "lite"
27
29
  ],
28
- "author": "Gaurang Mody - G8X",
30
+ "author": "Gaurang Mody",
29
31
  "license": "MIT",
30
32
  "repository": {
31
33
  "type": "git",