@utilix-tech/sdk 0.15.0 → 0.16.0
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/CHANGELOG.md +3 -0
- package/README.md +14 -5
- package/dist/{chunk-IPR7FSX4.js → chunk-DOWQZUTP.js} +61 -1
- package/dist/{chunk-RJPYVCKQ.js → chunk-M4MMO6C6.js} +18 -1
- package/dist/{encoding-7gmq-vkV.d.cts → encoding-Dk3wpmb3.d.cts} +19 -2
- package/dist/{encoding-7gmq-vkV.d.ts → encoding-Dk3wpmb3.d.ts} +19 -2
- package/dist/index.cjs +77 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/tools/encoding.cjs +60 -0
- package/dist/tools/encoding.d.cts +1 -1
- package/dist/tools/encoding.d.ts +1 -1
- package/dist/tools/encoding.js +1 -1
- package/dist/tools/units.cjs +17 -0
- package/dist/tools/units.d.cts +1 -1
- package/dist/tools/units.d.ts +1 -1
- package/dist/tools/units.js +1 -1
- package/dist/{units-CADUCiYZ.d.cts → units-CkV4kAIs.d.cts} +21 -2
- package/dist/{units-CADUCiYZ.d.ts → units-CkV4kAIs.d.ts} +21 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Full release notes for all Utilix surfaces (browser tools, REST API, SDKs, MCP server) live at [utilix.tech/changelog](https://utilix.tech/changelog). This file tracks just this package.
|
|
4
4
|
|
|
5
|
+
## 0.16.0
|
|
6
|
+
- Added Simple Interest Calculator (`calculateSimpleInterest`) and Base58 / Base62 Encoder (`base58Encode`, `base58Decode`, `base62Encode`, `base62Decode`).
|
|
7
|
+
|
|
5
8
|
## 0.15.0
|
|
6
9
|
- Added MIME Type Lookup (`lookupMime`) and Tip / Bill Split Calculator (`calculateTipSplit`).
|
|
7
10
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @utilix-tech/sdk
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**548 developer utility functions for Node.js: runs locally, no API key required.**
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@utilix-tech/sdk)
|
|
6
6
|
[](https://www.npmjs.com/package/@utilix-tech/sdk)
|
|
@@ -93,13 +93,18 @@ validateJson(data, schema);
|
|
|
93
93
|
|
|
94
94
|
```ts
|
|
95
95
|
import { encodeBase64, decodeBase64, encodeUrl, decodeUrl,
|
|
96
|
-
encodeHtmlEntities, decodeHtmlEntities, base32Encode, base32Decode
|
|
96
|
+
encodeHtmlEntities, decodeHtmlEntities, base32Encode, base32Decode,
|
|
97
|
+
base58Encode, base58Decode, base62Encode, base62Decode } from "@utilix-tech/sdk/encoding";
|
|
97
98
|
|
|
98
99
|
encodeBase64("Hello, World!"); // "SGVsbG8sIFdvcmxkIQ=="
|
|
99
100
|
decodeBase64("SGVsbG8sIFdvcmxkIQ=="); // "Hello, World!"
|
|
100
101
|
encodeUrl("hello world?"); // "hello%20world%3F"
|
|
101
102
|
encodeHtmlEntities("<div class=\"a\">"); // "<div class="a">"
|
|
102
103
|
base32Encode("hello"); // "NBSWY3DPEB3W64TMMQ======"
|
|
104
|
+
|
|
105
|
+
// Base58 (Bitcoin-style, no ambiguous 0/O/I/l) and Base62 (alphanumeric)
|
|
106
|
+
base58Encode("hello world"); // "StV1DL6CwTryKyV"
|
|
107
|
+
base62Encode("hello world"); // "AAwf93rvy4aWQVw"
|
|
103
108
|
```
|
|
104
109
|
|
|
105
110
|
---
|
|
@@ -242,7 +247,7 @@ getNextRuns("*/5 * * * *", 5); // next 5 run timestamps
|
|
|
242
247
|
### `/units`: Conversions
|
|
243
248
|
|
|
244
249
|
```ts
|
|
245
|
-
import { convertBytes, pxToAll, convert, formatValue, validateCardNumber, validateIban, calculateLoan, validateBarcode, calculateTax, calculateCompoundInterest, validateIsbn, calculateTipSplit } from "@utilix-tech/sdk/units";
|
|
250
|
+
import { convertBytes, pxToAll, convert, formatValue, validateCardNumber, validateIban, calculateLoan, validateBarcode, calculateTax, calculateCompoundInterest, validateIsbn, calculateTipSplit, calculateSimpleInterest } from "@utilix-tech/sdk/units";
|
|
246
251
|
|
|
247
252
|
// File sizes
|
|
248
253
|
convertBytes(1073741824, "GB"); // 1
|
|
@@ -292,6 +297,10 @@ validateIsbn("0-306-40615-2");
|
|
|
292
297
|
// Tip / bill split: tip amount, total, and an even per-person split
|
|
293
298
|
calculateTipSplit(84.5, 18, 2);
|
|
294
299
|
// { tipAmount: 15.21, totalAmount: 99.71, perPersonTotal: 49.86, ... }
|
|
300
|
+
|
|
301
|
+
// Simple (non-compounding) interest: principal x rate x time
|
|
302
|
+
calculateSimpleInterest(1000, 5, 2);
|
|
303
|
+
// { interest: 100, totalPayoff: 1100, ... }
|
|
295
304
|
```
|
|
296
305
|
|
|
297
306
|
---
|
|
@@ -520,13 +529,13 @@ readIcoInfo(new Uint8Array(icoBytes));
|
|
|
520
529
|
| Import | What it does |
|
|
521
530
|
|---|---|
|
|
522
531
|
| `@utilix-tech/sdk/json` | Format, minify, diff, validate, JSONPath, CSV↔JSON, YAML↔JSON, TS types |
|
|
523
|
-
| `@utilix-tech/sdk/encoding` | Base64, URL, HTML entities, Base32 encode/decode |
|
|
532
|
+
| `@utilix-tech/sdk/encoding` | Base64, URL, HTML entities, Base32/Base58/Base62 encode/decode |
|
|
524
533
|
| `@utilix-tech/sdk/hashing` | MD5, SHA-1/256/512, bcrypt, HMAC, .htpasswd |
|
|
525
534
|
| `@utilix-tech/sdk/text` | Case convert, slugify, word count, lorem ipsum, line ops, HTML→Markdown |
|
|
526
535
|
| `@utilix-tech/sdk/data` | CSV, YAML, TOML, XML, INI, NDJSON parse and convert |
|
|
527
536
|
| `@utilix-tech/sdk/generators` | UUID v4/v7, ULID, passwords, strength check, fake data |
|
|
528
537
|
| `@utilix-tech/sdk/time` | Date diff, timezone convert, cron parse, relative time |
|
|
529
|
-
| `@utilix-tech/sdk/units` | Bytes, CSS px/rem, number bases, currency format, credit card/IBAN/barcode/ISBN validation, loan calculator, compound interest
|
|
538
|
+
| `@utilix-tech/sdk/units` | Bytes, CSS px/rem, number bases, currency format, credit card/IBAN/barcode/ISBN validation, loan calculator, compound/simple interest calculators, VAT/sales tax calculator, tip/bill split calculator |
|
|
530
539
|
| `@utilix-tech/sdk/network` | HTTP status codes, IP validation, country flags, geolocation URLs, HAR file parsing |
|
|
531
540
|
| `@utilix-tech/sdk/api` | cURL build/parse, JWT decode/sign, JWKS parse, CORS headers, CSP header |
|
|
532
541
|
| `@utilix-tech/sdk/code` | SQL format/minify, HTML format/minify, regex tester, GraphQL format, MIME type lookup |
|
|
@@ -8,6 +8,10 @@ __export(encoding_exports, {
|
|
|
8
8
|
base32DecodeBytes: () => base32DecodeBytes,
|
|
9
9
|
base32Encode: () => base32Encode,
|
|
10
10
|
base32EncodeBytes: () => base32EncodeBytes,
|
|
11
|
+
base58Decode: () => base58Decode,
|
|
12
|
+
base58Encode: () => base58Encode,
|
|
13
|
+
base62Decode: () => base62Decode,
|
|
14
|
+
base62Encode: () => base62Encode,
|
|
11
15
|
decodeBase64: () => decodeBase64,
|
|
12
16
|
decodeHtmlEntities: () => decodeHtmlEntities,
|
|
13
17
|
decodeUrl: () => decodeUrl,
|
|
@@ -261,5 +265,61 @@ function isValidBase32(input, alphabet = "standard") {
|
|
|
261
265
|
if (rem === 1 || rem === 3 || rem === 6) return false;
|
|
262
266
|
return true;
|
|
263
267
|
}
|
|
268
|
+
var BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
269
|
+
var BASE62_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
270
|
+
function encodeBytesToBase(bytes, alphabet) {
|
|
271
|
+
const base = BigInt(alphabet.length);
|
|
272
|
+
let num = 0n;
|
|
273
|
+
for (const byte of bytes) num = num << 8n | BigInt(byte);
|
|
274
|
+
let out = "";
|
|
275
|
+
while (num > 0n) {
|
|
276
|
+
out = alphabet[Number(num % base)] + out;
|
|
277
|
+
num = num / base;
|
|
278
|
+
}
|
|
279
|
+
let leadingZeros = 0;
|
|
280
|
+
for (const byte of bytes) {
|
|
281
|
+
if (byte === 0) leadingZeros++;
|
|
282
|
+
else break;
|
|
283
|
+
}
|
|
284
|
+
return alphabet[0].repeat(leadingZeros) + out;
|
|
285
|
+
}
|
|
286
|
+
function decodeBaseToBytes(input, alphabet) {
|
|
287
|
+
const base = BigInt(alphabet.length);
|
|
288
|
+
let num = 0n;
|
|
289
|
+
for (const char of input) {
|
|
290
|
+
const idx = alphabet.indexOf(char);
|
|
291
|
+
if (idx === -1) return { error: `Invalid character '${char}' for this alphabet` };
|
|
292
|
+
num = num * base + BigInt(idx);
|
|
293
|
+
}
|
|
294
|
+
const bytes = [];
|
|
295
|
+
while (num > 0n) {
|
|
296
|
+
bytes.unshift(Number(num % 256n));
|
|
297
|
+
num = num / 256n;
|
|
298
|
+
}
|
|
299
|
+
let leadingZeros = 0;
|
|
300
|
+
for (const char of input) {
|
|
301
|
+
if (char === alphabet[0]) leadingZeros++;
|
|
302
|
+
else break;
|
|
303
|
+
}
|
|
304
|
+
return new Uint8Array([...new Array(leadingZeros).fill(0), ...bytes]);
|
|
305
|
+
}
|
|
306
|
+
function base58Encode(input) {
|
|
307
|
+
return encodeBytesToBase(stringToBytes(input), BASE58_ALPHABET);
|
|
308
|
+
}
|
|
309
|
+
function base58Decode(input) {
|
|
310
|
+
if (!input) return { error: "No input provided" };
|
|
311
|
+
const result = decodeBaseToBytes(input, BASE58_ALPHABET);
|
|
312
|
+
if (!(result instanceof Uint8Array)) return result;
|
|
313
|
+
return bytesToString(result);
|
|
314
|
+
}
|
|
315
|
+
function base62Encode(input) {
|
|
316
|
+
return encodeBytesToBase(stringToBytes(input), BASE62_ALPHABET);
|
|
317
|
+
}
|
|
318
|
+
function base62Decode(input) {
|
|
319
|
+
if (!input) return { error: "No input provided" };
|
|
320
|
+
const result = decodeBaseToBytes(input, BASE62_ALPHABET);
|
|
321
|
+
if (!(result instanceof Uint8Array)) return result;
|
|
322
|
+
return bytesToString(result);
|
|
323
|
+
}
|
|
264
324
|
|
|
265
|
-
export { ALPHABETS, base32Decode, base32DecodeBytes, base32Encode, base32EncodeBytes, decodeBase64, decodeHtmlEntities, decodeUrl, diffSegments, encodeBase64, encodeHtmlEntities, encodeHtmlEntitiesAll, encodeUrl, encoding_exports, isValidBase32 };
|
|
325
|
+
export { ALPHABETS, base32Decode, base32DecodeBytes, base32Encode, base32EncodeBytes, base58Decode, base58Encode, base62Decode, base62Encode, decodeBase64, decodeHtmlEntities, decodeUrl, diffSegments, encodeBase64, encodeHtmlEntities, encodeHtmlEntitiesAll, encodeUrl, encoding_exports, isValidBase32 };
|
|
@@ -20,6 +20,7 @@ __export(units_exports, {
|
|
|
20
20
|
calcSubnet: () => calcSubnet,
|
|
21
21
|
calculateCompoundInterest: () => calculateCompoundInterest,
|
|
22
22
|
calculateLoan: () => calculateLoan,
|
|
23
|
+
calculateSimpleInterest: () => calculateSimpleInterest,
|
|
23
24
|
calculateTax: () => calculateTax,
|
|
24
25
|
calculateTipSplit: () => calculateTipSplit,
|
|
25
26
|
compareSemver: () => compareSemver,
|
|
@@ -1280,5 +1281,21 @@ function calculateTipSplit(billAmount, tipPercent, numPeople = 1) {
|
|
|
1280
1281
|
perPersonTotal: round22(totalAmount / numPeople)
|
|
1281
1282
|
};
|
|
1282
1283
|
}
|
|
1284
|
+
function calculateSimpleInterest(principal, annualRatePercent, years) {
|
|
1285
|
+
if (!Number.isFinite(principal) || principal < 0) return { error: "Principal must be zero or a positive number" };
|
|
1286
|
+
if (!Number.isFinite(annualRatePercent) || annualRatePercent < 0) {
|
|
1287
|
+
return { error: "Annual interest rate must be zero or a positive number" };
|
|
1288
|
+
}
|
|
1289
|
+
if (!Number.isFinite(years) || years <= 0) return { error: "Years must be a positive number" };
|
|
1290
|
+
const round22 = (n) => Math.round(n * 100) / 100;
|
|
1291
|
+
const interest = round22(principal * (annualRatePercent / 100) * years);
|
|
1292
|
+
return {
|
|
1293
|
+
principal: round22(principal),
|
|
1294
|
+
annualRatePercent,
|
|
1295
|
+
years,
|
|
1296
|
+
interest,
|
|
1297
|
+
totalPayoff: round22(principal + interest)
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1283
1300
|
|
|
1284
|
-
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_TIP_PERCENTAGES, COMMON_VIEWPORTS, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateCompoundInterest, calculateLoan, calculateTax, calculateTipSplit, compareSemver, convert, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, units_exports, validateBarcode, validateCardNumber, validateIban, validateIsbn, viewportToPx };
|
|
1301
|
+
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_TIP_PERCENTAGES, COMMON_VIEWPORTS, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateCompoundInterest, calculateLoan, calculateSimpleInterest, calculateTax, calculateTipSplit, compareSemver, convert, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, units_exports, validateBarcode, validateCardNumber, validateIban, validateIsbn, viewportToPx };
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* - url-encode: encodeUrl, decodeUrl, diffSegments
|
|
8
8
|
* - html-entities: encodeHtmlEntities, decodeHtmlEntities, encodeHtmlEntitiesAll
|
|
9
9
|
* - base32 : base32Encode, base32Decode, base32EncodeBytes, base32DecodeBytes, isValidBase32, ALPHABETS
|
|
10
|
+
* - base58-base62 : base58Encode, base58Decode, base62Encode, base62Decode
|
|
10
11
|
*/
|
|
11
12
|
type Base64Variant = 'standard' | 'urlsafe';
|
|
12
13
|
interface EncodeResult {
|
|
@@ -74,6 +75,18 @@ declare function base32Decode(input: string, alphabet?: Base32Alphabet): string
|
|
|
74
75
|
error: string;
|
|
75
76
|
};
|
|
76
77
|
declare function isValidBase32(input: string, alphabet?: Base32Alphabet): boolean;
|
|
78
|
+
/** Encode text as Base58 (Bitcoin-address style, no ambiguous 0/O/I/l characters). */
|
|
79
|
+
declare function base58Encode(input: string): string;
|
|
80
|
+
/** Decode a Base58 string back to text. */
|
|
81
|
+
declare function base58Decode(input: string): string | {
|
|
82
|
+
error: string;
|
|
83
|
+
};
|
|
84
|
+
/** Encode text as Base62 (alphanumeric, URL-safe, no punctuation). */
|
|
85
|
+
declare function base62Encode(input: string): string;
|
|
86
|
+
/** Decode a Base62 string back to text. */
|
|
87
|
+
declare function base62Decode(input: string): string | {
|
|
88
|
+
error: string;
|
|
89
|
+
};
|
|
77
90
|
|
|
78
91
|
declare const encoding_ALPHABETS: typeof ALPHABETS;
|
|
79
92
|
type encoding_Base32Alphabet = Base32Alphabet;
|
|
@@ -91,6 +104,10 @@ declare const encoding_base32Decode: typeof base32Decode;
|
|
|
91
104
|
declare const encoding_base32DecodeBytes: typeof base32DecodeBytes;
|
|
92
105
|
declare const encoding_base32Encode: typeof base32Encode;
|
|
93
106
|
declare const encoding_base32EncodeBytes: typeof base32EncodeBytes;
|
|
107
|
+
declare const encoding_base58Decode: typeof base58Decode;
|
|
108
|
+
declare const encoding_base58Encode: typeof base58Encode;
|
|
109
|
+
declare const encoding_base62Decode: typeof base62Decode;
|
|
110
|
+
declare const encoding_base62Encode: typeof base62Encode;
|
|
94
111
|
declare const encoding_decodeBase64: typeof decodeBase64;
|
|
95
112
|
declare const encoding_decodeHtmlEntities: typeof decodeHtmlEntities;
|
|
96
113
|
declare const encoding_decodeUrl: typeof decodeUrl;
|
|
@@ -102,7 +119,7 @@ type encoding_encodeMode = encodeMode;
|
|
|
102
119
|
declare const encoding_encodeUrl: typeof encodeUrl;
|
|
103
120
|
declare const encoding_isValidBase32: typeof isValidBase32;
|
|
104
121
|
declare namespace encoding {
|
|
105
|
-
export { encoding_ALPHABETS as ALPHABETS, type encoding_Base32Alphabet as Base32Alphabet, type encoding_Base64DecodeResult as Base64DecodeResult, type encoding_Base64EncodeResult as Base64EncodeResult, type encoding_Base64Error as Base64Error, type encoding_Base64Variant as Base64Variant, type encoding_DecodeResult as DecodeResult, type encoding_EncodeResult as EncodeResult, type encoding_UrlEncodeError as UrlEncodeError, type encoding_UrlEncodeMode as UrlEncodeMode, type encoding_UrlEncodeResult as UrlEncodeResult, type encoding_UrlResult as UrlResult, encoding_base32Decode as base32Decode, encoding_base32DecodeBytes as base32DecodeBytes, encoding_base32Encode as base32Encode, encoding_base32EncodeBytes as base32EncodeBytes, encoding_decodeBase64 as decodeBase64, encoding_decodeHtmlEntities as decodeHtmlEntities, encoding_decodeUrl as decodeUrl, encoding_diffSegments as diffSegments, encoding_encodeBase64 as encodeBase64, encoding_encodeHtmlEntities as encodeHtmlEntities, encoding_encodeHtmlEntitiesAll as encodeHtmlEntitiesAll, type encoding_encodeMode as encodeMode, encoding_encodeUrl as encodeUrl, encoding_isValidBase32 as isValidBase32 };
|
|
122
|
+
export { encoding_ALPHABETS as ALPHABETS, type encoding_Base32Alphabet as Base32Alphabet, type encoding_Base64DecodeResult as Base64DecodeResult, type encoding_Base64EncodeResult as Base64EncodeResult, type encoding_Base64Error as Base64Error, type encoding_Base64Variant as Base64Variant, type encoding_DecodeResult as DecodeResult, type encoding_EncodeResult as EncodeResult, type encoding_UrlEncodeError as UrlEncodeError, type encoding_UrlEncodeMode as UrlEncodeMode, type encoding_UrlEncodeResult as UrlEncodeResult, type encoding_UrlResult as UrlResult, encoding_base32Decode as base32Decode, encoding_base32DecodeBytes as base32DecodeBytes, encoding_base32Encode as base32Encode, encoding_base32EncodeBytes as base32EncodeBytes, encoding_base58Decode as base58Decode, encoding_base58Encode as base58Encode, encoding_base62Decode as base62Decode, encoding_base62Encode as base62Encode, encoding_decodeBase64 as decodeBase64, encoding_decodeHtmlEntities as decodeHtmlEntities, encoding_decodeUrl as decodeUrl, encoding_diffSegments as diffSegments, encoding_encodeBase64 as encodeBase64, encoding_encodeHtmlEntities as encodeHtmlEntities, encoding_encodeHtmlEntitiesAll as encodeHtmlEntitiesAll, type encoding_encodeMode as encodeMode, encoding_encodeUrl as encodeUrl, encoding_isValidBase32 as isValidBase32 };
|
|
106
123
|
}
|
|
107
124
|
|
|
108
|
-
export { ALPHABETS as A, type Base32Alphabet as B, type DecodeResult as D, type EncodeResult as E, type UrlEncodeError as U, type Base64DecodeResult as a, type Base64EncodeResult as b, type Base64Error as c, type Base64Variant as d, encoding as e, type UrlEncodeMode as f, type UrlEncodeResult as g, type UrlResult as h, base32Decode as i, base32DecodeBytes as j, base32Encode as k, base32EncodeBytes as l,
|
|
125
|
+
export { ALPHABETS as A, type Base32Alphabet as B, type DecodeResult as D, type EncodeResult as E, type UrlEncodeError as U, type Base64DecodeResult as a, type Base64EncodeResult as b, type Base64Error as c, type Base64Variant as d, encoding as e, type UrlEncodeMode as f, type UrlEncodeResult as g, type UrlResult as h, base32Decode as i, base32DecodeBytes as j, base32Encode as k, base32EncodeBytes as l, base58Decode as m, base58Encode as n, base62Decode as o, base62Encode as p, decodeBase64 as q, decodeHtmlEntities as r, decodeUrl as s, diffSegments as t, encodeBase64 as u, encodeHtmlEntities as v, encodeHtmlEntitiesAll as w, type encodeMode as x, encodeUrl as y, isValidBase32 as z };
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* - url-encode: encodeUrl, decodeUrl, diffSegments
|
|
8
8
|
* - html-entities: encodeHtmlEntities, decodeHtmlEntities, encodeHtmlEntitiesAll
|
|
9
9
|
* - base32 : base32Encode, base32Decode, base32EncodeBytes, base32DecodeBytes, isValidBase32, ALPHABETS
|
|
10
|
+
* - base58-base62 : base58Encode, base58Decode, base62Encode, base62Decode
|
|
10
11
|
*/
|
|
11
12
|
type Base64Variant = 'standard' | 'urlsafe';
|
|
12
13
|
interface EncodeResult {
|
|
@@ -74,6 +75,18 @@ declare function base32Decode(input: string, alphabet?: Base32Alphabet): string
|
|
|
74
75
|
error: string;
|
|
75
76
|
};
|
|
76
77
|
declare function isValidBase32(input: string, alphabet?: Base32Alphabet): boolean;
|
|
78
|
+
/** Encode text as Base58 (Bitcoin-address style, no ambiguous 0/O/I/l characters). */
|
|
79
|
+
declare function base58Encode(input: string): string;
|
|
80
|
+
/** Decode a Base58 string back to text. */
|
|
81
|
+
declare function base58Decode(input: string): string | {
|
|
82
|
+
error: string;
|
|
83
|
+
};
|
|
84
|
+
/** Encode text as Base62 (alphanumeric, URL-safe, no punctuation). */
|
|
85
|
+
declare function base62Encode(input: string): string;
|
|
86
|
+
/** Decode a Base62 string back to text. */
|
|
87
|
+
declare function base62Decode(input: string): string | {
|
|
88
|
+
error: string;
|
|
89
|
+
};
|
|
77
90
|
|
|
78
91
|
declare const encoding_ALPHABETS: typeof ALPHABETS;
|
|
79
92
|
type encoding_Base32Alphabet = Base32Alphabet;
|
|
@@ -91,6 +104,10 @@ declare const encoding_base32Decode: typeof base32Decode;
|
|
|
91
104
|
declare const encoding_base32DecodeBytes: typeof base32DecodeBytes;
|
|
92
105
|
declare const encoding_base32Encode: typeof base32Encode;
|
|
93
106
|
declare const encoding_base32EncodeBytes: typeof base32EncodeBytes;
|
|
107
|
+
declare const encoding_base58Decode: typeof base58Decode;
|
|
108
|
+
declare const encoding_base58Encode: typeof base58Encode;
|
|
109
|
+
declare const encoding_base62Decode: typeof base62Decode;
|
|
110
|
+
declare const encoding_base62Encode: typeof base62Encode;
|
|
94
111
|
declare const encoding_decodeBase64: typeof decodeBase64;
|
|
95
112
|
declare const encoding_decodeHtmlEntities: typeof decodeHtmlEntities;
|
|
96
113
|
declare const encoding_decodeUrl: typeof decodeUrl;
|
|
@@ -102,7 +119,7 @@ type encoding_encodeMode = encodeMode;
|
|
|
102
119
|
declare const encoding_encodeUrl: typeof encodeUrl;
|
|
103
120
|
declare const encoding_isValidBase32: typeof isValidBase32;
|
|
104
121
|
declare namespace encoding {
|
|
105
|
-
export { encoding_ALPHABETS as ALPHABETS, type encoding_Base32Alphabet as Base32Alphabet, type encoding_Base64DecodeResult as Base64DecodeResult, type encoding_Base64EncodeResult as Base64EncodeResult, type encoding_Base64Error as Base64Error, type encoding_Base64Variant as Base64Variant, type encoding_DecodeResult as DecodeResult, type encoding_EncodeResult as EncodeResult, type encoding_UrlEncodeError as UrlEncodeError, type encoding_UrlEncodeMode as UrlEncodeMode, type encoding_UrlEncodeResult as UrlEncodeResult, type encoding_UrlResult as UrlResult, encoding_base32Decode as base32Decode, encoding_base32DecodeBytes as base32DecodeBytes, encoding_base32Encode as base32Encode, encoding_base32EncodeBytes as base32EncodeBytes, encoding_decodeBase64 as decodeBase64, encoding_decodeHtmlEntities as decodeHtmlEntities, encoding_decodeUrl as decodeUrl, encoding_diffSegments as diffSegments, encoding_encodeBase64 as encodeBase64, encoding_encodeHtmlEntities as encodeHtmlEntities, encoding_encodeHtmlEntitiesAll as encodeHtmlEntitiesAll, type encoding_encodeMode as encodeMode, encoding_encodeUrl as encodeUrl, encoding_isValidBase32 as isValidBase32 };
|
|
122
|
+
export { encoding_ALPHABETS as ALPHABETS, type encoding_Base32Alphabet as Base32Alphabet, type encoding_Base64DecodeResult as Base64DecodeResult, type encoding_Base64EncodeResult as Base64EncodeResult, type encoding_Base64Error as Base64Error, type encoding_Base64Variant as Base64Variant, type encoding_DecodeResult as DecodeResult, type encoding_EncodeResult as EncodeResult, type encoding_UrlEncodeError as UrlEncodeError, type encoding_UrlEncodeMode as UrlEncodeMode, type encoding_UrlEncodeResult as UrlEncodeResult, type encoding_UrlResult as UrlResult, encoding_base32Decode as base32Decode, encoding_base32DecodeBytes as base32DecodeBytes, encoding_base32Encode as base32Encode, encoding_base32EncodeBytes as base32EncodeBytes, encoding_base58Decode as base58Decode, encoding_base58Encode as base58Encode, encoding_base62Decode as base62Decode, encoding_base62Encode as base62Encode, encoding_decodeBase64 as decodeBase64, encoding_decodeHtmlEntities as decodeHtmlEntities, encoding_decodeUrl as decodeUrl, encoding_diffSegments as diffSegments, encoding_encodeBase64 as encodeBase64, encoding_encodeHtmlEntities as encodeHtmlEntities, encoding_encodeHtmlEntitiesAll as encodeHtmlEntitiesAll, type encoding_encodeMode as encodeMode, encoding_encodeUrl as encodeUrl, encoding_isValidBase32 as isValidBase32 };
|
|
106
123
|
}
|
|
107
124
|
|
|
108
|
-
export { ALPHABETS as A, type Base32Alphabet as B, type DecodeResult as D, type EncodeResult as E, type UrlEncodeError as U, type Base64DecodeResult as a, type Base64EncodeResult as b, type Base64Error as c, type Base64Variant as d, encoding as e, type UrlEncodeMode as f, type UrlEncodeResult as g, type UrlResult as h, base32Decode as i, base32DecodeBytes as j, base32Encode as k, base32EncodeBytes as l,
|
|
125
|
+
export { ALPHABETS as A, type Base32Alphabet as B, type DecodeResult as D, type EncodeResult as E, type UrlEncodeError as U, type Base64DecodeResult as a, type Base64EncodeResult as b, type Base64Error as c, type Base64Variant as d, encoding as e, type UrlEncodeMode as f, type UrlEncodeResult as g, type UrlResult as h, base32Decode as i, base32DecodeBytes as j, base32Encode as k, base32EncodeBytes as l, base58Decode as m, base58Encode as n, base62Decode as o, base62Encode as p, decodeBase64 as q, decodeHtmlEntities as r, decodeUrl as s, diffSegments as t, encodeBase64 as u, encodeHtmlEntities as v, encodeHtmlEntitiesAll as w, type encodeMode as x, encodeUrl as y, isValidBase32 as z };
|
package/dist/index.cjs
CHANGED
|
@@ -1296,6 +1296,10 @@ __export(encoding_exports, {
|
|
|
1296
1296
|
base32DecodeBytes: () => base32DecodeBytes,
|
|
1297
1297
|
base32Encode: () => base32Encode,
|
|
1298
1298
|
base32EncodeBytes: () => base32EncodeBytes,
|
|
1299
|
+
base58Decode: () => base58Decode,
|
|
1300
|
+
base58Encode: () => base58Encode,
|
|
1301
|
+
base62Decode: () => base62Decode,
|
|
1302
|
+
base62Encode: () => base62Encode,
|
|
1299
1303
|
decodeBase64: () => decodeBase64,
|
|
1300
1304
|
decodeHtmlEntities: () => decodeHtmlEntities,
|
|
1301
1305
|
decodeUrl: () => decodeUrl,
|
|
@@ -1549,6 +1553,62 @@ function isValidBase32(input, alphabet = "standard") {
|
|
|
1549
1553
|
if (rem === 1 || rem === 3 || rem === 6) return false;
|
|
1550
1554
|
return true;
|
|
1551
1555
|
}
|
|
1556
|
+
var BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
1557
|
+
var BASE62_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
1558
|
+
function encodeBytesToBase(bytes, alphabet) {
|
|
1559
|
+
const base = BigInt(alphabet.length);
|
|
1560
|
+
let num = 0n;
|
|
1561
|
+
for (const byte of bytes) num = num << 8n | BigInt(byte);
|
|
1562
|
+
let out = "";
|
|
1563
|
+
while (num > 0n) {
|
|
1564
|
+
out = alphabet[Number(num % base)] + out;
|
|
1565
|
+
num = num / base;
|
|
1566
|
+
}
|
|
1567
|
+
let leadingZeros = 0;
|
|
1568
|
+
for (const byte of bytes) {
|
|
1569
|
+
if (byte === 0) leadingZeros++;
|
|
1570
|
+
else break;
|
|
1571
|
+
}
|
|
1572
|
+
return alphabet[0].repeat(leadingZeros) + out;
|
|
1573
|
+
}
|
|
1574
|
+
function decodeBaseToBytes(input, alphabet) {
|
|
1575
|
+
const base = BigInt(alphabet.length);
|
|
1576
|
+
let num = 0n;
|
|
1577
|
+
for (const char of input) {
|
|
1578
|
+
const idx = alphabet.indexOf(char);
|
|
1579
|
+
if (idx === -1) return { error: `Invalid character '${char}' for this alphabet` };
|
|
1580
|
+
num = num * base + BigInt(idx);
|
|
1581
|
+
}
|
|
1582
|
+
const bytes = [];
|
|
1583
|
+
while (num > 0n) {
|
|
1584
|
+
bytes.unshift(Number(num % 256n));
|
|
1585
|
+
num = num / 256n;
|
|
1586
|
+
}
|
|
1587
|
+
let leadingZeros = 0;
|
|
1588
|
+
for (const char of input) {
|
|
1589
|
+
if (char === alphabet[0]) leadingZeros++;
|
|
1590
|
+
else break;
|
|
1591
|
+
}
|
|
1592
|
+
return new Uint8Array([...new Array(leadingZeros).fill(0), ...bytes]);
|
|
1593
|
+
}
|
|
1594
|
+
function base58Encode(input) {
|
|
1595
|
+
return encodeBytesToBase(stringToBytes(input), BASE58_ALPHABET);
|
|
1596
|
+
}
|
|
1597
|
+
function base58Decode(input) {
|
|
1598
|
+
if (!input) return { error: "No input provided" };
|
|
1599
|
+
const result = decodeBaseToBytes(input, BASE58_ALPHABET);
|
|
1600
|
+
if (!(result instanceof Uint8Array)) return result;
|
|
1601
|
+
return bytesToString(result);
|
|
1602
|
+
}
|
|
1603
|
+
function base62Encode(input) {
|
|
1604
|
+
return encodeBytesToBase(stringToBytes(input), BASE62_ALPHABET);
|
|
1605
|
+
}
|
|
1606
|
+
function base62Decode(input) {
|
|
1607
|
+
if (!input) return { error: "No input provided" };
|
|
1608
|
+
const result = decodeBaseToBytes(input, BASE62_ALPHABET);
|
|
1609
|
+
if (!(result instanceof Uint8Array)) return result;
|
|
1610
|
+
return bytesToString(result);
|
|
1611
|
+
}
|
|
1552
1612
|
|
|
1553
1613
|
// src/tools/hashing.ts
|
|
1554
1614
|
var hashing_exports = {};
|
|
@@ -6625,6 +6685,7 @@ __export(units_exports, {
|
|
|
6625
6685
|
calcSubnet: () => calcSubnet,
|
|
6626
6686
|
calculateCompoundInterest: () => calculateCompoundInterest,
|
|
6627
6687
|
calculateLoan: () => calculateLoan,
|
|
6688
|
+
calculateSimpleInterest: () => calculateSimpleInterest,
|
|
6628
6689
|
calculateTax: () => calculateTax,
|
|
6629
6690
|
calculateTipSplit: () => calculateTipSplit,
|
|
6630
6691
|
compareSemver: () => compareSemver,
|
|
@@ -7885,6 +7946,22 @@ function calculateTipSplit(billAmount, tipPercent, numPeople = 1) {
|
|
|
7885
7946
|
perPersonTotal: round23(totalAmount / numPeople)
|
|
7886
7947
|
};
|
|
7887
7948
|
}
|
|
7949
|
+
function calculateSimpleInterest(principal, annualRatePercent, years) {
|
|
7950
|
+
if (!Number.isFinite(principal) || principal < 0) return { error: "Principal must be zero or a positive number" };
|
|
7951
|
+
if (!Number.isFinite(annualRatePercent) || annualRatePercent < 0) {
|
|
7952
|
+
return { error: "Annual interest rate must be zero or a positive number" };
|
|
7953
|
+
}
|
|
7954
|
+
if (!Number.isFinite(years) || years <= 0) return { error: "Years must be a positive number" };
|
|
7955
|
+
const round23 = (n) => Math.round(n * 100) / 100;
|
|
7956
|
+
const interest = round23(principal * (annualRatePercent / 100) * years);
|
|
7957
|
+
return {
|
|
7958
|
+
principal: round23(principal),
|
|
7959
|
+
annualRatePercent,
|
|
7960
|
+
years,
|
|
7961
|
+
interest,
|
|
7962
|
+
totalPayoff: round23(principal + interest)
|
|
7963
|
+
};
|
|
7964
|
+
}
|
|
7888
7965
|
|
|
7889
7966
|
// src/tools/network.ts
|
|
7890
7967
|
var network_exports = {};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { j as json } from './json-BjSoIS1h.cjs';
|
|
2
|
-
export { e as encoding } from './encoding-
|
|
2
|
+
export { e as encoding } from './encoding-Dk3wpmb3.cjs';
|
|
3
3
|
export { h as hashing } from './hashing-CnetQFD_.cjs';
|
|
4
4
|
export { t as text } from './text-Bbx-tZ43.cjs';
|
|
5
5
|
export { d as data } from './data-D8XTI7Du.cjs';
|
|
6
6
|
export { g as generators } from './generators-BGtRGpJZ.cjs';
|
|
7
7
|
export { t as time } from './time-DbT8fjaF.cjs';
|
|
8
|
-
export { u as units } from './units-
|
|
8
|
+
export { u as units } from './units-CkV4kAIs.cjs';
|
|
9
9
|
export { n as network } from './network-DaNoZ5ER.cjs';
|
|
10
10
|
export { a as api } from './api-Xl7OzIgq.cjs';
|
|
11
11
|
export { c as code } from './code-C4skwg3l.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { j as json } from './json-BjSoIS1h.js';
|
|
2
|
-
export { e as encoding } from './encoding-
|
|
2
|
+
export { e as encoding } from './encoding-Dk3wpmb3.js';
|
|
3
3
|
export { h as hashing } from './hashing-CnetQFD_.js';
|
|
4
4
|
export { t as text } from './text-Bbx-tZ43.js';
|
|
5
5
|
export { d as data } from './data-D8XTI7Du.js';
|
|
6
6
|
export { g as generators } from './generators-BGtRGpJZ.js';
|
|
7
7
|
export { t as time } from './time-DbT8fjaF.js';
|
|
8
|
-
export { u as units } from './units-
|
|
8
|
+
export { u as units } from './units-CkV4kAIs.js';
|
|
9
9
|
export { n as network } from './network-DaNoZ5ER.js';
|
|
10
10
|
export { a as api } from './api-Xl7OzIgq.js';
|
|
11
11
|
export { c as code } from './code-C4skwg3l.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { media_exports as media } from './chunk-XMKJYVKB.js';
|
|
2
|
-
export { units_exports as units } from './chunk-
|
|
2
|
+
export { units_exports as units } from './chunk-M4MMO6C6.js';
|
|
3
3
|
export { network_exports as network } from './chunk-OB56VNKJ.js';
|
|
4
4
|
export { api_exports as api } from './chunk-Q3B3YWOA.js';
|
|
5
5
|
export { code_exports as code } from './chunk-Y5X34JAC.js';
|
|
@@ -8,7 +8,7 @@ export { css_exports as css } from './chunk-6YPV2AB5.js';
|
|
|
8
8
|
export { misc_exports as misc } from './chunk-GX7H6TAX.js';
|
|
9
9
|
export { ai_agent_exports as ai_agent } from './chunk-M35VJETW.js';
|
|
10
10
|
export { json_exports as json } from './chunk-TSAGO3XP.js';
|
|
11
|
-
export { encoding_exports as encoding } from './chunk-
|
|
11
|
+
export { encoding_exports as encoding } from './chunk-DOWQZUTP.js';
|
|
12
12
|
export { hashing_exports as hashing } from './chunk-GEFVMGZR.js';
|
|
13
13
|
export { text_exports as text } from './chunk-F57WMKZO.js';
|
|
14
14
|
export { data_exports as data } from './chunk-TINQFTLO.js';
|
package/dist/tools/encoding.cjs
CHANGED
|
@@ -244,12 +244,72 @@ function isValidBase32(input, alphabet = "standard") {
|
|
|
244
244
|
if (rem === 1 || rem === 3 || rem === 6) return false;
|
|
245
245
|
return true;
|
|
246
246
|
}
|
|
247
|
+
var BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
248
|
+
var BASE62_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
249
|
+
function encodeBytesToBase(bytes, alphabet) {
|
|
250
|
+
const base = BigInt(alphabet.length);
|
|
251
|
+
let num = 0n;
|
|
252
|
+
for (const byte of bytes) num = num << 8n | BigInt(byte);
|
|
253
|
+
let out = "";
|
|
254
|
+
while (num > 0n) {
|
|
255
|
+
out = alphabet[Number(num % base)] + out;
|
|
256
|
+
num = num / base;
|
|
257
|
+
}
|
|
258
|
+
let leadingZeros = 0;
|
|
259
|
+
for (const byte of bytes) {
|
|
260
|
+
if (byte === 0) leadingZeros++;
|
|
261
|
+
else break;
|
|
262
|
+
}
|
|
263
|
+
return alphabet[0].repeat(leadingZeros) + out;
|
|
264
|
+
}
|
|
265
|
+
function decodeBaseToBytes(input, alphabet) {
|
|
266
|
+
const base = BigInt(alphabet.length);
|
|
267
|
+
let num = 0n;
|
|
268
|
+
for (const char of input) {
|
|
269
|
+
const idx = alphabet.indexOf(char);
|
|
270
|
+
if (idx === -1) return { error: `Invalid character '${char}' for this alphabet` };
|
|
271
|
+
num = num * base + BigInt(idx);
|
|
272
|
+
}
|
|
273
|
+
const bytes = [];
|
|
274
|
+
while (num > 0n) {
|
|
275
|
+
bytes.unshift(Number(num % 256n));
|
|
276
|
+
num = num / 256n;
|
|
277
|
+
}
|
|
278
|
+
let leadingZeros = 0;
|
|
279
|
+
for (const char of input) {
|
|
280
|
+
if (char === alphabet[0]) leadingZeros++;
|
|
281
|
+
else break;
|
|
282
|
+
}
|
|
283
|
+
return new Uint8Array([...new Array(leadingZeros).fill(0), ...bytes]);
|
|
284
|
+
}
|
|
285
|
+
function base58Encode(input) {
|
|
286
|
+
return encodeBytesToBase(stringToBytes(input), BASE58_ALPHABET);
|
|
287
|
+
}
|
|
288
|
+
function base58Decode(input) {
|
|
289
|
+
if (!input) return { error: "No input provided" };
|
|
290
|
+
const result = decodeBaseToBytes(input, BASE58_ALPHABET);
|
|
291
|
+
if (!(result instanceof Uint8Array)) return result;
|
|
292
|
+
return bytesToString(result);
|
|
293
|
+
}
|
|
294
|
+
function base62Encode(input) {
|
|
295
|
+
return encodeBytesToBase(stringToBytes(input), BASE62_ALPHABET);
|
|
296
|
+
}
|
|
297
|
+
function base62Decode(input) {
|
|
298
|
+
if (!input) return { error: "No input provided" };
|
|
299
|
+
const result = decodeBaseToBytes(input, BASE62_ALPHABET);
|
|
300
|
+
if (!(result instanceof Uint8Array)) return result;
|
|
301
|
+
return bytesToString(result);
|
|
302
|
+
}
|
|
247
303
|
|
|
248
304
|
exports.ALPHABETS = ALPHABETS;
|
|
249
305
|
exports.base32Decode = base32Decode;
|
|
250
306
|
exports.base32DecodeBytes = base32DecodeBytes;
|
|
251
307
|
exports.base32Encode = base32Encode;
|
|
252
308
|
exports.base32EncodeBytes = base32EncodeBytes;
|
|
309
|
+
exports.base58Decode = base58Decode;
|
|
310
|
+
exports.base58Encode = base58Encode;
|
|
311
|
+
exports.base62Decode = base62Decode;
|
|
312
|
+
exports.base62Encode = base62Encode;
|
|
253
313
|
exports.decodeBase64 = decodeBase64;
|
|
254
314
|
exports.decodeHtmlEntities = decodeHtmlEntities;
|
|
255
315
|
exports.decodeUrl = decodeUrl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as ALPHABETS, B as Base32Alphabet, a as Base64DecodeResult, b as Base64EncodeResult, c as Base64Error, d as Base64Variant, D as DecodeResult, E as EncodeResult, U as UrlEncodeError, f as UrlEncodeMode, g as UrlEncodeResult, h as UrlResult, i as base32Decode, j as base32DecodeBytes, k as base32Encode, l as base32EncodeBytes, m as
|
|
1
|
+
export { A as ALPHABETS, B as Base32Alphabet, a as Base64DecodeResult, b as Base64EncodeResult, c as Base64Error, d as Base64Variant, D as DecodeResult, E as EncodeResult, U as UrlEncodeError, f as UrlEncodeMode, g as UrlEncodeResult, h as UrlResult, i as base32Decode, j as base32DecodeBytes, k as base32Encode, l as base32EncodeBytes, m as base58Decode, n as base58Encode, o as base62Decode, p as base62Encode, q as decodeBase64, r as decodeHtmlEntities, s as decodeUrl, t as diffSegments, u as encodeBase64, v as encodeHtmlEntities, w as encodeHtmlEntitiesAll, x as encodeMode, y as encodeUrl, z as isValidBase32 } from '../encoding-Dk3wpmb3.cjs';
|
package/dist/tools/encoding.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as ALPHABETS, B as Base32Alphabet, a as Base64DecodeResult, b as Base64EncodeResult, c as Base64Error, d as Base64Variant, D as DecodeResult, E as EncodeResult, U as UrlEncodeError, f as UrlEncodeMode, g as UrlEncodeResult, h as UrlResult, i as base32Decode, j as base32DecodeBytes, k as base32Encode, l as base32EncodeBytes, m as
|
|
1
|
+
export { A as ALPHABETS, B as Base32Alphabet, a as Base64DecodeResult, b as Base64EncodeResult, c as Base64Error, d as Base64Variant, D as DecodeResult, E as EncodeResult, U as UrlEncodeError, f as UrlEncodeMode, g as UrlEncodeResult, h as UrlResult, i as base32Decode, j as base32DecodeBytes, k as base32Encode, l as base32EncodeBytes, m as base58Decode, n as base58Encode, o as base62Decode, p as base62Encode, q as decodeBase64, r as decodeHtmlEntities, s as decodeUrl, t as diffSegments, u as encodeBase64, v as encodeHtmlEntities, w as encodeHtmlEntitiesAll, x as encodeMode, y as encodeUrl, z as isValidBase32 } from '../encoding-Dk3wpmb3.js';
|
package/dist/tools/encoding.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ALPHABETS, base32Decode, base32DecodeBytes, base32Encode, base32EncodeBytes, decodeBase64, decodeHtmlEntities, decodeUrl, diffSegments, encodeBase64, encodeHtmlEntities, encodeHtmlEntitiesAll, encodeUrl, isValidBase32 } from '../chunk-
|
|
1
|
+
export { ALPHABETS, base32Decode, base32DecodeBytes, base32Encode, base32EncodeBytes, base58Decode, base58Encode, base62Decode, base62Encode, decodeBase64, decodeHtmlEntities, decodeUrl, diffSegments, encodeBase64, encodeHtmlEntities, encodeHtmlEntitiesAll, encodeUrl, isValidBase32 } from '../chunk-DOWQZUTP.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
package/dist/tools/units.cjs
CHANGED
|
@@ -1209,6 +1209,22 @@ function calculateTipSplit(billAmount, tipPercent, numPeople = 1) {
|
|
|
1209
1209
|
perPersonTotal: round22(totalAmount / numPeople)
|
|
1210
1210
|
};
|
|
1211
1211
|
}
|
|
1212
|
+
function calculateSimpleInterest(principal, annualRatePercent, years) {
|
|
1213
|
+
if (!Number.isFinite(principal) || principal < 0) return { error: "Principal must be zero or a positive number" };
|
|
1214
|
+
if (!Number.isFinite(annualRatePercent) || annualRatePercent < 0) {
|
|
1215
|
+
return { error: "Annual interest rate must be zero or a positive number" };
|
|
1216
|
+
}
|
|
1217
|
+
if (!Number.isFinite(years) || years <= 0) return { error: "Years must be a positive number" };
|
|
1218
|
+
const round22 = (n) => Math.round(n * 100) / 100;
|
|
1219
|
+
const interest = round22(principal * (annualRatePercent / 100) * years);
|
|
1220
|
+
return {
|
|
1221
|
+
principal: round22(principal),
|
|
1222
|
+
annualRatePercent,
|
|
1223
|
+
years,
|
|
1224
|
+
interest,
|
|
1225
|
+
totalPayoff: round22(principal + interest)
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1212
1228
|
|
|
1213
1229
|
exports.BASE_LABELS = BASE_LABELS;
|
|
1214
1230
|
exports.BASE_PREFIXES = BASE_PREFIXES;
|
|
@@ -1227,6 +1243,7 @@ exports.calcAspectRatio = calcAspectRatio;
|
|
|
1227
1243
|
exports.calcSubnet = calcSubnet;
|
|
1228
1244
|
exports.calculateCompoundInterest = calculateCompoundInterest;
|
|
1229
1245
|
exports.calculateLoan = calculateLoan;
|
|
1246
|
+
exports.calculateSimpleInterest = calculateSimpleInterest;
|
|
1230
1247
|
exports.calculateTax = calculateTax;
|
|
1231
1248
|
exports.calculateTipSplit = calculateTipSplit;
|
|
1232
1249
|
exports.compareSemver = compareSemver;
|
package/dist/tools/units.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as AmortizationRow, a as AspectRatioResult, B as BASE_LABELS, b as BASE_PREFIXES, c as BYTE_UNITS, d as BarcodeFormat, e as BarcodeValidationResult, f as BaseConvertResult, g as ByteConvertResult, h as ByteUnit, C as COMMON_CURRENCIES, i as COMMON_LOCALES, j as COMMON_PERMISSIONS, k as COMMON_RATIOS, l as COMMON_SIZES, m as COMMON_TAX_RATES, n as COMMON_TIP_PERCENTAGES, o as COMMON_VIEWPORTS, p as CardValidationResult, q as CompoundInterestResult, r as CompoundYearRow, D as Dimensions, F as FilePermissions, s as FormatOptions, I as IbanValidationResult, t as IpConversion, v as IsbnFormat, w as IsbnResult, L as LoanResult, N as NotationStyle, x as NumberBase, P as Permission, y as PxConvertResult, S as SemverVersion, z as SubnetInfo, T as TaxDirection,
|
|
1
|
+
export { A as AmortizationRow, a as AspectRatioResult, B as BASE_LABELS, b as BASE_PREFIXES, c as BYTE_UNITS, d as BarcodeFormat, e as BarcodeValidationResult, f as BaseConvertResult, g as ByteConvertResult, h as ByteUnit, C as COMMON_CURRENCIES, i as COMMON_LOCALES, j as COMMON_PERMISSIONS, k as COMMON_RATIOS, l as COMMON_SIZES, m as COMMON_TAX_RATES, n as COMMON_TIP_PERCENTAGES, o as COMMON_VIEWPORTS, p as CardValidationResult, q as CompoundInterestResult, r as CompoundYearRow, D as Dimensions, F as FilePermissions, s as FormatOptions, I as IbanValidationResult, t as IpConversion, v as IsbnFormat, w as IsbnResult, L as LoanResult, N as NotationStyle, x as NumberBase, P as Permission, y as PxConvertResult, S as SemverVersion, z as SimpleInterestResult, E as SubnetInfo, T as TaxDirection, G as TaxResult, H as TipSplitResult, V as ViewportConvertResult, J as autoFormat, K as bumpVersion, M as calcAspectRatio, O as calcSubnet, Q as calculateCompoundInterest, R as calculateLoan, U as calculateSimpleInterest, W as calculateTax, X as calculateTipSplit, Y as compareSemver, Z as convert, _ as convertBytes, $ as convertIp, a0 as coverBox, a1 as decimalToIp, a2 as decimalToIpCidr, a3 as describePermissions, a4 as fitIntoBox, a5 as formatNumber, a6 as formatValue, a7 as formatVwValue, a8 as formatWithSeparator, a9 as gcd, aa as ipFromBinary, ab as ipFromDecimal, ac as ipFromHex, ad as ipToBinary, ae as ipToDecimal, af as ipToDecimalCidr, ag as ipToHex, ah as ipToOctal, ai as isValid, aj as isValidCidr, ak as isValidIp, al as isValidIpv4, am as octalToPermissions, an as parseFileSize, ao as parseInput, ap as parseNumberString, aq as parseSemver, ar as permissionsToChmod, as as permissionsToOctal, at as permissionsToSymbolic, au as ptToPx, av as pxToAll, aw as pxToViewport, ax as remToPx, ay as satisfiesRange, az as scaleByHeight, aA as scaleByWidth, aB as sortVersions, aC as splitSubnet, aD as symbolicToPermissions, aE as validateBarcode, aF as validateCardNumber, aG as validateIban, aH as validateIsbn, aI as viewportToPx } from '../units-CkV4kAIs.cjs';
|
package/dist/tools/units.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as AmortizationRow, a as AspectRatioResult, B as BASE_LABELS, b as BASE_PREFIXES, c as BYTE_UNITS, d as BarcodeFormat, e as BarcodeValidationResult, f as BaseConvertResult, g as ByteConvertResult, h as ByteUnit, C as COMMON_CURRENCIES, i as COMMON_LOCALES, j as COMMON_PERMISSIONS, k as COMMON_RATIOS, l as COMMON_SIZES, m as COMMON_TAX_RATES, n as COMMON_TIP_PERCENTAGES, o as COMMON_VIEWPORTS, p as CardValidationResult, q as CompoundInterestResult, r as CompoundYearRow, D as Dimensions, F as FilePermissions, s as FormatOptions, I as IbanValidationResult, t as IpConversion, v as IsbnFormat, w as IsbnResult, L as LoanResult, N as NotationStyle, x as NumberBase, P as Permission, y as PxConvertResult, S as SemverVersion, z as SubnetInfo, T as TaxDirection,
|
|
1
|
+
export { A as AmortizationRow, a as AspectRatioResult, B as BASE_LABELS, b as BASE_PREFIXES, c as BYTE_UNITS, d as BarcodeFormat, e as BarcodeValidationResult, f as BaseConvertResult, g as ByteConvertResult, h as ByteUnit, C as COMMON_CURRENCIES, i as COMMON_LOCALES, j as COMMON_PERMISSIONS, k as COMMON_RATIOS, l as COMMON_SIZES, m as COMMON_TAX_RATES, n as COMMON_TIP_PERCENTAGES, o as COMMON_VIEWPORTS, p as CardValidationResult, q as CompoundInterestResult, r as CompoundYearRow, D as Dimensions, F as FilePermissions, s as FormatOptions, I as IbanValidationResult, t as IpConversion, v as IsbnFormat, w as IsbnResult, L as LoanResult, N as NotationStyle, x as NumberBase, P as Permission, y as PxConvertResult, S as SemverVersion, z as SimpleInterestResult, E as SubnetInfo, T as TaxDirection, G as TaxResult, H as TipSplitResult, V as ViewportConvertResult, J as autoFormat, K as bumpVersion, M as calcAspectRatio, O as calcSubnet, Q as calculateCompoundInterest, R as calculateLoan, U as calculateSimpleInterest, W as calculateTax, X as calculateTipSplit, Y as compareSemver, Z as convert, _ as convertBytes, $ as convertIp, a0 as coverBox, a1 as decimalToIp, a2 as decimalToIpCidr, a3 as describePermissions, a4 as fitIntoBox, a5 as formatNumber, a6 as formatValue, a7 as formatVwValue, a8 as formatWithSeparator, a9 as gcd, aa as ipFromBinary, ab as ipFromDecimal, ac as ipFromHex, ad as ipToBinary, ae as ipToDecimal, af as ipToDecimalCidr, ag as ipToHex, ah as ipToOctal, ai as isValid, aj as isValidCidr, ak as isValidIp, al as isValidIpv4, am as octalToPermissions, an as parseFileSize, ao as parseInput, ap as parseNumberString, aq as parseSemver, ar as permissionsToChmod, as as permissionsToOctal, at as permissionsToSymbolic, au as ptToPx, av as pxToAll, aw as pxToViewport, ax as remToPx, ay as satisfiesRange, az as scaleByHeight, aA as scaleByWidth, aB as sortVersions, aC as splitSubnet, aD as symbolicToPermissions, aE as validateBarcode, aF as validateCardNumber, aG as validateIban, aH as validateIsbn, aI as viewportToPx } from '../units-CkV4kAIs.js';
|
package/dist/tools/units.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_TIP_PERCENTAGES, COMMON_VIEWPORTS, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateCompoundInterest, calculateLoan, calculateTax, calculateTipSplit, compareSemver, convert, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, validateBarcode, validateCardNumber, validateIban, validateIsbn, viewportToPx } from '../chunk-
|
|
1
|
+
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_TIP_PERCENTAGES, COMMON_VIEWPORTS, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateCompoundInterest, calculateLoan, calculateSimpleInterest, calculateTax, calculateTipSplit, compareSemver, convert, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, validateBarcode, validateCardNumber, validateIban, validateIsbn, viewportToPx } from '../chunk-M4MMO6C6.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* - compound-interest-calculator : calculateCompoundInterest
|
|
21
21
|
* - isbn-validator : validateIsbn
|
|
22
22
|
* - tip-calculator : calculateTipSplit
|
|
23
|
+
* - simple-interest-calculator : calculateSimpleInterest
|
|
23
24
|
*/
|
|
24
25
|
interface PxConvertResult {
|
|
25
26
|
px: number;
|
|
@@ -387,6 +388,22 @@ declare const COMMON_TIP_PERCENTAGES: number[];
|
|
|
387
388
|
declare function calculateTipSplit(billAmount: number, tipPercent: number, numPeople?: number): TipSplitResult | {
|
|
388
389
|
error: string;
|
|
389
390
|
};
|
|
391
|
+
interface SimpleInterestResult {
|
|
392
|
+
principal: number;
|
|
393
|
+
annualRatePercent: number;
|
|
394
|
+
years: number;
|
|
395
|
+
interest: number;
|
|
396
|
+
totalPayoff: number;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Compute simple (non-compounding) interest: interest = principal × rate ×
|
|
400
|
+
* time. Distinct from calculateCompoundInterest, which reinvests interest
|
|
401
|
+
* each period; this is the flat-rate formula commonly used for short-term
|
|
402
|
+
* loans and bonds.
|
|
403
|
+
*/
|
|
404
|
+
declare function calculateSimpleInterest(principal: number, annualRatePercent: number, years: number): SimpleInterestResult | {
|
|
405
|
+
error: string;
|
|
406
|
+
};
|
|
390
407
|
|
|
391
408
|
type units_AmortizationRow = AmortizationRow;
|
|
392
409
|
type units_AspectRatioResult = AspectRatioResult;
|
|
@@ -422,6 +439,7 @@ type units_NumberBase = NumberBase;
|
|
|
422
439
|
type units_Permission = Permission;
|
|
423
440
|
type units_PxConvertResult = PxConvertResult;
|
|
424
441
|
type units_SemverVersion = SemverVersion;
|
|
442
|
+
type units_SimpleInterestResult = SimpleInterestResult;
|
|
425
443
|
type units_SubnetInfo = SubnetInfo;
|
|
426
444
|
type units_TaxDirection = TaxDirection;
|
|
427
445
|
type units_TaxResult = TaxResult;
|
|
@@ -433,6 +451,7 @@ declare const units_calcAspectRatio: typeof calcAspectRatio;
|
|
|
433
451
|
declare const units_calcSubnet: typeof calcSubnet;
|
|
434
452
|
declare const units_calculateCompoundInterest: typeof calculateCompoundInterest;
|
|
435
453
|
declare const units_calculateLoan: typeof calculateLoan;
|
|
454
|
+
declare const units_calculateSimpleInterest: typeof calculateSimpleInterest;
|
|
436
455
|
declare const units_calculateTax: typeof calculateTax;
|
|
437
456
|
declare const units_calculateTipSplit: typeof calculateTipSplit;
|
|
438
457
|
declare const units_compareSemver: typeof compareSemver;
|
|
@@ -485,7 +504,7 @@ declare const units_validateIban: typeof validateIban;
|
|
|
485
504
|
declare const units_validateIsbn: typeof validateIsbn;
|
|
486
505
|
declare const units_viewportToPx: typeof viewportToPx;
|
|
487
506
|
declare namespace units {
|
|
488
|
-
export { type units_AmortizationRow as AmortizationRow, type units_AspectRatioResult as AspectRatioResult, units_BASE_LABELS as BASE_LABELS, units_BASE_PREFIXES as BASE_PREFIXES, units_BYTE_UNITS as BYTE_UNITS, type units_BarcodeFormat as BarcodeFormat, type units_BarcodeValidationResult as BarcodeValidationResult, type units_BaseConvertResult as BaseConvertResult, type units_ByteConvertResult as ByteConvertResult, type units_ByteUnit as ByteUnit, units_COMMON_CURRENCIES as COMMON_CURRENCIES, units_COMMON_LOCALES as COMMON_LOCALES, units_COMMON_PERMISSIONS as COMMON_PERMISSIONS, units_COMMON_RATIOS as COMMON_RATIOS, units_COMMON_SIZES as COMMON_SIZES, units_COMMON_TAX_RATES as COMMON_TAX_RATES, units_COMMON_TIP_PERCENTAGES as COMMON_TIP_PERCENTAGES, units_COMMON_VIEWPORTS as COMMON_VIEWPORTS, type units_CardValidationResult as CardValidationResult, type units_CompoundInterestResult as CompoundInterestResult, type units_CompoundYearRow as CompoundYearRow, type units_Dimensions as Dimensions, type units_FilePermissions as FilePermissions, type units_FormatOptions as FormatOptions, type units_IbanValidationResult as IbanValidationResult, type units_IpConversion as IpConversion, type units_IsbnFormat as IsbnFormat, type units_IsbnResult as IsbnResult, type units_LoanResult as LoanResult, type units_NotationStyle as NotationStyle, type units_NumberBase as NumberBase, type units_Permission as Permission, type units_PxConvertResult as PxConvertResult, type units_SemverVersion as SemverVersion, type units_SubnetInfo as SubnetInfo, type units_TaxDirection as TaxDirection, type units_TaxResult as TaxResult, type units_TipSplitResult as TipSplitResult, type units_ViewportConvertResult as ViewportConvertResult, units_autoFormat as autoFormat, units_bumpVersion as bumpVersion, units_calcAspectRatio as calcAspectRatio, units_calcSubnet as calcSubnet, units_calculateCompoundInterest as calculateCompoundInterest, units_calculateLoan as calculateLoan, units_calculateTax as calculateTax, units_calculateTipSplit as calculateTipSplit, units_compareSemver as compareSemver, units_convert as convert, units_convertBytes as convertBytes, units_convertIp as convertIp, units_coverBox as coverBox, units_decimalToIp as decimalToIp, units_decimalToIpCidr as decimalToIpCidr, units_describePermissions as describePermissions, units_fitIntoBox as fitIntoBox, units_formatNumber as formatNumber, units_formatValue as formatValue, units_formatVwValue as formatVwValue, units_formatWithSeparator as formatWithSeparator, units_gcd as gcd, units_ipFromBinary as ipFromBinary, units_ipFromDecimal as ipFromDecimal, units_ipFromHex as ipFromHex, units_ipToBinary as ipToBinary, units_ipToDecimal as ipToDecimal, units_ipToDecimalCidr as ipToDecimalCidr, units_ipToHex as ipToHex, units_ipToOctal as ipToOctal, units_isValid as isValid, units_isValidCidr as isValidCidr, units_isValidIp as isValidIp, units_isValidIpv4 as isValidIpv4, units_octalToPermissions as octalToPermissions, units_parseFileSize as parseFileSize, units_parseInput as parseInput, units_parseNumberString as parseNumberString, units_parseSemver as parseSemver, units_permissionsToChmod as permissionsToChmod, units_permissionsToOctal as permissionsToOctal, units_permissionsToSymbolic as permissionsToSymbolic, units_ptToPx as ptToPx, units_pxToAll as pxToAll, units_pxToViewport as pxToViewport, units_remToPx as remToPx, units_satisfiesRange as satisfiesRange, units_scaleByHeight as scaleByHeight, units_scaleByWidth as scaleByWidth, units_sortVersions as sortVersions, units_splitSubnet as splitSubnet, units_symbolicToPermissions as symbolicToPermissions, units_validateBarcode as validateBarcode, units_validateCardNumber as validateCardNumber, units_validateIban as validateIban, units_validateIsbn as validateIsbn, units_viewportToPx as viewportToPx };
|
|
507
|
+
export { type units_AmortizationRow as AmortizationRow, type units_AspectRatioResult as AspectRatioResult, units_BASE_LABELS as BASE_LABELS, units_BASE_PREFIXES as BASE_PREFIXES, units_BYTE_UNITS as BYTE_UNITS, type units_BarcodeFormat as BarcodeFormat, type units_BarcodeValidationResult as BarcodeValidationResult, type units_BaseConvertResult as BaseConvertResult, type units_ByteConvertResult as ByteConvertResult, type units_ByteUnit as ByteUnit, units_COMMON_CURRENCIES as COMMON_CURRENCIES, units_COMMON_LOCALES as COMMON_LOCALES, units_COMMON_PERMISSIONS as COMMON_PERMISSIONS, units_COMMON_RATIOS as COMMON_RATIOS, units_COMMON_SIZES as COMMON_SIZES, units_COMMON_TAX_RATES as COMMON_TAX_RATES, units_COMMON_TIP_PERCENTAGES as COMMON_TIP_PERCENTAGES, units_COMMON_VIEWPORTS as COMMON_VIEWPORTS, type units_CardValidationResult as CardValidationResult, type units_CompoundInterestResult as CompoundInterestResult, type units_CompoundYearRow as CompoundYearRow, type units_Dimensions as Dimensions, type units_FilePermissions as FilePermissions, type units_FormatOptions as FormatOptions, type units_IbanValidationResult as IbanValidationResult, type units_IpConversion as IpConversion, type units_IsbnFormat as IsbnFormat, type units_IsbnResult as IsbnResult, type units_LoanResult as LoanResult, type units_NotationStyle as NotationStyle, type units_NumberBase as NumberBase, type units_Permission as Permission, type units_PxConvertResult as PxConvertResult, type units_SemverVersion as SemverVersion, type units_SimpleInterestResult as SimpleInterestResult, type units_SubnetInfo as SubnetInfo, type units_TaxDirection as TaxDirection, type units_TaxResult as TaxResult, type units_TipSplitResult as TipSplitResult, type units_ViewportConvertResult as ViewportConvertResult, units_autoFormat as autoFormat, units_bumpVersion as bumpVersion, units_calcAspectRatio as calcAspectRatio, units_calcSubnet as calcSubnet, units_calculateCompoundInterest as calculateCompoundInterest, units_calculateLoan as calculateLoan, units_calculateSimpleInterest as calculateSimpleInterest, units_calculateTax as calculateTax, units_calculateTipSplit as calculateTipSplit, units_compareSemver as compareSemver, units_convert as convert, units_convertBytes as convertBytes, units_convertIp as convertIp, units_coverBox as coverBox, units_decimalToIp as decimalToIp, units_decimalToIpCidr as decimalToIpCidr, units_describePermissions as describePermissions, units_fitIntoBox as fitIntoBox, units_formatNumber as formatNumber, units_formatValue as formatValue, units_formatVwValue as formatVwValue, units_formatWithSeparator as formatWithSeparator, units_gcd as gcd, units_ipFromBinary as ipFromBinary, units_ipFromDecimal as ipFromDecimal, units_ipFromHex as ipFromHex, units_ipToBinary as ipToBinary, units_ipToDecimal as ipToDecimal, units_ipToDecimalCidr as ipToDecimalCidr, units_ipToHex as ipToHex, units_ipToOctal as ipToOctal, units_isValid as isValid, units_isValidCidr as isValidCidr, units_isValidIp as isValidIp, units_isValidIpv4 as isValidIpv4, units_octalToPermissions as octalToPermissions, units_parseFileSize as parseFileSize, units_parseInput as parseInput, units_parseNumberString as parseNumberString, units_parseSemver as parseSemver, units_permissionsToChmod as permissionsToChmod, units_permissionsToOctal as permissionsToOctal, units_permissionsToSymbolic as permissionsToSymbolic, units_ptToPx as ptToPx, units_pxToAll as pxToAll, units_pxToViewport as pxToViewport, units_remToPx as remToPx, units_satisfiesRange as satisfiesRange, units_scaleByHeight as scaleByHeight, units_scaleByWidth as scaleByWidth, units_sortVersions as sortVersions, units_splitSubnet as splitSubnet, units_symbolicToPermissions as symbolicToPermissions, units_validateBarcode as validateBarcode, units_validateCardNumber as validateCardNumber, units_validateIban as validateIban, units_validateIsbn as validateIsbn, units_viewportToPx as viewportToPx };
|
|
489
508
|
}
|
|
490
509
|
|
|
491
|
-
export {
|
|
510
|
+
export { convertIp as $, type AmortizationRow as A, BASE_LABELS as B, COMMON_CURRENCIES as C, type Dimensions as D, type SubnetInfo as E, type FilePermissions as F, type TaxResult as G, type TipSplitResult as H, type IbanValidationResult as I, autoFormat as J, bumpVersion as K, type LoanResult as L, calcAspectRatio as M, type NotationStyle as N, calcSubnet as O, type Permission as P, calculateCompoundInterest as Q, calculateLoan as R, type SemverVersion as S, type TaxDirection as T, calculateSimpleInterest as U, type ViewportConvertResult as V, calculateTax as W, calculateTipSplit as X, compareSemver as Y, convert as Z, convertBytes as _, type AspectRatioResult as a, coverBox as a0, decimalToIp as a1, decimalToIpCidr as a2, describePermissions as a3, fitIntoBox as a4, formatNumber as a5, formatValue as a6, formatVwValue as a7, formatWithSeparator as a8, gcd as a9, scaleByWidth as aA, sortVersions as aB, splitSubnet as aC, symbolicToPermissions as aD, validateBarcode as aE, validateCardNumber as aF, validateIban as aG, validateIsbn as aH, viewportToPx as aI, ipFromBinary as aa, ipFromDecimal as ab, ipFromHex as ac, ipToBinary as ad, ipToDecimal as ae, ipToDecimalCidr as af, ipToHex as ag, ipToOctal as ah, isValid as ai, isValidCidr as aj, isValidIp as ak, isValidIpv4 as al, octalToPermissions as am, parseFileSize as an, parseInput as ao, parseNumberString as ap, parseSemver as aq, permissionsToChmod as ar, permissionsToOctal as as, permissionsToSymbolic as at, ptToPx as au, pxToAll as av, pxToViewport as aw, remToPx as ax, satisfiesRange as ay, scaleByHeight as az, BASE_PREFIXES as b, BYTE_UNITS as c, type BarcodeFormat as d, type BarcodeValidationResult as e, type BaseConvertResult as f, type ByteConvertResult as g, type ByteUnit as h, COMMON_LOCALES as i, COMMON_PERMISSIONS as j, COMMON_RATIOS as k, COMMON_SIZES as l, COMMON_TAX_RATES as m, COMMON_TIP_PERCENTAGES as n, COMMON_VIEWPORTS as o, type CardValidationResult as p, type CompoundInterestResult as q, type CompoundYearRow as r, type FormatOptions as s, type IpConversion as t, units as u, type IsbnFormat as v, type IsbnResult as w, type NumberBase as x, type PxConvertResult as y, type SimpleInterestResult as z };
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* - compound-interest-calculator : calculateCompoundInterest
|
|
21
21
|
* - isbn-validator : validateIsbn
|
|
22
22
|
* - tip-calculator : calculateTipSplit
|
|
23
|
+
* - simple-interest-calculator : calculateSimpleInterest
|
|
23
24
|
*/
|
|
24
25
|
interface PxConvertResult {
|
|
25
26
|
px: number;
|
|
@@ -387,6 +388,22 @@ declare const COMMON_TIP_PERCENTAGES: number[];
|
|
|
387
388
|
declare function calculateTipSplit(billAmount: number, tipPercent: number, numPeople?: number): TipSplitResult | {
|
|
388
389
|
error: string;
|
|
389
390
|
};
|
|
391
|
+
interface SimpleInterestResult {
|
|
392
|
+
principal: number;
|
|
393
|
+
annualRatePercent: number;
|
|
394
|
+
years: number;
|
|
395
|
+
interest: number;
|
|
396
|
+
totalPayoff: number;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Compute simple (non-compounding) interest: interest = principal × rate ×
|
|
400
|
+
* time. Distinct from calculateCompoundInterest, which reinvests interest
|
|
401
|
+
* each period; this is the flat-rate formula commonly used for short-term
|
|
402
|
+
* loans and bonds.
|
|
403
|
+
*/
|
|
404
|
+
declare function calculateSimpleInterest(principal: number, annualRatePercent: number, years: number): SimpleInterestResult | {
|
|
405
|
+
error: string;
|
|
406
|
+
};
|
|
390
407
|
|
|
391
408
|
type units_AmortizationRow = AmortizationRow;
|
|
392
409
|
type units_AspectRatioResult = AspectRatioResult;
|
|
@@ -422,6 +439,7 @@ type units_NumberBase = NumberBase;
|
|
|
422
439
|
type units_Permission = Permission;
|
|
423
440
|
type units_PxConvertResult = PxConvertResult;
|
|
424
441
|
type units_SemverVersion = SemverVersion;
|
|
442
|
+
type units_SimpleInterestResult = SimpleInterestResult;
|
|
425
443
|
type units_SubnetInfo = SubnetInfo;
|
|
426
444
|
type units_TaxDirection = TaxDirection;
|
|
427
445
|
type units_TaxResult = TaxResult;
|
|
@@ -433,6 +451,7 @@ declare const units_calcAspectRatio: typeof calcAspectRatio;
|
|
|
433
451
|
declare const units_calcSubnet: typeof calcSubnet;
|
|
434
452
|
declare const units_calculateCompoundInterest: typeof calculateCompoundInterest;
|
|
435
453
|
declare const units_calculateLoan: typeof calculateLoan;
|
|
454
|
+
declare const units_calculateSimpleInterest: typeof calculateSimpleInterest;
|
|
436
455
|
declare const units_calculateTax: typeof calculateTax;
|
|
437
456
|
declare const units_calculateTipSplit: typeof calculateTipSplit;
|
|
438
457
|
declare const units_compareSemver: typeof compareSemver;
|
|
@@ -485,7 +504,7 @@ declare const units_validateIban: typeof validateIban;
|
|
|
485
504
|
declare const units_validateIsbn: typeof validateIsbn;
|
|
486
505
|
declare const units_viewportToPx: typeof viewportToPx;
|
|
487
506
|
declare namespace units {
|
|
488
|
-
export { type units_AmortizationRow as AmortizationRow, type units_AspectRatioResult as AspectRatioResult, units_BASE_LABELS as BASE_LABELS, units_BASE_PREFIXES as BASE_PREFIXES, units_BYTE_UNITS as BYTE_UNITS, type units_BarcodeFormat as BarcodeFormat, type units_BarcodeValidationResult as BarcodeValidationResult, type units_BaseConvertResult as BaseConvertResult, type units_ByteConvertResult as ByteConvertResult, type units_ByteUnit as ByteUnit, units_COMMON_CURRENCIES as COMMON_CURRENCIES, units_COMMON_LOCALES as COMMON_LOCALES, units_COMMON_PERMISSIONS as COMMON_PERMISSIONS, units_COMMON_RATIOS as COMMON_RATIOS, units_COMMON_SIZES as COMMON_SIZES, units_COMMON_TAX_RATES as COMMON_TAX_RATES, units_COMMON_TIP_PERCENTAGES as COMMON_TIP_PERCENTAGES, units_COMMON_VIEWPORTS as COMMON_VIEWPORTS, type units_CardValidationResult as CardValidationResult, type units_CompoundInterestResult as CompoundInterestResult, type units_CompoundYearRow as CompoundYearRow, type units_Dimensions as Dimensions, type units_FilePermissions as FilePermissions, type units_FormatOptions as FormatOptions, type units_IbanValidationResult as IbanValidationResult, type units_IpConversion as IpConversion, type units_IsbnFormat as IsbnFormat, type units_IsbnResult as IsbnResult, type units_LoanResult as LoanResult, type units_NotationStyle as NotationStyle, type units_NumberBase as NumberBase, type units_Permission as Permission, type units_PxConvertResult as PxConvertResult, type units_SemverVersion as SemverVersion, type units_SubnetInfo as SubnetInfo, type units_TaxDirection as TaxDirection, type units_TaxResult as TaxResult, type units_TipSplitResult as TipSplitResult, type units_ViewportConvertResult as ViewportConvertResult, units_autoFormat as autoFormat, units_bumpVersion as bumpVersion, units_calcAspectRatio as calcAspectRatio, units_calcSubnet as calcSubnet, units_calculateCompoundInterest as calculateCompoundInterest, units_calculateLoan as calculateLoan, units_calculateTax as calculateTax, units_calculateTipSplit as calculateTipSplit, units_compareSemver as compareSemver, units_convert as convert, units_convertBytes as convertBytes, units_convertIp as convertIp, units_coverBox as coverBox, units_decimalToIp as decimalToIp, units_decimalToIpCidr as decimalToIpCidr, units_describePermissions as describePermissions, units_fitIntoBox as fitIntoBox, units_formatNumber as formatNumber, units_formatValue as formatValue, units_formatVwValue as formatVwValue, units_formatWithSeparator as formatWithSeparator, units_gcd as gcd, units_ipFromBinary as ipFromBinary, units_ipFromDecimal as ipFromDecimal, units_ipFromHex as ipFromHex, units_ipToBinary as ipToBinary, units_ipToDecimal as ipToDecimal, units_ipToDecimalCidr as ipToDecimalCidr, units_ipToHex as ipToHex, units_ipToOctal as ipToOctal, units_isValid as isValid, units_isValidCidr as isValidCidr, units_isValidIp as isValidIp, units_isValidIpv4 as isValidIpv4, units_octalToPermissions as octalToPermissions, units_parseFileSize as parseFileSize, units_parseInput as parseInput, units_parseNumberString as parseNumberString, units_parseSemver as parseSemver, units_permissionsToChmod as permissionsToChmod, units_permissionsToOctal as permissionsToOctal, units_permissionsToSymbolic as permissionsToSymbolic, units_ptToPx as ptToPx, units_pxToAll as pxToAll, units_pxToViewport as pxToViewport, units_remToPx as remToPx, units_satisfiesRange as satisfiesRange, units_scaleByHeight as scaleByHeight, units_scaleByWidth as scaleByWidth, units_sortVersions as sortVersions, units_splitSubnet as splitSubnet, units_symbolicToPermissions as symbolicToPermissions, units_validateBarcode as validateBarcode, units_validateCardNumber as validateCardNumber, units_validateIban as validateIban, units_validateIsbn as validateIsbn, units_viewportToPx as viewportToPx };
|
|
507
|
+
export { type units_AmortizationRow as AmortizationRow, type units_AspectRatioResult as AspectRatioResult, units_BASE_LABELS as BASE_LABELS, units_BASE_PREFIXES as BASE_PREFIXES, units_BYTE_UNITS as BYTE_UNITS, type units_BarcodeFormat as BarcodeFormat, type units_BarcodeValidationResult as BarcodeValidationResult, type units_BaseConvertResult as BaseConvertResult, type units_ByteConvertResult as ByteConvertResult, type units_ByteUnit as ByteUnit, units_COMMON_CURRENCIES as COMMON_CURRENCIES, units_COMMON_LOCALES as COMMON_LOCALES, units_COMMON_PERMISSIONS as COMMON_PERMISSIONS, units_COMMON_RATIOS as COMMON_RATIOS, units_COMMON_SIZES as COMMON_SIZES, units_COMMON_TAX_RATES as COMMON_TAX_RATES, units_COMMON_TIP_PERCENTAGES as COMMON_TIP_PERCENTAGES, units_COMMON_VIEWPORTS as COMMON_VIEWPORTS, type units_CardValidationResult as CardValidationResult, type units_CompoundInterestResult as CompoundInterestResult, type units_CompoundYearRow as CompoundYearRow, type units_Dimensions as Dimensions, type units_FilePermissions as FilePermissions, type units_FormatOptions as FormatOptions, type units_IbanValidationResult as IbanValidationResult, type units_IpConversion as IpConversion, type units_IsbnFormat as IsbnFormat, type units_IsbnResult as IsbnResult, type units_LoanResult as LoanResult, type units_NotationStyle as NotationStyle, type units_NumberBase as NumberBase, type units_Permission as Permission, type units_PxConvertResult as PxConvertResult, type units_SemverVersion as SemverVersion, type units_SimpleInterestResult as SimpleInterestResult, type units_SubnetInfo as SubnetInfo, type units_TaxDirection as TaxDirection, type units_TaxResult as TaxResult, type units_TipSplitResult as TipSplitResult, type units_ViewportConvertResult as ViewportConvertResult, units_autoFormat as autoFormat, units_bumpVersion as bumpVersion, units_calcAspectRatio as calcAspectRatio, units_calcSubnet as calcSubnet, units_calculateCompoundInterest as calculateCompoundInterest, units_calculateLoan as calculateLoan, units_calculateSimpleInterest as calculateSimpleInterest, units_calculateTax as calculateTax, units_calculateTipSplit as calculateTipSplit, units_compareSemver as compareSemver, units_convert as convert, units_convertBytes as convertBytes, units_convertIp as convertIp, units_coverBox as coverBox, units_decimalToIp as decimalToIp, units_decimalToIpCidr as decimalToIpCidr, units_describePermissions as describePermissions, units_fitIntoBox as fitIntoBox, units_formatNumber as formatNumber, units_formatValue as formatValue, units_formatVwValue as formatVwValue, units_formatWithSeparator as formatWithSeparator, units_gcd as gcd, units_ipFromBinary as ipFromBinary, units_ipFromDecimal as ipFromDecimal, units_ipFromHex as ipFromHex, units_ipToBinary as ipToBinary, units_ipToDecimal as ipToDecimal, units_ipToDecimalCidr as ipToDecimalCidr, units_ipToHex as ipToHex, units_ipToOctal as ipToOctal, units_isValid as isValid, units_isValidCidr as isValidCidr, units_isValidIp as isValidIp, units_isValidIpv4 as isValidIpv4, units_octalToPermissions as octalToPermissions, units_parseFileSize as parseFileSize, units_parseInput as parseInput, units_parseNumberString as parseNumberString, units_parseSemver as parseSemver, units_permissionsToChmod as permissionsToChmod, units_permissionsToOctal as permissionsToOctal, units_permissionsToSymbolic as permissionsToSymbolic, units_ptToPx as ptToPx, units_pxToAll as pxToAll, units_pxToViewport as pxToViewport, units_remToPx as remToPx, units_satisfiesRange as satisfiesRange, units_scaleByHeight as scaleByHeight, units_scaleByWidth as scaleByWidth, units_sortVersions as sortVersions, units_splitSubnet as splitSubnet, units_symbolicToPermissions as symbolicToPermissions, units_validateBarcode as validateBarcode, units_validateCardNumber as validateCardNumber, units_validateIban as validateIban, units_validateIsbn as validateIsbn, units_viewportToPx as viewportToPx };
|
|
489
508
|
}
|
|
490
509
|
|
|
491
|
-
export {
|
|
510
|
+
export { convertIp as $, type AmortizationRow as A, BASE_LABELS as B, COMMON_CURRENCIES as C, type Dimensions as D, type SubnetInfo as E, type FilePermissions as F, type TaxResult as G, type TipSplitResult as H, type IbanValidationResult as I, autoFormat as J, bumpVersion as K, type LoanResult as L, calcAspectRatio as M, type NotationStyle as N, calcSubnet as O, type Permission as P, calculateCompoundInterest as Q, calculateLoan as R, type SemverVersion as S, type TaxDirection as T, calculateSimpleInterest as U, type ViewportConvertResult as V, calculateTax as W, calculateTipSplit as X, compareSemver as Y, convert as Z, convertBytes as _, type AspectRatioResult as a, coverBox as a0, decimalToIp as a1, decimalToIpCidr as a2, describePermissions as a3, fitIntoBox as a4, formatNumber as a5, formatValue as a6, formatVwValue as a7, formatWithSeparator as a8, gcd as a9, scaleByWidth as aA, sortVersions as aB, splitSubnet as aC, symbolicToPermissions as aD, validateBarcode as aE, validateCardNumber as aF, validateIban as aG, validateIsbn as aH, viewportToPx as aI, ipFromBinary as aa, ipFromDecimal as ab, ipFromHex as ac, ipToBinary as ad, ipToDecimal as ae, ipToDecimalCidr as af, ipToHex as ag, ipToOctal as ah, isValid as ai, isValidCidr as aj, isValidIp as ak, isValidIpv4 as al, octalToPermissions as am, parseFileSize as an, parseInput as ao, parseNumberString as ap, parseSemver as aq, permissionsToChmod as ar, permissionsToOctal as as, permissionsToSymbolic as at, ptToPx as au, pxToAll as av, pxToViewport as aw, remToPx as ax, satisfiesRange as ay, scaleByHeight as az, BASE_PREFIXES as b, BYTE_UNITS as c, type BarcodeFormat as d, type BarcodeValidationResult as e, type BaseConvertResult as f, type ByteConvertResult as g, type ByteUnit as h, COMMON_LOCALES as i, COMMON_PERMISSIONS as j, COMMON_RATIOS as k, COMMON_SIZES as l, COMMON_TAX_RATES as m, COMMON_TIP_PERCENTAGES as n, COMMON_VIEWPORTS as o, type CardValidationResult as p, type CompoundInterestResult as q, type CompoundYearRow as r, type FormatOptions as s, type IpConversion as t, units as u, type IsbnFormat as v, type IsbnResult as w, type NumberBase as x, type PxConvertResult as y, type SimpleInterestResult as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utilix-tech/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "154+ developer utility tools for Node.js: JSON, encoding, hashing, color, CSS, network and more. Runs locally, no API key required.",
|
|
5
5
|
"author": "Utilix <hello@utilix.tech>",
|
|
6
6
|
"license": "MIT",
|