@utilix-tech/sdk 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +21 -7
- package/dist/{chunk-GGDDCTFM.js → chunk-BI3SOWM7.js} +53 -1
- package/dist/{chunk-GUUYEIU6.js → chunk-XMKJYVKB.js} +35 -1
- package/dist/index.cjs +86 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{media-C3ZvGyKc.d.cts → media-9HEpTPGA.d.cts} +29 -2
- package/dist/{media-C3ZvGyKc.d.ts → media-9HEpTPGA.d.ts} +29 -2
- package/dist/tools/media.cjs +34 -0
- package/dist/tools/media.d.cts +1 -1
- package/dist/tools/media.d.ts +1 -1
- package/dist/tools/media.js +1 -1
- package/dist/tools/units.cjs +52 -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-BG387sch.d.cts → units-CKS5W_ih.d.cts} +48 -2
- package/dist/{units-BG387sch.d.ts → units-CKS5W_ih.d.ts} +48 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Full release notes for all Utilix surfaces (browser tools, REST API, SDKs, MCP server) live at [utilix.tech/changelog](https://utilix.tech/changelog). This file tracks just this package.
|
|
4
4
|
|
|
5
|
+
## 0.13.0
|
|
6
|
+
- Added VAT / Sales Tax Calculator (`calculateTax`).
|
|
7
|
+
|
|
8
|
+
## 0.12.0
|
|
9
|
+
- Added ICO Favicon Inspector (`readIcoInfo`) and Barcode Checksum Validator (`validateBarcode`).
|
|
10
|
+
|
|
5
11
|
## 0.11.0
|
|
6
12
|
- Added IBAN Validator / Formatter (`validateIban`) and Loan / Mortgage Calculator (`calculateLoan`).
|
|
7
13
|
- (npm publish for this version was retried after fixing a CI pin: `npm install -g npm@latest` started pulling npm 12, which requires Node >=22 and broke on this job's pinned Node 20 — now pinned to the npm 11 line.)
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @utilix-tech/sdk
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**537 developer utility functions for Node.js: runs locally, no API key required.**
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@utilix-tech/sdk)
|
|
6
6
|
[](https://www.npmjs.com/package/@utilix-tech/sdk)
|
|
@@ -242,7 +242,7 @@ getNextRuns("*/5 * * * *", 5); // next 5 run timestamps
|
|
|
242
242
|
### `/units`: Conversions
|
|
243
243
|
|
|
244
244
|
```ts
|
|
245
|
-
import { convertBytes, pxToAll, convert, formatValue, validateCardNumber, validateIban, calculateLoan } from "@utilix-tech/sdk/units";
|
|
245
|
+
import { convertBytes, pxToAll, convert, formatValue, validateCardNumber, validateIban, calculateLoan, validateBarcode, calculateTax } from "@utilix-tech/sdk/units";
|
|
246
246
|
|
|
247
247
|
// File sizes
|
|
248
248
|
convertBytes(1073741824, "GB"); // 1
|
|
@@ -272,6 +272,14 @@ validateIban("DE89 3704 0044 0532 0130 00");
|
|
|
272
272
|
// Loan / mortgage amortization
|
|
273
273
|
calculateLoan(200000, 6.5, 360);
|
|
274
274
|
// { monthlyPayment: 1264.14, totalInterest: 255085.82, termMonths: 360, schedule: [...] }
|
|
275
|
+
|
|
276
|
+
// EAN-13 / EAN-8 / UPC-A barcode checksum validation
|
|
277
|
+
validateBarcode("4006381333931");
|
|
278
|
+
// { valid: true, format: "EAN-13", digits: "4006381333931", checkDigit: 1, expectedCheckDigit: 1 }
|
|
279
|
+
|
|
280
|
+
// VAT / sales tax: add or remove tax in either direction
|
|
281
|
+
calculateTax(100, 20, "add");
|
|
282
|
+
// { netAmount: 100, taxAmount: 20, grossAmount: 120, ratePercent: 20, direction: "add" }
|
|
275
283
|
```
|
|
276
284
|
|
|
277
285
|
---
|
|
@@ -444,10 +452,10 @@ analyzeString("café"); // { length: 4, codePoints: [...], ... }
|
|
|
444
452
|
|
|
445
453
|
---
|
|
446
454
|
|
|
447
|
-
### `/media`: Image Header Parsing, EXIF, PDF, WAV &
|
|
455
|
+
### `/media`: Image Header Parsing, EXIF, PDF, WAV, ID3 & ICO Metadata
|
|
448
456
|
|
|
449
457
|
```ts
|
|
450
|
-
import { readImageInfo, readExifData, readPdfMetadata, readWavInfo, readId3Tags } from "@utilix-tech/sdk/media";
|
|
458
|
+
import { readImageInfo, readExifData, readPdfMetadata, readWavInfo, readId3Tags, readIcoInfo } from "@utilix-tech/sdk/media";
|
|
451
459
|
|
|
452
460
|
// Reads format, dimensions, bit depth, and alpha channel straight from
|
|
453
461
|
// file bytes: no decoding, no canvas, no image library.
|
|
@@ -479,9 +487,15 @@ readWavInfo(new Uint8Array(wavBytes));
|
|
|
479
487
|
const mp3Bytes = await fs.promises.readFile("track.mp3");
|
|
480
488
|
readId3Tags(new Uint8Array(mp3Bytes));
|
|
481
489
|
// { version: "ID3v2.3.0", title: "Track Name", artist: "Artist Name", genre: "Rock", ... }
|
|
490
|
+
|
|
491
|
+
// Reads how many images a .ico file embeds and each one's dimensions, color
|
|
492
|
+
// depth, and size directly from its ICONDIR/ICONDIRENTRY header table.
|
|
493
|
+
const icoBytes = await fs.promises.readFile("favicon.ico");
|
|
494
|
+
readIcoInfo(new Uint8Array(icoBytes));
|
|
495
|
+
// { imageCount: 3, images: [{ width: 16, height: 16, bitCount: 32, bytesInRes: 1128, ... }, ...] }
|
|
482
496
|
```
|
|
483
497
|
|
|
484
|
-
`readImageInfo` supports PNG, JPEG, GIF, WebP, and BMP. `readExifData` supports JPEG only. `readWavInfo` supports the canonical RIFF/WAVE container only. `readId3Tags` decodes ID3v2.3/2.4 and ID3v1/1.1 only (ID3v2.2 is detected but not decoded).
|
|
498
|
+
`readImageInfo` supports PNG, JPEG, GIF, WebP, and BMP. `readExifData` supports JPEG only. `readWavInfo` supports the canonical RIFF/WAVE container only. `readId3Tags` decodes ID3v2.3/2.4 and ID3v1/1.1 only (ID3v2.2 is detected but not decoded). `readIcoInfo` reads .ico icon files only and rejects .cur cursor files.
|
|
485
499
|
|
|
486
500
|
---
|
|
487
501
|
|
|
@@ -496,7 +510,7 @@ readId3Tags(new Uint8Array(mp3Bytes));
|
|
|
496
510
|
| `@utilix-tech/sdk/data` | CSV, YAML, TOML, XML, INI, NDJSON parse and convert |
|
|
497
511
|
| `@utilix-tech/sdk/generators` | UUID v4/v7, ULID, passwords, strength check, fake data |
|
|
498
512
|
| `@utilix-tech/sdk/time` | Date diff, timezone convert, cron parse, relative time |
|
|
499
|
-
| `@utilix-tech/sdk/units` | Bytes, CSS px/rem, number bases, currency format |
|
|
513
|
+
| `@utilix-tech/sdk/units` | Bytes, CSS px/rem, number bases, currency format, credit card/IBAN/barcode validation, loan calculator, VAT/sales tax calculator |
|
|
500
514
|
| `@utilix-tech/sdk/network` | HTTP status codes, IP validation, country flags, geolocation URLs, HAR file parsing |
|
|
501
515
|
| `@utilix-tech/sdk/api` | cURL build/parse, JWT decode/sign, JWKS parse, CORS headers, CSP header |
|
|
502
516
|
| `@utilix-tech/sdk/code` | SQL format/minify, HTML format/minify, regex tester, GraphQL format |
|
|
@@ -504,7 +518,7 @@ readId3Tags(new Uint8Array(mp3Bytes));
|
|
|
504
518
|
| `@utilix-tech/sdk/css` | CSS gradient, box-shadow, border-radius, keyframe animation generators |
|
|
505
519
|
| `@utilix-tech/sdk/misc` | SVG optimize/sanitize, file size format, Unicode inspector |
|
|
506
520
|
| `@utilix-tech/sdk/ai_agent` | Token estimate/trim, chunk text, extract URLs/JSON/keywords, sanitize HTML, flatten/merge JSON, dedupe lines, validate schema, PII/secret/injection detect |
|
|
507
|
-
| `@utilix-tech/sdk/media` | Image format & dimension reading from raw bytes (PNG, JPEG, GIF, WebP, BMP); PDF metadata reading; WAV audio info |
|
|
521
|
+
| `@utilix-tech/sdk/media` | Image format & dimension reading from raw bytes (PNG, JPEG, GIF, WebP, BMP); PDF metadata reading; WAV audio info; ID3 tags; ICO favicon inspection |
|
|
508
522
|
|
|
509
523
|
---
|
|
510
524
|
|
|
@@ -11,12 +11,14 @@ __export(units_exports, {
|
|
|
11
11
|
COMMON_PERMISSIONS: () => COMMON_PERMISSIONS,
|
|
12
12
|
COMMON_RATIOS: () => COMMON_RATIOS,
|
|
13
13
|
COMMON_SIZES: () => COMMON_SIZES,
|
|
14
|
+
COMMON_TAX_RATES: () => COMMON_TAX_RATES,
|
|
14
15
|
COMMON_VIEWPORTS: () => COMMON_VIEWPORTS,
|
|
15
16
|
autoFormat: () => autoFormat,
|
|
16
17
|
bumpVersion: () => bumpVersion,
|
|
17
18
|
calcAspectRatio: () => calcAspectRatio,
|
|
18
19
|
calcSubnet: () => calcSubnet,
|
|
19
20
|
calculateLoan: () => calculateLoan,
|
|
21
|
+
calculateTax: () => calculateTax,
|
|
20
22
|
compareSemver: () => compareSemver,
|
|
21
23
|
convert: () => convert,
|
|
22
24
|
convertBytes: () => convertBytes,
|
|
@@ -61,6 +63,7 @@ __export(units_exports, {
|
|
|
61
63
|
sortVersions: () => sortVersions,
|
|
62
64
|
splitSubnet: () => splitSubnet,
|
|
63
65
|
symbolicToPermissions: () => symbolicToPermissions,
|
|
66
|
+
validateBarcode: () => validateBarcode,
|
|
64
67
|
validateCardNumber: () => validateCardNumber,
|
|
65
68
|
validateIban: () => validateIban,
|
|
66
69
|
viewportToPx: () => viewportToPx
|
|
@@ -1115,5 +1118,54 @@ function calculateLoan(principal, annualRatePercent, termMonths) {
|
|
|
1115
1118
|
schedule
|
|
1116
1119
|
};
|
|
1117
1120
|
}
|
|
1121
|
+
var BARCODE_FORMAT_BY_LENGTH = { 8: "EAN-8", 12: "UPC-A", 13: "EAN-13" };
|
|
1122
|
+
function computeBarcodeCheckDigit(dataDigits) {
|
|
1123
|
+
let sum = 0;
|
|
1124
|
+
const n = dataDigits.length;
|
|
1125
|
+
for (let i = 0; i < n; i++) {
|
|
1126
|
+
const distanceFromEnd = n - 1 - i;
|
|
1127
|
+
const weight = distanceFromEnd % 2 === 0 ? 3 : 1;
|
|
1128
|
+
sum += dataDigits[i] * weight;
|
|
1129
|
+
}
|
|
1130
|
+
return (10 - sum % 10) % 10;
|
|
1131
|
+
}
|
|
1132
|
+
function validateBarcode(input) {
|
|
1133
|
+
if (!input || !input.trim()) return { error: "Input is empty" };
|
|
1134
|
+
const digits = input.replace(/[\s-]/g, "");
|
|
1135
|
+
if (!/^\d+$/.test(digits)) return { error: "Barcode must contain only digits (spaces and hyphens are ignored)" };
|
|
1136
|
+
const format = BARCODE_FORMAT_BY_LENGTH[digits.length];
|
|
1137
|
+
if (!format) {
|
|
1138
|
+
return { error: `Unsupported barcode length (${digits.length} digits); expected 8 (EAN-8), 12 (UPC-A), or 13 (EAN-13)` };
|
|
1139
|
+
}
|
|
1140
|
+
const dataDigits = digits.slice(0, -1).split("").map(Number);
|
|
1141
|
+
const checkDigit = Number(digits[digits.length - 1]);
|
|
1142
|
+
const expectedCheckDigit = computeBarcodeCheckDigit(dataDigits);
|
|
1143
|
+
return { valid: checkDigit === expectedCheckDigit, format, digits, checkDigit, expectedCheckDigit };
|
|
1144
|
+
}
|
|
1145
|
+
var COMMON_TAX_RATES = [
|
|
1146
|
+
{ country: "US", label: "US (avg. state sales tax)", ratePercent: 7.25 },
|
|
1147
|
+
{ country: "GB", label: "UK VAT (standard)", ratePercent: 20 },
|
|
1148
|
+
{ country: "DE", label: "Germany VAT (standard)", ratePercent: 19 },
|
|
1149
|
+
{ country: "FR", label: "France VAT (standard)", ratePercent: 20 },
|
|
1150
|
+
{ country: "CA", label: "Canada GST", ratePercent: 5 },
|
|
1151
|
+
{ country: "AU", label: "Australia GST", ratePercent: 10 },
|
|
1152
|
+
{ country: "IN", label: "India GST (standard)", ratePercent: 18 },
|
|
1153
|
+
{ country: "JP", label: "Japan consumption tax", ratePercent: 10 }
|
|
1154
|
+
];
|
|
1155
|
+
function calculateTax(amount, ratePercent, direction) {
|
|
1156
|
+
if (!Number.isFinite(amount) || amount < 0) return { error: "Amount must be zero or a positive number" };
|
|
1157
|
+
if (!Number.isFinite(ratePercent) || ratePercent < 0) return { error: "Tax rate must be zero or a positive number" };
|
|
1158
|
+
if (direction !== "add" && direction !== "remove") return { error: 'Direction must be "add" or "remove"' };
|
|
1159
|
+
const round22 = (n) => Math.round(n * 100) / 100;
|
|
1160
|
+
if (direction === "add") {
|
|
1161
|
+
const netAmount2 = round22(amount);
|
|
1162
|
+
const taxAmount2 = round22(amount * (ratePercent / 100));
|
|
1163
|
+
return { netAmount: netAmount2, taxAmount: taxAmount2, grossAmount: round22(netAmount2 + taxAmount2), ratePercent, direction };
|
|
1164
|
+
}
|
|
1165
|
+
const grossAmount = round22(amount);
|
|
1166
|
+
const netAmount = round22(amount / (1 + ratePercent / 100));
|
|
1167
|
+
const taxAmount = round22(grossAmount - netAmount);
|
|
1168
|
+
return { netAmount, taxAmount, grossAmount, ratePercent, direction };
|
|
1169
|
+
}
|
|
1118
1170
|
|
|
1119
|
-
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_VIEWPORTS, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateLoan, compareSemver, convert, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, units_exports, validateCardNumber, validateIban, viewportToPx };
|
|
1171
|
+
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_VIEWPORTS, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateLoan, calculateTax, compareSemver, convert, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, units_exports, validateBarcode, validateCardNumber, validateIban, viewportToPx };
|
|
@@ -4,6 +4,7 @@ import { __export } from './chunk-MLKGABMK.js';
|
|
|
4
4
|
var media_exports = {};
|
|
5
5
|
__export(media_exports, {
|
|
6
6
|
readExifData: () => readExifData,
|
|
7
|
+
readIcoInfo: () => readIcoInfo,
|
|
7
8
|
readId3Tags: () => readId3Tags,
|
|
8
9
|
readImageInfo: () => readImageInfo,
|
|
9
10
|
readPdfMetadata: () => readPdfMetadata,
|
|
@@ -730,5 +731,38 @@ function readId3Tags(bytes) {
|
|
|
730
731
|
}
|
|
731
732
|
return { error: "No ID3v1 or ID3v2.3/2.4 tags found in this file" };
|
|
732
733
|
}
|
|
734
|
+
function readU16LE(bytes, offset) {
|
|
735
|
+
return bytes[offset] | bytes[offset + 1] << 8;
|
|
736
|
+
}
|
|
737
|
+
function readU32LE(bytes, offset) {
|
|
738
|
+
return (bytes[offset] | bytes[offset + 1] << 8 | bytes[offset + 2] << 16 | bytes[offset + 3] << 24) >>> 0;
|
|
739
|
+
}
|
|
740
|
+
function readIcoInfo(bytes) {
|
|
741
|
+
if (bytes.length < 6) return { error: "File too small to be a valid ICO file" };
|
|
742
|
+
if (readU16LE(bytes, 0) !== 0) return { error: "Not a valid ICO file (reserved header field must be 0)" };
|
|
743
|
+
const type = readU16LE(bytes, 2);
|
|
744
|
+
if (type === 2) return { error: "This is a .cur cursor file (type 2), not a .ico icon file" };
|
|
745
|
+
if (type !== 1) return { error: `Unrecognized ICONDIR type (${type}); expected 1 for an icon file` };
|
|
746
|
+
const count = readU16LE(bytes, 4);
|
|
747
|
+
if (count === 0) return { error: "ICO file declares zero embedded images" };
|
|
748
|
+
const images = [];
|
|
749
|
+
for (let i = 0; i < count; i++) {
|
|
750
|
+
const offset = 6 + i * 16;
|
|
751
|
+
if (offset + 16 > bytes.length) return { error: `Truncated ICONDIRENTRY for image ${i}` };
|
|
752
|
+
const widthRaw = bytes[offset];
|
|
753
|
+
const heightRaw = bytes[offset + 1];
|
|
754
|
+
const colorCountRaw = bytes[offset + 2];
|
|
755
|
+
images.push({
|
|
756
|
+
width: widthRaw === 0 ? 256 : widthRaw,
|
|
757
|
+
height: heightRaw === 0 ? 256 : heightRaw,
|
|
758
|
+
colorCount: colorCountRaw === 0 ? null : colorCountRaw,
|
|
759
|
+
planes: readU16LE(bytes, offset + 4),
|
|
760
|
+
bitCount: readU16LE(bytes, offset + 6),
|
|
761
|
+
bytesInRes: readU32LE(bytes, offset + 8),
|
|
762
|
+
imageOffset: readU32LE(bytes, offset + 12)
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
return { imageCount: count, images };
|
|
766
|
+
}
|
|
733
767
|
|
|
734
|
-
export { media_exports, readExifData, readId3Tags, readImageInfo, readPdfMetadata, readWavInfo };
|
|
768
|
+
export { media_exports, readExifData, readIcoInfo, readId3Tags, readImageInfo, readPdfMetadata, readWavInfo };
|
package/dist/index.cjs
CHANGED
|
@@ -6616,12 +6616,14 @@ __export(units_exports, {
|
|
|
6616
6616
|
COMMON_PERMISSIONS: () => COMMON_PERMISSIONS,
|
|
6617
6617
|
COMMON_RATIOS: () => COMMON_RATIOS,
|
|
6618
6618
|
COMMON_SIZES: () => COMMON_SIZES,
|
|
6619
|
+
COMMON_TAX_RATES: () => COMMON_TAX_RATES,
|
|
6619
6620
|
COMMON_VIEWPORTS: () => COMMON_VIEWPORTS,
|
|
6620
6621
|
autoFormat: () => autoFormat,
|
|
6621
6622
|
bumpVersion: () => bumpVersion,
|
|
6622
6623
|
calcAspectRatio: () => calcAspectRatio,
|
|
6623
6624
|
calcSubnet: () => calcSubnet,
|
|
6624
6625
|
calculateLoan: () => calculateLoan,
|
|
6626
|
+
calculateTax: () => calculateTax,
|
|
6625
6627
|
compareSemver: () => compareSemver,
|
|
6626
6628
|
convert: () => convert,
|
|
6627
6629
|
convertBytes: () => convertBytes,
|
|
@@ -6666,6 +6668,7 @@ __export(units_exports, {
|
|
|
6666
6668
|
sortVersions: () => sortVersions,
|
|
6667
6669
|
splitSubnet: () => splitSubnet,
|
|
6668
6670
|
symbolicToPermissions: () => symbolicToPermissions,
|
|
6671
|
+
validateBarcode: () => validateBarcode,
|
|
6669
6672
|
validateCardNumber: () => validateCardNumber,
|
|
6670
6673
|
validateIban: () => validateIban,
|
|
6671
6674
|
viewportToPx: () => viewportToPx
|
|
@@ -7720,6 +7723,55 @@ function calculateLoan(principal, annualRatePercent, termMonths) {
|
|
|
7720
7723
|
schedule
|
|
7721
7724
|
};
|
|
7722
7725
|
}
|
|
7726
|
+
var BARCODE_FORMAT_BY_LENGTH = { 8: "EAN-8", 12: "UPC-A", 13: "EAN-13" };
|
|
7727
|
+
function computeBarcodeCheckDigit(dataDigits) {
|
|
7728
|
+
let sum = 0;
|
|
7729
|
+
const n = dataDigits.length;
|
|
7730
|
+
for (let i = 0; i < n; i++) {
|
|
7731
|
+
const distanceFromEnd = n - 1 - i;
|
|
7732
|
+
const weight = distanceFromEnd % 2 === 0 ? 3 : 1;
|
|
7733
|
+
sum += dataDigits[i] * weight;
|
|
7734
|
+
}
|
|
7735
|
+
return (10 - sum % 10) % 10;
|
|
7736
|
+
}
|
|
7737
|
+
function validateBarcode(input) {
|
|
7738
|
+
if (!input || !input.trim()) return { error: "Input is empty" };
|
|
7739
|
+
const digits = input.replace(/[\s-]/g, "");
|
|
7740
|
+
if (!/^\d+$/.test(digits)) return { error: "Barcode must contain only digits (spaces and hyphens are ignored)" };
|
|
7741
|
+
const format = BARCODE_FORMAT_BY_LENGTH[digits.length];
|
|
7742
|
+
if (!format) {
|
|
7743
|
+
return { error: `Unsupported barcode length (${digits.length} digits); expected 8 (EAN-8), 12 (UPC-A), or 13 (EAN-13)` };
|
|
7744
|
+
}
|
|
7745
|
+
const dataDigits = digits.slice(0, -1).split("").map(Number);
|
|
7746
|
+
const checkDigit = Number(digits[digits.length - 1]);
|
|
7747
|
+
const expectedCheckDigit = computeBarcodeCheckDigit(dataDigits);
|
|
7748
|
+
return { valid: checkDigit === expectedCheckDigit, format, digits, checkDigit, expectedCheckDigit };
|
|
7749
|
+
}
|
|
7750
|
+
var COMMON_TAX_RATES = [
|
|
7751
|
+
{ country: "US", label: "US (avg. state sales tax)", ratePercent: 7.25 },
|
|
7752
|
+
{ country: "GB", label: "UK VAT (standard)", ratePercent: 20 },
|
|
7753
|
+
{ country: "DE", label: "Germany VAT (standard)", ratePercent: 19 },
|
|
7754
|
+
{ country: "FR", label: "France VAT (standard)", ratePercent: 20 },
|
|
7755
|
+
{ country: "CA", label: "Canada GST", ratePercent: 5 },
|
|
7756
|
+
{ country: "AU", label: "Australia GST", ratePercent: 10 },
|
|
7757
|
+
{ country: "IN", label: "India GST (standard)", ratePercent: 18 },
|
|
7758
|
+
{ country: "JP", label: "Japan consumption tax", ratePercent: 10 }
|
|
7759
|
+
];
|
|
7760
|
+
function calculateTax(amount, ratePercent, direction) {
|
|
7761
|
+
if (!Number.isFinite(amount) || amount < 0) return { error: "Amount must be zero or a positive number" };
|
|
7762
|
+
if (!Number.isFinite(ratePercent) || ratePercent < 0) return { error: "Tax rate must be zero or a positive number" };
|
|
7763
|
+
if (direction !== "add" && direction !== "remove") return { error: 'Direction must be "add" or "remove"' };
|
|
7764
|
+
const round23 = (n) => Math.round(n * 100) / 100;
|
|
7765
|
+
if (direction === "add") {
|
|
7766
|
+
const netAmount2 = round23(amount);
|
|
7767
|
+
const taxAmount2 = round23(amount * (ratePercent / 100));
|
|
7768
|
+
return { netAmount: netAmount2, taxAmount: taxAmount2, grossAmount: round23(netAmount2 + taxAmount2), ratePercent, direction };
|
|
7769
|
+
}
|
|
7770
|
+
const grossAmount = round23(amount);
|
|
7771
|
+
const netAmount = round23(amount / (1 + ratePercent / 100));
|
|
7772
|
+
const taxAmount = round23(grossAmount - netAmount);
|
|
7773
|
+
return { netAmount, taxAmount, grossAmount, ratePercent, direction };
|
|
7774
|
+
}
|
|
7723
7775
|
|
|
7724
7776
|
// src/tools/network.ts
|
|
7725
7777
|
var network_exports = {};
|
|
@@ -17413,6 +17465,7 @@ function summarizeForLlm(text, maxTokens = 200, strategy = "extractive") {
|
|
|
17413
17465
|
var media_exports = {};
|
|
17414
17466
|
__export(media_exports, {
|
|
17415
17467
|
readExifData: () => readExifData,
|
|
17468
|
+
readIcoInfo: () => readIcoInfo,
|
|
17416
17469
|
readId3Tags: () => readId3Tags,
|
|
17417
17470
|
readImageInfo: () => readImageInfo,
|
|
17418
17471
|
readPdfMetadata: () => readPdfMetadata,
|
|
@@ -18139,6 +18192,39 @@ function readId3Tags(bytes) {
|
|
|
18139
18192
|
}
|
|
18140
18193
|
return { error: "No ID3v1 or ID3v2.3/2.4 tags found in this file" };
|
|
18141
18194
|
}
|
|
18195
|
+
function readU16LE(bytes, offset) {
|
|
18196
|
+
return bytes[offset] | bytes[offset + 1] << 8;
|
|
18197
|
+
}
|
|
18198
|
+
function readU32LE(bytes, offset) {
|
|
18199
|
+
return (bytes[offset] | bytes[offset + 1] << 8 | bytes[offset + 2] << 16 | bytes[offset + 3] << 24) >>> 0;
|
|
18200
|
+
}
|
|
18201
|
+
function readIcoInfo(bytes) {
|
|
18202
|
+
if (bytes.length < 6) return { error: "File too small to be a valid ICO file" };
|
|
18203
|
+
if (readU16LE(bytes, 0) !== 0) return { error: "Not a valid ICO file (reserved header field must be 0)" };
|
|
18204
|
+
const type = readU16LE(bytes, 2);
|
|
18205
|
+
if (type === 2) return { error: "This is a .cur cursor file (type 2), not a .ico icon file" };
|
|
18206
|
+
if (type !== 1) return { error: `Unrecognized ICONDIR type (${type}); expected 1 for an icon file` };
|
|
18207
|
+
const count = readU16LE(bytes, 4);
|
|
18208
|
+
if (count === 0) return { error: "ICO file declares zero embedded images" };
|
|
18209
|
+
const images = [];
|
|
18210
|
+
for (let i = 0; i < count; i++) {
|
|
18211
|
+
const offset = 6 + i * 16;
|
|
18212
|
+
if (offset + 16 > bytes.length) return { error: `Truncated ICONDIRENTRY for image ${i}` };
|
|
18213
|
+
const widthRaw = bytes[offset];
|
|
18214
|
+
const heightRaw = bytes[offset + 1];
|
|
18215
|
+
const colorCountRaw = bytes[offset + 2];
|
|
18216
|
+
images.push({
|
|
18217
|
+
width: widthRaw === 0 ? 256 : widthRaw,
|
|
18218
|
+
height: heightRaw === 0 ? 256 : heightRaw,
|
|
18219
|
+
colorCount: colorCountRaw === 0 ? null : colorCountRaw,
|
|
18220
|
+
planes: readU16LE(bytes, offset + 4),
|
|
18221
|
+
bitCount: readU16LE(bytes, offset + 6),
|
|
18222
|
+
bytesInRes: readU32LE(bytes, offset + 8),
|
|
18223
|
+
imageOffset: readU32LE(bytes, offset + 12)
|
|
18224
|
+
});
|
|
18225
|
+
}
|
|
18226
|
+
return { imageCount: count, images };
|
|
18227
|
+
}
|
|
18142
18228
|
|
|
18143
18229
|
// src/index.ts
|
|
18144
18230
|
var version = "0.1.0";
|
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ export { t as text } from './text-Bbx-tZ43.cjs';
|
|
|
5
5
|
export { d as data } from './data-D8XTI7Du.cjs';
|
|
6
6
|
export { g as generators } from './generators-BGtRGpJZ.cjs';
|
|
7
7
|
export { t as time } from './time-DbT8fjaF.cjs';
|
|
8
|
-
export { u as units } from './units-
|
|
8
|
+
export { u as units } from './units-CKS5W_ih.cjs';
|
|
9
9
|
export { n as network } from './network-DaNoZ5ER.cjs';
|
|
10
10
|
export { a as api } from './api-Xl7OzIgq.cjs';
|
|
11
11
|
export { c as code } from './code-BUqyaofO.cjs';
|
|
@@ -13,7 +13,7 @@ export { c as color } from './color-tPwZCr9H.cjs';
|
|
|
13
13
|
export { c as css } from './css-Cf7AMGM-.cjs';
|
|
14
14
|
export { m as misc } from './misc-CA3N198T.cjs';
|
|
15
15
|
export { a as ai_agent } from './ai_agent-CcpkV2DR.cjs';
|
|
16
|
-
export { m as media } from './media-
|
|
16
|
+
export { m as media } from './media-9HEpTPGA.cjs';
|
|
17
17
|
|
|
18
18
|
declare const version = "0.1.0";
|
|
19
19
|
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { t as text } from './text-Bbx-tZ43.js';
|
|
|
5
5
|
export { d as data } from './data-D8XTI7Du.js';
|
|
6
6
|
export { g as generators } from './generators-BGtRGpJZ.js';
|
|
7
7
|
export { t as time } from './time-DbT8fjaF.js';
|
|
8
|
-
export { u as units } from './units-
|
|
8
|
+
export { u as units } from './units-CKS5W_ih.js';
|
|
9
9
|
export { n as network } from './network-DaNoZ5ER.js';
|
|
10
10
|
export { a as api } from './api-Xl7OzIgq.js';
|
|
11
11
|
export { c as code } from './code-BUqyaofO.js';
|
|
@@ -13,7 +13,7 @@ export { c as color } from './color-tPwZCr9H.js';
|
|
|
13
13
|
export { c as css } from './css-Cf7AMGM-.js';
|
|
14
14
|
export { m as misc } from './misc-CA3N198T.js';
|
|
15
15
|
export { a as ai_agent } from './ai_agent-CcpkV2DR.js';
|
|
16
|
-
export { m as media } from './media-
|
|
16
|
+
export { m as media } from './media-9HEpTPGA.js';
|
|
17
17
|
|
|
18
18
|
declare const version = "0.1.0";
|
|
19
19
|
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { media_exports as media } from './chunk-
|
|
2
|
-
export { units_exports as units } from './chunk-
|
|
1
|
+
export { media_exports as media } from './chunk-XMKJYVKB.js';
|
|
2
|
+
export { units_exports as units } from './chunk-BI3SOWM7.js';
|
|
3
3
|
export { network_exports as network } from './chunk-OB56VNKJ.js';
|
|
4
4
|
export { api_exports as api } from './chunk-Q3B3YWOA.js';
|
|
5
5
|
export { code_exports as code } from './chunk-V5S6OJ4A.js';
|
|
@@ -108,9 +108,35 @@ interface Id3TagsError {
|
|
|
108
108
|
* ID3v2.2 tags are detected but their 3-character frame IDs are not decoded.
|
|
109
109
|
*/
|
|
110
110
|
declare function readId3Tags(bytes: Uint8Array): Id3Tags | Id3TagsError;
|
|
111
|
+
interface IcoImageEntry {
|
|
112
|
+
width: number;
|
|
113
|
+
height: number;
|
|
114
|
+
colorCount: number | null;
|
|
115
|
+
planes: number;
|
|
116
|
+
bitCount: number;
|
|
117
|
+
bytesInRes: number;
|
|
118
|
+
imageOffset: number;
|
|
119
|
+
}
|
|
120
|
+
interface IcoInfo {
|
|
121
|
+
imageCount: number;
|
|
122
|
+
images: IcoImageEntry[];
|
|
123
|
+
}
|
|
124
|
+
interface IcoInfoError {
|
|
125
|
+
error: string;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Read a .ico file's ICONDIR/ICONDIRENTRY header table to report how many
|
|
129
|
+
* images it embeds and each one's width, height, color depth, and size,
|
|
130
|
+
* without decoding any pixel data. Rejects .cur cursor files, which share
|
|
131
|
+
* the same container format but a different type flag.
|
|
132
|
+
*/
|
|
133
|
+
declare function readIcoInfo(bytes: Uint8Array): IcoInfo | IcoInfoError;
|
|
111
134
|
|
|
112
135
|
type media_ExifData = ExifData;
|
|
113
136
|
type media_ExifError = ExifError;
|
|
137
|
+
type media_IcoImageEntry = IcoImageEntry;
|
|
138
|
+
type media_IcoInfo = IcoInfo;
|
|
139
|
+
type media_IcoInfoError = IcoInfoError;
|
|
114
140
|
type media_Id3Tags = Id3Tags;
|
|
115
141
|
type media_Id3TagsError = Id3TagsError;
|
|
116
142
|
type media_ImageFormat = ImageFormat;
|
|
@@ -121,12 +147,13 @@ type media_PdfMetadataError = PdfMetadataError;
|
|
|
121
147
|
type media_WavInfo = WavInfo;
|
|
122
148
|
type media_WavInfoError = WavInfoError;
|
|
123
149
|
declare const media_readExifData: typeof readExifData;
|
|
150
|
+
declare const media_readIcoInfo: typeof readIcoInfo;
|
|
124
151
|
declare const media_readId3Tags: typeof readId3Tags;
|
|
125
152
|
declare const media_readImageInfo: typeof readImageInfo;
|
|
126
153
|
declare const media_readPdfMetadata: typeof readPdfMetadata;
|
|
127
154
|
declare const media_readWavInfo: typeof readWavInfo;
|
|
128
155
|
declare namespace media {
|
|
129
|
-
export { type media_ExifData as ExifData, type media_ExifError as ExifError, type media_Id3Tags as Id3Tags, type media_Id3TagsError as Id3TagsError, type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, type media_PdfMetadata as PdfMetadata, type media_PdfMetadataError as PdfMetadataError, type media_WavInfo as WavInfo, type media_WavInfoError as WavInfoError, media_readExifData as readExifData, media_readId3Tags as readId3Tags, media_readImageInfo as readImageInfo, media_readPdfMetadata as readPdfMetadata, media_readWavInfo as readWavInfo };
|
|
156
|
+
export { type media_ExifData as ExifData, type media_ExifError as ExifError, type media_IcoImageEntry as IcoImageEntry, type media_IcoInfo as IcoInfo, type media_IcoInfoError as IcoInfoError, type media_Id3Tags as Id3Tags, type media_Id3TagsError as Id3TagsError, type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, type media_PdfMetadata as PdfMetadata, type media_PdfMetadataError as PdfMetadataError, type media_WavInfo as WavInfo, type media_WavInfoError as WavInfoError, media_readExifData as readExifData, media_readIcoInfo as readIcoInfo, media_readId3Tags as readId3Tags, media_readImageInfo as readImageInfo, media_readPdfMetadata as readPdfMetadata, media_readWavInfo as readWavInfo };
|
|
130
157
|
}
|
|
131
158
|
|
|
132
|
-
export { type ExifData as E, type
|
|
159
|
+
export { type ExifData as E, type IcoImageEntry as I, type PdfMetadata as P, type WavInfo as W, type ExifError as a, type IcoInfo as b, type IcoInfoError as c, type Id3Tags as d, type Id3TagsError as e, type ImageFormat as f, type ImageInfo as g, type ImageInfoError as h, type PdfMetadataError as i, type WavInfoError as j, readIcoInfo as k, readId3Tags as l, media as m, readImageInfo as n, readPdfMetadata as o, readWavInfo as p, readExifData as r };
|
|
@@ -108,9 +108,35 @@ interface Id3TagsError {
|
|
|
108
108
|
* ID3v2.2 tags are detected but their 3-character frame IDs are not decoded.
|
|
109
109
|
*/
|
|
110
110
|
declare function readId3Tags(bytes: Uint8Array): Id3Tags | Id3TagsError;
|
|
111
|
+
interface IcoImageEntry {
|
|
112
|
+
width: number;
|
|
113
|
+
height: number;
|
|
114
|
+
colorCount: number | null;
|
|
115
|
+
planes: number;
|
|
116
|
+
bitCount: number;
|
|
117
|
+
bytesInRes: number;
|
|
118
|
+
imageOffset: number;
|
|
119
|
+
}
|
|
120
|
+
interface IcoInfo {
|
|
121
|
+
imageCount: number;
|
|
122
|
+
images: IcoImageEntry[];
|
|
123
|
+
}
|
|
124
|
+
interface IcoInfoError {
|
|
125
|
+
error: string;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Read a .ico file's ICONDIR/ICONDIRENTRY header table to report how many
|
|
129
|
+
* images it embeds and each one's width, height, color depth, and size,
|
|
130
|
+
* without decoding any pixel data. Rejects .cur cursor files, which share
|
|
131
|
+
* the same container format but a different type flag.
|
|
132
|
+
*/
|
|
133
|
+
declare function readIcoInfo(bytes: Uint8Array): IcoInfo | IcoInfoError;
|
|
111
134
|
|
|
112
135
|
type media_ExifData = ExifData;
|
|
113
136
|
type media_ExifError = ExifError;
|
|
137
|
+
type media_IcoImageEntry = IcoImageEntry;
|
|
138
|
+
type media_IcoInfo = IcoInfo;
|
|
139
|
+
type media_IcoInfoError = IcoInfoError;
|
|
114
140
|
type media_Id3Tags = Id3Tags;
|
|
115
141
|
type media_Id3TagsError = Id3TagsError;
|
|
116
142
|
type media_ImageFormat = ImageFormat;
|
|
@@ -121,12 +147,13 @@ type media_PdfMetadataError = PdfMetadataError;
|
|
|
121
147
|
type media_WavInfo = WavInfo;
|
|
122
148
|
type media_WavInfoError = WavInfoError;
|
|
123
149
|
declare const media_readExifData: typeof readExifData;
|
|
150
|
+
declare const media_readIcoInfo: typeof readIcoInfo;
|
|
124
151
|
declare const media_readId3Tags: typeof readId3Tags;
|
|
125
152
|
declare const media_readImageInfo: typeof readImageInfo;
|
|
126
153
|
declare const media_readPdfMetadata: typeof readPdfMetadata;
|
|
127
154
|
declare const media_readWavInfo: typeof readWavInfo;
|
|
128
155
|
declare namespace media {
|
|
129
|
-
export { type media_ExifData as ExifData, type media_ExifError as ExifError, type media_Id3Tags as Id3Tags, type media_Id3TagsError as Id3TagsError, type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, type media_PdfMetadata as PdfMetadata, type media_PdfMetadataError as PdfMetadataError, type media_WavInfo as WavInfo, type media_WavInfoError as WavInfoError, media_readExifData as readExifData, media_readId3Tags as readId3Tags, media_readImageInfo as readImageInfo, media_readPdfMetadata as readPdfMetadata, media_readWavInfo as readWavInfo };
|
|
156
|
+
export { type media_ExifData as ExifData, type media_ExifError as ExifError, type media_IcoImageEntry as IcoImageEntry, type media_IcoInfo as IcoInfo, type media_IcoInfoError as IcoInfoError, type media_Id3Tags as Id3Tags, type media_Id3TagsError as Id3TagsError, type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, type media_PdfMetadata as PdfMetadata, type media_PdfMetadataError as PdfMetadataError, type media_WavInfo as WavInfo, type media_WavInfoError as WavInfoError, media_readExifData as readExifData, media_readIcoInfo as readIcoInfo, media_readId3Tags as readId3Tags, media_readImageInfo as readImageInfo, media_readPdfMetadata as readPdfMetadata, media_readWavInfo as readWavInfo };
|
|
130
157
|
}
|
|
131
158
|
|
|
132
|
-
export { type ExifData as E, type
|
|
159
|
+
export { type ExifData as E, type IcoImageEntry as I, type PdfMetadata as P, type WavInfo as W, type ExifError as a, type IcoInfo as b, type IcoInfoError as c, type Id3Tags as d, type Id3TagsError as e, type ImageFormat as f, type ImageInfo as g, type ImageInfoError as h, type PdfMetadataError as i, type WavInfoError as j, readIcoInfo as k, readId3Tags as l, media as m, readImageInfo as n, readPdfMetadata as o, readWavInfo as p, readExifData as r };
|
package/dist/tools/media.cjs
CHANGED
|
@@ -722,8 +722,42 @@ function readId3Tags(bytes) {
|
|
|
722
722
|
}
|
|
723
723
|
return { error: "No ID3v1 or ID3v2.3/2.4 tags found in this file" };
|
|
724
724
|
}
|
|
725
|
+
function readU16LE(bytes, offset) {
|
|
726
|
+
return bytes[offset] | bytes[offset + 1] << 8;
|
|
727
|
+
}
|
|
728
|
+
function readU32LE(bytes, offset) {
|
|
729
|
+
return (bytes[offset] | bytes[offset + 1] << 8 | bytes[offset + 2] << 16 | bytes[offset + 3] << 24) >>> 0;
|
|
730
|
+
}
|
|
731
|
+
function readIcoInfo(bytes) {
|
|
732
|
+
if (bytes.length < 6) return { error: "File too small to be a valid ICO file" };
|
|
733
|
+
if (readU16LE(bytes, 0) !== 0) return { error: "Not a valid ICO file (reserved header field must be 0)" };
|
|
734
|
+
const type = readU16LE(bytes, 2);
|
|
735
|
+
if (type === 2) return { error: "This is a .cur cursor file (type 2), not a .ico icon file" };
|
|
736
|
+
if (type !== 1) return { error: `Unrecognized ICONDIR type (${type}); expected 1 for an icon file` };
|
|
737
|
+
const count = readU16LE(bytes, 4);
|
|
738
|
+
if (count === 0) return { error: "ICO file declares zero embedded images" };
|
|
739
|
+
const images = [];
|
|
740
|
+
for (let i = 0; i < count; i++) {
|
|
741
|
+
const offset = 6 + i * 16;
|
|
742
|
+
if (offset + 16 > bytes.length) return { error: `Truncated ICONDIRENTRY for image ${i}` };
|
|
743
|
+
const widthRaw = bytes[offset];
|
|
744
|
+
const heightRaw = bytes[offset + 1];
|
|
745
|
+
const colorCountRaw = bytes[offset + 2];
|
|
746
|
+
images.push({
|
|
747
|
+
width: widthRaw === 0 ? 256 : widthRaw,
|
|
748
|
+
height: heightRaw === 0 ? 256 : heightRaw,
|
|
749
|
+
colorCount: colorCountRaw === 0 ? null : colorCountRaw,
|
|
750
|
+
planes: readU16LE(bytes, offset + 4),
|
|
751
|
+
bitCount: readU16LE(bytes, offset + 6),
|
|
752
|
+
bytesInRes: readU32LE(bytes, offset + 8),
|
|
753
|
+
imageOffset: readU32LE(bytes, offset + 12)
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
return { imageCount: count, images };
|
|
757
|
+
}
|
|
725
758
|
|
|
726
759
|
exports.readExifData = readExifData;
|
|
760
|
+
exports.readIcoInfo = readIcoInfo;
|
|
727
761
|
exports.readId3Tags = readId3Tags;
|
|
728
762
|
exports.readImageInfo = readImageInfo;
|
|
729
763
|
exports.readPdfMetadata = readPdfMetadata;
|
package/dist/tools/media.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { E as ExifData, a as ExifError, I as
|
|
1
|
+
export { E as ExifData, a as ExifError, I as IcoImageEntry, b as IcoInfo, c as IcoInfoError, d as Id3Tags, e as Id3TagsError, f as ImageFormat, g as ImageInfo, h as ImageInfoError, P as PdfMetadata, i as PdfMetadataError, W as WavInfo, j as WavInfoError, r as readExifData, k as readIcoInfo, l as readId3Tags, n as readImageInfo, o as readPdfMetadata, p as readWavInfo } from '../media-9HEpTPGA.cjs';
|
package/dist/tools/media.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { E as ExifData, a as ExifError, I as
|
|
1
|
+
export { E as ExifData, a as ExifError, I as IcoImageEntry, b as IcoInfo, c as IcoInfoError, d as Id3Tags, e as Id3TagsError, f as ImageFormat, g as ImageInfo, h as ImageInfoError, P as PdfMetadata, i as PdfMetadataError, W as WavInfo, j as WavInfoError, r as readExifData, k as readIcoInfo, l as readId3Tags, n as readImageInfo, o as readPdfMetadata, p as readWavInfo } from '../media-9HEpTPGA.js';
|
package/dist/tools/media.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { readExifData, readId3Tags, readImageInfo, readPdfMetadata, readWavInfo } from '../chunk-
|
|
1
|
+
export { readExifData, readIcoInfo, readId3Tags, readImageInfo, readPdfMetadata, readWavInfo } from '../chunk-XMKJYVKB.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
package/dist/tools/units.cjs
CHANGED
|
@@ -1051,6 +1051,55 @@ function calculateLoan(principal, annualRatePercent, termMonths) {
|
|
|
1051
1051
|
schedule
|
|
1052
1052
|
};
|
|
1053
1053
|
}
|
|
1054
|
+
var BARCODE_FORMAT_BY_LENGTH = { 8: "EAN-8", 12: "UPC-A", 13: "EAN-13" };
|
|
1055
|
+
function computeBarcodeCheckDigit(dataDigits) {
|
|
1056
|
+
let sum = 0;
|
|
1057
|
+
const n = dataDigits.length;
|
|
1058
|
+
for (let i = 0; i < n; i++) {
|
|
1059
|
+
const distanceFromEnd = n - 1 - i;
|
|
1060
|
+
const weight = distanceFromEnd % 2 === 0 ? 3 : 1;
|
|
1061
|
+
sum += dataDigits[i] * weight;
|
|
1062
|
+
}
|
|
1063
|
+
return (10 - sum % 10) % 10;
|
|
1064
|
+
}
|
|
1065
|
+
function validateBarcode(input) {
|
|
1066
|
+
if (!input || !input.trim()) return { error: "Input is empty" };
|
|
1067
|
+
const digits = input.replace(/[\s-]/g, "");
|
|
1068
|
+
if (!/^\d+$/.test(digits)) return { error: "Barcode must contain only digits (spaces and hyphens are ignored)" };
|
|
1069
|
+
const format = BARCODE_FORMAT_BY_LENGTH[digits.length];
|
|
1070
|
+
if (!format) {
|
|
1071
|
+
return { error: `Unsupported barcode length (${digits.length} digits); expected 8 (EAN-8), 12 (UPC-A), or 13 (EAN-13)` };
|
|
1072
|
+
}
|
|
1073
|
+
const dataDigits = digits.slice(0, -1).split("").map(Number);
|
|
1074
|
+
const checkDigit = Number(digits[digits.length - 1]);
|
|
1075
|
+
const expectedCheckDigit = computeBarcodeCheckDigit(dataDigits);
|
|
1076
|
+
return { valid: checkDigit === expectedCheckDigit, format, digits, checkDigit, expectedCheckDigit };
|
|
1077
|
+
}
|
|
1078
|
+
var COMMON_TAX_RATES = [
|
|
1079
|
+
{ country: "US", label: "US (avg. state sales tax)", ratePercent: 7.25 },
|
|
1080
|
+
{ country: "GB", label: "UK VAT (standard)", ratePercent: 20 },
|
|
1081
|
+
{ country: "DE", label: "Germany VAT (standard)", ratePercent: 19 },
|
|
1082
|
+
{ country: "FR", label: "France VAT (standard)", ratePercent: 20 },
|
|
1083
|
+
{ country: "CA", label: "Canada GST", ratePercent: 5 },
|
|
1084
|
+
{ country: "AU", label: "Australia GST", ratePercent: 10 },
|
|
1085
|
+
{ country: "IN", label: "India GST (standard)", ratePercent: 18 },
|
|
1086
|
+
{ country: "JP", label: "Japan consumption tax", ratePercent: 10 }
|
|
1087
|
+
];
|
|
1088
|
+
function calculateTax(amount, ratePercent, direction) {
|
|
1089
|
+
if (!Number.isFinite(amount) || amount < 0) return { error: "Amount must be zero or a positive number" };
|
|
1090
|
+
if (!Number.isFinite(ratePercent) || ratePercent < 0) return { error: "Tax rate must be zero or a positive number" };
|
|
1091
|
+
if (direction !== "add" && direction !== "remove") return { error: 'Direction must be "add" or "remove"' };
|
|
1092
|
+
const round22 = (n) => Math.round(n * 100) / 100;
|
|
1093
|
+
if (direction === "add") {
|
|
1094
|
+
const netAmount2 = round22(amount);
|
|
1095
|
+
const taxAmount2 = round22(amount * (ratePercent / 100));
|
|
1096
|
+
return { netAmount: netAmount2, taxAmount: taxAmount2, grossAmount: round22(netAmount2 + taxAmount2), ratePercent, direction };
|
|
1097
|
+
}
|
|
1098
|
+
const grossAmount = round22(amount);
|
|
1099
|
+
const netAmount = round22(amount / (1 + ratePercent / 100));
|
|
1100
|
+
const taxAmount = round22(grossAmount - netAmount);
|
|
1101
|
+
return { netAmount, taxAmount, grossAmount, ratePercent, direction };
|
|
1102
|
+
}
|
|
1054
1103
|
|
|
1055
1104
|
exports.BASE_LABELS = BASE_LABELS;
|
|
1056
1105
|
exports.BASE_PREFIXES = BASE_PREFIXES;
|
|
@@ -1060,12 +1109,14 @@ exports.COMMON_LOCALES = COMMON_LOCALES;
|
|
|
1060
1109
|
exports.COMMON_PERMISSIONS = COMMON_PERMISSIONS;
|
|
1061
1110
|
exports.COMMON_RATIOS = COMMON_RATIOS;
|
|
1062
1111
|
exports.COMMON_SIZES = COMMON_SIZES;
|
|
1112
|
+
exports.COMMON_TAX_RATES = COMMON_TAX_RATES;
|
|
1063
1113
|
exports.COMMON_VIEWPORTS = COMMON_VIEWPORTS;
|
|
1064
1114
|
exports.autoFormat = autoFormat;
|
|
1065
1115
|
exports.bumpVersion = bumpVersion;
|
|
1066
1116
|
exports.calcAspectRatio = calcAspectRatio;
|
|
1067
1117
|
exports.calcSubnet = calcSubnet;
|
|
1068
1118
|
exports.calculateLoan = calculateLoan;
|
|
1119
|
+
exports.calculateTax = calculateTax;
|
|
1069
1120
|
exports.compareSemver = compareSemver;
|
|
1070
1121
|
exports.convert = convert;
|
|
1071
1122
|
exports.convertBytes = convertBytes;
|
|
@@ -1110,6 +1161,7 @@ exports.scaleByWidth = scaleByWidth;
|
|
|
1110
1161
|
exports.sortVersions = sortVersions;
|
|
1111
1162
|
exports.splitSubnet = splitSubnet;
|
|
1112
1163
|
exports.symbolicToPermissions = symbolicToPermissions;
|
|
1164
|
+
exports.validateBarcode = validateBarcode;
|
|
1113
1165
|
exports.validateCardNumber = validateCardNumber;
|
|
1114
1166
|
exports.validateIban = validateIban;
|
|
1115
1167
|
exports.viewportToPx = viewportToPx;
|
package/dist/tools/units.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as AmortizationRow, a as AspectRatioResult, B as BASE_LABELS, b as BASE_PREFIXES, c as BYTE_UNITS, d as
|
|
1
|
+
export { A as AmortizationRow, a as AspectRatioResult, B as BASE_LABELS, b as BASE_PREFIXES, c as BYTE_UNITS, d as BarcodeFormat, e as BarcodeValidationResult, f as BaseConvertResult, g as ByteConvertResult, h as ByteUnit, C as COMMON_CURRENCIES, i as COMMON_LOCALES, j as COMMON_PERMISSIONS, k as COMMON_RATIOS, l as COMMON_SIZES, m as COMMON_TAX_RATES, n as COMMON_VIEWPORTS, o as CardValidationResult, D as Dimensions, F as FilePermissions, p as FormatOptions, I as IbanValidationResult, q as IpConversion, L as LoanResult, N as NotationStyle, r as NumberBase, P as Permission, s as PxConvertResult, S as SemverVersion, t as SubnetInfo, T as TaxDirection, v as TaxResult, V as ViewportConvertResult, w as autoFormat, x as bumpVersion, y as calcAspectRatio, z as calcSubnet, E as calculateLoan, G as calculateTax, H as compareSemver, J as convert, K as convertBytes, M as convertIp, O as coverBox, Q as decimalToIp, R as decimalToIpCidr, U as describePermissions, W as fitIntoBox, X as formatNumber, Y as formatValue, Z as formatVwValue, _ as formatWithSeparator, $ as gcd, a0 as ipFromBinary, a1 as ipFromDecimal, a2 as ipFromHex, a3 as ipToBinary, a4 as ipToDecimal, a5 as ipToDecimalCidr, a6 as ipToHex, a7 as ipToOctal, a8 as isValid, a9 as isValidCidr, aa as isValidIp, ab as isValidIpv4, ac as octalToPermissions, ad as parseFileSize, ae as parseInput, af as parseNumberString, ag as parseSemver, ah as permissionsToChmod, ai as permissionsToOctal, aj as permissionsToSymbolic, ak as ptToPx, al as pxToAll, am as pxToViewport, an as remToPx, ao as satisfiesRange, ap as scaleByHeight, aq as scaleByWidth, ar as sortVersions, as as splitSubnet, at as symbolicToPermissions, au as validateBarcode, av as validateCardNumber, aw as validateIban, ax as viewportToPx } from '../units-CKS5W_ih.cjs';
|
package/dist/tools/units.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as AmortizationRow, a as AspectRatioResult, B as BASE_LABELS, b as BASE_PREFIXES, c as BYTE_UNITS, d as
|
|
1
|
+
export { A as AmortizationRow, a as AspectRatioResult, B as BASE_LABELS, b as BASE_PREFIXES, c as BYTE_UNITS, d as BarcodeFormat, e as BarcodeValidationResult, f as BaseConvertResult, g as ByteConvertResult, h as ByteUnit, C as COMMON_CURRENCIES, i as COMMON_LOCALES, j as COMMON_PERMISSIONS, k as COMMON_RATIOS, l as COMMON_SIZES, m as COMMON_TAX_RATES, n as COMMON_VIEWPORTS, o as CardValidationResult, D as Dimensions, F as FilePermissions, p as FormatOptions, I as IbanValidationResult, q as IpConversion, L as LoanResult, N as NotationStyle, r as NumberBase, P as Permission, s as PxConvertResult, S as SemverVersion, t as SubnetInfo, T as TaxDirection, v as TaxResult, V as ViewportConvertResult, w as autoFormat, x as bumpVersion, y as calcAspectRatio, z as calcSubnet, E as calculateLoan, G as calculateTax, H as compareSemver, J as convert, K as convertBytes, M as convertIp, O as coverBox, Q as decimalToIp, R as decimalToIpCidr, U as describePermissions, W as fitIntoBox, X as formatNumber, Y as formatValue, Z as formatVwValue, _ as formatWithSeparator, $ as gcd, a0 as ipFromBinary, a1 as ipFromDecimal, a2 as ipFromHex, a3 as ipToBinary, a4 as ipToDecimal, a5 as ipToDecimalCidr, a6 as ipToHex, a7 as ipToOctal, a8 as isValid, a9 as isValidCidr, aa as isValidIp, ab as isValidIpv4, ac as octalToPermissions, ad as parseFileSize, ae as parseInput, af as parseNumberString, ag as parseSemver, ah as permissionsToChmod, ai as permissionsToOctal, aj as permissionsToSymbolic, ak as ptToPx, al as pxToAll, am as pxToViewport, an as remToPx, ao as satisfiesRange, ap as scaleByHeight, aq as scaleByWidth, ar as sortVersions, as as splitSubnet, at as symbolicToPermissions, au as validateBarcode, av as validateCardNumber, aw as validateIban, ax as viewportToPx } from '../units-CKS5W_ih.js';
|
package/dist/tools/units.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_VIEWPORTS, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateLoan, compareSemver, convert, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, validateCardNumber, validateIban, viewportToPx } from '../chunk-
|
|
1
|
+
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_VIEWPORTS, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateLoan, calculateTax, compareSemver, convert, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, validateBarcode, validateCardNumber, validateIban, viewportToPx } from '../chunk-BI3SOWM7.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
|
@@ -279,12 +279,53 @@ interface LoanResult {
|
|
|
279
279
|
declare function calculateLoan(principal: number, annualRatePercent: number, termMonths: number): LoanResult | {
|
|
280
280
|
error: string;
|
|
281
281
|
};
|
|
282
|
+
type BarcodeFormat = "EAN-13" | "EAN-8" | "UPC-A";
|
|
283
|
+
interface BarcodeValidationResult {
|
|
284
|
+
valid: boolean;
|
|
285
|
+
format: BarcodeFormat;
|
|
286
|
+
digits: string;
|
|
287
|
+
checkDigit: number;
|
|
288
|
+
expectedCheckDigit: number;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Validate an EAN-13, EAN-8, or UPC-A barcode number via its weighted
|
|
292
|
+
* mod-10 check digit algorithm. The format is inferred from the digit
|
|
293
|
+
* count (8, 12, or 13) once spaces and hyphens are stripped.
|
|
294
|
+
*/
|
|
295
|
+
declare function validateBarcode(input: string): BarcodeValidationResult | {
|
|
296
|
+
error: string;
|
|
297
|
+
};
|
|
298
|
+
type TaxDirection = "add" | "remove";
|
|
299
|
+
interface TaxResult {
|
|
300
|
+
netAmount: number;
|
|
301
|
+
taxAmount: number;
|
|
302
|
+
grossAmount: number;
|
|
303
|
+
ratePercent: number;
|
|
304
|
+
direction: TaxDirection;
|
|
305
|
+
}
|
|
306
|
+
/** Reference table of well-known published VAT/GST/sales-tax rates. Not a live feed. */
|
|
307
|
+
declare const COMMON_TAX_RATES: Array<{
|
|
308
|
+
country: string;
|
|
309
|
+
label: string;
|
|
310
|
+
ratePercent: number;
|
|
311
|
+
}>;
|
|
312
|
+
/**
|
|
313
|
+
* Add or remove tax from a price given a rate, in either direction: "add"
|
|
314
|
+
* treats the input as the net (pre-tax) amount and computes the gross,
|
|
315
|
+
* "remove" treats the input as the gross (tax-inclusive) amount and backs
|
|
316
|
+
* out the net. Pure formula over user-supplied numbers, no live rate feed.
|
|
317
|
+
*/
|
|
318
|
+
declare function calculateTax(amount: number, ratePercent: number, direction: TaxDirection): TaxResult | {
|
|
319
|
+
error: string;
|
|
320
|
+
};
|
|
282
321
|
|
|
283
322
|
type units_AmortizationRow = AmortizationRow;
|
|
284
323
|
type units_AspectRatioResult = AspectRatioResult;
|
|
285
324
|
declare const units_BASE_LABELS: typeof BASE_LABELS;
|
|
286
325
|
declare const units_BASE_PREFIXES: typeof BASE_PREFIXES;
|
|
287
326
|
declare const units_BYTE_UNITS: typeof BYTE_UNITS;
|
|
327
|
+
type units_BarcodeFormat = BarcodeFormat;
|
|
328
|
+
type units_BarcodeValidationResult = BarcodeValidationResult;
|
|
288
329
|
type units_BaseConvertResult = BaseConvertResult;
|
|
289
330
|
type units_ByteConvertResult = ByteConvertResult;
|
|
290
331
|
type units_ByteUnit = ByteUnit;
|
|
@@ -293,6 +334,7 @@ declare const units_COMMON_LOCALES: typeof COMMON_LOCALES;
|
|
|
293
334
|
declare const units_COMMON_PERMISSIONS: typeof COMMON_PERMISSIONS;
|
|
294
335
|
declare const units_COMMON_RATIOS: typeof COMMON_RATIOS;
|
|
295
336
|
declare const units_COMMON_SIZES: typeof COMMON_SIZES;
|
|
337
|
+
declare const units_COMMON_TAX_RATES: typeof COMMON_TAX_RATES;
|
|
296
338
|
declare const units_COMMON_VIEWPORTS: typeof COMMON_VIEWPORTS;
|
|
297
339
|
type units_CardValidationResult = CardValidationResult;
|
|
298
340
|
type units_Dimensions = Dimensions;
|
|
@@ -307,12 +349,15 @@ type units_Permission = Permission;
|
|
|
307
349
|
type units_PxConvertResult = PxConvertResult;
|
|
308
350
|
type units_SemverVersion = SemverVersion;
|
|
309
351
|
type units_SubnetInfo = SubnetInfo;
|
|
352
|
+
type units_TaxDirection = TaxDirection;
|
|
353
|
+
type units_TaxResult = TaxResult;
|
|
310
354
|
type units_ViewportConvertResult = ViewportConvertResult;
|
|
311
355
|
declare const units_autoFormat: typeof autoFormat;
|
|
312
356
|
declare const units_bumpVersion: typeof bumpVersion;
|
|
313
357
|
declare const units_calcAspectRatio: typeof calcAspectRatio;
|
|
314
358
|
declare const units_calcSubnet: typeof calcSubnet;
|
|
315
359
|
declare const units_calculateLoan: typeof calculateLoan;
|
|
360
|
+
declare const units_calculateTax: typeof calculateTax;
|
|
316
361
|
declare const units_compareSemver: typeof compareSemver;
|
|
317
362
|
declare const units_convert: typeof convert;
|
|
318
363
|
declare const units_convertBytes: typeof convertBytes;
|
|
@@ -357,11 +402,12 @@ declare const units_scaleByWidth: typeof scaleByWidth;
|
|
|
357
402
|
declare const units_sortVersions: typeof sortVersions;
|
|
358
403
|
declare const units_splitSubnet: typeof splitSubnet;
|
|
359
404
|
declare const units_symbolicToPermissions: typeof symbolicToPermissions;
|
|
405
|
+
declare const units_validateBarcode: typeof validateBarcode;
|
|
360
406
|
declare const units_validateCardNumber: typeof validateCardNumber;
|
|
361
407
|
declare const units_validateIban: typeof validateIban;
|
|
362
408
|
declare const units_viewportToPx: typeof viewportToPx;
|
|
363
409
|
declare namespace units {
|
|
364
|
-
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_BaseConvertResult as BaseConvertResult, type units_ByteConvertResult as ByteConvertResult, type units_ByteUnit as ByteUnit, units_COMMON_CURRENCIES as COMMON_CURRENCIES, units_COMMON_LOCALES as COMMON_LOCALES, units_COMMON_PERMISSIONS as COMMON_PERMISSIONS, units_COMMON_RATIOS as COMMON_RATIOS, units_COMMON_SIZES as COMMON_SIZES, units_COMMON_VIEWPORTS as COMMON_VIEWPORTS, type units_CardValidationResult as CardValidationResult, type units_Dimensions as Dimensions, type units_FilePermissions as FilePermissions, type units_FormatOptions as FormatOptions, type units_IbanValidationResult as IbanValidationResult, type units_IpConversion as IpConversion, type units_LoanResult as LoanResult, type units_NotationStyle as NotationStyle, type units_NumberBase as NumberBase, type units_Permission as Permission, type units_PxConvertResult as PxConvertResult, type units_SemverVersion as SemverVersion, type units_SubnetInfo as SubnetInfo, type units_ViewportConvertResult as ViewportConvertResult, units_autoFormat as autoFormat, units_bumpVersion as bumpVersion, units_calcAspectRatio as calcAspectRatio, units_calcSubnet as calcSubnet, units_calculateLoan as calculateLoan, units_compareSemver as compareSemver, units_convert as convert, units_convertBytes as convertBytes, units_convertIp as convertIp, units_coverBox as coverBox, units_decimalToIp as decimalToIp, units_decimalToIpCidr as decimalToIpCidr, units_describePermissions as describePermissions, units_fitIntoBox as fitIntoBox, units_formatNumber as formatNumber, units_formatValue as formatValue, units_formatVwValue as formatVwValue, units_formatWithSeparator as formatWithSeparator, units_gcd as gcd, units_ipFromBinary as ipFromBinary, units_ipFromDecimal as ipFromDecimal, units_ipFromHex as ipFromHex, units_ipToBinary as ipToBinary, units_ipToDecimal as ipToDecimal, units_ipToDecimalCidr as ipToDecimalCidr, units_ipToHex as ipToHex, units_ipToOctal as ipToOctal, units_isValid as isValid, units_isValidCidr as isValidCidr, units_isValidIp as isValidIp, units_isValidIpv4 as isValidIpv4, units_octalToPermissions as octalToPermissions, units_parseFileSize as parseFileSize, units_parseInput as parseInput, units_parseNumberString as parseNumberString, units_parseSemver as parseSemver, units_permissionsToChmod as permissionsToChmod, units_permissionsToOctal as permissionsToOctal, units_permissionsToSymbolic as permissionsToSymbolic, units_ptToPx as ptToPx, units_pxToAll as pxToAll, units_pxToViewport as pxToViewport, units_remToPx as remToPx, units_satisfiesRange as satisfiesRange, units_scaleByHeight as scaleByHeight, units_scaleByWidth as scaleByWidth, units_sortVersions as sortVersions, units_splitSubnet as splitSubnet, units_symbolicToPermissions as symbolicToPermissions, units_validateCardNumber as validateCardNumber, units_validateIban as validateIban, units_viewportToPx as viewportToPx };
|
|
410
|
+
export { type units_AmortizationRow as AmortizationRow, type units_AspectRatioResult as AspectRatioResult, units_BASE_LABELS as BASE_LABELS, units_BASE_PREFIXES as BASE_PREFIXES, units_BYTE_UNITS as BYTE_UNITS, type units_BarcodeFormat as BarcodeFormat, type units_BarcodeValidationResult as BarcodeValidationResult, type units_BaseConvertResult as BaseConvertResult, type units_ByteConvertResult as ByteConvertResult, type units_ByteUnit as ByteUnit, units_COMMON_CURRENCIES as COMMON_CURRENCIES, units_COMMON_LOCALES as COMMON_LOCALES, units_COMMON_PERMISSIONS as COMMON_PERMISSIONS, units_COMMON_RATIOS as COMMON_RATIOS, units_COMMON_SIZES as COMMON_SIZES, units_COMMON_TAX_RATES as COMMON_TAX_RATES, units_COMMON_VIEWPORTS as COMMON_VIEWPORTS, type units_CardValidationResult as CardValidationResult, type units_Dimensions as Dimensions, type units_FilePermissions as FilePermissions, type units_FormatOptions as FormatOptions, type units_IbanValidationResult as IbanValidationResult, type units_IpConversion as IpConversion, type units_LoanResult as LoanResult, type units_NotationStyle as NotationStyle, type units_NumberBase as NumberBase, type units_Permission as Permission, type units_PxConvertResult as PxConvertResult, type units_SemverVersion as SemverVersion, type units_SubnetInfo as SubnetInfo, type units_TaxDirection as TaxDirection, type units_TaxResult as TaxResult, type units_ViewportConvertResult as ViewportConvertResult, units_autoFormat as autoFormat, units_bumpVersion as bumpVersion, units_calcAspectRatio as calcAspectRatio, units_calcSubnet as calcSubnet, units_calculateLoan as calculateLoan, units_calculateTax as calculateTax, units_compareSemver as compareSemver, units_convert as convert, units_convertBytes as convertBytes, units_convertIp as convertIp, units_coverBox as coverBox, units_decimalToIp as decimalToIp, units_decimalToIpCidr as decimalToIpCidr, units_describePermissions as describePermissions, units_fitIntoBox as fitIntoBox, units_formatNumber as formatNumber, units_formatValue as formatValue, units_formatVwValue as formatVwValue, units_formatWithSeparator as formatWithSeparator, units_gcd as gcd, units_ipFromBinary as ipFromBinary, units_ipFromDecimal as ipFromDecimal, units_ipFromHex as ipFromHex, units_ipToBinary as ipToBinary, units_ipToDecimal as ipToDecimal, units_ipToDecimalCidr as ipToDecimalCidr, units_ipToHex as ipToHex, units_ipToOctal as ipToOctal, units_isValid as isValid, units_isValidCidr as isValidCidr, units_isValidIp as isValidIp, units_isValidIpv4 as isValidIpv4, units_octalToPermissions as octalToPermissions, units_parseFileSize as parseFileSize, units_parseInput as parseInput, units_parseNumberString as parseNumberString, units_parseSemver as parseSemver, units_permissionsToChmod as permissionsToChmod, units_permissionsToOctal as permissionsToOctal, units_permissionsToSymbolic as permissionsToSymbolic, units_ptToPx as ptToPx, units_pxToAll as pxToAll, units_pxToViewport as pxToViewport, units_remToPx as remToPx, units_satisfiesRange as satisfiesRange, units_scaleByHeight as scaleByHeight, units_scaleByWidth as scaleByWidth, units_sortVersions as sortVersions, units_splitSubnet as splitSubnet, units_symbolicToPermissions as symbolicToPermissions, units_validateBarcode as validateBarcode, units_validateCardNumber as validateCardNumber, units_validateIban as validateIban, units_viewportToPx as viewportToPx };
|
|
365
411
|
}
|
|
366
412
|
|
|
367
|
-
export {
|
|
413
|
+
export { gcd as $, type AmortizationRow as A, BASE_LABELS as B, COMMON_CURRENCIES as C, type Dimensions as D, calculateLoan as E, type FilePermissions as F, calculateTax as G, compareSemver as H, type IbanValidationResult as I, convert as J, convertBytes as K, type LoanResult as L, convertIp as M, type NotationStyle as N, coverBox as O, type Permission as P, decimalToIp as Q, decimalToIpCidr as R, type SemverVersion as S, type TaxDirection as T, describePermissions as U, type ViewportConvertResult as V, fitIntoBox as W, formatNumber as X, formatValue as Y, formatVwValue as Z, formatWithSeparator as _, type AspectRatioResult as a, ipFromBinary as a0, ipFromDecimal as a1, ipFromHex as a2, ipToBinary as a3, ipToDecimal as a4, ipToDecimalCidr as a5, ipToHex as a6, ipToOctal as a7, isValid as a8, isValidCidr as a9, isValidIp as aa, isValidIpv4 as ab, octalToPermissions as ac, parseFileSize as ad, parseInput as ae, parseNumberString as af, parseSemver as ag, permissionsToChmod as ah, permissionsToOctal as ai, permissionsToSymbolic as aj, ptToPx as ak, pxToAll as al, pxToViewport as am, remToPx as an, satisfiesRange as ao, scaleByHeight as ap, scaleByWidth as aq, sortVersions as ar, splitSubnet as as, symbolicToPermissions as at, validateBarcode as au, validateCardNumber as av, validateIban as aw, viewportToPx as ax, BASE_PREFIXES as b, BYTE_UNITS as c, type BarcodeFormat as d, type BarcodeValidationResult as e, type BaseConvertResult as f, type ByteConvertResult as g, type ByteUnit as h, COMMON_LOCALES as i, COMMON_PERMISSIONS as j, COMMON_RATIOS as k, COMMON_SIZES as l, COMMON_TAX_RATES as m, COMMON_VIEWPORTS as n, type CardValidationResult as o, type FormatOptions as p, type IpConversion as q, type NumberBase as r, type PxConvertResult as s, type SubnetInfo as t, units as u, type TaxResult as v, autoFormat as w, bumpVersion as x, calcAspectRatio as y, calcSubnet as z };
|
|
@@ -279,12 +279,53 @@ interface LoanResult {
|
|
|
279
279
|
declare function calculateLoan(principal: number, annualRatePercent: number, termMonths: number): LoanResult | {
|
|
280
280
|
error: string;
|
|
281
281
|
};
|
|
282
|
+
type BarcodeFormat = "EAN-13" | "EAN-8" | "UPC-A";
|
|
283
|
+
interface BarcodeValidationResult {
|
|
284
|
+
valid: boolean;
|
|
285
|
+
format: BarcodeFormat;
|
|
286
|
+
digits: string;
|
|
287
|
+
checkDigit: number;
|
|
288
|
+
expectedCheckDigit: number;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Validate an EAN-13, EAN-8, or UPC-A barcode number via its weighted
|
|
292
|
+
* mod-10 check digit algorithm. The format is inferred from the digit
|
|
293
|
+
* count (8, 12, or 13) once spaces and hyphens are stripped.
|
|
294
|
+
*/
|
|
295
|
+
declare function validateBarcode(input: string): BarcodeValidationResult | {
|
|
296
|
+
error: string;
|
|
297
|
+
};
|
|
298
|
+
type TaxDirection = "add" | "remove";
|
|
299
|
+
interface TaxResult {
|
|
300
|
+
netAmount: number;
|
|
301
|
+
taxAmount: number;
|
|
302
|
+
grossAmount: number;
|
|
303
|
+
ratePercent: number;
|
|
304
|
+
direction: TaxDirection;
|
|
305
|
+
}
|
|
306
|
+
/** Reference table of well-known published VAT/GST/sales-tax rates. Not a live feed. */
|
|
307
|
+
declare const COMMON_TAX_RATES: Array<{
|
|
308
|
+
country: string;
|
|
309
|
+
label: string;
|
|
310
|
+
ratePercent: number;
|
|
311
|
+
}>;
|
|
312
|
+
/**
|
|
313
|
+
* Add or remove tax from a price given a rate, in either direction: "add"
|
|
314
|
+
* treats the input as the net (pre-tax) amount and computes the gross,
|
|
315
|
+
* "remove" treats the input as the gross (tax-inclusive) amount and backs
|
|
316
|
+
* out the net. Pure formula over user-supplied numbers, no live rate feed.
|
|
317
|
+
*/
|
|
318
|
+
declare function calculateTax(amount: number, ratePercent: number, direction: TaxDirection): TaxResult | {
|
|
319
|
+
error: string;
|
|
320
|
+
};
|
|
282
321
|
|
|
283
322
|
type units_AmortizationRow = AmortizationRow;
|
|
284
323
|
type units_AspectRatioResult = AspectRatioResult;
|
|
285
324
|
declare const units_BASE_LABELS: typeof BASE_LABELS;
|
|
286
325
|
declare const units_BASE_PREFIXES: typeof BASE_PREFIXES;
|
|
287
326
|
declare const units_BYTE_UNITS: typeof BYTE_UNITS;
|
|
327
|
+
type units_BarcodeFormat = BarcodeFormat;
|
|
328
|
+
type units_BarcodeValidationResult = BarcodeValidationResult;
|
|
288
329
|
type units_BaseConvertResult = BaseConvertResult;
|
|
289
330
|
type units_ByteConvertResult = ByteConvertResult;
|
|
290
331
|
type units_ByteUnit = ByteUnit;
|
|
@@ -293,6 +334,7 @@ declare const units_COMMON_LOCALES: typeof COMMON_LOCALES;
|
|
|
293
334
|
declare const units_COMMON_PERMISSIONS: typeof COMMON_PERMISSIONS;
|
|
294
335
|
declare const units_COMMON_RATIOS: typeof COMMON_RATIOS;
|
|
295
336
|
declare const units_COMMON_SIZES: typeof COMMON_SIZES;
|
|
337
|
+
declare const units_COMMON_TAX_RATES: typeof COMMON_TAX_RATES;
|
|
296
338
|
declare const units_COMMON_VIEWPORTS: typeof COMMON_VIEWPORTS;
|
|
297
339
|
type units_CardValidationResult = CardValidationResult;
|
|
298
340
|
type units_Dimensions = Dimensions;
|
|
@@ -307,12 +349,15 @@ type units_Permission = Permission;
|
|
|
307
349
|
type units_PxConvertResult = PxConvertResult;
|
|
308
350
|
type units_SemverVersion = SemverVersion;
|
|
309
351
|
type units_SubnetInfo = SubnetInfo;
|
|
352
|
+
type units_TaxDirection = TaxDirection;
|
|
353
|
+
type units_TaxResult = TaxResult;
|
|
310
354
|
type units_ViewportConvertResult = ViewportConvertResult;
|
|
311
355
|
declare const units_autoFormat: typeof autoFormat;
|
|
312
356
|
declare const units_bumpVersion: typeof bumpVersion;
|
|
313
357
|
declare const units_calcAspectRatio: typeof calcAspectRatio;
|
|
314
358
|
declare const units_calcSubnet: typeof calcSubnet;
|
|
315
359
|
declare const units_calculateLoan: typeof calculateLoan;
|
|
360
|
+
declare const units_calculateTax: typeof calculateTax;
|
|
316
361
|
declare const units_compareSemver: typeof compareSemver;
|
|
317
362
|
declare const units_convert: typeof convert;
|
|
318
363
|
declare const units_convertBytes: typeof convertBytes;
|
|
@@ -357,11 +402,12 @@ declare const units_scaleByWidth: typeof scaleByWidth;
|
|
|
357
402
|
declare const units_sortVersions: typeof sortVersions;
|
|
358
403
|
declare const units_splitSubnet: typeof splitSubnet;
|
|
359
404
|
declare const units_symbolicToPermissions: typeof symbolicToPermissions;
|
|
405
|
+
declare const units_validateBarcode: typeof validateBarcode;
|
|
360
406
|
declare const units_validateCardNumber: typeof validateCardNumber;
|
|
361
407
|
declare const units_validateIban: typeof validateIban;
|
|
362
408
|
declare const units_viewportToPx: typeof viewportToPx;
|
|
363
409
|
declare namespace units {
|
|
364
|
-
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_BaseConvertResult as BaseConvertResult, type units_ByteConvertResult as ByteConvertResult, type units_ByteUnit as ByteUnit, units_COMMON_CURRENCIES as COMMON_CURRENCIES, units_COMMON_LOCALES as COMMON_LOCALES, units_COMMON_PERMISSIONS as COMMON_PERMISSIONS, units_COMMON_RATIOS as COMMON_RATIOS, units_COMMON_SIZES as COMMON_SIZES, units_COMMON_VIEWPORTS as COMMON_VIEWPORTS, type units_CardValidationResult as CardValidationResult, type units_Dimensions as Dimensions, type units_FilePermissions as FilePermissions, type units_FormatOptions as FormatOptions, type units_IbanValidationResult as IbanValidationResult, type units_IpConversion as IpConversion, type units_LoanResult as LoanResult, type units_NotationStyle as NotationStyle, type units_NumberBase as NumberBase, type units_Permission as Permission, type units_PxConvertResult as PxConvertResult, type units_SemverVersion as SemverVersion, type units_SubnetInfo as SubnetInfo, type units_ViewportConvertResult as ViewportConvertResult, units_autoFormat as autoFormat, units_bumpVersion as bumpVersion, units_calcAspectRatio as calcAspectRatio, units_calcSubnet as calcSubnet, units_calculateLoan as calculateLoan, units_compareSemver as compareSemver, units_convert as convert, units_convertBytes as convertBytes, units_convertIp as convertIp, units_coverBox as coverBox, units_decimalToIp as decimalToIp, units_decimalToIpCidr as decimalToIpCidr, units_describePermissions as describePermissions, units_fitIntoBox as fitIntoBox, units_formatNumber as formatNumber, units_formatValue as formatValue, units_formatVwValue as formatVwValue, units_formatWithSeparator as formatWithSeparator, units_gcd as gcd, units_ipFromBinary as ipFromBinary, units_ipFromDecimal as ipFromDecimal, units_ipFromHex as ipFromHex, units_ipToBinary as ipToBinary, units_ipToDecimal as ipToDecimal, units_ipToDecimalCidr as ipToDecimalCidr, units_ipToHex as ipToHex, units_ipToOctal as ipToOctal, units_isValid as isValid, units_isValidCidr as isValidCidr, units_isValidIp as isValidIp, units_isValidIpv4 as isValidIpv4, units_octalToPermissions as octalToPermissions, units_parseFileSize as parseFileSize, units_parseInput as parseInput, units_parseNumberString as parseNumberString, units_parseSemver as parseSemver, units_permissionsToChmod as permissionsToChmod, units_permissionsToOctal as permissionsToOctal, units_permissionsToSymbolic as permissionsToSymbolic, units_ptToPx as ptToPx, units_pxToAll as pxToAll, units_pxToViewport as pxToViewport, units_remToPx as remToPx, units_satisfiesRange as satisfiesRange, units_scaleByHeight as scaleByHeight, units_scaleByWidth as scaleByWidth, units_sortVersions as sortVersions, units_splitSubnet as splitSubnet, units_symbolicToPermissions as symbolicToPermissions, units_validateCardNumber as validateCardNumber, units_validateIban as validateIban, units_viewportToPx as viewportToPx };
|
|
410
|
+
export { type units_AmortizationRow as AmortizationRow, type units_AspectRatioResult as AspectRatioResult, units_BASE_LABELS as BASE_LABELS, units_BASE_PREFIXES as BASE_PREFIXES, units_BYTE_UNITS as BYTE_UNITS, type units_BarcodeFormat as BarcodeFormat, type units_BarcodeValidationResult as BarcodeValidationResult, type units_BaseConvertResult as BaseConvertResult, type units_ByteConvertResult as ByteConvertResult, type units_ByteUnit as ByteUnit, units_COMMON_CURRENCIES as COMMON_CURRENCIES, units_COMMON_LOCALES as COMMON_LOCALES, units_COMMON_PERMISSIONS as COMMON_PERMISSIONS, units_COMMON_RATIOS as COMMON_RATIOS, units_COMMON_SIZES as COMMON_SIZES, units_COMMON_TAX_RATES as COMMON_TAX_RATES, units_COMMON_VIEWPORTS as COMMON_VIEWPORTS, type units_CardValidationResult as CardValidationResult, type units_Dimensions as Dimensions, type units_FilePermissions as FilePermissions, type units_FormatOptions as FormatOptions, type units_IbanValidationResult as IbanValidationResult, type units_IpConversion as IpConversion, type units_LoanResult as LoanResult, type units_NotationStyle as NotationStyle, type units_NumberBase as NumberBase, type units_Permission as Permission, type units_PxConvertResult as PxConvertResult, type units_SemverVersion as SemverVersion, type units_SubnetInfo as SubnetInfo, type units_TaxDirection as TaxDirection, type units_TaxResult as TaxResult, type units_ViewportConvertResult as ViewportConvertResult, units_autoFormat as autoFormat, units_bumpVersion as bumpVersion, units_calcAspectRatio as calcAspectRatio, units_calcSubnet as calcSubnet, units_calculateLoan as calculateLoan, units_calculateTax as calculateTax, units_compareSemver as compareSemver, units_convert as convert, units_convertBytes as convertBytes, units_convertIp as convertIp, units_coverBox as coverBox, units_decimalToIp as decimalToIp, units_decimalToIpCidr as decimalToIpCidr, units_describePermissions as describePermissions, units_fitIntoBox as fitIntoBox, units_formatNumber as formatNumber, units_formatValue as formatValue, units_formatVwValue as formatVwValue, units_formatWithSeparator as formatWithSeparator, units_gcd as gcd, units_ipFromBinary as ipFromBinary, units_ipFromDecimal as ipFromDecimal, units_ipFromHex as ipFromHex, units_ipToBinary as ipToBinary, units_ipToDecimal as ipToDecimal, units_ipToDecimalCidr as ipToDecimalCidr, units_ipToHex as ipToHex, units_ipToOctal as ipToOctal, units_isValid as isValid, units_isValidCidr as isValidCidr, units_isValidIp as isValidIp, units_isValidIpv4 as isValidIpv4, units_octalToPermissions as octalToPermissions, units_parseFileSize as parseFileSize, units_parseInput as parseInput, units_parseNumberString as parseNumberString, units_parseSemver as parseSemver, units_permissionsToChmod as permissionsToChmod, units_permissionsToOctal as permissionsToOctal, units_permissionsToSymbolic as permissionsToSymbolic, units_ptToPx as ptToPx, units_pxToAll as pxToAll, units_pxToViewport as pxToViewport, units_remToPx as remToPx, units_satisfiesRange as satisfiesRange, units_scaleByHeight as scaleByHeight, units_scaleByWidth as scaleByWidth, units_sortVersions as sortVersions, units_splitSubnet as splitSubnet, units_symbolicToPermissions as symbolicToPermissions, units_validateBarcode as validateBarcode, units_validateCardNumber as validateCardNumber, units_validateIban as validateIban, units_viewportToPx as viewportToPx };
|
|
365
411
|
}
|
|
366
412
|
|
|
367
|
-
export {
|
|
413
|
+
export { gcd as $, type AmortizationRow as A, BASE_LABELS as B, COMMON_CURRENCIES as C, type Dimensions as D, calculateLoan as E, type FilePermissions as F, calculateTax as G, compareSemver as H, type IbanValidationResult as I, convert as J, convertBytes as K, type LoanResult as L, convertIp as M, type NotationStyle as N, coverBox as O, type Permission as P, decimalToIp as Q, decimalToIpCidr as R, type SemverVersion as S, type TaxDirection as T, describePermissions as U, type ViewportConvertResult as V, fitIntoBox as W, formatNumber as X, formatValue as Y, formatVwValue as Z, formatWithSeparator as _, type AspectRatioResult as a, ipFromBinary as a0, ipFromDecimal as a1, ipFromHex as a2, ipToBinary as a3, ipToDecimal as a4, ipToDecimalCidr as a5, ipToHex as a6, ipToOctal as a7, isValid as a8, isValidCidr as a9, isValidIp as aa, isValidIpv4 as ab, octalToPermissions as ac, parseFileSize as ad, parseInput as ae, parseNumberString as af, parseSemver as ag, permissionsToChmod as ah, permissionsToOctal as ai, permissionsToSymbolic as aj, ptToPx as ak, pxToAll as al, pxToViewport as am, remToPx as an, satisfiesRange as ao, scaleByHeight as ap, scaleByWidth as aq, sortVersions as ar, splitSubnet as as, symbolicToPermissions as at, validateBarcode as au, validateCardNumber as av, validateIban as aw, viewportToPx as ax, BASE_PREFIXES as b, BYTE_UNITS as c, type BarcodeFormat as d, type BarcodeValidationResult as e, type BaseConvertResult as f, type ByteConvertResult as g, type ByteUnit as h, COMMON_LOCALES as i, COMMON_PERMISSIONS as j, COMMON_RATIOS as k, COMMON_SIZES as l, COMMON_TAX_RATES as m, COMMON_VIEWPORTS as n, type CardValidationResult as o, type FormatOptions as p, type IpConversion as q, type NumberBase as r, type PxConvertResult as s, type SubnetInfo as t, units as u, type TaxResult as v, autoFormat as w, bumpVersion as x, calcAspectRatio as y, calcSubnet as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utilix-tech/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.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",
|