@utilix-tech/sdk 0.12.0 → 0.14.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 +6 -0
- package/README.md +15 -3
- package/dist/{chunk-CJGHHS5M.js → chunk-2TQTKZCN.js} +119 -1
- package/dist/index.cjs +118 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/tools/units.cjs +118 -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-Dt80-S2j.d.cts → units-C4N1Dq7_.d.cts} +83 -2
- package/dist/{units-Dt80-S2j.d.ts → units-C4N1Dq7_.d.ts} +83 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
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.14.0
|
|
6
|
+
- Added Compound Interest Calculator (`calculateCompoundInterest`) and ISBN Validator / Converter (`validateIsbn`).
|
|
7
|
+
|
|
8
|
+
## 0.13.0
|
|
9
|
+
- Added VAT / Sales Tax Calculator (`calculateTax`).
|
|
10
|
+
|
|
5
11
|
## 0.12.0
|
|
6
12
|
- Added ICO Favicon Inspector (`readIcoInfo`) and Barcode Checksum Validator (`validateBarcode`).
|
|
7
13
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @utilix-tech/sdk
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**539 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)
|
|
@@ -242,7 +242,7 @@ getNextRuns("*/5 * * * *", 5); // next 5 run timestamps
|
|
|
242
242
|
### `/units`: Conversions
|
|
243
243
|
|
|
244
244
|
```ts
|
|
245
|
-
import { convertBytes, pxToAll, convert, formatValue, validateCardNumber, validateIban, calculateLoan, validateBarcode } from "@utilix-tech/sdk/units";
|
|
245
|
+
import { convertBytes, pxToAll, convert, formatValue, validateCardNumber, validateIban, calculateLoan, validateBarcode, calculateTax, calculateCompoundInterest, validateIsbn } from "@utilix-tech/sdk/units";
|
|
246
246
|
|
|
247
247
|
// File sizes
|
|
248
248
|
convertBytes(1073741824, "GB"); // 1
|
|
@@ -276,6 +276,18 @@ calculateLoan(200000, 6.5, 360);
|
|
|
276
276
|
// EAN-13 / EAN-8 / UPC-A barcode checksum validation
|
|
277
277
|
validateBarcode("4006381333931");
|
|
278
278
|
// { valid: true, format: "EAN-13", digits: "4006381333931", checkDigit: 1, expectedCheckDigit: 1 }
|
|
279
|
+
|
|
280
|
+
// VAT / sales tax: add or remove tax in either direction
|
|
281
|
+
calculateTax(100, 20, "add");
|
|
282
|
+
// { netAmount: 100, taxAmount: 20, grossAmount: 120, ratePercent: 20, direction: "add" }
|
|
283
|
+
|
|
284
|
+
// Compound interest: future value with an optional recurring contribution
|
|
285
|
+
calculateCompoundInterest(1000, 5, 10, 1);
|
|
286
|
+
// { futureValue: 1628.89, totalInterest: 628.89, years: 10, compoundsPerYear: 1, schedule: [...] }
|
|
287
|
+
|
|
288
|
+
// ISBN-10 / ISBN-13 checksum validation + format conversion
|
|
289
|
+
validateIsbn("0-306-40615-2");
|
|
290
|
+
// { valid: true, format: "ISBN-10", converted: "9780306406157", ... }
|
|
279
291
|
```
|
|
280
292
|
|
|
281
293
|
---
|
|
@@ -506,7 +518,7 @@ readIcoInfo(new Uint8Array(icoBytes));
|
|
|
506
518
|
| `@utilix-tech/sdk/data` | CSV, YAML, TOML, XML, INI, NDJSON parse and convert |
|
|
507
519
|
| `@utilix-tech/sdk/generators` | UUID v4/v7, ULID, passwords, strength check, fake data |
|
|
508
520
|
| `@utilix-tech/sdk/time` | Date diff, timezone convert, cron parse, relative time |
|
|
509
|
-
| `@utilix-tech/sdk/units` | Bytes, CSS px/rem, number bases, currency format, credit card/IBAN/barcode validation, loan calculator |
|
|
521
|
+
| `@utilix-tech/sdk/units` | Bytes, CSS px/rem, number bases, currency format, credit card/IBAN/barcode/ISBN validation, loan calculator, compound interest calculator, VAT/sales tax calculator |
|
|
510
522
|
| `@utilix-tech/sdk/network` | HTTP status codes, IP validation, country flags, geolocation URLs, HAR file parsing |
|
|
511
523
|
| `@utilix-tech/sdk/api` | cURL build/parse, JWT decode/sign, JWKS parse, CORS headers, CSP header |
|
|
512
524
|
| `@utilix-tech/sdk/code` | SQL format/minify, HTML format/minify, regex tester, GraphQL format |
|
|
@@ -11,12 +11,15 @@ __export(units_exports, {
|
|
|
11
11
|
COMMON_PERMISSIONS: () => COMMON_PERMISSIONS,
|
|
12
12
|
COMMON_RATIOS: () => COMMON_RATIOS,
|
|
13
13
|
COMMON_SIZES: () => COMMON_SIZES,
|
|
14
|
+
COMMON_TAX_RATES: () => COMMON_TAX_RATES,
|
|
14
15
|
COMMON_VIEWPORTS: () => COMMON_VIEWPORTS,
|
|
15
16
|
autoFormat: () => autoFormat,
|
|
16
17
|
bumpVersion: () => bumpVersion,
|
|
17
18
|
calcAspectRatio: () => calcAspectRatio,
|
|
18
19
|
calcSubnet: () => calcSubnet,
|
|
20
|
+
calculateCompoundInterest: () => calculateCompoundInterest,
|
|
19
21
|
calculateLoan: () => calculateLoan,
|
|
22
|
+
calculateTax: () => calculateTax,
|
|
20
23
|
compareSemver: () => compareSemver,
|
|
21
24
|
convert: () => convert,
|
|
22
25
|
convertBytes: () => convertBytes,
|
|
@@ -64,6 +67,7 @@ __export(units_exports, {
|
|
|
64
67
|
validateBarcode: () => validateBarcode,
|
|
65
68
|
validateCardNumber: () => validateCardNumber,
|
|
66
69
|
validateIban: () => validateIban,
|
|
70
|
+
validateIsbn: () => validateIsbn,
|
|
67
71
|
viewportToPx: () => viewportToPx
|
|
68
72
|
});
|
|
69
73
|
function pxToAll(px, baseFontSize = 16, viewportWidth = 1440, viewportHeight = 900) {
|
|
@@ -1140,5 +1144,119 @@ function validateBarcode(input) {
|
|
|
1140
1144
|
const expectedCheckDigit = computeBarcodeCheckDigit(dataDigits);
|
|
1141
1145
|
return { valid: checkDigit === expectedCheckDigit, format, digits, checkDigit, expectedCheckDigit };
|
|
1142
1146
|
}
|
|
1147
|
+
var COMMON_TAX_RATES = [
|
|
1148
|
+
{ country: "US", label: "US (avg. state sales tax)", ratePercent: 7.25 },
|
|
1149
|
+
{ country: "GB", label: "UK VAT (standard)", ratePercent: 20 },
|
|
1150
|
+
{ country: "DE", label: "Germany VAT (standard)", ratePercent: 19 },
|
|
1151
|
+
{ country: "FR", label: "France VAT (standard)", ratePercent: 20 },
|
|
1152
|
+
{ country: "CA", label: "Canada GST", ratePercent: 5 },
|
|
1153
|
+
{ country: "AU", label: "Australia GST", ratePercent: 10 },
|
|
1154
|
+
{ country: "IN", label: "India GST (standard)", ratePercent: 18 },
|
|
1155
|
+
{ country: "JP", label: "Japan consumption tax", ratePercent: 10 }
|
|
1156
|
+
];
|
|
1157
|
+
function calculateTax(amount, ratePercent, direction) {
|
|
1158
|
+
if (!Number.isFinite(amount) || amount < 0) return { error: "Amount must be zero or a positive number" };
|
|
1159
|
+
if (!Number.isFinite(ratePercent) || ratePercent < 0) return { error: "Tax rate must be zero or a positive number" };
|
|
1160
|
+
if (direction !== "add" && direction !== "remove") return { error: 'Direction must be "add" or "remove"' };
|
|
1161
|
+
const round22 = (n) => Math.round(n * 100) / 100;
|
|
1162
|
+
if (direction === "add") {
|
|
1163
|
+
const netAmount2 = round22(amount);
|
|
1164
|
+
const taxAmount2 = round22(amount * (ratePercent / 100));
|
|
1165
|
+
return { netAmount: netAmount2, taxAmount: taxAmount2, grossAmount: round22(netAmount2 + taxAmount2), ratePercent, direction };
|
|
1166
|
+
}
|
|
1167
|
+
const grossAmount = round22(amount);
|
|
1168
|
+
const netAmount = round22(amount / (1 + ratePercent / 100));
|
|
1169
|
+
const taxAmount = round22(grossAmount - netAmount);
|
|
1170
|
+
return { netAmount, taxAmount, grossAmount, ratePercent, direction };
|
|
1171
|
+
}
|
|
1172
|
+
function calculateCompoundInterest(principal, annualRatePercent, years, compoundsPerYear, contributionPerPeriod = 0) {
|
|
1173
|
+
if (!Number.isFinite(principal) || principal < 0) return { error: "Principal must be zero or a positive number" };
|
|
1174
|
+
if (!Number.isFinite(annualRatePercent) || annualRatePercent < 0) {
|
|
1175
|
+
return { error: "Annual interest rate must be zero or a positive number" };
|
|
1176
|
+
}
|
|
1177
|
+
if (!Number.isInteger(years) || years <= 0) return { error: "Years must be a positive whole number" };
|
|
1178
|
+
if (!Number.isInteger(compoundsPerYear) || compoundsPerYear <= 0) {
|
|
1179
|
+
return { error: "Compounding frequency must be a positive whole number of periods per year" };
|
|
1180
|
+
}
|
|
1181
|
+
if (!Number.isFinite(contributionPerPeriod) || contributionPerPeriod < 0) {
|
|
1182
|
+
return { error: "Contribution per period must be zero or a positive number" };
|
|
1183
|
+
}
|
|
1184
|
+
if (principal === 0 && contributionPerPeriod === 0) return { error: "Enter a principal or a recurring contribution" };
|
|
1185
|
+
const round22 = (n) => Math.round(n * 100) / 100;
|
|
1186
|
+
const ratePerPeriod = annualRatePercent / 100 / compoundsPerYear;
|
|
1187
|
+
function futureValueAtPeriod(periods) {
|
|
1188
|
+
const growth = ratePerPeriod === 0 ? 1 : Math.pow(1 + ratePerPeriod, periods);
|
|
1189
|
+
const fvPrincipal = principal * growth;
|
|
1190
|
+
const fvContributions = contributionPerPeriod === 0 ? 0 : ratePerPeriod === 0 ? contributionPerPeriod * periods : contributionPerPeriod * ((growth - 1) / ratePerPeriod);
|
|
1191
|
+
return fvPrincipal + fvContributions;
|
|
1192
|
+
}
|
|
1193
|
+
const schedule = [];
|
|
1194
|
+
for (let year = 1; year <= years; year++) {
|
|
1195
|
+
const periods = year * compoundsPerYear;
|
|
1196
|
+
const balance = round22(futureValueAtPeriod(periods));
|
|
1197
|
+
const contributions = round22(contributionPerPeriod * periods);
|
|
1198
|
+
schedule.push({ year, balance, contributions, interest: round22(balance - principal - contributions) });
|
|
1199
|
+
}
|
|
1200
|
+
const totalPeriods = years * compoundsPerYear;
|
|
1201
|
+
const futureValue = round22(futureValueAtPeriod(totalPeriods));
|
|
1202
|
+
const totalContributions = round22(contributionPerPeriod * totalPeriods);
|
|
1203
|
+
const totalInterest = round22(futureValue - principal - totalContributions);
|
|
1204
|
+
return {
|
|
1205
|
+
futureValue,
|
|
1206
|
+
totalPrincipal: round22(principal),
|
|
1207
|
+
totalContributions,
|
|
1208
|
+
totalInterest,
|
|
1209
|
+
years,
|
|
1210
|
+
compoundsPerYear,
|
|
1211
|
+
schedule
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
function computeIsbn10CheckDigit(dataDigits) {
|
|
1215
|
+
let sum = 0;
|
|
1216
|
+
for (let i = 0; i < 9; i++) sum += dataDigits[i] * (10 - i);
|
|
1217
|
+
const check = (11 - sum % 11) % 11;
|
|
1218
|
+
return check === 10 ? "X" : String(check);
|
|
1219
|
+
}
|
|
1220
|
+
function computeIsbn13CheckDigit(dataDigits) {
|
|
1221
|
+
let sum = 0;
|
|
1222
|
+
const n = dataDigits.length;
|
|
1223
|
+
for (let i = 0; i < n; i++) {
|
|
1224
|
+
const distanceFromEnd = n - 1 - i;
|
|
1225
|
+
const weight = distanceFromEnd % 2 === 0 ? 3 : 1;
|
|
1226
|
+
sum += dataDigits[i] * weight;
|
|
1227
|
+
}
|
|
1228
|
+
return String((10 - sum % 10) % 10);
|
|
1229
|
+
}
|
|
1230
|
+
function validateIsbn(input) {
|
|
1231
|
+
if (!input || !input.trim()) return { error: "Input is empty" };
|
|
1232
|
+
const cleaned = input.replace(/[\s-]/g, "").toUpperCase();
|
|
1233
|
+
if (cleaned.length === 10) {
|
|
1234
|
+
if (!/^\d{9}[\dX]$/.test(cleaned)) {
|
|
1235
|
+
return { error: 'ISBN-10 must be 9 digits followed by a digit or "X" check digit' };
|
|
1236
|
+
}
|
|
1237
|
+
const dataDigits = cleaned.slice(0, 9).split("").map(Number);
|
|
1238
|
+
const checkDigit = cleaned[9];
|
|
1239
|
+
const expectedCheckDigit = computeIsbn10CheckDigit(dataDigits);
|
|
1240
|
+
const valid = checkDigit === expectedCheckDigit;
|
|
1241
|
+
const isbn13Digits = [9, 7, 8, ...dataDigits];
|
|
1242
|
+
const isbn13Check = computeIsbn13CheckDigit(isbn13Digits);
|
|
1243
|
+
const converted = valid ? isbn13Digits.join("") + isbn13Check : null;
|
|
1244
|
+
return { valid, format: "ISBN-10", digits: cleaned, checkDigit, expectedCheckDigit, converted };
|
|
1245
|
+
}
|
|
1246
|
+
if (cleaned.length === 13) {
|
|
1247
|
+
if (!/^\d{13}$/.test(cleaned)) return { error: "ISBN-13 must contain only digits" };
|
|
1248
|
+
const dataDigits = cleaned.slice(0, 12).split("").map(Number);
|
|
1249
|
+
const checkDigit = cleaned[12];
|
|
1250
|
+
const expectedCheckDigit = computeIsbn13CheckDigit(dataDigits);
|
|
1251
|
+
const valid = checkDigit === expectedCheckDigit;
|
|
1252
|
+
let converted = null;
|
|
1253
|
+
if (valid && cleaned.startsWith("978")) {
|
|
1254
|
+
const isbn10Digits = dataDigits.slice(3);
|
|
1255
|
+
converted = isbn10Digits.join("") + computeIsbn10CheckDigit(isbn10Digits);
|
|
1256
|
+
}
|
|
1257
|
+
return { valid, format: "ISBN-13", digits: cleaned, checkDigit, expectedCheckDigit, converted };
|
|
1258
|
+
}
|
|
1259
|
+
return { error: `Unsupported length (${cleaned.length} characters); expected 10 (ISBN-10) or 13 (ISBN-13)` };
|
|
1260
|
+
}
|
|
1143
1261
|
|
|
1144
|
-
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_VIEWPORTS, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateLoan, 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, viewportToPx };
|
|
1262
|
+
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_VIEWPORTS, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateCompoundInterest, calculateLoan, calculateTax, 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 };
|
package/dist/index.cjs
CHANGED
|
@@ -6616,12 +6616,15 @@ __export(units_exports, {
|
|
|
6616
6616
|
COMMON_PERMISSIONS: () => COMMON_PERMISSIONS,
|
|
6617
6617
|
COMMON_RATIOS: () => COMMON_RATIOS,
|
|
6618
6618
|
COMMON_SIZES: () => COMMON_SIZES,
|
|
6619
|
+
COMMON_TAX_RATES: () => COMMON_TAX_RATES,
|
|
6619
6620
|
COMMON_VIEWPORTS: () => COMMON_VIEWPORTS,
|
|
6620
6621
|
autoFormat: () => autoFormat,
|
|
6621
6622
|
bumpVersion: () => bumpVersion,
|
|
6622
6623
|
calcAspectRatio: () => calcAspectRatio,
|
|
6623
6624
|
calcSubnet: () => calcSubnet,
|
|
6625
|
+
calculateCompoundInterest: () => calculateCompoundInterest,
|
|
6624
6626
|
calculateLoan: () => calculateLoan,
|
|
6627
|
+
calculateTax: () => calculateTax,
|
|
6625
6628
|
compareSemver: () => compareSemver,
|
|
6626
6629
|
convert: () => convert,
|
|
6627
6630
|
convertBytes: () => convertBytes,
|
|
@@ -6669,6 +6672,7 @@ __export(units_exports, {
|
|
|
6669
6672
|
validateBarcode: () => validateBarcode,
|
|
6670
6673
|
validateCardNumber: () => validateCardNumber,
|
|
6671
6674
|
validateIban: () => validateIban,
|
|
6675
|
+
validateIsbn: () => validateIsbn,
|
|
6672
6676
|
viewportToPx: () => viewportToPx
|
|
6673
6677
|
});
|
|
6674
6678
|
function pxToAll(px, baseFontSize = 16, viewportWidth = 1440, viewportHeight = 900) {
|
|
@@ -7745,6 +7749,120 @@ function validateBarcode(input) {
|
|
|
7745
7749
|
const expectedCheckDigit = computeBarcodeCheckDigit(dataDigits);
|
|
7746
7750
|
return { valid: checkDigit === expectedCheckDigit, format, digits, checkDigit, expectedCheckDigit };
|
|
7747
7751
|
}
|
|
7752
|
+
var COMMON_TAX_RATES = [
|
|
7753
|
+
{ country: "US", label: "US (avg. state sales tax)", ratePercent: 7.25 },
|
|
7754
|
+
{ country: "GB", label: "UK VAT (standard)", ratePercent: 20 },
|
|
7755
|
+
{ country: "DE", label: "Germany VAT (standard)", ratePercent: 19 },
|
|
7756
|
+
{ country: "FR", label: "France VAT (standard)", ratePercent: 20 },
|
|
7757
|
+
{ country: "CA", label: "Canada GST", ratePercent: 5 },
|
|
7758
|
+
{ country: "AU", label: "Australia GST", ratePercent: 10 },
|
|
7759
|
+
{ country: "IN", label: "India GST (standard)", ratePercent: 18 },
|
|
7760
|
+
{ country: "JP", label: "Japan consumption tax", ratePercent: 10 }
|
|
7761
|
+
];
|
|
7762
|
+
function calculateTax(amount, ratePercent, direction) {
|
|
7763
|
+
if (!Number.isFinite(amount) || amount < 0) return { error: "Amount must be zero or a positive number" };
|
|
7764
|
+
if (!Number.isFinite(ratePercent) || ratePercent < 0) return { error: "Tax rate must be zero or a positive number" };
|
|
7765
|
+
if (direction !== "add" && direction !== "remove") return { error: 'Direction must be "add" or "remove"' };
|
|
7766
|
+
const round23 = (n) => Math.round(n * 100) / 100;
|
|
7767
|
+
if (direction === "add") {
|
|
7768
|
+
const netAmount2 = round23(amount);
|
|
7769
|
+
const taxAmount2 = round23(amount * (ratePercent / 100));
|
|
7770
|
+
return { netAmount: netAmount2, taxAmount: taxAmount2, grossAmount: round23(netAmount2 + taxAmount2), ratePercent, direction };
|
|
7771
|
+
}
|
|
7772
|
+
const grossAmount = round23(amount);
|
|
7773
|
+
const netAmount = round23(amount / (1 + ratePercent / 100));
|
|
7774
|
+
const taxAmount = round23(grossAmount - netAmount);
|
|
7775
|
+
return { netAmount, taxAmount, grossAmount, ratePercent, direction };
|
|
7776
|
+
}
|
|
7777
|
+
function calculateCompoundInterest(principal, annualRatePercent, years, compoundsPerYear, contributionPerPeriod = 0) {
|
|
7778
|
+
if (!Number.isFinite(principal) || principal < 0) return { error: "Principal must be zero or a positive number" };
|
|
7779
|
+
if (!Number.isFinite(annualRatePercent) || annualRatePercent < 0) {
|
|
7780
|
+
return { error: "Annual interest rate must be zero or a positive number" };
|
|
7781
|
+
}
|
|
7782
|
+
if (!Number.isInteger(years) || years <= 0) return { error: "Years must be a positive whole number" };
|
|
7783
|
+
if (!Number.isInteger(compoundsPerYear) || compoundsPerYear <= 0) {
|
|
7784
|
+
return { error: "Compounding frequency must be a positive whole number of periods per year" };
|
|
7785
|
+
}
|
|
7786
|
+
if (!Number.isFinite(contributionPerPeriod) || contributionPerPeriod < 0) {
|
|
7787
|
+
return { error: "Contribution per period must be zero or a positive number" };
|
|
7788
|
+
}
|
|
7789
|
+
if (principal === 0 && contributionPerPeriod === 0) return { error: "Enter a principal or a recurring contribution" };
|
|
7790
|
+
const round23 = (n) => Math.round(n * 100) / 100;
|
|
7791
|
+
const ratePerPeriod = annualRatePercent / 100 / compoundsPerYear;
|
|
7792
|
+
function futureValueAtPeriod(periods) {
|
|
7793
|
+
const growth = ratePerPeriod === 0 ? 1 : Math.pow(1 + ratePerPeriod, periods);
|
|
7794
|
+
const fvPrincipal = principal * growth;
|
|
7795
|
+
const fvContributions = contributionPerPeriod === 0 ? 0 : ratePerPeriod === 0 ? contributionPerPeriod * periods : contributionPerPeriod * ((growth - 1) / ratePerPeriod);
|
|
7796
|
+
return fvPrincipal + fvContributions;
|
|
7797
|
+
}
|
|
7798
|
+
const schedule = [];
|
|
7799
|
+
for (let year = 1; year <= years; year++) {
|
|
7800
|
+
const periods = year * compoundsPerYear;
|
|
7801
|
+
const balance = round23(futureValueAtPeriod(periods));
|
|
7802
|
+
const contributions = round23(contributionPerPeriod * periods);
|
|
7803
|
+
schedule.push({ year, balance, contributions, interest: round23(balance - principal - contributions) });
|
|
7804
|
+
}
|
|
7805
|
+
const totalPeriods = years * compoundsPerYear;
|
|
7806
|
+
const futureValue = round23(futureValueAtPeriod(totalPeriods));
|
|
7807
|
+
const totalContributions = round23(contributionPerPeriod * totalPeriods);
|
|
7808
|
+
const totalInterest = round23(futureValue - principal - totalContributions);
|
|
7809
|
+
return {
|
|
7810
|
+
futureValue,
|
|
7811
|
+
totalPrincipal: round23(principal),
|
|
7812
|
+
totalContributions,
|
|
7813
|
+
totalInterest,
|
|
7814
|
+
years,
|
|
7815
|
+
compoundsPerYear,
|
|
7816
|
+
schedule
|
|
7817
|
+
};
|
|
7818
|
+
}
|
|
7819
|
+
function computeIsbn10CheckDigit(dataDigits) {
|
|
7820
|
+
let sum = 0;
|
|
7821
|
+
for (let i = 0; i < 9; i++) sum += dataDigits[i] * (10 - i);
|
|
7822
|
+
const check = (11 - sum % 11) % 11;
|
|
7823
|
+
return check === 10 ? "X" : String(check);
|
|
7824
|
+
}
|
|
7825
|
+
function computeIsbn13CheckDigit(dataDigits) {
|
|
7826
|
+
let sum = 0;
|
|
7827
|
+
const n = dataDigits.length;
|
|
7828
|
+
for (let i = 0; i < n; i++) {
|
|
7829
|
+
const distanceFromEnd = n - 1 - i;
|
|
7830
|
+
const weight = distanceFromEnd % 2 === 0 ? 3 : 1;
|
|
7831
|
+
sum += dataDigits[i] * weight;
|
|
7832
|
+
}
|
|
7833
|
+
return String((10 - sum % 10) % 10);
|
|
7834
|
+
}
|
|
7835
|
+
function validateIsbn(input) {
|
|
7836
|
+
if (!input || !input.trim()) return { error: "Input is empty" };
|
|
7837
|
+
const cleaned = input.replace(/[\s-]/g, "").toUpperCase();
|
|
7838
|
+
if (cleaned.length === 10) {
|
|
7839
|
+
if (!/^\d{9}[\dX]$/.test(cleaned)) {
|
|
7840
|
+
return { error: 'ISBN-10 must be 9 digits followed by a digit or "X" check digit' };
|
|
7841
|
+
}
|
|
7842
|
+
const dataDigits = cleaned.slice(0, 9).split("").map(Number);
|
|
7843
|
+
const checkDigit = cleaned[9];
|
|
7844
|
+
const expectedCheckDigit = computeIsbn10CheckDigit(dataDigits);
|
|
7845
|
+
const valid = checkDigit === expectedCheckDigit;
|
|
7846
|
+
const isbn13Digits = [9, 7, 8, ...dataDigits];
|
|
7847
|
+
const isbn13Check = computeIsbn13CheckDigit(isbn13Digits);
|
|
7848
|
+
const converted = valid ? isbn13Digits.join("") + isbn13Check : null;
|
|
7849
|
+
return { valid, format: "ISBN-10", digits: cleaned, checkDigit, expectedCheckDigit, converted };
|
|
7850
|
+
}
|
|
7851
|
+
if (cleaned.length === 13) {
|
|
7852
|
+
if (!/^\d{13}$/.test(cleaned)) return { error: "ISBN-13 must contain only digits" };
|
|
7853
|
+
const dataDigits = cleaned.slice(0, 12).split("").map(Number);
|
|
7854
|
+
const checkDigit = cleaned[12];
|
|
7855
|
+
const expectedCheckDigit = computeIsbn13CheckDigit(dataDigits);
|
|
7856
|
+
const valid = checkDigit === expectedCheckDigit;
|
|
7857
|
+
let converted = null;
|
|
7858
|
+
if (valid && cleaned.startsWith("978")) {
|
|
7859
|
+
const isbn10Digits = dataDigits.slice(3);
|
|
7860
|
+
converted = isbn10Digits.join("") + computeIsbn10CheckDigit(isbn10Digits);
|
|
7861
|
+
}
|
|
7862
|
+
return { valid, format: "ISBN-13", digits: cleaned, checkDigit, expectedCheckDigit, converted };
|
|
7863
|
+
}
|
|
7864
|
+
return { error: `Unsupported length (${cleaned.length} characters); expected 10 (ISBN-10) or 13 (ISBN-13)` };
|
|
7865
|
+
}
|
|
7748
7866
|
|
|
7749
7867
|
// src/tools/network.ts
|
|
7750
7868
|
var network_exports = {};
|
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ 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-C4N1Dq7_.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-BUqyaofO.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ 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-C4N1Dq7_.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-BUqyaofO.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-2TQTKZCN.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-V5S6OJ4A.js';
|
package/dist/tools/units.cjs
CHANGED
|
@@ -1075,6 +1075,120 @@ function validateBarcode(input) {
|
|
|
1075
1075
|
const expectedCheckDigit = computeBarcodeCheckDigit(dataDigits);
|
|
1076
1076
|
return { valid: checkDigit === expectedCheckDigit, format, digits, checkDigit, expectedCheckDigit };
|
|
1077
1077
|
}
|
|
1078
|
+
var COMMON_TAX_RATES = [
|
|
1079
|
+
{ country: "US", label: "US (avg. state sales tax)", ratePercent: 7.25 },
|
|
1080
|
+
{ country: "GB", label: "UK VAT (standard)", ratePercent: 20 },
|
|
1081
|
+
{ country: "DE", label: "Germany VAT (standard)", ratePercent: 19 },
|
|
1082
|
+
{ country: "FR", label: "France VAT (standard)", ratePercent: 20 },
|
|
1083
|
+
{ country: "CA", label: "Canada GST", ratePercent: 5 },
|
|
1084
|
+
{ country: "AU", label: "Australia GST", ratePercent: 10 },
|
|
1085
|
+
{ country: "IN", label: "India GST (standard)", ratePercent: 18 },
|
|
1086
|
+
{ country: "JP", label: "Japan consumption tax", ratePercent: 10 }
|
|
1087
|
+
];
|
|
1088
|
+
function calculateTax(amount, ratePercent, direction) {
|
|
1089
|
+
if (!Number.isFinite(amount) || amount < 0) return { error: "Amount must be zero or a positive number" };
|
|
1090
|
+
if (!Number.isFinite(ratePercent) || ratePercent < 0) return { error: "Tax rate must be zero or a positive number" };
|
|
1091
|
+
if (direction !== "add" && direction !== "remove") return { error: 'Direction must be "add" or "remove"' };
|
|
1092
|
+
const round22 = (n) => Math.round(n * 100) / 100;
|
|
1093
|
+
if (direction === "add") {
|
|
1094
|
+
const netAmount2 = round22(amount);
|
|
1095
|
+
const taxAmount2 = round22(amount * (ratePercent / 100));
|
|
1096
|
+
return { netAmount: netAmount2, taxAmount: taxAmount2, grossAmount: round22(netAmount2 + taxAmount2), ratePercent, direction };
|
|
1097
|
+
}
|
|
1098
|
+
const grossAmount = round22(amount);
|
|
1099
|
+
const netAmount = round22(amount / (1 + ratePercent / 100));
|
|
1100
|
+
const taxAmount = round22(grossAmount - netAmount);
|
|
1101
|
+
return { netAmount, taxAmount, grossAmount, ratePercent, direction };
|
|
1102
|
+
}
|
|
1103
|
+
function calculateCompoundInterest(principal, annualRatePercent, years, compoundsPerYear, contributionPerPeriod = 0) {
|
|
1104
|
+
if (!Number.isFinite(principal) || principal < 0) return { error: "Principal must be zero or a positive number" };
|
|
1105
|
+
if (!Number.isFinite(annualRatePercent) || annualRatePercent < 0) {
|
|
1106
|
+
return { error: "Annual interest rate must be zero or a positive number" };
|
|
1107
|
+
}
|
|
1108
|
+
if (!Number.isInteger(years) || years <= 0) return { error: "Years must be a positive whole number" };
|
|
1109
|
+
if (!Number.isInteger(compoundsPerYear) || compoundsPerYear <= 0) {
|
|
1110
|
+
return { error: "Compounding frequency must be a positive whole number of periods per year" };
|
|
1111
|
+
}
|
|
1112
|
+
if (!Number.isFinite(contributionPerPeriod) || contributionPerPeriod < 0) {
|
|
1113
|
+
return { error: "Contribution per period must be zero or a positive number" };
|
|
1114
|
+
}
|
|
1115
|
+
if (principal === 0 && contributionPerPeriod === 0) return { error: "Enter a principal or a recurring contribution" };
|
|
1116
|
+
const round22 = (n) => Math.round(n * 100) / 100;
|
|
1117
|
+
const ratePerPeriod = annualRatePercent / 100 / compoundsPerYear;
|
|
1118
|
+
function futureValueAtPeriod(periods) {
|
|
1119
|
+
const growth = ratePerPeriod === 0 ? 1 : Math.pow(1 + ratePerPeriod, periods);
|
|
1120
|
+
const fvPrincipal = principal * growth;
|
|
1121
|
+
const fvContributions = contributionPerPeriod === 0 ? 0 : ratePerPeriod === 0 ? contributionPerPeriod * periods : contributionPerPeriod * ((growth - 1) / ratePerPeriod);
|
|
1122
|
+
return fvPrincipal + fvContributions;
|
|
1123
|
+
}
|
|
1124
|
+
const schedule = [];
|
|
1125
|
+
for (let year = 1; year <= years; year++) {
|
|
1126
|
+
const periods = year * compoundsPerYear;
|
|
1127
|
+
const balance = round22(futureValueAtPeriod(periods));
|
|
1128
|
+
const contributions = round22(contributionPerPeriod * periods);
|
|
1129
|
+
schedule.push({ year, balance, contributions, interest: round22(balance - principal - contributions) });
|
|
1130
|
+
}
|
|
1131
|
+
const totalPeriods = years * compoundsPerYear;
|
|
1132
|
+
const futureValue = round22(futureValueAtPeriod(totalPeriods));
|
|
1133
|
+
const totalContributions = round22(contributionPerPeriod * totalPeriods);
|
|
1134
|
+
const totalInterest = round22(futureValue - principal - totalContributions);
|
|
1135
|
+
return {
|
|
1136
|
+
futureValue,
|
|
1137
|
+
totalPrincipal: round22(principal),
|
|
1138
|
+
totalContributions,
|
|
1139
|
+
totalInterest,
|
|
1140
|
+
years,
|
|
1141
|
+
compoundsPerYear,
|
|
1142
|
+
schedule
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
function computeIsbn10CheckDigit(dataDigits) {
|
|
1146
|
+
let sum = 0;
|
|
1147
|
+
for (let i = 0; i < 9; i++) sum += dataDigits[i] * (10 - i);
|
|
1148
|
+
const check = (11 - sum % 11) % 11;
|
|
1149
|
+
return check === 10 ? "X" : String(check);
|
|
1150
|
+
}
|
|
1151
|
+
function computeIsbn13CheckDigit(dataDigits) {
|
|
1152
|
+
let sum = 0;
|
|
1153
|
+
const n = dataDigits.length;
|
|
1154
|
+
for (let i = 0; i < n; i++) {
|
|
1155
|
+
const distanceFromEnd = n - 1 - i;
|
|
1156
|
+
const weight = distanceFromEnd % 2 === 0 ? 3 : 1;
|
|
1157
|
+
sum += dataDigits[i] * weight;
|
|
1158
|
+
}
|
|
1159
|
+
return String((10 - sum % 10) % 10);
|
|
1160
|
+
}
|
|
1161
|
+
function validateIsbn(input) {
|
|
1162
|
+
if (!input || !input.trim()) return { error: "Input is empty" };
|
|
1163
|
+
const cleaned = input.replace(/[\s-]/g, "").toUpperCase();
|
|
1164
|
+
if (cleaned.length === 10) {
|
|
1165
|
+
if (!/^\d{9}[\dX]$/.test(cleaned)) {
|
|
1166
|
+
return { error: 'ISBN-10 must be 9 digits followed by a digit or "X" check digit' };
|
|
1167
|
+
}
|
|
1168
|
+
const dataDigits = cleaned.slice(0, 9).split("").map(Number);
|
|
1169
|
+
const checkDigit = cleaned[9];
|
|
1170
|
+
const expectedCheckDigit = computeIsbn10CheckDigit(dataDigits);
|
|
1171
|
+
const valid = checkDigit === expectedCheckDigit;
|
|
1172
|
+
const isbn13Digits = [9, 7, 8, ...dataDigits];
|
|
1173
|
+
const isbn13Check = computeIsbn13CheckDigit(isbn13Digits);
|
|
1174
|
+
const converted = valid ? isbn13Digits.join("") + isbn13Check : null;
|
|
1175
|
+
return { valid, format: "ISBN-10", digits: cleaned, checkDigit, expectedCheckDigit, converted };
|
|
1176
|
+
}
|
|
1177
|
+
if (cleaned.length === 13) {
|
|
1178
|
+
if (!/^\d{13}$/.test(cleaned)) return { error: "ISBN-13 must contain only digits" };
|
|
1179
|
+
const dataDigits = cleaned.slice(0, 12).split("").map(Number);
|
|
1180
|
+
const checkDigit = cleaned[12];
|
|
1181
|
+
const expectedCheckDigit = computeIsbn13CheckDigit(dataDigits);
|
|
1182
|
+
const valid = checkDigit === expectedCheckDigit;
|
|
1183
|
+
let converted = null;
|
|
1184
|
+
if (valid && cleaned.startsWith("978")) {
|
|
1185
|
+
const isbn10Digits = dataDigits.slice(3);
|
|
1186
|
+
converted = isbn10Digits.join("") + computeIsbn10CheckDigit(isbn10Digits);
|
|
1187
|
+
}
|
|
1188
|
+
return { valid, format: "ISBN-13", digits: cleaned, checkDigit, expectedCheckDigit, converted };
|
|
1189
|
+
}
|
|
1190
|
+
return { error: `Unsupported length (${cleaned.length} characters); expected 10 (ISBN-10) or 13 (ISBN-13)` };
|
|
1191
|
+
}
|
|
1078
1192
|
|
|
1079
1193
|
exports.BASE_LABELS = BASE_LABELS;
|
|
1080
1194
|
exports.BASE_PREFIXES = BASE_PREFIXES;
|
|
@@ -1084,12 +1198,15 @@ exports.COMMON_LOCALES = COMMON_LOCALES;
|
|
|
1084
1198
|
exports.COMMON_PERMISSIONS = COMMON_PERMISSIONS;
|
|
1085
1199
|
exports.COMMON_RATIOS = COMMON_RATIOS;
|
|
1086
1200
|
exports.COMMON_SIZES = COMMON_SIZES;
|
|
1201
|
+
exports.COMMON_TAX_RATES = COMMON_TAX_RATES;
|
|
1087
1202
|
exports.COMMON_VIEWPORTS = COMMON_VIEWPORTS;
|
|
1088
1203
|
exports.autoFormat = autoFormat;
|
|
1089
1204
|
exports.bumpVersion = bumpVersion;
|
|
1090
1205
|
exports.calcAspectRatio = calcAspectRatio;
|
|
1091
1206
|
exports.calcSubnet = calcSubnet;
|
|
1207
|
+
exports.calculateCompoundInterest = calculateCompoundInterest;
|
|
1092
1208
|
exports.calculateLoan = calculateLoan;
|
|
1209
|
+
exports.calculateTax = calculateTax;
|
|
1093
1210
|
exports.compareSemver = compareSemver;
|
|
1094
1211
|
exports.convert = convert;
|
|
1095
1212
|
exports.convertBytes = convertBytes;
|
|
@@ -1137,4 +1254,5 @@ exports.symbolicToPermissions = symbolicToPermissions;
|
|
|
1137
1254
|
exports.validateBarcode = validateBarcode;
|
|
1138
1255
|
exports.validateCardNumber = validateCardNumber;
|
|
1139
1256
|
exports.validateIban = validateIban;
|
|
1257
|
+
exports.validateIsbn = validateIsbn;
|
|
1140
1258
|
exports.viewportToPx = viewportToPx;
|
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
|
|
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_VIEWPORTS, o as CardValidationResult, p as CompoundInterestResult, q as CompoundYearRow, D as Dimensions, F as FilePermissions, r as FormatOptions, I as IbanValidationResult, s as IpConversion, t as IsbnFormat, v as IsbnResult, L as LoanResult, N as NotationStyle, w as NumberBase, P as Permission, x as PxConvertResult, S as SemverVersion, y as SubnetInfo, T as TaxDirection, z as TaxResult, V as ViewportConvertResult, E as autoFormat, G as bumpVersion, H as calcAspectRatio, J as calcSubnet, K as calculateCompoundInterest, M as calculateLoan, O as calculateTax, Q as compareSemver, R as convert, U as convertBytes, W as convertIp, X as coverBox, Y as decimalToIp, Z as decimalToIpCidr, _ as describePermissions, $ as fitIntoBox, a0 as formatNumber, a1 as formatValue, a2 as formatVwValue, a3 as formatWithSeparator, a4 as gcd, a5 as ipFromBinary, a6 as ipFromDecimal, a7 as ipFromHex, a8 as ipToBinary, a9 as ipToDecimal, aa as ipToDecimalCidr, ab as ipToHex, ac as ipToOctal, ad as isValid, ae as isValidCidr, af as isValidIp, ag as isValidIpv4, ah as octalToPermissions, ai as parseFileSize, aj as parseInput, ak as parseNumberString, al as parseSemver, am as permissionsToChmod, an as permissionsToOctal, ao as permissionsToSymbolic, ap as ptToPx, aq as pxToAll, ar as pxToViewport, as as remToPx, at as satisfiesRange, au as scaleByHeight, av as scaleByWidth, aw as sortVersions, ax as splitSubnet, ay as symbolicToPermissions, az as validateBarcode, aA as validateCardNumber, aB as validateIban, aC as validateIsbn, aD as viewportToPx } from '../units-C4N1Dq7_.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
|
|
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_VIEWPORTS, o as CardValidationResult, p as CompoundInterestResult, q as CompoundYearRow, D as Dimensions, F as FilePermissions, r as FormatOptions, I as IbanValidationResult, s as IpConversion, t as IsbnFormat, v as IsbnResult, L as LoanResult, N as NotationStyle, w as NumberBase, P as Permission, x as PxConvertResult, S as SemverVersion, y as SubnetInfo, T as TaxDirection, z as TaxResult, V as ViewportConvertResult, E as autoFormat, G as bumpVersion, H as calcAspectRatio, J as calcSubnet, K as calculateCompoundInterest, M as calculateLoan, O as calculateTax, Q as compareSemver, R as convert, U as convertBytes, W as convertIp, X as coverBox, Y as decimalToIp, Z as decimalToIpCidr, _ as describePermissions, $ as fitIntoBox, a0 as formatNumber, a1 as formatValue, a2 as formatVwValue, a3 as formatWithSeparator, a4 as gcd, a5 as ipFromBinary, a6 as ipFromDecimal, a7 as ipFromHex, a8 as ipToBinary, a9 as ipToDecimal, aa as ipToDecimalCidr, ab as ipToHex, ac as ipToOctal, ad as isValid, ae as isValidCidr, af as isValidIp, ag as isValidIpv4, ah as octalToPermissions, ai as parseFileSize, aj as parseInput, ak as parseNumberString, al as parseSemver, am as permissionsToChmod, an as permissionsToOctal, ao as permissionsToSymbolic, ap as ptToPx, aq as pxToAll, ar as pxToViewport, as as remToPx, at as satisfiesRange, au as scaleByHeight, av as scaleByWidth, aw as sortVersions, ax as splitSubnet, ay as symbolicToPermissions, az as validateBarcode, aA as validateCardNumber, aB as validateIban, aC as validateIsbn, aD as viewportToPx } from '../units-C4N1Dq7_.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_VIEWPORTS, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateLoan, 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, 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_VIEWPORTS, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateCompoundInterest, calculateLoan, calculateTax, 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-2TQTKZCN.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
* - credit-card-validator : validateCardNumber
|
|
16
16
|
* - iban-validator : validateIban
|
|
17
17
|
* - loan-calculator : calculateLoan
|
|
18
|
+
* - barcode-validator : validateBarcode
|
|
19
|
+
* - vat-calculator : calculateTax
|
|
20
|
+
* - compound-interest-calculator : calculateCompoundInterest
|
|
21
|
+
* - isbn-validator : validateIsbn
|
|
18
22
|
*/
|
|
19
23
|
interface PxConvertResult {
|
|
20
24
|
px: number;
|
|
@@ -295,6 +299,73 @@ interface BarcodeValidationResult {
|
|
|
295
299
|
declare function validateBarcode(input: string): BarcodeValidationResult | {
|
|
296
300
|
error: string;
|
|
297
301
|
};
|
|
302
|
+
type TaxDirection = "add" | "remove";
|
|
303
|
+
interface TaxResult {
|
|
304
|
+
netAmount: number;
|
|
305
|
+
taxAmount: number;
|
|
306
|
+
grossAmount: number;
|
|
307
|
+
ratePercent: number;
|
|
308
|
+
direction: TaxDirection;
|
|
309
|
+
}
|
|
310
|
+
/** Reference table of well-known published VAT/GST/sales-tax rates. Not a live feed. */
|
|
311
|
+
declare const COMMON_TAX_RATES: Array<{
|
|
312
|
+
country: string;
|
|
313
|
+
label: string;
|
|
314
|
+
ratePercent: number;
|
|
315
|
+
}>;
|
|
316
|
+
/**
|
|
317
|
+
* Add or remove tax from a price given a rate, in either direction: "add"
|
|
318
|
+
* treats the input as the net (pre-tax) amount and computes the gross,
|
|
319
|
+
* "remove" treats the input as the gross (tax-inclusive) amount and backs
|
|
320
|
+
* out the net. Pure formula over user-supplied numbers, no live rate feed.
|
|
321
|
+
*/
|
|
322
|
+
declare function calculateTax(amount: number, ratePercent: number, direction: TaxDirection): TaxResult | {
|
|
323
|
+
error: string;
|
|
324
|
+
};
|
|
325
|
+
interface CompoundYearRow {
|
|
326
|
+
year: number;
|
|
327
|
+
balance: number;
|
|
328
|
+
contributions: number;
|
|
329
|
+
interest: number;
|
|
330
|
+
}
|
|
331
|
+
interface CompoundInterestResult {
|
|
332
|
+
futureValue: number;
|
|
333
|
+
totalPrincipal: number;
|
|
334
|
+
totalContributions: number;
|
|
335
|
+
totalInterest: number;
|
|
336
|
+
years: number;
|
|
337
|
+
compoundsPerYear: number;
|
|
338
|
+
schedule: CompoundYearRow[];
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Compute the future value of a principal (plus an optional recurring
|
|
342
|
+
* contribution made at the end of each compounding period) under compound
|
|
343
|
+
* interest, given an annual interest rate (as a percent, e.g. 5), a term in
|
|
344
|
+
* years, and a compounding frequency (periods per year, e.g. 1 = annually,
|
|
345
|
+
* 12 = monthly, 365 = daily).
|
|
346
|
+
*/
|
|
347
|
+
declare function calculateCompoundInterest(principal: number, annualRatePercent: number, years: number, compoundsPerYear: number, contributionPerPeriod?: number): CompoundInterestResult | {
|
|
348
|
+
error: string;
|
|
349
|
+
};
|
|
350
|
+
type IsbnFormat = "ISBN-10" | "ISBN-13";
|
|
351
|
+
interface IsbnResult {
|
|
352
|
+
valid: boolean;
|
|
353
|
+
format: IsbnFormat;
|
|
354
|
+
digits: string;
|
|
355
|
+
checkDigit: string;
|
|
356
|
+
expectedCheckDigit: string;
|
|
357
|
+
converted: string | null;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Validate an ISBN-10 or ISBN-13 number via its checksum, inferred from the
|
|
361
|
+
* character count (10 or 13) once spaces and hyphens are stripped, and
|
|
362
|
+
* convert it to the other format where possible: ISBN-10 always converts to
|
|
363
|
+
* ISBN-13 by prefixing "978" and recomputing the check digit, but an
|
|
364
|
+
* ISBN-13 only converts back to ISBN-10 if it starts with the "978" prefix.
|
|
365
|
+
*/
|
|
366
|
+
declare function validateIsbn(input: string): IsbnResult | {
|
|
367
|
+
error: string;
|
|
368
|
+
};
|
|
298
369
|
|
|
299
370
|
type units_AmortizationRow = AmortizationRow;
|
|
300
371
|
type units_AspectRatioResult = AspectRatioResult;
|
|
@@ -311,13 +382,18 @@ declare const units_COMMON_LOCALES: typeof COMMON_LOCALES;
|
|
|
311
382
|
declare const units_COMMON_PERMISSIONS: typeof COMMON_PERMISSIONS;
|
|
312
383
|
declare const units_COMMON_RATIOS: typeof COMMON_RATIOS;
|
|
313
384
|
declare const units_COMMON_SIZES: typeof COMMON_SIZES;
|
|
385
|
+
declare const units_COMMON_TAX_RATES: typeof COMMON_TAX_RATES;
|
|
314
386
|
declare const units_COMMON_VIEWPORTS: typeof COMMON_VIEWPORTS;
|
|
315
387
|
type units_CardValidationResult = CardValidationResult;
|
|
388
|
+
type units_CompoundInterestResult = CompoundInterestResult;
|
|
389
|
+
type units_CompoundYearRow = CompoundYearRow;
|
|
316
390
|
type units_Dimensions = Dimensions;
|
|
317
391
|
type units_FilePermissions = FilePermissions;
|
|
318
392
|
type units_FormatOptions = FormatOptions;
|
|
319
393
|
type units_IbanValidationResult = IbanValidationResult;
|
|
320
394
|
type units_IpConversion = IpConversion;
|
|
395
|
+
type units_IsbnFormat = IsbnFormat;
|
|
396
|
+
type units_IsbnResult = IsbnResult;
|
|
321
397
|
type units_LoanResult = LoanResult;
|
|
322
398
|
type units_NotationStyle = NotationStyle;
|
|
323
399
|
type units_NumberBase = NumberBase;
|
|
@@ -325,12 +401,16 @@ type units_Permission = Permission;
|
|
|
325
401
|
type units_PxConvertResult = PxConvertResult;
|
|
326
402
|
type units_SemverVersion = SemverVersion;
|
|
327
403
|
type units_SubnetInfo = SubnetInfo;
|
|
404
|
+
type units_TaxDirection = TaxDirection;
|
|
405
|
+
type units_TaxResult = TaxResult;
|
|
328
406
|
type units_ViewportConvertResult = ViewportConvertResult;
|
|
329
407
|
declare const units_autoFormat: typeof autoFormat;
|
|
330
408
|
declare const units_bumpVersion: typeof bumpVersion;
|
|
331
409
|
declare const units_calcAspectRatio: typeof calcAspectRatio;
|
|
332
410
|
declare const units_calcSubnet: typeof calcSubnet;
|
|
411
|
+
declare const units_calculateCompoundInterest: typeof calculateCompoundInterest;
|
|
333
412
|
declare const units_calculateLoan: typeof calculateLoan;
|
|
413
|
+
declare const units_calculateTax: typeof calculateTax;
|
|
334
414
|
declare const units_compareSemver: typeof compareSemver;
|
|
335
415
|
declare const units_convert: typeof convert;
|
|
336
416
|
declare const units_convertBytes: typeof convertBytes;
|
|
@@ -378,9 +458,10 @@ declare const units_symbolicToPermissions: typeof symbolicToPermissions;
|
|
|
378
458
|
declare const units_validateBarcode: typeof validateBarcode;
|
|
379
459
|
declare const units_validateCardNumber: typeof validateCardNumber;
|
|
380
460
|
declare const units_validateIban: typeof validateIban;
|
|
461
|
+
declare const units_validateIsbn: typeof validateIsbn;
|
|
381
462
|
declare const units_viewportToPx: typeof viewportToPx;
|
|
382
463
|
declare namespace units {
|
|
383
|
-
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_VIEWPORTS as COMMON_VIEWPORTS, type units_CardValidationResult as CardValidationResult, 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_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_ViewportConvertResult as ViewportConvertResult, units_autoFormat as autoFormat, units_bumpVersion as bumpVersion, units_calcAspectRatio as calcAspectRatio, units_calcSubnet as calcSubnet, units_calculateLoan as calculateLoan, 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_viewportToPx as viewportToPx };
|
|
464
|
+
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_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_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_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 };
|
|
384
465
|
}
|
|
385
466
|
|
|
386
|
-
export {
|
|
467
|
+
export { fitIntoBox as $, type AmortizationRow as A, BASE_LABELS as B, COMMON_CURRENCIES as C, type Dimensions as D, autoFormat as E, type FilePermissions as F, bumpVersion as G, calcAspectRatio as H, type IbanValidationResult as I, calcSubnet as J, calculateCompoundInterest as K, type LoanResult as L, calculateLoan as M, type NotationStyle as N, calculateTax as O, type Permission as P, compareSemver as Q, convert as R, type SemverVersion as S, type TaxDirection as T, convertBytes as U, type ViewportConvertResult as V, convertIp as W, coverBox as X, decimalToIp as Y, decimalToIpCidr as Z, describePermissions as _, type AspectRatioResult as a, formatNumber as a0, formatValue as a1, formatVwValue as a2, formatWithSeparator as a3, gcd as a4, ipFromBinary as a5, ipFromDecimal as a6, ipFromHex as a7, ipToBinary as a8, ipToDecimal as a9, validateCardNumber as aA, validateIban as aB, validateIsbn as aC, viewportToPx as aD, ipToDecimalCidr as aa, ipToHex as ab, ipToOctal as ac, isValid as ad, isValidCidr as ae, isValidIp as af, isValidIpv4 as ag, octalToPermissions as ah, parseFileSize as ai, parseInput as aj, parseNumberString as ak, parseSemver as al, permissionsToChmod as am, permissionsToOctal as an, permissionsToSymbolic as ao, ptToPx as ap, pxToAll as aq, pxToViewport as ar, remToPx as as, satisfiesRange as at, scaleByHeight as au, scaleByWidth as av, sortVersions as aw, splitSubnet as ax, symbolicToPermissions as ay, validateBarcode 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_VIEWPORTS as n, type CardValidationResult as o, type CompoundInterestResult as p, type CompoundYearRow as q, type FormatOptions as r, type IpConversion as s, type IsbnFormat as t, units as u, type IsbnResult as v, type NumberBase as w, type PxConvertResult as x, type SubnetInfo as y, type TaxResult as z };
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
* - credit-card-validator : validateCardNumber
|
|
16
16
|
* - iban-validator : validateIban
|
|
17
17
|
* - loan-calculator : calculateLoan
|
|
18
|
+
* - barcode-validator : validateBarcode
|
|
19
|
+
* - vat-calculator : calculateTax
|
|
20
|
+
* - compound-interest-calculator : calculateCompoundInterest
|
|
21
|
+
* - isbn-validator : validateIsbn
|
|
18
22
|
*/
|
|
19
23
|
interface PxConvertResult {
|
|
20
24
|
px: number;
|
|
@@ -295,6 +299,73 @@ interface BarcodeValidationResult {
|
|
|
295
299
|
declare function validateBarcode(input: string): BarcodeValidationResult | {
|
|
296
300
|
error: string;
|
|
297
301
|
};
|
|
302
|
+
type TaxDirection = "add" | "remove";
|
|
303
|
+
interface TaxResult {
|
|
304
|
+
netAmount: number;
|
|
305
|
+
taxAmount: number;
|
|
306
|
+
grossAmount: number;
|
|
307
|
+
ratePercent: number;
|
|
308
|
+
direction: TaxDirection;
|
|
309
|
+
}
|
|
310
|
+
/** Reference table of well-known published VAT/GST/sales-tax rates. Not a live feed. */
|
|
311
|
+
declare const COMMON_TAX_RATES: Array<{
|
|
312
|
+
country: string;
|
|
313
|
+
label: string;
|
|
314
|
+
ratePercent: number;
|
|
315
|
+
}>;
|
|
316
|
+
/**
|
|
317
|
+
* Add or remove tax from a price given a rate, in either direction: "add"
|
|
318
|
+
* treats the input as the net (pre-tax) amount and computes the gross,
|
|
319
|
+
* "remove" treats the input as the gross (tax-inclusive) amount and backs
|
|
320
|
+
* out the net. Pure formula over user-supplied numbers, no live rate feed.
|
|
321
|
+
*/
|
|
322
|
+
declare function calculateTax(amount: number, ratePercent: number, direction: TaxDirection): TaxResult | {
|
|
323
|
+
error: string;
|
|
324
|
+
};
|
|
325
|
+
interface CompoundYearRow {
|
|
326
|
+
year: number;
|
|
327
|
+
balance: number;
|
|
328
|
+
contributions: number;
|
|
329
|
+
interest: number;
|
|
330
|
+
}
|
|
331
|
+
interface CompoundInterestResult {
|
|
332
|
+
futureValue: number;
|
|
333
|
+
totalPrincipal: number;
|
|
334
|
+
totalContributions: number;
|
|
335
|
+
totalInterest: number;
|
|
336
|
+
years: number;
|
|
337
|
+
compoundsPerYear: number;
|
|
338
|
+
schedule: CompoundYearRow[];
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Compute the future value of a principal (plus an optional recurring
|
|
342
|
+
* contribution made at the end of each compounding period) under compound
|
|
343
|
+
* interest, given an annual interest rate (as a percent, e.g. 5), a term in
|
|
344
|
+
* years, and a compounding frequency (periods per year, e.g. 1 = annually,
|
|
345
|
+
* 12 = monthly, 365 = daily).
|
|
346
|
+
*/
|
|
347
|
+
declare function calculateCompoundInterest(principal: number, annualRatePercent: number, years: number, compoundsPerYear: number, contributionPerPeriod?: number): CompoundInterestResult | {
|
|
348
|
+
error: string;
|
|
349
|
+
};
|
|
350
|
+
type IsbnFormat = "ISBN-10" | "ISBN-13";
|
|
351
|
+
interface IsbnResult {
|
|
352
|
+
valid: boolean;
|
|
353
|
+
format: IsbnFormat;
|
|
354
|
+
digits: string;
|
|
355
|
+
checkDigit: string;
|
|
356
|
+
expectedCheckDigit: string;
|
|
357
|
+
converted: string | null;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Validate an ISBN-10 or ISBN-13 number via its checksum, inferred from the
|
|
361
|
+
* character count (10 or 13) once spaces and hyphens are stripped, and
|
|
362
|
+
* convert it to the other format where possible: ISBN-10 always converts to
|
|
363
|
+
* ISBN-13 by prefixing "978" and recomputing the check digit, but an
|
|
364
|
+
* ISBN-13 only converts back to ISBN-10 if it starts with the "978" prefix.
|
|
365
|
+
*/
|
|
366
|
+
declare function validateIsbn(input: string): IsbnResult | {
|
|
367
|
+
error: string;
|
|
368
|
+
};
|
|
298
369
|
|
|
299
370
|
type units_AmortizationRow = AmortizationRow;
|
|
300
371
|
type units_AspectRatioResult = AspectRatioResult;
|
|
@@ -311,13 +382,18 @@ declare const units_COMMON_LOCALES: typeof COMMON_LOCALES;
|
|
|
311
382
|
declare const units_COMMON_PERMISSIONS: typeof COMMON_PERMISSIONS;
|
|
312
383
|
declare const units_COMMON_RATIOS: typeof COMMON_RATIOS;
|
|
313
384
|
declare const units_COMMON_SIZES: typeof COMMON_SIZES;
|
|
385
|
+
declare const units_COMMON_TAX_RATES: typeof COMMON_TAX_RATES;
|
|
314
386
|
declare const units_COMMON_VIEWPORTS: typeof COMMON_VIEWPORTS;
|
|
315
387
|
type units_CardValidationResult = CardValidationResult;
|
|
388
|
+
type units_CompoundInterestResult = CompoundInterestResult;
|
|
389
|
+
type units_CompoundYearRow = CompoundYearRow;
|
|
316
390
|
type units_Dimensions = Dimensions;
|
|
317
391
|
type units_FilePermissions = FilePermissions;
|
|
318
392
|
type units_FormatOptions = FormatOptions;
|
|
319
393
|
type units_IbanValidationResult = IbanValidationResult;
|
|
320
394
|
type units_IpConversion = IpConversion;
|
|
395
|
+
type units_IsbnFormat = IsbnFormat;
|
|
396
|
+
type units_IsbnResult = IsbnResult;
|
|
321
397
|
type units_LoanResult = LoanResult;
|
|
322
398
|
type units_NotationStyle = NotationStyle;
|
|
323
399
|
type units_NumberBase = NumberBase;
|
|
@@ -325,12 +401,16 @@ type units_Permission = Permission;
|
|
|
325
401
|
type units_PxConvertResult = PxConvertResult;
|
|
326
402
|
type units_SemverVersion = SemverVersion;
|
|
327
403
|
type units_SubnetInfo = SubnetInfo;
|
|
404
|
+
type units_TaxDirection = TaxDirection;
|
|
405
|
+
type units_TaxResult = TaxResult;
|
|
328
406
|
type units_ViewportConvertResult = ViewportConvertResult;
|
|
329
407
|
declare const units_autoFormat: typeof autoFormat;
|
|
330
408
|
declare const units_bumpVersion: typeof bumpVersion;
|
|
331
409
|
declare const units_calcAspectRatio: typeof calcAspectRatio;
|
|
332
410
|
declare const units_calcSubnet: typeof calcSubnet;
|
|
411
|
+
declare const units_calculateCompoundInterest: typeof calculateCompoundInterest;
|
|
333
412
|
declare const units_calculateLoan: typeof calculateLoan;
|
|
413
|
+
declare const units_calculateTax: typeof calculateTax;
|
|
334
414
|
declare const units_compareSemver: typeof compareSemver;
|
|
335
415
|
declare const units_convert: typeof convert;
|
|
336
416
|
declare const units_convertBytes: typeof convertBytes;
|
|
@@ -378,9 +458,10 @@ declare const units_symbolicToPermissions: typeof symbolicToPermissions;
|
|
|
378
458
|
declare const units_validateBarcode: typeof validateBarcode;
|
|
379
459
|
declare const units_validateCardNumber: typeof validateCardNumber;
|
|
380
460
|
declare const units_validateIban: typeof validateIban;
|
|
461
|
+
declare const units_validateIsbn: typeof validateIsbn;
|
|
381
462
|
declare const units_viewportToPx: typeof viewportToPx;
|
|
382
463
|
declare namespace units {
|
|
383
|
-
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_VIEWPORTS as COMMON_VIEWPORTS, type units_CardValidationResult as CardValidationResult, 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_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_ViewportConvertResult as ViewportConvertResult, units_autoFormat as autoFormat, units_bumpVersion as bumpVersion, units_calcAspectRatio as calcAspectRatio, units_calcSubnet as calcSubnet, units_calculateLoan as calculateLoan, 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_viewportToPx as viewportToPx };
|
|
464
|
+
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_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_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_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 };
|
|
384
465
|
}
|
|
385
466
|
|
|
386
|
-
export {
|
|
467
|
+
export { fitIntoBox as $, type AmortizationRow as A, BASE_LABELS as B, COMMON_CURRENCIES as C, type Dimensions as D, autoFormat as E, type FilePermissions as F, bumpVersion as G, calcAspectRatio as H, type IbanValidationResult as I, calcSubnet as J, calculateCompoundInterest as K, type LoanResult as L, calculateLoan as M, type NotationStyle as N, calculateTax as O, type Permission as P, compareSemver as Q, convert as R, type SemverVersion as S, type TaxDirection as T, convertBytes as U, type ViewportConvertResult as V, convertIp as W, coverBox as X, decimalToIp as Y, decimalToIpCidr as Z, describePermissions as _, type AspectRatioResult as a, formatNumber as a0, formatValue as a1, formatVwValue as a2, formatWithSeparator as a3, gcd as a4, ipFromBinary as a5, ipFromDecimal as a6, ipFromHex as a7, ipToBinary as a8, ipToDecimal as a9, validateCardNumber as aA, validateIban as aB, validateIsbn as aC, viewportToPx as aD, ipToDecimalCidr as aa, ipToHex as ab, ipToOctal as ac, isValid as ad, isValidCidr as ae, isValidIp as af, isValidIpv4 as ag, octalToPermissions as ah, parseFileSize as ai, parseInput as aj, parseNumberString as ak, parseSemver as al, permissionsToChmod as am, permissionsToOctal as an, permissionsToSymbolic as ao, ptToPx as ap, pxToAll as aq, pxToViewport as ar, remToPx as as, satisfiesRange as at, scaleByHeight as au, scaleByWidth as av, sortVersions as aw, splitSubnet as ax, symbolicToPermissions as ay, validateBarcode 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_VIEWPORTS as n, type CardValidationResult as o, type CompoundInterestResult as p, type CompoundYearRow as q, type FormatOptions as r, type IpConversion as s, type IsbnFormat as t, units as u, type IsbnResult as v, type NumberBase as w, type PxConvertResult as x, type SubnetInfo as y, type TaxResult as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utilix-tech/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.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",
|