@utilix-tech/sdk 0.21.0 → 0.22.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 +4 -0
- package/README.md +11 -2
- package/dist/{chunk-ZPQZEIXP.js → chunk-IEPWZERQ.js} +95 -2
- package/dist/{chunk-TFNCFD3E.js → chunk-TLRSQHMP.js} +34 -1
- package/dist/index.cjs +127 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{time-DbT8fjaF.d.cts → time-KqJjdqII.d.cts} +48 -2
- package/dist/{time-DbT8fjaF.d.ts → time-KqJjdqII.d.ts} +48 -2
- package/dist/tools/time.cjs +93 -0
- package/dist/tools/time.d.cts +1 -1
- package/dist/tools/time.d.ts +1 -1
- package/dist/tools/time.js +1 -1
- package/dist/tools/units.cjs +33 -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-pIRkHnsU.d.cts → units-KrjRyu0w.d.cts} +31 -2
- package/dist/{units-pIRkHnsU.d.ts → units-KrjRyu0w.d.ts} +31 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
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.22.0
|
|
6
|
+
- Add `convertAprApy` (apr-apy-converter): convert between a nominal APR and effective APY for a given compounding frequency, in both directions.
|
|
7
|
+
- Add `parseIso8601Duration` / `formatIso8601Duration` (iso8601-duration): parse an ISO 8601 duration into components and total seconds, or format seconds into a canonical duration string.
|
|
8
|
+
|
|
5
9
|
## 0.21.0
|
|
6
10
|
- Add `calculatePercentageChange` (percentage-change-calculator): percentage change between two numbers, with absolute change, direction, and multiplier.
|
|
7
11
|
- Add `resolveJsonPointer` (json-pointer-resolver): resolve an RFC 6901 JSON Pointer against a document, with ~0/~1 escaping and clear not-found reasons.
|
package/README.md
CHANGED
|
@@ -234,7 +234,8 @@ generateData([
|
|
|
234
234
|
|
|
235
235
|
```ts
|
|
236
236
|
import { diffDates, parseCron, convertTime, formatRelative,
|
|
237
|
-
getNextRuns, humanizeDiff
|
|
237
|
+
getNextRuns, humanizeDiff, parseIso8601Duration,
|
|
238
|
+
formatIso8601Duration } from "@utilix-tech/sdk/time";
|
|
238
239
|
|
|
239
240
|
formatRelative(new Date("2024-01-01")); // "2 years ago"
|
|
240
241
|
|
|
@@ -249,6 +250,10 @@ parseCron("0 9 * * MON-FRI");
|
|
|
249
250
|
// { description: "At 09:00, Monday through Friday", ... }
|
|
250
251
|
|
|
251
252
|
getNextRuns("*/5 * * * *", 5); // next 5 run timestamps
|
|
253
|
+
|
|
254
|
+
// ISO 8601 durations, both directions
|
|
255
|
+
parseIso8601Duration("P3DT4H30M"); // { totalSeconds: 275400, days: 3, ... }
|
|
256
|
+
formatIso8601Duration(90061); // { iso: "P1DT1H1M1S", ... }
|
|
252
257
|
```
|
|
253
258
|
|
|
254
259
|
---
|
|
@@ -256,7 +261,7 @@ getNextRuns("*/5 * * * *", 5); // next 5 run timestamps
|
|
|
256
261
|
### `/units`: Conversions
|
|
257
262
|
|
|
258
263
|
```ts
|
|
259
|
-
import { convertBytes, pxToAll, convert, formatValue, validateCardNumber, validateIban, calculateLoan, validateBarcode, calculateTax, calculateCompoundInterest, validateIsbn, calculateTipSplit, calculateSimpleInterest, calculateTimeValue, calculatePercentageChange } from "@utilix-tech/sdk/units";
|
|
264
|
+
import { convertBytes, pxToAll, convert, formatValue, validateCardNumber, validateIban, calculateLoan, validateBarcode, calculateTax, calculateCompoundInterest, validateIsbn, calculateTipSplit, calculateSimpleInterest, calculateTimeValue, calculatePercentageChange, convertAprApy } from "@utilix-tech/sdk/units";
|
|
260
265
|
|
|
261
266
|
// File sizes
|
|
262
267
|
convertBytes(1073741824, "GB"); // 1
|
|
@@ -318,6 +323,10 @@ calculateTimeValue(1000, 5, 10, "future");
|
|
|
318
323
|
// Percentage change between two numbers
|
|
319
324
|
calculatePercentageChange(200, 250);
|
|
320
325
|
// { percentChange: 25, absoluteChange: 50, direction: "increase", multiplier: 1.25 }
|
|
326
|
+
|
|
327
|
+
// APR <-> APY conversion for a given compounding frequency
|
|
328
|
+
convertAprApy(12, 12, "apr-to-apy");
|
|
329
|
+
// { apr: 12, apy: 12.682503, difference: 0.682503, compoundsPerYear: 12, ... }
|
|
321
330
|
```
|
|
322
331
|
|
|
323
332
|
---
|
|
@@ -9,6 +9,7 @@ __export(time_exports, {
|
|
|
9
9
|
convertTime: () => convertTime,
|
|
10
10
|
diffDates: () => diffDates,
|
|
11
11
|
formatInTimezone: () => formatInTimezone,
|
|
12
|
+
formatIso8601Duration: () => formatIso8601Duration,
|
|
12
13
|
formatRelative: () => formatRelative,
|
|
13
14
|
formatRunDate: () => formatRunDate,
|
|
14
15
|
fromIsoString: () => fromIsoString,
|
|
@@ -21,7 +22,8 @@ __export(time_exports, {
|
|
|
21
22
|
humanizeDiff: () => humanizeDiff,
|
|
22
23
|
parseCron: () => parseCron,
|
|
23
24
|
parseCronExpression: () => parseCronExpression,
|
|
24
|
-
parseDate: () => parseDate
|
|
25
|
+
parseDate: () => parseDate,
|
|
26
|
+
parseIso8601Duration: () => parseIso8601Duration
|
|
25
27
|
});
|
|
26
28
|
function formatRelative(diffMs) {
|
|
27
29
|
const absMs = Math.abs(diffMs);
|
|
@@ -681,5 +683,96 @@ function getRunInterval(dates) {
|
|
|
681
683
|
const days = Math.round(diffMins / 1440);
|
|
682
684
|
return `Every ${days} days`;
|
|
683
685
|
}
|
|
686
|
+
var DURATION_SECONDS_PER_YEAR = 365 * 86400;
|
|
687
|
+
var DURATION_SECONDS_PER_MONTH = 30 * 86400;
|
|
688
|
+
function humanizeDurationParts(parts) {
|
|
689
|
+
const pieces = [];
|
|
690
|
+
for (const [value, label] of parts) {
|
|
691
|
+
if (value === 0) continue;
|
|
692
|
+
pieces.push(`${value} ${label}${value === 1 ? "" : "s"}`);
|
|
693
|
+
}
|
|
694
|
+
return pieces.length > 0 ? pieces.join(", ") : "0 seconds";
|
|
695
|
+
}
|
|
696
|
+
function parseIso8601Duration(input) {
|
|
697
|
+
if (typeof input !== "string") return { error: "Duration must be a string" };
|
|
698
|
+
const trimmed = input.trim();
|
|
699
|
+
if (trimmed.length === 0) return { error: "Duration is empty" };
|
|
700
|
+
const match = trimmed.match(
|
|
701
|
+
/^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/
|
|
702
|
+
);
|
|
703
|
+
if (!match) {
|
|
704
|
+
return { error: 'Not a valid ISO 8601 duration (expected a form like "P3DT4H30M")' };
|
|
705
|
+
}
|
|
706
|
+
const years = match[1] ? parseInt(match[1], 10) : 0;
|
|
707
|
+
const months = match[2] ? parseInt(match[2], 10) : 0;
|
|
708
|
+
const weeks = match[3] ? parseInt(match[3], 10) : 0;
|
|
709
|
+
const days = match[4] ? parseInt(match[4], 10) : 0;
|
|
710
|
+
const hours = match[5] ? parseInt(match[5], 10) : 0;
|
|
711
|
+
const minutes = match[6] ? parseInt(match[6], 10) : 0;
|
|
712
|
+
const seconds = match[7] ? parseFloat(match[7]) : 0;
|
|
713
|
+
if (years + months + weeks + days + hours + minutes + seconds === 0) {
|
|
714
|
+
return { error: 'Duration has no components (a bare "P" or "PT" is not valid)' };
|
|
715
|
+
}
|
|
716
|
+
const approximate = years > 0 || months > 0;
|
|
717
|
+
const totalSeconds = years * DURATION_SECONDS_PER_YEAR + months * DURATION_SECONDS_PER_MONTH + weeks * 7 * 86400 + days * 86400 + hours * 3600 + minutes * 60 + seconds;
|
|
718
|
+
const human = humanizeDurationParts([
|
|
719
|
+
[years, "year"],
|
|
720
|
+
[months, "month"],
|
|
721
|
+
[weeks, "week"],
|
|
722
|
+
[days, "day"],
|
|
723
|
+
[hours, "hour"],
|
|
724
|
+
[minutes, "minute"],
|
|
725
|
+
[seconds, "second"]
|
|
726
|
+
]);
|
|
727
|
+
return {
|
|
728
|
+
input: trimmed,
|
|
729
|
+
years,
|
|
730
|
+
months,
|
|
731
|
+
weeks,
|
|
732
|
+
days,
|
|
733
|
+
hours,
|
|
734
|
+
minutes,
|
|
735
|
+
seconds,
|
|
736
|
+
totalSeconds: Math.round(totalSeconds * 1e6) / 1e6,
|
|
737
|
+
approximate,
|
|
738
|
+
human
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
function formatIso8601Duration(seconds) {
|
|
742
|
+
if (typeof seconds !== "number" || !Number.isFinite(seconds) || seconds < 0) {
|
|
743
|
+
return { error: "Seconds must be zero or a positive number" };
|
|
744
|
+
}
|
|
745
|
+
const totalDays = Math.floor(seconds / 86400);
|
|
746
|
+
let rem = seconds - totalDays * 86400;
|
|
747
|
+
const hours = Math.floor(rem / 3600);
|
|
748
|
+
rem -= hours * 3600;
|
|
749
|
+
const minutes = Math.floor(rem / 60);
|
|
750
|
+
let secs = rem - minutes * 60;
|
|
751
|
+
secs = Math.round(secs * 1e6) / 1e6;
|
|
752
|
+
let iso = "P";
|
|
753
|
+
if (totalDays > 0) iso += `${totalDays}D`;
|
|
754
|
+
const hasTime = hours > 0 || minutes > 0 || secs > 0;
|
|
755
|
+
if (hasTime) {
|
|
756
|
+
iso += "T";
|
|
757
|
+
if (hours > 0) iso += `${hours}H`;
|
|
758
|
+
if (minutes > 0) iso += `${minutes}M`;
|
|
759
|
+
if (secs > 0) iso += `${secs}S`;
|
|
760
|
+
}
|
|
761
|
+
if (iso === "P") iso = "PT0S";
|
|
762
|
+
const human = humanizeDurationParts([
|
|
763
|
+
[totalDays, "day"],
|
|
764
|
+
[hours, "hour"],
|
|
765
|
+
[minutes, "minute"],
|
|
766
|
+
[secs, "second"]
|
|
767
|
+
]);
|
|
768
|
+
return {
|
|
769
|
+
seconds,
|
|
770
|
+
iso,
|
|
771
|
+
days: totalDays,
|
|
772
|
+
hours,
|
|
773
|
+
minutes,
|
|
774
|
+
human
|
|
775
|
+
};
|
|
776
|
+
}
|
|
684
777
|
|
|
685
|
-
export { COMMON_CRONS, COMMON_DATE_PRESETS, TIMEZONES, convertTime, diffDates, formatInTimezone, formatRelative, formatRunDate, fromIsoString, fromUnix, getAllZonesForTime, getNextRuns, getNow, getRunInterval, getTimezoneOffset, humanizeDiff, parseCron, parseCronExpression, parseDate, time_exports };
|
|
778
|
+
export { COMMON_CRONS, COMMON_DATE_PRESETS, TIMEZONES, convertTime, diffDates, formatInTimezone, formatIso8601Duration, formatRelative, formatRunDate, fromIsoString, fromUnix, getAllZonesForTime, getNextRuns, getNow, getRunInterval, getTimezoneOffset, humanizeDiff, parseCron, parseCronExpression, parseDate, parseIso8601Duration, time_exports };
|
|
@@ -27,6 +27,7 @@ __export(units_exports, {
|
|
|
27
27
|
calculateTipSplit: () => calculateTipSplit,
|
|
28
28
|
compareSemver: () => compareSemver,
|
|
29
29
|
convert: () => convert,
|
|
30
|
+
convertAprApy: () => convertAprApy,
|
|
30
31
|
convertBytes: () => convertBytes,
|
|
31
32
|
convertIp: () => convertIp,
|
|
32
33
|
coverBox: () => coverBox,
|
|
@@ -1361,5 +1362,37 @@ function calculatePercentageChange(oldValue, newValue) {
|
|
|
1361
1362
|
multiplier: round4(multiplier)
|
|
1362
1363
|
};
|
|
1363
1364
|
}
|
|
1365
|
+
function convertAprApy(rate, compoundsPerYear, direction) {
|
|
1366
|
+
if (!Number.isFinite(rate) || rate < 0) return { error: "Rate must be zero or a positive number" };
|
|
1367
|
+
if (!Number.isInteger(compoundsPerYear) || compoundsPerYear <= 0) {
|
|
1368
|
+
return { error: "Compounding frequency must be a positive whole number of periods per year" };
|
|
1369
|
+
}
|
|
1370
|
+
if (direction !== "apr-to-apy" && direction !== "apy-to-apr") {
|
|
1371
|
+
return { error: 'Direction must be "apr-to-apy" or "apy-to-apr"' };
|
|
1372
|
+
}
|
|
1373
|
+
const round6 = (n2) => Math.round(n2 * 1e6) / 1e6;
|
|
1374
|
+
const round8 = (n2) => Math.round(n2 * 1e8) / 1e8;
|
|
1375
|
+
const n = compoundsPerYear;
|
|
1376
|
+
let aprDecimal;
|
|
1377
|
+
let apyDecimal;
|
|
1378
|
+
if (direction === "apr-to-apy") {
|
|
1379
|
+
aprDecimal = rate / 100;
|
|
1380
|
+
apyDecimal = Math.pow(1 + aprDecimal / n, n) - 1;
|
|
1381
|
+
} else {
|
|
1382
|
+
apyDecimal = rate / 100;
|
|
1383
|
+
aprDecimal = n * (Math.pow(1 + apyDecimal, 1 / n) - 1);
|
|
1384
|
+
}
|
|
1385
|
+
const apr = round6(aprDecimal * 100);
|
|
1386
|
+
const apy = round6(apyDecimal * 100);
|
|
1387
|
+
return {
|
|
1388
|
+
direction,
|
|
1389
|
+
compoundsPerYear: n,
|
|
1390
|
+
apr,
|
|
1391
|
+
apy,
|
|
1392
|
+
aprDecimal: round8(aprDecimal),
|
|
1393
|
+
apyDecimal: round8(apyDecimal),
|
|
1394
|
+
difference: round6(apy - apr)
|
|
1395
|
+
};
|
|
1396
|
+
}
|
|
1364
1397
|
|
|
1365
|
-
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, calculatePercentageChange, calculateSimpleInterest, calculateTax, calculateTimeValue, 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 };
|
|
1398
|
+
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, calculatePercentageChange, calculateSimpleInterest, calculateTax, calculateTimeValue, calculateTipSplit, compareSemver, convert, convertAprApy, 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
|
@@ -6144,6 +6144,7 @@ __export(time_exports, {
|
|
|
6144
6144
|
convertTime: () => convertTime,
|
|
6145
6145
|
diffDates: () => diffDates,
|
|
6146
6146
|
formatInTimezone: () => formatInTimezone,
|
|
6147
|
+
formatIso8601Duration: () => formatIso8601Duration,
|
|
6147
6148
|
formatRelative: () => formatRelative,
|
|
6148
6149
|
formatRunDate: () => formatRunDate,
|
|
6149
6150
|
fromIsoString: () => fromIsoString,
|
|
@@ -6156,7 +6157,8 @@ __export(time_exports, {
|
|
|
6156
6157
|
humanizeDiff: () => humanizeDiff,
|
|
6157
6158
|
parseCron: () => parseCron,
|
|
6158
6159
|
parseCronExpression: () => parseCronExpression,
|
|
6159
|
-
parseDate: () => parseDate
|
|
6160
|
+
parseDate: () => parseDate,
|
|
6161
|
+
parseIso8601Duration: () => parseIso8601Duration
|
|
6160
6162
|
});
|
|
6161
6163
|
function formatRelative(diffMs) {
|
|
6162
6164
|
const absMs = Math.abs(diffMs);
|
|
@@ -6816,6 +6818,97 @@ function getRunInterval(dates) {
|
|
|
6816
6818
|
const days = Math.round(diffMins / 1440);
|
|
6817
6819
|
return `Every ${days} days`;
|
|
6818
6820
|
}
|
|
6821
|
+
var DURATION_SECONDS_PER_YEAR = 365 * 86400;
|
|
6822
|
+
var DURATION_SECONDS_PER_MONTH = 30 * 86400;
|
|
6823
|
+
function humanizeDurationParts(parts) {
|
|
6824
|
+
const pieces = [];
|
|
6825
|
+
for (const [value, label] of parts) {
|
|
6826
|
+
if (value === 0) continue;
|
|
6827
|
+
pieces.push(`${value} ${label}${value === 1 ? "" : "s"}`);
|
|
6828
|
+
}
|
|
6829
|
+
return pieces.length > 0 ? pieces.join(", ") : "0 seconds";
|
|
6830
|
+
}
|
|
6831
|
+
function parseIso8601Duration(input) {
|
|
6832
|
+
if (typeof input !== "string") return { error: "Duration must be a string" };
|
|
6833
|
+
const trimmed = input.trim();
|
|
6834
|
+
if (trimmed.length === 0) return { error: "Duration is empty" };
|
|
6835
|
+
const match = trimmed.match(
|
|
6836
|
+
/^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/
|
|
6837
|
+
);
|
|
6838
|
+
if (!match) {
|
|
6839
|
+
return { error: 'Not a valid ISO 8601 duration (expected a form like "P3DT4H30M")' };
|
|
6840
|
+
}
|
|
6841
|
+
const years = match[1] ? parseInt(match[1], 10) : 0;
|
|
6842
|
+
const months = match[2] ? parseInt(match[2], 10) : 0;
|
|
6843
|
+
const weeks = match[3] ? parseInt(match[3], 10) : 0;
|
|
6844
|
+
const days = match[4] ? parseInt(match[4], 10) : 0;
|
|
6845
|
+
const hours = match[5] ? parseInt(match[5], 10) : 0;
|
|
6846
|
+
const minutes = match[6] ? parseInt(match[6], 10) : 0;
|
|
6847
|
+
const seconds = match[7] ? parseFloat(match[7]) : 0;
|
|
6848
|
+
if (years + months + weeks + days + hours + minutes + seconds === 0) {
|
|
6849
|
+
return { error: 'Duration has no components (a bare "P" or "PT" is not valid)' };
|
|
6850
|
+
}
|
|
6851
|
+
const approximate = years > 0 || months > 0;
|
|
6852
|
+
const totalSeconds = years * DURATION_SECONDS_PER_YEAR + months * DURATION_SECONDS_PER_MONTH + weeks * 7 * 86400 + days * 86400 + hours * 3600 + minutes * 60 + seconds;
|
|
6853
|
+
const human = humanizeDurationParts([
|
|
6854
|
+
[years, "year"],
|
|
6855
|
+
[months, "month"],
|
|
6856
|
+
[weeks, "week"],
|
|
6857
|
+
[days, "day"],
|
|
6858
|
+
[hours, "hour"],
|
|
6859
|
+
[minutes, "minute"],
|
|
6860
|
+
[seconds, "second"]
|
|
6861
|
+
]);
|
|
6862
|
+
return {
|
|
6863
|
+
input: trimmed,
|
|
6864
|
+
years,
|
|
6865
|
+
months,
|
|
6866
|
+
weeks,
|
|
6867
|
+
days,
|
|
6868
|
+
hours,
|
|
6869
|
+
minutes,
|
|
6870
|
+
seconds,
|
|
6871
|
+
totalSeconds: Math.round(totalSeconds * 1e6) / 1e6,
|
|
6872
|
+
approximate,
|
|
6873
|
+
human
|
|
6874
|
+
};
|
|
6875
|
+
}
|
|
6876
|
+
function formatIso8601Duration(seconds) {
|
|
6877
|
+
if (typeof seconds !== "number" || !Number.isFinite(seconds) || seconds < 0) {
|
|
6878
|
+
return { error: "Seconds must be zero or a positive number" };
|
|
6879
|
+
}
|
|
6880
|
+
const totalDays = Math.floor(seconds / 86400);
|
|
6881
|
+
let rem = seconds - totalDays * 86400;
|
|
6882
|
+
const hours = Math.floor(rem / 3600);
|
|
6883
|
+
rem -= hours * 3600;
|
|
6884
|
+
const minutes = Math.floor(rem / 60);
|
|
6885
|
+
let secs = rem - minutes * 60;
|
|
6886
|
+
secs = Math.round(secs * 1e6) / 1e6;
|
|
6887
|
+
let iso = "P";
|
|
6888
|
+
if (totalDays > 0) iso += `${totalDays}D`;
|
|
6889
|
+
const hasTime = hours > 0 || minutes > 0 || secs > 0;
|
|
6890
|
+
if (hasTime) {
|
|
6891
|
+
iso += "T";
|
|
6892
|
+
if (hours > 0) iso += `${hours}H`;
|
|
6893
|
+
if (minutes > 0) iso += `${minutes}M`;
|
|
6894
|
+
if (secs > 0) iso += `${secs}S`;
|
|
6895
|
+
}
|
|
6896
|
+
if (iso === "P") iso = "PT0S";
|
|
6897
|
+
const human = humanizeDurationParts([
|
|
6898
|
+
[totalDays, "day"],
|
|
6899
|
+
[hours, "hour"],
|
|
6900
|
+
[minutes, "minute"],
|
|
6901
|
+
[secs, "second"]
|
|
6902
|
+
]);
|
|
6903
|
+
return {
|
|
6904
|
+
seconds,
|
|
6905
|
+
iso,
|
|
6906
|
+
days: totalDays,
|
|
6907
|
+
hours,
|
|
6908
|
+
minutes,
|
|
6909
|
+
human
|
|
6910
|
+
};
|
|
6911
|
+
}
|
|
6819
6912
|
|
|
6820
6913
|
// src/tools/units.ts
|
|
6821
6914
|
var units_exports = {};
|
|
@@ -6844,6 +6937,7 @@ __export(units_exports, {
|
|
|
6844
6937
|
calculateTipSplit: () => calculateTipSplit,
|
|
6845
6938
|
compareSemver: () => compareSemver,
|
|
6846
6939
|
convert: () => convert,
|
|
6940
|
+
convertAprApy: () => convertAprApy,
|
|
6847
6941
|
convertBytes: () => convertBytes,
|
|
6848
6942
|
convertIp: () => convertIp,
|
|
6849
6943
|
coverBox: () => coverBox,
|
|
@@ -8178,6 +8272,38 @@ function calculatePercentageChange(oldValue, newValue) {
|
|
|
8178
8272
|
multiplier: round4(multiplier)
|
|
8179
8273
|
};
|
|
8180
8274
|
}
|
|
8275
|
+
function convertAprApy(rate, compoundsPerYear, direction) {
|
|
8276
|
+
if (!Number.isFinite(rate) || rate < 0) return { error: "Rate must be zero or a positive number" };
|
|
8277
|
+
if (!Number.isInteger(compoundsPerYear) || compoundsPerYear <= 0) {
|
|
8278
|
+
return { error: "Compounding frequency must be a positive whole number of periods per year" };
|
|
8279
|
+
}
|
|
8280
|
+
if (direction !== "apr-to-apy" && direction !== "apy-to-apr") {
|
|
8281
|
+
return { error: 'Direction must be "apr-to-apy" or "apy-to-apr"' };
|
|
8282
|
+
}
|
|
8283
|
+
const round6 = (n2) => Math.round(n2 * 1e6) / 1e6;
|
|
8284
|
+
const round8 = (n2) => Math.round(n2 * 1e8) / 1e8;
|
|
8285
|
+
const n = compoundsPerYear;
|
|
8286
|
+
let aprDecimal;
|
|
8287
|
+
let apyDecimal;
|
|
8288
|
+
if (direction === "apr-to-apy") {
|
|
8289
|
+
aprDecimal = rate / 100;
|
|
8290
|
+
apyDecimal = Math.pow(1 + aprDecimal / n, n) - 1;
|
|
8291
|
+
} else {
|
|
8292
|
+
apyDecimal = rate / 100;
|
|
8293
|
+
aprDecimal = n * (Math.pow(1 + apyDecimal, 1 / n) - 1);
|
|
8294
|
+
}
|
|
8295
|
+
const apr = round6(aprDecimal * 100);
|
|
8296
|
+
const apy = round6(apyDecimal * 100);
|
|
8297
|
+
return {
|
|
8298
|
+
direction,
|
|
8299
|
+
compoundsPerYear: n,
|
|
8300
|
+
apr,
|
|
8301
|
+
apy,
|
|
8302
|
+
aprDecimal: round8(aprDecimal),
|
|
8303
|
+
apyDecimal: round8(apyDecimal),
|
|
8304
|
+
difference: round6(apy - apr)
|
|
8305
|
+
};
|
|
8306
|
+
}
|
|
8181
8307
|
|
|
8182
8308
|
// src/tools/network.ts
|
|
8183
8309
|
var network_exports = {};
|
package/dist/index.d.cts
CHANGED
|
@@ -4,8 +4,8 @@ export { h as hashing } from './hashing-CnetQFD_.cjs';
|
|
|
4
4
|
export { t as text } from './text-DS70aMY5.cjs';
|
|
5
5
|
export { d as data } from './data-D8XTI7Du.cjs';
|
|
6
6
|
export { g as generators } from './generators-BGtRGpJZ.cjs';
|
|
7
|
-
export { t as time } from './time-
|
|
8
|
-
export { u as units } from './units-
|
|
7
|
+
export { t as time } from './time-KqJjdqII.cjs';
|
|
8
|
+
export { u as units } from './units-KrjRyu0w.cjs';
|
|
9
9
|
export { n as network } from './network-BJOjJnmY.cjs';
|
|
10
10
|
export { a as api } from './api-Xl7OzIgq.cjs';
|
|
11
11
|
export { c as code } from './code-DaRvff2v.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export { h as hashing } from './hashing-CnetQFD_.js';
|
|
|
4
4
|
export { t as text } from './text-DS70aMY5.js';
|
|
5
5
|
export { d as data } from './data-D8XTI7Du.js';
|
|
6
6
|
export { g as generators } from './generators-BGtRGpJZ.js';
|
|
7
|
-
export { t as time } from './time-
|
|
8
|
-
export { u as units } from './units-
|
|
7
|
+
export { t as time } from './time-KqJjdqII.js';
|
|
8
|
+
export { u as units } from './units-KrjRyu0w.js';
|
|
9
9
|
export { n as network } from './network-BJOjJnmY.js';
|
|
10
10
|
export { a as api } from './api-Xl7OzIgq.js';
|
|
11
11
|
export { c as code } from './code-DaRvff2v.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-TLRSQHMP.js';
|
|
3
3
|
export { network_exports as network } from './chunk-Y5OOP6WN.js';
|
|
4
4
|
export { api_exports as api } from './chunk-Q3B3YWOA.js';
|
|
5
5
|
export { code_exports as code } from './chunk-LXKIPPDG.js';
|
|
@@ -13,7 +13,7 @@ export { hashing_exports as hashing } from './chunk-GEFVMGZR.js';
|
|
|
13
13
|
export { text_exports as text } from './chunk-2I4O5YCT.js';
|
|
14
14
|
export { data_exports as data } from './chunk-TINQFTLO.js';
|
|
15
15
|
export { generators_exports as generators } from './chunk-2CJSLYWI.js';
|
|
16
|
-
export { time_exports as time } from './chunk-
|
|
16
|
+
export { time_exports as time } from './chunk-IEPWZERQ.js';
|
|
17
17
|
import './chunk-MLKGABMK.js';
|
|
18
18
|
|
|
19
19
|
// src/index.ts
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* - date-diff : parseDate, humanizeDiff, diffDates, COMMON_DATE_PRESETS
|
|
7
7
|
* - timezone : TIMEZONES, getTimezoneOffset, convertTime, formatInTimezone, getAllZonesForTime
|
|
8
8
|
* - cron-next : parseCronExpression, getNextRuns, formatRunDate, getRunInterval
|
|
9
|
+
* - iso8601-duration : parseIso8601Duration, formatIso8601Duration
|
|
9
10
|
*/
|
|
10
11
|
interface TimestampResult {
|
|
11
12
|
unix: number;
|
|
@@ -111,6 +112,47 @@ declare function getNextRuns(expr: string, count?: number, fromDate?: Date): Dat
|
|
|
111
112
|
};
|
|
112
113
|
declare function formatRunDate(date: Date, timezone?: string): string;
|
|
113
114
|
declare function getRunInterval(dates: Date[]): string;
|
|
115
|
+
interface DurationParseResult {
|
|
116
|
+
input: string;
|
|
117
|
+
years: number;
|
|
118
|
+
months: number;
|
|
119
|
+
weeks: number;
|
|
120
|
+
days: number;
|
|
121
|
+
hours: number;
|
|
122
|
+
minutes: number;
|
|
123
|
+
seconds: number;
|
|
124
|
+
totalSeconds: number;
|
|
125
|
+
approximate: boolean;
|
|
126
|
+
human: string;
|
|
127
|
+
}
|
|
128
|
+
interface DurationFormatResult {
|
|
129
|
+
seconds: number;
|
|
130
|
+
iso: string;
|
|
131
|
+
days: number;
|
|
132
|
+
hours: number;
|
|
133
|
+
minutes: number;
|
|
134
|
+
human: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Parse an ISO 8601 duration string (e.g. "P3DT4H30M", "PT1H", "P1Y6M") into
|
|
138
|
+
* its individual components plus a total number of seconds. Years and months
|
|
139
|
+
* have no fixed length, so when either is present `totalSeconds` uses nominal
|
|
140
|
+
* conversions (1 year = 365 days, 1 month = 30 days) and `approximate` is set
|
|
141
|
+
* to true. Weeks, days, hours, minutes, and seconds are exact. Fractional
|
|
142
|
+
* seconds are supported.
|
|
143
|
+
*/
|
|
144
|
+
declare function parseIso8601Duration(input: string): DurationParseResult | {
|
|
145
|
+
error: string;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Format a non-negative number of seconds into a canonical ISO 8601 duration
|
|
149
|
+
* string. The output uses only days, hours, minutes, and seconds (never years
|
|
150
|
+
* or months, which have no fixed length), e.g. 90061 -> "P1DT1H1M1S". Zero is
|
|
151
|
+
* rendered as "PT0S". Fractional seconds are preserved.
|
|
152
|
+
*/
|
|
153
|
+
declare function formatIso8601Duration(seconds: number): DurationFormatResult | {
|
|
154
|
+
error: string;
|
|
155
|
+
};
|
|
114
156
|
|
|
115
157
|
declare const time_COMMON_CRONS: typeof COMMON_CRONS;
|
|
116
158
|
declare const time_COMMON_DATE_PRESETS: typeof COMMON_DATE_PRESETS;
|
|
@@ -118,6 +160,8 @@ type time_CronField = CronField;
|
|
|
118
160
|
type time_CronNextField = CronNextField;
|
|
119
161
|
type time_CronResult = CronResult;
|
|
120
162
|
type time_DateDiffResult = DateDiffResult;
|
|
163
|
+
type time_DurationFormatResult = DurationFormatResult;
|
|
164
|
+
type time_DurationParseResult = DurationParseResult;
|
|
121
165
|
type time_ParsedCron = ParsedCron;
|
|
122
166
|
declare const time_TIMEZONES: typeof TIMEZONES;
|
|
123
167
|
type time_TimestampResult = TimestampResult;
|
|
@@ -125,6 +169,7 @@ type time_TimezoneEntry = TimezoneEntry;
|
|
|
125
169
|
declare const time_convertTime: typeof convertTime;
|
|
126
170
|
declare const time_diffDates: typeof diffDates;
|
|
127
171
|
declare const time_formatInTimezone: typeof formatInTimezone;
|
|
172
|
+
declare const time_formatIso8601Duration: typeof formatIso8601Duration;
|
|
128
173
|
declare const time_formatRelative: typeof formatRelative;
|
|
129
174
|
declare const time_formatRunDate: typeof formatRunDate;
|
|
130
175
|
declare const time_fromIsoString: typeof fromIsoString;
|
|
@@ -138,8 +183,9 @@ declare const time_humanizeDiff: typeof humanizeDiff;
|
|
|
138
183
|
declare const time_parseCron: typeof parseCron;
|
|
139
184
|
declare const time_parseCronExpression: typeof parseCronExpression;
|
|
140
185
|
declare const time_parseDate: typeof parseDate;
|
|
186
|
+
declare const time_parseIso8601Duration: typeof parseIso8601Duration;
|
|
141
187
|
declare namespace time {
|
|
142
|
-
export { time_COMMON_CRONS as COMMON_CRONS, time_COMMON_DATE_PRESETS as COMMON_DATE_PRESETS, type time_CronField as CronField, type time_CronNextField as CronNextField, type time_CronResult as CronResult, type time_DateDiffResult as DateDiffResult, type time_ParsedCron as ParsedCron, time_TIMEZONES as TIMEZONES, type time_TimestampResult as TimestampResult, type time_TimezoneEntry as TimezoneEntry, time_convertTime as convertTime, time_diffDates as diffDates, time_formatInTimezone as formatInTimezone, time_formatRelative as formatRelative, time_formatRunDate as formatRunDate, time_fromIsoString as fromIsoString, time_fromUnix as fromUnix, time_getAllZonesForTime as getAllZonesForTime, time_getNextRuns as getNextRuns, time_getNow as getNow, time_getRunInterval as getRunInterval, time_getTimezoneOffset as getTimezoneOffset, time_humanizeDiff as humanizeDiff, time_parseCron as parseCron, time_parseCronExpression as parseCronExpression, time_parseDate as parseDate };
|
|
188
|
+
export { time_COMMON_CRONS as COMMON_CRONS, time_COMMON_DATE_PRESETS as COMMON_DATE_PRESETS, type time_CronField as CronField, type time_CronNextField as CronNextField, type time_CronResult as CronResult, type time_DateDiffResult as DateDiffResult, type time_DurationFormatResult as DurationFormatResult, type time_DurationParseResult as DurationParseResult, type time_ParsedCron as ParsedCron, time_TIMEZONES as TIMEZONES, type time_TimestampResult as TimestampResult, type time_TimezoneEntry as TimezoneEntry, time_convertTime as convertTime, time_diffDates as diffDates, time_formatInTimezone as formatInTimezone, time_formatIso8601Duration as formatIso8601Duration, time_formatRelative as formatRelative, time_formatRunDate as formatRunDate, time_fromIsoString as fromIsoString, time_fromUnix as fromUnix, time_getAllZonesForTime as getAllZonesForTime, time_getNextRuns as getNextRuns, time_getNow as getNow, time_getRunInterval as getRunInterval, time_getTimezoneOffset as getTimezoneOffset, time_humanizeDiff as humanizeDiff, time_parseCron as parseCron, time_parseCronExpression as parseCronExpression, time_parseDate as parseDate, time_parseIso8601Duration as parseIso8601Duration };
|
|
143
189
|
}
|
|
144
190
|
|
|
145
|
-
export { COMMON_CRONS as C, type DateDiffResult as D, type ParsedCron as P, TIMEZONES as T, COMMON_DATE_PRESETS as a, type CronField as b, type CronNextField as c, type CronResult as d, type
|
|
191
|
+
export { parseIso8601Duration as A, COMMON_CRONS as C, type DateDiffResult as D, type ParsedCron as P, TIMEZONES as T, COMMON_DATE_PRESETS as a, type CronField as b, type CronNextField as c, type CronResult as d, type DurationFormatResult as e, type DurationParseResult as f, type TimestampResult as g, type TimezoneEntry as h, convertTime as i, diffDates as j, formatInTimezone as k, formatIso8601Duration as l, formatRelative as m, formatRunDate as n, fromIsoString as o, fromUnix as p, getAllZonesForTime as q, getNextRuns as r, getNow as s, time as t, getRunInterval as u, getTimezoneOffset as v, humanizeDiff as w, parseCron as x, parseCronExpression as y, parseDate as z };
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* - date-diff : parseDate, humanizeDiff, diffDates, COMMON_DATE_PRESETS
|
|
7
7
|
* - timezone : TIMEZONES, getTimezoneOffset, convertTime, formatInTimezone, getAllZonesForTime
|
|
8
8
|
* - cron-next : parseCronExpression, getNextRuns, formatRunDate, getRunInterval
|
|
9
|
+
* - iso8601-duration : parseIso8601Duration, formatIso8601Duration
|
|
9
10
|
*/
|
|
10
11
|
interface TimestampResult {
|
|
11
12
|
unix: number;
|
|
@@ -111,6 +112,47 @@ declare function getNextRuns(expr: string, count?: number, fromDate?: Date): Dat
|
|
|
111
112
|
};
|
|
112
113
|
declare function formatRunDate(date: Date, timezone?: string): string;
|
|
113
114
|
declare function getRunInterval(dates: Date[]): string;
|
|
115
|
+
interface DurationParseResult {
|
|
116
|
+
input: string;
|
|
117
|
+
years: number;
|
|
118
|
+
months: number;
|
|
119
|
+
weeks: number;
|
|
120
|
+
days: number;
|
|
121
|
+
hours: number;
|
|
122
|
+
minutes: number;
|
|
123
|
+
seconds: number;
|
|
124
|
+
totalSeconds: number;
|
|
125
|
+
approximate: boolean;
|
|
126
|
+
human: string;
|
|
127
|
+
}
|
|
128
|
+
interface DurationFormatResult {
|
|
129
|
+
seconds: number;
|
|
130
|
+
iso: string;
|
|
131
|
+
days: number;
|
|
132
|
+
hours: number;
|
|
133
|
+
minutes: number;
|
|
134
|
+
human: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Parse an ISO 8601 duration string (e.g. "P3DT4H30M", "PT1H", "P1Y6M") into
|
|
138
|
+
* its individual components plus a total number of seconds. Years and months
|
|
139
|
+
* have no fixed length, so when either is present `totalSeconds` uses nominal
|
|
140
|
+
* conversions (1 year = 365 days, 1 month = 30 days) and `approximate` is set
|
|
141
|
+
* to true. Weeks, days, hours, minutes, and seconds are exact. Fractional
|
|
142
|
+
* seconds are supported.
|
|
143
|
+
*/
|
|
144
|
+
declare function parseIso8601Duration(input: string): DurationParseResult | {
|
|
145
|
+
error: string;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Format a non-negative number of seconds into a canonical ISO 8601 duration
|
|
149
|
+
* string. The output uses only days, hours, minutes, and seconds (never years
|
|
150
|
+
* or months, which have no fixed length), e.g. 90061 -> "P1DT1H1M1S". Zero is
|
|
151
|
+
* rendered as "PT0S". Fractional seconds are preserved.
|
|
152
|
+
*/
|
|
153
|
+
declare function formatIso8601Duration(seconds: number): DurationFormatResult | {
|
|
154
|
+
error: string;
|
|
155
|
+
};
|
|
114
156
|
|
|
115
157
|
declare const time_COMMON_CRONS: typeof COMMON_CRONS;
|
|
116
158
|
declare const time_COMMON_DATE_PRESETS: typeof COMMON_DATE_PRESETS;
|
|
@@ -118,6 +160,8 @@ type time_CronField = CronField;
|
|
|
118
160
|
type time_CronNextField = CronNextField;
|
|
119
161
|
type time_CronResult = CronResult;
|
|
120
162
|
type time_DateDiffResult = DateDiffResult;
|
|
163
|
+
type time_DurationFormatResult = DurationFormatResult;
|
|
164
|
+
type time_DurationParseResult = DurationParseResult;
|
|
121
165
|
type time_ParsedCron = ParsedCron;
|
|
122
166
|
declare const time_TIMEZONES: typeof TIMEZONES;
|
|
123
167
|
type time_TimestampResult = TimestampResult;
|
|
@@ -125,6 +169,7 @@ type time_TimezoneEntry = TimezoneEntry;
|
|
|
125
169
|
declare const time_convertTime: typeof convertTime;
|
|
126
170
|
declare const time_diffDates: typeof diffDates;
|
|
127
171
|
declare const time_formatInTimezone: typeof formatInTimezone;
|
|
172
|
+
declare const time_formatIso8601Duration: typeof formatIso8601Duration;
|
|
128
173
|
declare const time_formatRelative: typeof formatRelative;
|
|
129
174
|
declare const time_formatRunDate: typeof formatRunDate;
|
|
130
175
|
declare const time_fromIsoString: typeof fromIsoString;
|
|
@@ -138,8 +183,9 @@ declare const time_humanizeDiff: typeof humanizeDiff;
|
|
|
138
183
|
declare const time_parseCron: typeof parseCron;
|
|
139
184
|
declare const time_parseCronExpression: typeof parseCronExpression;
|
|
140
185
|
declare const time_parseDate: typeof parseDate;
|
|
186
|
+
declare const time_parseIso8601Duration: typeof parseIso8601Duration;
|
|
141
187
|
declare namespace time {
|
|
142
|
-
export { time_COMMON_CRONS as COMMON_CRONS, time_COMMON_DATE_PRESETS as COMMON_DATE_PRESETS, type time_CronField as CronField, type time_CronNextField as CronNextField, type time_CronResult as CronResult, type time_DateDiffResult as DateDiffResult, type time_ParsedCron as ParsedCron, time_TIMEZONES as TIMEZONES, type time_TimestampResult as TimestampResult, type time_TimezoneEntry as TimezoneEntry, time_convertTime as convertTime, time_diffDates as diffDates, time_formatInTimezone as formatInTimezone, time_formatRelative as formatRelative, time_formatRunDate as formatRunDate, time_fromIsoString as fromIsoString, time_fromUnix as fromUnix, time_getAllZonesForTime as getAllZonesForTime, time_getNextRuns as getNextRuns, time_getNow as getNow, time_getRunInterval as getRunInterval, time_getTimezoneOffset as getTimezoneOffset, time_humanizeDiff as humanizeDiff, time_parseCron as parseCron, time_parseCronExpression as parseCronExpression, time_parseDate as parseDate };
|
|
188
|
+
export { time_COMMON_CRONS as COMMON_CRONS, time_COMMON_DATE_PRESETS as COMMON_DATE_PRESETS, type time_CronField as CronField, type time_CronNextField as CronNextField, type time_CronResult as CronResult, type time_DateDiffResult as DateDiffResult, type time_DurationFormatResult as DurationFormatResult, type time_DurationParseResult as DurationParseResult, type time_ParsedCron as ParsedCron, time_TIMEZONES as TIMEZONES, type time_TimestampResult as TimestampResult, type time_TimezoneEntry as TimezoneEntry, time_convertTime as convertTime, time_diffDates as diffDates, time_formatInTimezone as formatInTimezone, time_formatIso8601Duration as formatIso8601Duration, time_formatRelative as formatRelative, time_formatRunDate as formatRunDate, time_fromIsoString as fromIsoString, time_fromUnix as fromUnix, time_getAllZonesForTime as getAllZonesForTime, time_getNextRuns as getNextRuns, time_getNow as getNow, time_getRunInterval as getRunInterval, time_getTimezoneOffset as getTimezoneOffset, time_humanizeDiff as humanizeDiff, time_parseCron as parseCron, time_parseCronExpression as parseCronExpression, time_parseDate as parseDate, time_parseIso8601Duration as parseIso8601Duration };
|
|
143
189
|
}
|
|
144
190
|
|
|
145
|
-
export { COMMON_CRONS as C, type DateDiffResult as D, type ParsedCron as P, TIMEZONES as T, COMMON_DATE_PRESETS as a, type CronField as b, type CronNextField as c, type CronResult as d, type
|
|
191
|
+
export { parseIso8601Duration as A, COMMON_CRONS as C, type DateDiffResult as D, type ParsedCron as P, TIMEZONES as T, COMMON_DATE_PRESETS as a, type CronField as b, type CronNextField as c, type CronResult as d, type DurationFormatResult as e, type DurationParseResult as f, type TimestampResult as g, type TimezoneEntry as h, convertTime as i, diffDates as j, formatInTimezone as k, formatIso8601Duration as l, formatRelative as m, formatRunDate as n, fromIsoString as o, fromUnix as p, getAllZonesForTime as q, getNextRuns as r, getNow as s, time as t, getRunInterval as u, getTimezoneOffset as v, humanizeDiff as w, parseCron as x, parseCronExpression as y, parseDate as z };
|
package/dist/tools/time.cjs
CHANGED
|
@@ -659,6 +659,97 @@ function getRunInterval(dates) {
|
|
|
659
659
|
const days = Math.round(diffMins / 1440);
|
|
660
660
|
return `Every ${days} days`;
|
|
661
661
|
}
|
|
662
|
+
var DURATION_SECONDS_PER_YEAR = 365 * 86400;
|
|
663
|
+
var DURATION_SECONDS_PER_MONTH = 30 * 86400;
|
|
664
|
+
function humanizeDurationParts(parts) {
|
|
665
|
+
const pieces = [];
|
|
666
|
+
for (const [value, label] of parts) {
|
|
667
|
+
if (value === 0) continue;
|
|
668
|
+
pieces.push(`${value} ${label}${value === 1 ? "" : "s"}`);
|
|
669
|
+
}
|
|
670
|
+
return pieces.length > 0 ? pieces.join(", ") : "0 seconds";
|
|
671
|
+
}
|
|
672
|
+
function parseIso8601Duration(input) {
|
|
673
|
+
if (typeof input !== "string") return { error: "Duration must be a string" };
|
|
674
|
+
const trimmed = input.trim();
|
|
675
|
+
if (trimmed.length === 0) return { error: "Duration is empty" };
|
|
676
|
+
const match = trimmed.match(
|
|
677
|
+
/^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/
|
|
678
|
+
);
|
|
679
|
+
if (!match) {
|
|
680
|
+
return { error: 'Not a valid ISO 8601 duration (expected a form like "P3DT4H30M")' };
|
|
681
|
+
}
|
|
682
|
+
const years = match[1] ? parseInt(match[1], 10) : 0;
|
|
683
|
+
const months = match[2] ? parseInt(match[2], 10) : 0;
|
|
684
|
+
const weeks = match[3] ? parseInt(match[3], 10) : 0;
|
|
685
|
+
const days = match[4] ? parseInt(match[4], 10) : 0;
|
|
686
|
+
const hours = match[5] ? parseInt(match[5], 10) : 0;
|
|
687
|
+
const minutes = match[6] ? parseInt(match[6], 10) : 0;
|
|
688
|
+
const seconds = match[7] ? parseFloat(match[7]) : 0;
|
|
689
|
+
if (years + months + weeks + days + hours + minutes + seconds === 0) {
|
|
690
|
+
return { error: 'Duration has no components (a bare "P" or "PT" is not valid)' };
|
|
691
|
+
}
|
|
692
|
+
const approximate = years > 0 || months > 0;
|
|
693
|
+
const totalSeconds = years * DURATION_SECONDS_PER_YEAR + months * DURATION_SECONDS_PER_MONTH + weeks * 7 * 86400 + days * 86400 + hours * 3600 + minutes * 60 + seconds;
|
|
694
|
+
const human = humanizeDurationParts([
|
|
695
|
+
[years, "year"],
|
|
696
|
+
[months, "month"],
|
|
697
|
+
[weeks, "week"],
|
|
698
|
+
[days, "day"],
|
|
699
|
+
[hours, "hour"],
|
|
700
|
+
[minutes, "minute"],
|
|
701
|
+
[seconds, "second"]
|
|
702
|
+
]);
|
|
703
|
+
return {
|
|
704
|
+
input: trimmed,
|
|
705
|
+
years,
|
|
706
|
+
months,
|
|
707
|
+
weeks,
|
|
708
|
+
days,
|
|
709
|
+
hours,
|
|
710
|
+
minutes,
|
|
711
|
+
seconds,
|
|
712
|
+
totalSeconds: Math.round(totalSeconds * 1e6) / 1e6,
|
|
713
|
+
approximate,
|
|
714
|
+
human
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
function formatIso8601Duration(seconds) {
|
|
718
|
+
if (typeof seconds !== "number" || !Number.isFinite(seconds) || seconds < 0) {
|
|
719
|
+
return { error: "Seconds must be zero or a positive number" };
|
|
720
|
+
}
|
|
721
|
+
const totalDays = Math.floor(seconds / 86400);
|
|
722
|
+
let rem = seconds - totalDays * 86400;
|
|
723
|
+
const hours = Math.floor(rem / 3600);
|
|
724
|
+
rem -= hours * 3600;
|
|
725
|
+
const minutes = Math.floor(rem / 60);
|
|
726
|
+
let secs = rem - minutes * 60;
|
|
727
|
+
secs = Math.round(secs * 1e6) / 1e6;
|
|
728
|
+
let iso = "P";
|
|
729
|
+
if (totalDays > 0) iso += `${totalDays}D`;
|
|
730
|
+
const hasTime = hours > 0 || minutes > 0 || secs > 0;
|
|
731
|
+
if (hasTime) {
|
|
732
|
+
iso += "T";
|
|
733
|
+
if (hours > 0) iso += `${hours}H`;
|
|
734
|
+
if (minutes > 0) iso += `${minutes}M`;
|
|
735
|
+
if (secs > 0) iso += `${secs}S`;
|
|
736
|
+
}
|
|
737
|
+
if (iso === "P") iso = "PT0S";
|
|
738
|
+
const human = humanizeDurationParts([
|
|
739
|
+
[totalDays, "day"],
|
|
740
|
+
[hours, "hour"],
|
|
741
|
+
[minutes, "minute"],
|
|
742
|
+
[secs, "second"]
|
|
743
|
+
]);
|
|
744
|
+
return {
|
|
745
|
+
seconds,
|
|
746
|
+
iso,
|
|
747
|
+
days: totalDays,
|
|
748
|
+
hours,
|
|
749
|
+
minutes,
|
|
750
|
+
human
|
|
751
|
+
};
|
|
752
|
+
}
|
|
662
753
|
|
|
663
754
|
exports.COMMON_CRONS = COMMON_CRONS;
|
|
664
755
|
exports.COMMON_DATE_PRESETS = COMMON_DATE_PRESETS;
|
|
@@ -666,6 +757,7 @@ exports.TIMEZONES = TIMEZONES;
|
|
|
666
757
|
exports.convertTime = convertTime;
|
|
667
758
|
exports.diffDates = diffDates;
|
|
668
759
|
exports.formatInTimezone = formatInTimezone;
|
|
760
|
+
exports.formatIso8601Duration = formatIso8601Duration;
|
|
669
761
|
exports.formatRelative = formatRelative;
|
|
670
762
|
exports.formatRunDate = formatRunDate;
|
|
671
763
|
exports.fromIsoString = fromIsoString;
|
|
@@ -679,3 +771,4 @@ exports.humanizeDiff = humanizeDiff;
|
|
|
679
771
|
exports.parseCron = parseCron;
|
|
680
772
|
exports.parseCronExpression = parseCronExpression;
|
|
681
773
|
exports.parseDate = parseDate;
|
|
774
|
+
exports.parseIso8601Duration = parseIso8601Duration;
|
package/dist/tools/time.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as COMMON_CRONS, a as COMMON_DATE_PRESETS, b as CronField, c as CronNextField, d as CronResult, D as DateDiffResult, P as ParsedCron, T as TIMEZONES,
|
|
1
|
+
export { C as COMMON_CRONS, a as COMMON_DATE_PRESETS, b as CronField, c as CronNextField, d as CronResult, D as DateDiffResult, e as DurationFormatResult, f as DurationParseResult, P as ParsedCron, T as TIMEZONES, g as TimestampResult, h as TimezoneEntry, i as convertTime, j as diffDates, k as formatInTimezone, l as formatIso8601Duration, m as formatRelative, n as formatRunDate, o as fromIsoString, p as fromUnix, q as getAllZonesForTime, r as getNextRuns, s as getNow, u as getRunInterval, v as getTimezoneOffset, w as humanizeDiff, x as parseCron, y as parseCronExpression, z as parseDate, A as parseIso8601Duration } from '../time-KqJjdqII.cjs';
|
package/dist/tools/time.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as COMMON_CRONS, a as COMMON_DATE_PRESETS, b as CronField, c as CronNextField, d as CronResult, D as DateDiffResult, P as ParsedCron, T as TIMEZONES,
|
|
1
|
+
export { C as COMMON_CRONS, a as COMMON_DATE_PRESETS, b as CronField, c as CronNextField, d as CronResult, D as DateDiffResult, e as DurationFormatResult, f as DurationParseResult, P as ParsedCron, T as TIMEZONES, g as TimestampResult, h as TimezoneEntry, i as convertTime, j as diffDates, k as formatInTimezone, l as formatIso8601Duration, m as formatRelative, n as formatRunDate, o as fromIsoString, p as fromUnix, q as getAllZonesForTime, r as getNextRuns, s as getNow, u as getRunInterval, v as getTimezoneOffset, w as humanizeDiff, x as parseCron, y as parseCronExpression, z as parseDate, A as parseIso8601Duration } from '../time-KqJjdqII.js';
|
package/dist/tools/time.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { COMMON_CRONS, COMMON_DATE_PRESETS, TIMEZONES, convertTime, diffDates, formatInTimezone, formatRelative, formatRunDate, fromIsoString, fromUnix, getAllZonesForTime, getNextRuns, getNow, getRunInterval, getTimezoneOffset, humanizeDiff, parseCron, parseCronExpression, parseDate } from '../chunk-
|
|
1
|
+
export { COMMON_CRONS, COMMON_DATE_PRESETS, TIMEZONES, convertTime, diffDates, formatInTimezone, formatIso8601Duration, formatRelative, formatRunDate, fromIsoString, fromUnix, getAllZonesForTime, getNextRuns, getNow, getRunInterval, getTimezoneOffset, humanizeDiff, parseCron, parseCronExpression, parseDate, parseIso8601Duration } from '../chunk-IEPWZERQ.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
package/dist/tools/units.cjs
CHANGED
|
@@ -1287,6 +1287,38 @@ function calculatePercentageChange(oldValue, newValue) {
|
|
|
1287
1287
|
multiplier: round4(multiplier)
|
|
1288
1288
|
};
|
|
1289
1289
|
}
|
|
1290
|
+
function convertAprApy(rate, compoundsPerYear, direction) {
|
|
1291
|
+
if (!Number.isFinite(rate) || rate < 0) return { error: "Rate must be zero or a positive number" };
|
|
1292
|
+
if (!Number.isInteger(compoundsPerYear) || compoundsPerYear <= 0) {
|
|
1293
|
+
return { error: "Compounding frequency must be a positive whole number of periods per year" };
|
|
1294
|
+
}
|
|
1295
|
+
if (direction !== "apr-to-apy" && direction !== "apy-to-apr") {
|
|
1296
|
+
return { error: 'Direction must be "apr-to-apy" or "apy-to-apr"' };
|
|
1297
|
+
}
|
|
1298
|
+
const round6 = (n2) => Math.round(n2 * 1e6) / 1e6;
|
|
1299
|
+
const round8 = (n2) => Math.round(n2 * 1e8) / 1e8;
|
|
1300
|
+
const n = compoundsPerYear;
|
|
1301
|
+
let aprDecimal;
|
|
1302
|
+
let apyDecimal;
|
|
1303
|
+
if (direction === "apr-to-apy") {
|
|
1304
|
+
aprDecimal = rate / 100;
|
|
1305
|
+
apyDecimal = Math.pow(1 + aprDecimal / n, n) - 1;
|
|
1306
|
+
} else {
|
|
1307
|
+
apyDecimal = rate / 100;
|
|
1308
|
+
aprDecimal = n * (Math.pow(1 + apyDecimal, 1 / n) - 1);
|
|
1309
|
+
}
|
|
1310
|
+
const apr = round6(aprDecimal * 100);
|
|
1311
|
+
const apy = round6(apyDecimal * 100);
|
|
1312
|
+
return {
|
|
1313
|
+
direction,
|
|
1314
|
+
compoundsPerYear: n,
|
|
1315
|
+
apr,
|
|
1316
|
+
apy,
|
|
1317
|
+
aprDecimal: round8(aprDecimal),
|
|
1318
|
+
apyDecimal: round8(apyDecimal),
|
|
1319
|
+
difference: round6(apy - apr)
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1290
1322
|
|
|
1291
1323
|
exports.BASE_LABELS = BASE_LABELS;
|
|
1292
1324
|
exports.BASE_PREFIXES = BASE_PREFIXES;
|
|
@@ -1312,6 +1344,7 @@ exports.calculateTimeValue = calculateTimeValue;
|
|
|
1312
1344
|
exports.calculateTipSplit = calculateTipSplit;
|
|
1313
1345
|
exports.compareSemver = compareSemver;
|
|
1314
1346
|
exports.convert = convert;
|
|
1347
|
+
exports.convertAprApy = convertAprApy;
|
|
1315
1348
|
exports.convertBytes = convertBytes;
|
|
1316
1349
|
exports.convertIp = convertIp;
|
|
1317
1350
|
exports.coverBox = coverBox;
|
package/dist/tools/units.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as AmortizationRow, a as AspectRatioResult, B as BASE_LABELS,
|
|
1
|
+
export { A as AmortizationRow, a as AprApyDirection, b as AprApyResult, c as AspectRatioResult, B as BASE_LABELS, d as BASE_PREFIXES, e as BYTE_UNITS, f as BarcodeFormat, g as BarcodeValidationResult, h as BaseConvertResult, i as ByteConvertResult, j as ByteUnit, C as COMMON_CURRENCIES, k as COMMON_LOCALES, l as COMMON_PERMISSIONS, m as COMMON_RATIOS, n as COMMON_SIZES, o as COMMON_TAX_RATES, p as COMMON_TIP_PERCENTAGES, q as COMMON_VIEWPORTS, r as CardValidationResult, s as CompoundInterestResult, t as CompoundYearRow, D as Dimensions, F as FilePermissions, v as FormatOptions, I as IbanValidationResult, w as IpConversion, x as IsbnFormat, y as IsbnResult, L as LoanResult, N as NotationStyle, z as NumberBase, P as PercentChangeDirection, E as PercentageChangeResult, G as Permission, H as PxConvertResult, S as SemverVersion, J as SimpleInterestResult, K as SubnetInfo, T as TaxDirection, M as TaxResult, O as TimeValueDirection, Q as TimeValueResult, R as TipSplitResult, V as ViewportConvertResult, U as autoFormat, W as bumpVersion, X as calcAspectRatio, Y as calcSubnet, Z as calculateCompoundInterest, _ as calculateLoan, $ as calculatePercentageChange, a0 as calculateSimpleInterest, a1 as calculateTax, a2 as calculateTimeValue, a3 as calculateTipSplit, a4 as compareSemver, a5 as convert, a6 as convertAprApy, a7 as convertBytes, a8 as convertIp, a9 as coverBox, aa as decimalToIp, ab as decimalToIpCidr, ac as describePermissions, ad as fitIntoBox, ae as formatNumber, af as formatValue, ag as formatVwValue, ah as formatWithSeparator, ai as gcd, aj as ipFromBinary, ak as ipFromDecimal, al as ipFromHex, am as ipToBinary, an as ipToDecimal, ao as ipToDecimalCidr, ap as ipToHex, aq as ipToOctal, ar as isValid, as as isValidCidr, at as isValidIp, au as isValidIpv4, av as octalToPermissions, aw as parseFileSize, ax as parseInput, ay as parseNumberString, az as parseSemver, aA as permissionsToChmod, aB as permissionsToOctal, aC as permissionsToSymbolic, aD as ptToPx, aE as pxToAll, aF as pxToViewport, aG as remToPx, aH as satisfiesRange, aI as scaleByHeight, aJ as scaleByWidth, aK as sortVersions, aL as splitSubnet, aM as symbolicToPermissions, aN as validateBarcode, aO as validateCardNumber, aP as validateIban, aQ as validateIsbn, aR as viewportToPx } from '../units-KrjRyu0w.cjs';
|
package/dist/tools/units.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as AmortizationRow, a as AspectRatioResult, B as BASE_LABELS,
|
|
1
|
+
export { A as AmortizationRow, a as AprApyDirection, b as AprApyResult, c as AspectRatioResult, B as BASE_LABELS, d as BASE_PREFIXES, e as BYTE_UNITS, f as BarcodeFormat, g as BarcodeValidationResult, h as BaseConvertResult, i as ByteConvertResult, j as ByteUnit, C as COMMON_CURRENCIES, k as COMMON_LOCALES, l as COMMON_PERMISSIONS, m as COMMON_RATIOS, n as COMMON_SIZES, o as COMMON_TAX_RATES, p as COMMON_TIP_PERCENTAGES, q as COMMON_VIEWPORTS, r as CardValidationResult, s as CompoundInterestResult, t as CompoundYearRow, D as Dimensions, F as FilePermissions, v as FormatOptions, I as IbanValidationResult, w as IpConversion, x as IsbnFormat, y as IsbnResult, L as LoanResult, N as NotationStyle, z as NumberBase, P as PercentChangeDirection, E as PercentageChangeResult, G as Permission, H as PxConvertResult, S as SemverVersion, J as SimpleInterestResult, K as SubnetInfo, T as TaxDirection, M as TaxResult, O as TimeValueDirection, Q as TimeValueResult, R as TipSplitResult, V as ViewportConvertResult, U as autoFormat, W as bumpVersion, X as calcAspectRatio, Y as calcSubnet, Z as calculateCompoundInterest, _ as calculateLoan, $ as calculatePercentageChange, a0 as calculateSimpleInterest, a1 as calculateTax, a2 as calculateTimeValue, a3 as calculateTipSplit, a4 as compareSemver, a5 as convert, a6 as convertAprApy, a7 as convertBytes, a8 as convertIp, a9 as coverBox, aa as decimalToIp, ab as decimalToIpCidr, ac as describePermissions, ad as fitIntoBox, ae as formatNumber, af as formatValue, ag as formatVwValue, ah as formatWithSeparator, ai as gcd, aj as ipFromBinary, ak as ipFromDecimal, al as ipFromHex, am as ipToBinary, an as ipToDecimal, ao as ipToDecimalCidr, ap as ipToHex, aq as ipToOctal, ar as isValid, as as isValidCidr, at as isValidIp, au as isValidIpv4, av as octalToPermissions, aw as parseFileSize, ax as parseInput, ay as parseNumberString, az as parseSemver, aA as permissionsToChmod, aB as permissionsToOctal, aC as permissionsToSymbolic, aD as ptToPx, aE as pxToAll, aF as pxToViewport, aG as remToPx, aH as satisfiesRange, aI as scaleByHeight, aJ as scaleByWidth, aK as sortVersions, aL as splitSubnet, aM as symbolicToPermissions, aN as validateBarcode, aO as validateCardNumber, aP as validateIban, aQ as validateIsbn, aR as viewportToPx } from '../units-KrjRyu0w.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, calculatePercentageChange, calculateSimpleInterest, calculateTax, calculateTimeValue, 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, calculatePercentageChange, calculateSimpleInterest, calculateTax, calculateTimeValue, calculateTipSplit, compareSemver, convert, convertAprApy, 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-TLRSQHMP.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
* - isbn-validator : validateIsbn
|
|
22
22
|
* - tip-calculator : calculateTipSplit
|
|
23
23
|
* - simple-interest-calculator : calculateSimpleInterest
|
|
24
|
+
* - present-value-calculator : calculateTimeValue
|
|
25
|
+
* - percentage-change-calculator : calculatePercentageChange
|
|
26
|
+
* - apr-apy-converter : convertAprApy
|
|
24
27
|
*/
|
|
25
28
|
interface PxConvertResult {
|
|
26
29
|
px: number;
|
|
@@ -448,8 +451,33 @@ interface PercentageChangeResult {
|
|
|
448
451
|
declare function calculatePercentageChange(oldValue: number, newValue: number): PercentageChangeResult | {
|
|
449
452
|
error: string;
|
|
450
453
|
};
|
|
454
|
+
type AprApyDirection = "apr-to-apy" | "apy-to-apr";
|
|
455
|
+
interface AprApyResult {
|
|
456
|
+
direction: AprApyDirection;
|
|
457
|
+
compoundsPerYear: number;
|
|
458
|
+
apr: number;
|
|
459
|
+
apy: number;
|
|
460
|
+
aprDecimal: number;
|
|
461
|
+
apyDecimal: number;
|
|
462
|
+
difference: number;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Convert between a nominal annual rate (APR) and the effective annual yield
|
|
466
|
+
* (APY) for a given compounding frequency. With direction "apr-to-apy" the
|
|
467
|
+
* input rate is treated as the nominal APR and the effective APY is computed
|
|
468
|
+
* as (1 + apr/n)^n - 1; with "apy-to-apr" the input is the effective APY and
|
|
469
|
+
* the nominal APR is recovered as n * ((1 + apy)^(1/n) - 1). Both rates are
|
|
470
|
+
* percentages, `difference` is apy - apr in percentage points, and n is the
|
|
471
|
+
* number of compounding periods per year. Pure closed-form formula, no live
|
|
472
|
+
* rate feed.
|
|
473
|
+
*/
|
|
474
|
+
declare function convertAprApy(rate: number, compoundsPerYear: number, direction: AprApyDirection): AprApyResult | {
|
|
475
|
+
error: string;
|
|
476
|
+
};
|
|
451
477
|
|
|
452
478
|
type units_AmortizationRow = AmortizationRow;
|
|
479
|
+
type units_AprApyDirection = AprApyDirection;
|
|
480
|
+
type units_AprApyResult = AprApyResult;
|
|
453
481
|
type units_AspectRatioResult = AspectRatioResult;
|
|
454
482
|
declare const units_BASE_LABELS: typeof BASE_LABELS;
|
|
455
483
|
declare const units_BASE_PREFIXES: typeof BASE_PREFIXES;
|
|
@@ -506,6 +534,7 @@ declare const units_calculateTimeValue: typeof calculateTimeValue;
|
|
|
506
534
|
declare const units_calculateTipSplit: typeof calculateTipSplit;
|
|
507
535
|
declare const units_compareSemver: typeof compareSemver;
|
|
508
536
|
declare const units_convert: typeof convert;
|
|
537
|
+
declare const units_convertAprApy: typeof convertAprApy;
|
|
509
538
|
declare const units_convertBytes: typeof convertBytes;
|
|
510
539
|
declare const units_convertIp: typeof convertIp;
|
|
511
540
|
declare const units_coverBox: typeof coverBox;
|
|
@@ -554,7 +583,7 @@ declare const units_validateIban: typeof validateIban;
|
|
|
554
583
|
declare const units_validateIsbn: typeof validateIsbn;
|
|
555
584
|
declare const units_viewportToPx: typeof viewportToPx;
|
|
556
585
|
declare namespace units {
|
|
557
|
-
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_PercentChangeDirection as PercentChangeDirection, type units_PercentageChangeResult as PercentageChangeResult, 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_TimeValueDirection as TimeValueDirection, type units_TimeValueResult as TimeValueResult, 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_calculatePercentageChange as calculatePercentageChange, units_calculateSimpleInterest as calculateSimpleInterest, units_calculateTax as calculateTax, units_calculateTimeValue as calculateTimeValue, 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 };
|
|
586
|
+
export { type units_AmortizationRow as AmortizationRow, type units_AprApyDirection as AprApyDirection, type units_AprApyResult as AprApyResult, 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_PercentChangeDirection as PercentChangeDirection, type units_PercentageChangeResult as PercentageChangeResult, 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_TimeValueDirection as TimeValueDirection, type units_TimeValueResult as TimeValueResult, 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_calculatePercentageChange as calculatePercentageChange, units_calculateSimpleInterest as calculateSimpleInterest, units_calculateTax as calculateTax, units_calculateTimeValue as calculateTimeValue, units_calculateTipSplit as calculateTipSplit, units_compareSemver as compareSemver, units_convert as convert, units_convertAprApy as convertAprApy, 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 };
|
|
558
587
|
}
|
|
559
588
|
|
|
560
|
-
export {
|
|
589
|
+
export { calculatePercentageChange as $, type AmortizationRow as A, BASE_LABELS as B, COMMON_CURRENCIES as C, type Dimensions as D, type PercentageChangeResult as E, type FilePermissions as F, type Permission as G, type PxConvertResult as H, type IbanValidationResult as I, type SimpleInterestResult as J, type SubnetInfo as K, type LoanResult as L, type TaxResult as M, type NotationStyle as N, type TimeValueDirection as O, type PercentChangeDirection as P, type TimeValueResult as Q, type TipSplitResult as R, type SemverVersion as S, type TaxDirection as T, autoFormat as U, type ViewportConvertResult as V, bumpVersion as W, calcAspectRatio as X, calcSubnet as Y, calculateCompoundInterest as Z, calculateLoan as _, type AprApyDirection as a, calculateSimpleInterest as a0, calculateTax as a1, calculateTimeValue as a2, calculateTipSplit as a3, compareSemver as a4, convert as a5, convertAprApy as a6, convertBytes as a7, convertIp as a8, coverBox as a9, permissionsToChmod as aA, permissionsToOctal as aB, permissionsToSymbolic as aC, ptToPx as aD, pxToAll as aE, pxToViewport as aF, remToPx as aG, satisfiesRange as aH, scaleByHeight as aI, scaleByWidth as aJ, sortVersions as aK, splitSubnet as aL, symbolicToPermissions as aM, validateBarcode as aN, validateCardNumber as aO, validateIban as aP, validateIsbn as aQ, viewportToPx as aR, decimalToIp as aa, decimalToIpCidr as ab, describePermissions as ac, fitIntoBox as ad, formatNumber as ae, formatValue as af, formatVwValue as ag, formatWithSeparator as ah, gcd as ai, ipFromBinary as aj, ipFromDecimal as ak, ipFromHex as al, ipToBinary as am, ipToDecimal as an, ipToDecimalCidr as ao, ipToHex as ap, ipToOctal as aq, isValid as ar, isValidCidr as as, isValidIp as at, isValidIpv4 as au, octalToPermissions as av, parseFileSize as aw, parseInput as ax, parseNumberString as ay, parseSemver as az, type AprApyResult as b, type AspectRatioResult as c, BASE_PREFIXES as d, BYTE_UNITS as e, type BarcodeFormat as f, type BarcodeValidationResult as g, type BaseConvertResult as h, type ByteConvertResult as i, type ByteUnit as j, COMMON_LOCALES as k, COMMON_PERMISSIONS as l, COMMON_RATIOS as m, COMMON_SIZES as n, COMMON_TAX_RATES as o, COMMON_TIP_PERCENTAGES as p, COMMON_VIEWPORTS as q, type CardValidationResult as r, type CompoundInterestResult as s, type CompoundYearRow as t, units as u, type FormatOptions as v, type IpConversion as w, type IsbnFormat as x, type IsbnResult as y, type NumberBase as z };
|
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
* - isbn-validator : validateIsbn
|
|
22
22
|
* - tip-calculator : calculateTipSplit
|
|
23
23
|
* - simple-interest-calculator : calculateSimpleInterest
|
|
24
|
+
* - present-value-calculator : calculateTimeValue
|
|
25
|
+
* - percentage-change-calculator : calculatePercentageChange
|
|
26
|
+
* - apr-apy-converter : convertAprApy
|
|
24
27
|
*/
|
|
25
28
|
interface PxConvertResult {
|
|
26
29
|
px: number;
|
|
@@ -448,8 +451,33 @@ interface PercentageChangeResult {
|
|
|
448
451
|
declare function calculatePercentageChange(oldValue: number, newValue: number): PercentageChangeResult | {
|
|
449
452
|
error: string;
|
|
450
453
|
};
|
|
454
|
+
type AprApyDirection = "apr-to-apy" | "apy-to-apr";
|
|
455
|
+
interface AprApyResult {
|
|
456
|
+
direction: AprApyDirection;
|
|
457
|
+
compoundsPerYear: number;
|
|
458
|
+
apr: number;
|
|
459
|
+
apy: number;
|
|
460
|
+
aprDecimal: number;
|
|
461
|
+
apyDecimal: number;
|
|
462
|
+
difference: number;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Convert between a nominal annual rate (APR) and the effective annual yield
|
|
466
|
+
* (APY) for a given compounding frequency. With direction "apr-to-apy" the
|
|
467
|
+
* input rate is treated as the nominal APR and the effective APY is computed
|
|
468
|
+
* as (1 + apr/n)^n - 1; with "apy-to-apr" the input is the effective APY and
|
|
469
|
+
* the nominal APR is recovered as n * ((1 + apy)^(1/n) - 1). Both rates are
|
|
470
|
+
* percentages, `difference` is apy - apr in percentage points, and n is the
|
|
471
|
+
* number of compounding periods per year. Pure closed-form formula, no live
|
|
472
|
+
* rate feed.
|
|
473
|
+
*/
|
|
474
|
+
declare function convertAprApy(rate: number, compoundsPerYear: number, direction: AprApyDirection): AprApyResult | {
|
|
475
|
+
error: string;
|
|
476
|
+
};
|
|
451
477
|
|
|
452
478
|
type units_AmortizationRow = AmortizationRow;
|
|
479
|
+
type units_AprApyDirection = AprApyDirection;
|
|
480
|
+
type units_AprApyResult = AprApyResult;
|
|
453
481
|
type units_AspectRatioResult = AspectRatioResult;
|
|
454
482
|
declare const units_BASE_LABELS: typeof BASE_LABELS;
|
|
455
483
|
declare const units_BASE_PREFIXES: typeof BASE_PREFIXES;
|
|
@@ -506,6 +534,7 @@ declare const units_calculateTimeValue: typeof calculateTimeValue;
|
|
|
506
534
|
declare const units_calculateTipSplit: typeof calculateTipSplit;
|
|
507
535
|
declare const units_compareSemver: typeof compareSemver;
|
|
508
536
|
declare const units_convert: typeof convert;
|
|
537
|
+
declare const units_convertAprApy: typeof convertAprApy;
|
|
509
538
|
declare const units_convertBytes: typeof convertBytes;
|
|
510
539
|
declare const units_convertIp: typeof convertIp;
|
|
511
540
|
declare const units_coverBox: typeof coverBox;
|
|
@@ -554,7 +583,7 @@ declare const units_validateIban: typeof validateIban;
|
|
|
554
583
|
declare const units_validateIsbn: typeof validateIsbn;
|
|
555
584
|
declare const units_viewportToPx: typeof viewportToPx;
|
|
556
585
|
declare namespace units {
|
|
557
|
-
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_PercentChangeDirection as PercentChangeDirection, type units_PercentageChangeResult as PercentageChangeResult, 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_TimeValueDirection as TimeValueDirection, type units_TimeValueResult as TimeValueResult, 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_calculatePercentageChange as calculatePercentageChange, units_calculateSimpleInterest as calculateSimpleInterest, units_calculateTax as calculateTax, units_calculateTimeValue as calculateTimeValue, 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 };
|
|
586
|
+
export { type units_AmortizationRow as AmortizationRow, type units_AprApyDirection as AprApyDirection, type units_AprApyResult as AprApyResult, 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_PercentChangeDirection as PercentChangeDirection, type units_PercentageChangeResult as PercentageChangeResult, 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_TimeValueDirection as TimeValueDirection, type units_TimeValueResult as TimeValueResult, 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_calculatePercentageChange as calculatePercentageChange, units_calculateSimpleInterest as calculateSimpleInterest, units_calculateTax as calculateTax, units_calculateTimeValue as calculateTimeValue, units_calculateTipSplit as calculateTipSplit, units_compareSemver as compareSemver, units_convert as convert, units_convertAprApy as convertAprApy, 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 };
|
|
558
587
|
}
|
|
559
588
|
|
|
560
|
-
export {
|
|
589
|
+
export { calculatePercentageChange as $, type AmortizationRow as A, BASE_LABELS as B, COMMON_CURRENCIES as C, type Dimensions as D, type PercentageChangeResult as E, type FilePermissions as F, type Permission as G, type PxConvertResult as H, type IbanValidationResult as I, type SimpleInterestResult as J, type SubnetInfo as K, type LoanResult as L, type TaxResult as M, type NotationStyle as N, type TimeValueDirection as O, type PercentChangeDirection as P, type TimeValueResult as Q, type TipSplitResult as R, type SemverVersion as S, type TaxDirection as T, autoFormat as U, type ViewportConvertResult as V, bumpVersion as W, calcAspectRatio as X, calcSubnet as Y, calculateCompoundInterest as Z, calculateLoan as _, type AprApyDirection as a, calculateSimpleInterest as a0, calculateTax as a1, calculateTimeValue as a2, calculateTipSplit as a3, compareSemver as a4, convert as a5, convertAprApy as a6, convertBytes as a7, convertIp as a8, coverBox as a9, permissionsToChmod as aA, permissionsToOctal as aB, permissionsToSymbolic as aC, ptToPx as aD, pxToAll as aE, pxToViewport as aF, remToPx as aG, satisfiesRange as aH, scaleByHeight as aI, scaleByWidth as aJ, sortVersions as aK, splitSubnet as aL, symbolicToPermissions as aM, validateBarcode as aN, validateCardNumber as aO, validateIban as aP, validateIsbn as aQ, viewportToPx as aR, decimalToIp as aa, decimalToIpCidr as ab, describePermissions as ac, fitIntoBox as ad, formatNumber as ae, formatValue as af, formatVwValue as ag, formatWithSeparator as ah, gcd as ai, ipFromBinary as aj, ipFromDecimal as ak, ipFromHex as al, ipToBinary as am, ipToDecimal as an, ipToDecimalCidr as ao, ipToHex as ap, ipToOctal as aq, isValid as ar, isValidCidr as as, isValidIp as at, isValidIpv4 as au, octalToPermissions as av, parseFileSize as aw, parseInput as ax, parseNumberString as ay, parseSemver as az, type AprApyResult as b, type AspectRatioResult as c, BASE_PREFIXES as d, BYTE_UNITS as e, type BarcodeFormat as f, type BarcodeValidationResult as g, type BaseConvertResult as h, type ByteConvertResult as i, type ByteUnit as j, COMMON_LOCALES as k, COMMON_PERMISSIONS as l, COMMON_RATIOS as m, COMMON_SIZES as n, COMMON_TAX_RATES as o, COMMON_TIP_PERCENTAGES as p, COMMON_VIEWPORTS as q, type CardValidationResult as r, type CompoundInterestResult as s, type CompoundYearRow as t, units as u, type FormatOptions as v, type IpConversion as w, type IsbnFormat as x, type IsbnResult as y, type NumberBase as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utilix-tech/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.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",
|