@utilix-tech/sdk 0.21.0 → 0.23.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.
@@ -21,6 +21,10 @@
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
27
+ * - margin-markup-calculator : calculateMarginMarkup, marginToMarkup, markupToMargin
24
28
  */
25
29
  interface PxConvertResult {
26
30
  px: number;
@@ -448,8 +452,69 @@ interface PercentageChangeResult {
448
452
  declare function calculatePercentageChange(oldValue: number, newValue: number): PercentageChangeResult | {
449
453
  error: string;
450
454
  };
455
+ type AprApyDirection = "apr-to-apy" | "apy-to-apr";
456
+ interface AprApyResult {
457
+ direction: AprApyDirection;
458
+ compoundsPerYear: number;
459
+ apr: number;
460
+ apy: number;
461
+ aprDecimal: number;
462
+ apyDecimal: number;
463
+ difference: number;
464
+ }
465
+ /**
466
+ * Convert between a nominal annual rate (APR) and the effective annual yield
467
+ * (APY) for a given compounding frequency. With direction "apr-to-apy" the
468
+ * input rate is treated as the nominal APR and the effective APY is computed
469
+ * as (1 + apr/n)^n - 1; with "apy-to-apr" the input is the effective APY and
470
+ * the nominal APR is recovered as n * ((1 + apy)^(1/n) - 1). Both rates are
471
+ * percentages, `difference` is apy - apr in percentage points, and n is the
472
+ * number of compounding periods per year. Pure closed-form formula, no live
473
+ * rate feed.
474
+ */
475
+ declare function convertAprApy(rate: number, compoundsPerYear: number, direction: AprApyDirection): AprApyResult | {
476
+ error: string;
477
+ };
478
+ type MarginMarkupField = "cost" | "price" | "marginPercent" | "markupPercent";
479
+ interface MarginMarkupInput {
480
+ cost?: number | null;
481
+ price?: number | null;
482
+ marginPercent?: number | null;
483
+ markupPercent?: number | null;
484
+ }
485
+ interface MarginMarkupResult {
486
+ cost: number;
487
+ price: number;
488
+ profit: number;
489
+ marginPercent: number;
490
+ markupPercent: number;
491
+ given: MarginMarkupField[];
492
+ solvedFor: MarginMarkupField[];
493
+ }
494
+ /**
495
+ * Solve a pricing triangle: given exactly two of cost, price, gross margin
496
+ * percent, and markup percent, derive the other two. Margin is profit as a
497
+ * share of the selling price (profit / price) while markup is profit as a
498
+ * share of the cost (profit / cost), so a 20% margin is the same deal as a
499
+ * 25% markup — conflating them is the classic mistake this exists to avoid.
500
+ * Margin plus markup alone cannot be solved, since neither carries an
501
+ * absolute amount. Pure closed-form arithmetic, no live price feed.
502
+ */
503
+ declare function calculateMarginMarkup(input: MarginMarkupInput): MarginMarkupResult | {
504
+ error: string;
505
+ };
506
+ /** Markup percent that produces a given gross margin percent (margin < 100). */
507
+ declare function marginToMarkup(marginPercent: number): number | {
508
+ error: string;
509
+ };
510
+ /** Gross margin percent that results from a given markup percent (markup > -100). */
511
+ declare function markupToMargin(markupPercent: number): number | {
512
+ error: string;
513
+ };
451
514
 
452
515
  type units_AmortizationRow = AmortizationRow;
516
+ type units_AprApyDirection = AprApyDirection;
517
+ type units_AprApyResult = AprApyResult;
453
518
  type units_AspectRatioResult = AspectRatioResult;
454
519
  declare const units_BASE_LABELS: typeof BASE_LABELS;
455
520
  declare const units_BASE_PREFIXES: typeof BASE_PREFIXES;
@@ -478,6 +543,9 @@ type units_IpConversion = IpConversion;
478
543
  type units_IsbnFormat = IsbnFormat;
479
544
  type units_IsbnResult = IsbnResult;
480
545
  type units_LoanResult = LoanResult;
546
+ type units_MarginMarkupField = MarginMarkupField;
547
+ type units_MarginMarkupInput = MarginMarkupInput;
548
+ type units_MarginMarkupResult = MarginMarkupResult;
481
549
  type units_NotationStyle = NotationStyle;
482
550
  type units_NumberBase = NumberBase;
483
551
  type units_PercentChangeDirection = PercentChangeDirection;
@@ -499,6 +567,7 @@ declare const units_calcAspectRatio: typeof calcAspectRatio;
499
567
  declare const units_calcSubnet: typeof calcSubnet;
500
568
  declare const units_calculateCompoundInterest: typeof calculateCompoundInterest;
501
569
  declare const units_calculateLoan: typeof calculateLoan;
570
+ declare const units_calculateMarginMarkup: typeof calculateMarginMarkup;
502
571
  declare const units_calculatePercentageChange: typeof calculatePercentageChange;
503
572
  declare const units_calculateSimpleInterest: typeof calculateSimpleInterest;
504
573
  declare const units_calculateTax: typeof calculateTax;
@@ -506,6 +575,7 @@ declare const units_calculateTimeValue: typeof calculateTimeValue;
506
575
  declare const units_calculateTipSplit: typeof calculateTipSplit;
507
576
  declare const units_compareSemver: typeof compareSemver;
508
577
  declare const units_convert: typeof convert;
578
+ declare const units_convertAprApy: typeof convertAprApy;
509
579
  declare const units_convertBytes: typeof convertBytes;
510
580
  declare const units_convertIp: typeof convertIp;
511
581
  declare const units_coverBox: typeof coverBox;
@@ -530,6 +600,8 @@ declare const units_isValid: typeof isValid;
530
600
  declare const units_isValidCidr: typeof isValidCidr;
531
601
  declare const units_isValidIp: typeof isValidIp;
532
602
  declare const units_isValidIpv4: typeof isValidIpv4;
603
+ declare const units_marginToMarkup: typeof marginToMarkup;
604
+ declare const units_markupToMargin: typeof markupToMargin;
533
605
  declare const units_octalToPermissions: typeof octalToPermissions;
534
606
  declare const units_parseFileSize: typeof parseFileSize;
535
607
  declare const units_parseInput: typeof parseInput;
@@ -554,7 +626,7 @@ declare const units_validateIban: typeof validateIban;
554
626
  declare const units_validateIsbn: typeof validateIsbn;
555
627
  declare const units_viewportToPx: typeof viewportToPx;
556
628
  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 };
629
+ 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_MarginMarkupField as MarginMarkupField, type units_MarginMarkupInput as MarginMarkupInput, type units_MarginMarkupResult as MarginMarkupResult, 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_calculateMarginMarkup as calculateMarginMarkup, 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_marginToMarkup as marginToMarkup, units_markupToMargin as markupToMargin, 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
630
  }
559
631
 
560
- export { calculateTax as $, type AmortizationRow as A, BASE_LABELS as B, COMMON_CURRENCIES as C, type Dimensions as D, type PxConvertResult as E, type FilePermissions as F, type SimpleInterestResult as G, type SubnetInfo as H, type IbanValidationResult as I, type TaxResult as J, type TimeValueDirection as K, type LoanResult as L, type TimeValueResult as M, type NotationStyle as N, type TipSplitResult as O, type PercentChangeDirection as P, autoFormat as Q, bumpVersion as R, type SemverVersion as S, type TaxDirection as T, calcAspectRatio as U, type ViewportConvertResult as V, calcSubnet as W, calculateCompoundInterest as X, calculateLoan as Y, calculatePercentageChange as Z, calculateSimpleInterest as _, type AspectRatioResult as a, calculateTimeValue as a0, calculateTipSplit as a1, compareSemver as a2, convert as a3, convertBytes as a4, convertIp as a5, coverBox as a6, decimalToIp as a7, decimalToIpCidr as a8, describePermissions as a9, ptToPx as aA, pxToAll as aB, pxToViewport as aC, remToPx as aD, satisfiesRange as aE, scaleByHeight as aF, scaleByWidth as aG, sortVersions as aH, splitSubnet as aI, symbolicToPermissions as aJ, validateBarcode as aK, validateCardNumber as aL, validateIban as aM, validateIsbn as aN, viewportToPx as aO, fitIntoBox as aa, formatNumber as ab, formatValue as ac, formatVwValue as ad, formatWithSeparator as ae, gcd as af, ipFromBinary as ag, ipFromDecimal as ah, ipFromHex as ai, ipToBinary as aj, ipToDecimal as ak, ipToDecimalCidr as al, ipToHex as am, ipToOctal as an, isValid as ao, isValidCidr as ap, isValidIp as aq, isValidIpv4 as ar, octalToPermissions as as, parseFileSize as at, parseInput as au, parseNumberString as av, parseSemver as aw, permissionsToChmod as ax, permissionsToOctal as ay, permissionsToSymbolic as az, BASE_PREFIXES as b, BYTE_UNITS as c, type BarcodeFormat as d, type BarcodeValidationResult as e, type BaseConvertResult as f, type ByteConvertResult as g, type ByteUnit as h, COMMON_LOCALES as i, COMMON_PERMISSIONS as j, COMMON_RATIOS as k, COMMON_SIZES as l, COMMON_TAX_RATES as m, COMMON_TIP_PERCENTAGES as n, COMMON_VIEWPORTS as o, type CardValidationResult as p, type CompoundInterestResult as q, type CompoundYearRow as r, type FormatOptions as s, type IpConversion as t, units as u, type IsbnFormat as v, type IsbnResult as w, type NumberBase as x, type PercentageChangeResult as y, type Permission as z };
632
+ export { calcSubnet as $, type AmortizationRow as A, BASE_LABELS as B, COMMON_CURRENCIES as C, type Dimensions as D, type MarginMarkupResult as E, type FilePermissions as F, type NumberBase as G, type PercentageChangeResult as H, type IbanValidationResult as I, type Permission as J, type PxConvertResult as K, type LoanResult as L, type MarginMarkupField as M, type NotationStyle as N, type SimpleInterestResult as O, type PercentChangeDirection as P, type SubnetInfo as Q, type TaxResult as R, type SemverVersion as S, type TaxDirection as T, type TimeValueDirection as U, type TimeValueResult as V, type TipSplitResult as W, type ViewportConvertResult as X, autoFormat as Y, bumpVersion as Z, calcAspectRatio as _, type AprApyDirection as a, calculateCompoundInterest as a0, calculateLoan as a1, calculateMarginMarkup as a2, calculatePercentageChange as a3, calculateSimpleInterest as a4, calculateTax as a5, calculateTimeValue as a6, calculateTipSplit as a7, compareSemver as a8, convert as a9, markupToMargin as aA, octalToPermissions as aB, parseFileSize as aC, parseInput as aD, parseNumberString as aE, parseSemver as aF, permissionsToChmod as aG, permissionsToOctal as aH, permissionsToSymbolic as aI, ptToPx as aJ, pxToAll as aK, pxToViewport as aL, remToPx as aM, satisfiesRange as aN, scaleByHeight as aO, scaleByWidth as aP, sortVersions as aQ, splitSubnet as aR, symbolicToPermissions as aS, validateBarcode as aT, validateCardNumber as aU, validateIban as aV, validateIsbn as aW, viewportToPx as aX, convertAprApy as aa, convertBytes as ab, convertIp as ac, coverBox as ad, decimalToIp as ae, decimalToIpCidr as af, describePermissions as ag, fitIntoBox as ah, formatNumber as ai, formatValue as aj, formatVwValue as ak, formatWithSeparator as al, gcd as am, ipFromBinary as an, ipFromDecimal as ao, ipFromHex as ap, ipToBinary as aq, ipToDecimal as ar, ipToDecimalCidr as as, ipToHex as at, ipToOctal as au, isValid as av, isValidCidr as aw, isValidIp as ax, isValidIpv4 as ay, marginToMarkup 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 MarginMarkupInput as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utilix-tech/sdk",
3
- "version": "0.21.0",
3
+ "version": "0.23.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",