@tolki/num 2.0.2 → 2.0.4

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 (2) hide show
  1. package/README.md +29 -27
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ <p align="center"><img src="https://raw.githubusercontent.com/abetwothree/tolki/refs/heads/master/docs/vitepress/public/tolki-logo-short.svg" width="50%" alt="Laravel Tolki JS Logo"></p>
2
+
1
3
  # Tolki JS Num Package
2
4
 
3
5
  This package provides number utility functions similar to Laravel's Num class facade.
@@ -8,7 +10,7 @@ The full documentation for the number utilities can be found at [https://tolki.a
8
10
 
9
11
  <!-- AUTO-GENERATED-DOCS:START -->
10
12
 
11
- # Number Utilities Installation
13
+ ## Number Utilities Installation
12
14
 
13
15
  The [`@tolki/num`](https://www.npmjs.com/package/@tolki/num) package provides a variety of number manipulation utilities inspired by Laravel's Num class. You can install it via npm, yarn, or pnpm:
14
16
 
@@ -24,7 +26,7 @@ yarn add @tolki/num
24
26
  pnpm add @tolki/num
25
27
  ```
26
28
 
27
- ## Importing the Package
29
+ ### Importing the Package
28
30
 
29
31
  You can import individual functions for better tree-shaking or the entire package (not recommended).:
30
32
 
@@ -54,17 +56,17 @@ The reason that importing the entire package is not recommended is that it will
54
56
 
55
57
  However, if you are working on a backend project where bundle size is not a concern, importing the entire package can be more convenient.
56
58
 
57
- # Tolki Number Utilities List
59
+ ## Tolki Number Utilities List
58
60
 
59
- ## Number Utilities List
61
+ ### Number Utilities List
60
62
 
61
63
  These are the number utilities that can be used independently as single functions.
62
64
 
63
65
  [abbreviate](#abbreviate) [clamp](#clamp) [currency](#currency) [defaultCurrency](#defaultcurrency) [defaultLocale](#defaultlocale) [fileSize](#filesize) [forHumans](#forhumans) [format](#format) [minutesToHuman](#minutestohuman) [ordinal](#ordinal) [pairs](#pairs) [parseFloat](#parsefloat) [parseInt](#parseint) [percentage](#percentage) [spell](#spell) [spellOrdinal](#spellordinal) [secondsToHuman](#secondstohuman) [trim](#trim) [useLocale](#uselocale) [withLocale](#withlocale) [useCurrency](#usecurrency) [withCurrency](#withcurrency)
64
66
 
65
- ## Number Utilities Details
67
+ ### Number Utilities Details
66
68
 
67
- ### abbreviate
69
+ #### abbreviate
68
70
 
69
71
  Convert the number to its human-readable equivalent.
70
72
 
@@ -84,7 +86,7 @@ const result3 = abbreviate(1230000, 2);
84
86
  // result3 is "1.23M"
85
87
  ```
86
88
 
87
- ### clamp
89
+ #### clamp
88
90
 
89
91
  Clamp the given number between the given minimum and maximum.
90
92
 
@@ -108,7 +110,7 @@ const result4 = clamp(20, 10, 100);
108
110
  // result4 is 20
109
111
  ```
110
112
 
111
- ### currency
113
+ #### currency
112
114
 
113
115
  Convert the given number to its currency equivalent.
114
116
 
@@ -132,7 +134,7 @@ const result4 = currency(1000, "EUR", "de", 0);
132
134
  // result4 is "1.000 €"
133
135
  ```
134
136
 
135
- ### defaultCurrency
137
+ #### defaultCurrency
136
138
 
137
139
  Get the configured default currency.
138
140
 
@@ -144,7 +146,7 @@ const result = defaultCurrency();
144
146
  // result is "USD"
145
147
  ```
146
148
 
147
- ### defaultLocale
149
+ #### defaultLocale
148
150
 
149
151
  Get the configured default locale.
150
152
 
@@ -156,7 +158,7 @@ const result = defaultLocale();
156
158
  // result is "en"
157
159
  ```
158
160
 
159
- ### fileSize
161
+ #### fileSize
160
162
 
161
163
  Convert the given number to its file size equivalent.
162
164
 
@@ -176,7 +178,7 @@ const result3 = fileSize(1024, 2);
176
178
  // result3 is "1.00 KB"
177
179
  ```
178
180
 
179
- ### forHumans
181
+ #### forHumans
180
182
 
181
183
  Convert the number to its human-readable equivalent.
182
184
 
@@ -196,7 +198,7 @@ const result3 = forHumans(1230000, 2);
196
198
  // result3 is "1.23 million"
197
199
  ```
198
200
 
199
- ### format
201
+ #### format
200
202
 
201
203
  Format the given number according to the current locale.
202
204
 
@@ -220,7 +222,7 @@ const result4 = format(100000, null, null, "de");
220
222
  // result4 is "100.000"
221
223
  ```
222
224
 
223
- ### minutesToHuman
225
+ #### minutesToHuman
224
226
 
225
227
  Convert a duration in minutes to a human-readable format.
226
228
 
@@ -236,7 +238,7 @@ const result2 = minutesToHuman(61, false);
236
238
  // result2 is "1 hour, 1 minute"
237
239
  ```
238
240
 
239
- ### ordinal
241
+ #### ordinal
240
242
 
241
243
  Convert the given number to ordinal form.
242
244
 
@@ -260,7 +262,7 @@ const result4 = ordinal(13);
260
262
  // result4 is "13th"
261
263
  ```
262
264
 
263
- ### pairs
265
+ #### pairs
264
266
 
265
267
  Split the given number into pairs of min/max values.
266
268
 
@@ -276,7 +278,7 @@ const result2 = pairs(25, 10, 0, 0);
276
278
  // result2 is [[0, 10], [10, 20], [20, 25]]
277
279
  ```
278
280
 
279
- ### parseInt
281
+ #### parseInt
280
282
 
281
283
  Parse a string into an integer according to the specified locale.
282
284
 
@@ -292,7 +294,7 @@ const result2 = parseInt("10,123", "fr");
292
294
  // result2 is 10
293
295
  ```
294
296
 
295
- ### parseFloat
297
+ #### parseFloat
296
298
 
297
299
  Parse a string into a float according to the specified locale.
298
300
 
@@ -308,7 +310,7 @@ const result2 = parseFloat("10", "fr");
308
310
  // result2 is 10.0
309
311
  ```
310
312
 
311
- ### percentage
313
+ #### percentage
312
314
 
313
315
  Convert the given number to its percentage equivalent.
314
316
 
@@ -332,7 +334,7 @@ const result4 = percentage(10, 2, null, "de");
332
334
  // result4 is "10,00%"
333
335
  ```
334
336
 
335
- ### spell
337
+ #### spell
336
338
 
337
339
  Spell out the given number in the given locale. Returns a `Promise<string>`.
338
340
 
@@ -372,7 +374,7 @@ const result = await spell(15, null, null, 10);
372
374
  // result is "15"
373
375
  ```
374
376
 
375
- ### spellOrdinal
377
+ #### spellOrdinal
376
378
 
377
379
  Spell out the given number in the given locale in ordinal form. Returns a `Promise<string>`.
378
380
 
@@ -396,7 +398,7 @@ const result3 = await spellOrdinal(21);
396
398
  // result3 is "Twenty First"
397
399
  ```
398
400
 
399
- ### secondsToHuman
401
+ #### secondsToHuman
400
402
 
401
403
  Convert a duration in seconds to a human-readable format.
402
404
 
@@ -408,7 +410,7 @@ const result = secondsToHuman(3661);
408
410
  // result is "1 hour, 1 minute, 1 second"
409
411
  ```
410
412
 
411
- ### trim
413
+ #### trim
412
414
 
413
415
  Remove any trailing zero digits after the decimal point of the given number.
414
416
 
@@ -424,7 +426,7 @@ const result2 = trim(12.3);
424
426
  // result is 12.3
425
427
  ```
426
428
 
427
- ### useLocale
429
+ #### useLocale
428
430
 
429
431
  Set the default locale. This should be used at the start of your application to set the desired locale globally.
430
432
 
@@ -436,7 +438,7 @@ useLocale("fr");
436
438
  // The default locale is now set to French
437
439
  ```
438
440
 
439
- ### withLocale
441
+ #### withLocale
440
442
 
441
443
  Execute the given callback using the given locale.
442
444
 
@@ -448,7 +450,7 @@ withLocale("fr", () => {
448
450
  }); // "1 234,56"
449
451
  ```
450
452
 
451
- ### useCurrency
453
+ #### useCurrency
452
454
 
453
455
  Set the default currency. This should be used at the start of your application to set the desired currency globally.
454
456
 
@@ -460,7 +462,7 @@ useCurrency("EUR");
460
462
  // The default currency is now set to Euro
461
463
  ```
462
464
 
463
- ### withCurrency
465
+ #### withCurrency
464
466
 
465
467
  Execute the given callback using the given currency.
466
468
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolki/num",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Utilities for working with numbers similar to Laravel's Num class facade.",
5
5
  "author": "Abraham Arango <https://github.com/abetwothree>",
6
6
  "license": "MIT",