@tolki/num 2.0.2 → 2.0.3

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 +27 -27
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -8,7 +8,7 @@ The full documentation for the number utilities can be found at [https://tolki.a
8
8
 
9
9
  <!-- AUTO-GENERATED-DOCS:START -->
10
10
 
11
- # Number Utilities Installation
11
+ ## Number Utilities Installation
12
12
 
13
13
  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
14
 
@@ -24,7 +24,7 @@ yarn add @tolki/num
24
24
  pnpm add @tolki/num
25
25
  ```
26
26
 
27
- ## Importing the Package
27
+ ### Importing the Package
28
28
 
29
29
  You can import individual functions for better tree-shaking or the entire package (not recommended).:
30
30
 
@@ -54,17 +54,17 @@ The reason that importing the entire package is not recommended is that it will
54
54
 
55
55
  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
56
 
57
- # Tolki Number Utilities List
57
+ ## Tolki Number Utilities List
58
58
 
59
- ## Number Utilities List
59
+ ### Number Utilities List
60
60
 
61
61
  These are the number utilities that can be used independently as single functions.
62
62
 
63
63
  [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
64
 
65
- ## Number Utilities Details
65
+ ### Number Utilities Details
66
66
 
67
- ### abbreviate
67
+ #### abbreviate
68
68
 
69
69
  Convert the number to its human-readable equivalent.
70
70
 
@@ -84,7 +84,7 @@ const result3 = abbreviate(1230000, 2);
84
84
  // result3 is "1.23M"
85
85
  ```
86
86
 
87
- ### clamp
87
+ #### clamp
88
88
 
89
89
  Clamp the given number between the given minimum and maximum.
90
90
 
@@ -108,7 +108,7 @@ const result4 = clamp(20, 10, 100);
108
108
  // result4 is 20
109
109
  ```
110
110
 
111
- ### currency
111
+ #### currency
112
112
 
113
113
  Convert the given number to its currency equivalent.
114
114
 
@@ -132,7 +132,7 @@ const result4 = currency(1000, "EUR", "de", 0);
132
132
  // result4 is "1.000 €"
133
133
  ```
134
134
 
135
- ### defaultCurrency
135
+ #### defaultCurrency
136
136
 
137
137
  Get the configured default currency.
138
138
 
@@ -144,7 +144,7 @@ const result = defaultCurrency();
144
144
  // result is "USD"
145
145
  ```
146
146
 
147
- ### defaultLocale
147
+ #### defaultLocale
148
148
 
149
149
  Get the configured default locale.
150
150
 
@@ -156,7 +156,7 @@ const result = defaultLocale();
156
156
  // result is "en"
157
157
  ```
158
158
 
159
- ### fileSize
159
+ #### fileSize
160
160
 
161
161
  Convert the given number to its file size equivalent.
162
162
 
@@ -176,7 +176,7 @@ const result3 = fileSize(1024, 2);
176
176
  // result3 is "1.00 KB"
177
177
  ```
178
178
 
179
- ### forHumans
179
+ #### forHumans
180
180
 
181
181
  Convert the number to its human-readable equivalent.
182
182
 
@@ -196,7 +196,7 @@ const result3 = forHumans(1230000, 2);
196
196
  // result3 is "1.23 million"
197
197
  ```
198
198
 
199
- ### format
199
+ #### format
200
200
 
201
201
  Format the given number according to the current locale.
202
202
 
@@ -220,7 +220,7 @@ const result4 = format(100000, null, null, "de");
220
220
  // result4 is "100.000"
221
221
  ```
222
222
 
223
- ### minutesToHuman
223
+ #### minutesToHuman
224
224
 
225
225
  Convert a duration in minutes to a human-readable format.
226
226
 
@@ -236,7 +236,7 @@ const result2 = minutesToHuman(61, false);
236
236
  // result2 is "1 hour, 1 minute"
237
237
  ```
238
238
 
239
- ### ordinal
239
+ #### ordinal
240
240
 
241
241
  Convert the given number to ordinal form.
242
242
 
@@ -260,7 +260,7 @@ const result4 = ordinal(13);
260
260
  // result4 is "13th"
261
261
  ```
262
262
 
263
- ### pairs
263
+ #### pairs
264
264
 
265
265
  Split the given number into pairs of min/max values.
266
266
 
@@ -276,7 +276,7 @@ const result2 = pairs(25, 10, 0, 0);
276
276
  // result2 is [[0, 10], [10, 20], [20, 25]]
277
277
  ```
278
278
 
279
- ### parseInt
279
+ #### parseInt
280
280
 
281
281
  Parse a string into an integer according to the specified locale.
282
282
 
@@ -292,7 +292,7 @@ const result2 = parseInt("10,123", "fr");
292
292
  // result2 is 10
293
293
  ```
294
294
 
295
- ### parseFloat
295
+ #### parseFloat
296
296
 
297
297
  Parse a string into a float according to the specified locale.
298
298
 
@@ -308,7 +308,7 @@ const result2 = parseFloat("10", "fr");
308
308
  // result2 is 10.0
309
309
  ```
310
310
 
311
- ### percentage
311
+ #### percentage
312
312
 
313
313
  Convert the given number to its percentage equivalent.
314
314
 
@@ -332,7 +332,7 @@ const result4 = percentage(10, 2, null, "de");
332
332
  // result4 is "10,00%"
333
333
  ```
334
334
 
335
- ### spell
335
+ #### spell
336
336
 
337
337
  Spell out the given number in the given locale. Returns a `Promise<string>`.
338
338
 
@@ -372,7 +372,7 @@ const result = await spell(15, null, null, 10);
372
372
  // result is "15"
373
373
  ```
374
374
 
375
- ### spellOrdinal
375
+ #### spellOrdinal
376
376
 
377
377
  Spell out the given number in the given locale in ordinal form. Returns a `Promise<string>`.
378
378
 
@@ -396,7 +396,7 @@ const result3 = await spellOrdinal(21);
396
396
  // result3 is "Twenty First"
397
397
  ```
398
398
 
399
- ### secondsToHuman
399
+ #### secondsToHuman
400
400
 
401
401
  Convert a duration in seconds to a human-readable format.
402
402
 
@@ -408,7 +408,7 @@ const result = secondsToHuman(3661);
408
408
  // result is "1 hour, 1 minute, 1 second"
409
409
  ```
410
410
 
411
- ### trim
411
+ #### trim
412
412
 
413
413
  Remove any trailing zero digits after the decimal point of the given number.
414
414
 
@@ -424,7 +424,7 @@ const result2 = trim(12.3);
424
424
  // result is 12.3
425
425
  ```
426
426
 
427
- ### useLocale
427
+ #### useLocale
428
428
 
429
429
  Set the default locale. This should be used at the start of your application to set the desired locale globally.
430
430
 
@@ -436,7 +436,7 @@ useLocale("fr");
436
436
  // The default locale is now set to French
437
437
  ```
438
438
 
439
- ### withLocale
439
+ #### withLocale
440
440
 
441
441
  Execute the given callback using the given locale.
442
442
 
@@ -448,7 +448,7 @@ withLocale("fr", () => {
448
448
  }); // "1 234,56"
449
449
  ```
450
450
 
451
- ### useCurrency
451
+ #### useCurrency
452
452
 
453
453
  Set the default currency. This should be used at the start of your application to set the desired currency globally.
454
454
 
@@ -460,7 +460,7 @@ useCurrency("EUR");
460
460
  // The default currency is now set to Euro
461
461
  ```
462
462
 
463
- ### withCurrency
463
+ #### withCurrency
464
464
 
465
465
  Execute the given callback using the given currency.
466
466
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolki/num",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
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",