@utilix-tech/sdk 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +11 -3
- package/dist/{chunk-U34B5XPK.js → chunk-TFNCFD3E.js} +25 -1
- package/dist/{chunk-TSAGO3XP.js → chunk-WO3LJMVV.js} +54 -1
- package/dist/index.cjs +77 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{json-BjSoIS1h.d.cts → json-DEVFIpsC.d.cts} +26 -2
- package/dist/{json-BjSoIS1h.d.ts → json-DEVFIpsC.d.ts} +26 -2
- package/dist/tools/json.cjs +53 -0
- package/dist/tools/json.d.cts +1 -1
- package/dist/tools/json.d.ts +1 -1
- package/dist/tools/json.js +1 -1
- package/dist/tools/units.cjs +24 -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-BFTQwpBu.d.cts → units-pIRkHnsU.d.cts} +24 -2
- package/dist/{units-BFTQwpBu.d.ts → units-pIRkHnsU.d.ts} +24 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Full release notes for all Utilix surfaces (browser tools, REST API, SDKs, MCP server) live at [utilix.tech/changelog](https://utilix.tech/changelog). This file tracks just this package.
|
|
4
4
|
|
|
5
|
+
## 0.21.0
|
|
6
|
+
- Add `calculatePercentageChange` (percentage-change-calculator): percentage change between two numbers, with absolute change, direction, and multiplier.
|
|
7
|
+
- Add `resolveJsonPointer` (json-pointer-resolver): resolve an RFC 6901 JSON Pointer against a document, with ~0/~1 escaping and clear not-found reasons.
|
|
8
|
+
|
|
5
9
|
## 0.20.0
|
|
6
10
|
- Add `buildCacheControl` (cache-control-builder): assemble and explain a `Cache-Control` response header from directives, with warnings for combinations that cancel out.
|
|
7
11
|
- Add `detectFillerWords` (filler-word-detector): scan text for filler words, hedge phrases, and clichés with per-phrase counts and a density score.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @utilix-tech/sdk
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**558 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)
|
|
@@ -66,7 +66,7 @@ const { formatJson } = require("@utilix-tech/sdk/json");
|
|
|
66
66
|
|
|
67
67
|
```ts
|
|
68
68
|
import { formatJson, minifyJson, diffJson, jsonToTypescript, validateJson,
|
|
69
|
-
evaluateJsonPath, jsonToCsv, yamlToJson, jsonToYaml, getJsonStats } from "@utilix-tech/sdk/json";
|
|
69
|
+
evaluateJsonPath, resolveJsonPointer, jsonToCsv, yamlToJson, jsonToYaml, getJsonStats } from "@utilix-tech/sdk/json";
|
|
70
70
|
|
|
71
71
|
// Format with 2-space indent
|
|
72
72
|
formatJson('{"name":"alice","age":30}', { indent: 2 });
|
|
@@ -80,6 +80,10 @@ jsonToTypescript('{"id":1,"name":"Alice"}', { rootName: "User" });
|
|
|
80
80
|
// Query with JSONPath
|
|
81
81
|
evaluateJsonPath(obj, "$.users[*].name");
|
|
82
82
|
|
|
83
|
+
// Resolve an RFC 6901 JSON Pointer
|
|
84
|
+
resolveJsonPointer('{"users":[{"name":"Alice"}]}', "/users/0/name");
|
|
85
|
+
// { found: true, value: "Alice", tokens: ["users", "0", "name"] }
|
|
86
|
+
|
|
83
87
|
// Convert JSON to CSV
|
|
84
88
|
jsonToCsv('[{"a":1,"b":2}]');
|
|
85
89
|
|
|
@@ -252,7 +256,7 @@ getNextRuns("*/5 * * * *", 5); // next 5 run timestamps
|
|
|
252
256
|
### `/units`: Conversions
|
|
253
257
|
|
|
254
258
|
```ts
|
|
255
|
-
import { convertBytes, pxToAll, convert, formatValue, validateCardNumber, validateIban, calculateLoan, validateBarcode, calculateTax, calculateCompoundInterest, validateIsbn, calculateTipSplit, calculateSimpleInterest, calculateTimeValue } from "@utilix-tech/sdk/units";
|
|
259
|
+
import { convertBytes, pxToAll, convert, formatValue, validateCardNumber, validateIban, calculateLoan, validateBarcode, calculateTax, calculateCompoundInterest, validateIsbn, calculateTipSplit, calculateSimpleInterest, calculateTimeValue, calculatePercentageChange } from "@utilix-tech/sdk/units";
|
|
256
260
|
|
|
257
261
|
// File sizes
|
|
258
262
|
convertBytes(1073741824, "GB"); // 1
|
|
@@ -310,6 +314,10 @@ calculateSimpleInterest(1000, 5, 2);
|
|
|
310
314
|
// Present / future value (time value of money), either direction
|
|
311
315
|
calculateTimeValue(1000, 5, 10, "future");
|
|
312
316
|
// { presentValue: 1000, futureValue: 1628.89, growthFactor: 1.628895, ... }
|
|
317
|
+
|
|
318
|
+
// Percentage change between two numbers
|
|
319
|
+
calculatePercentageChange(200, 250);
|
|
320
|
+
// { percentChange: 25, absoluteChange: 50, direction: "increase", multiplier: 1.25 }
|
|
313
321
|
```
|
|
314
322
|
|
|
315
323
|
---
|
|
@@ -20,6 +20,7 @@ __export(units_exports, {
|
|
|
20
20
|
calcSubnet: () => calcSubnet,
|
|
21
21
|
calculateCompoundInterest: () => calculateCompoundInterest,
|
|
22
22
|
calculateLoan: () => calculateLoan,
|
|
23
|
+
calculatePercentageChange: () => calculatePercentageChange,
|
|
23
24
|
calculateSimpleInterest: () => calculateSimpleInterest,
|
|
24
25
|
calculateTax: () => calculateTax,
|
|
25
26
|
calculateTimeValue: () => calculateTimeValue,
|
|
@@ -1337,5 +1338,28 @@ function calculateTimeValue(amount, annualRatePercent, years, direction, compoun
|
|
|
1337
1338
|
interest: round22(futureValue - presentValue)
|
|
1338
1339
|
};
|
|
1339
1340
|
}
|
|
1341
|
+
function calculatePercentageChange(oldValue, newValue) {
|
|
1342
|
+
if (!Number.isFinite(oldValue)) return { error: "Original value must be a finite number" };
|
|
1343
|
+
if (!Number.isFinite(newValue)) return { error: "New value must be a finite number" };
|
|
1344
|
+
if (oldValue === 0 && newValue !== 0) {
|
|
1345
|
+
return { error: "Percentage change from zero is undefined (division by zero); use a nonzero original value" };
|
|
1346
|
+
}
|
|
1347
|
+
const round4 = (n) => Math.round(n * 1e4) / 1e4;
|
|
1348
|
+
const absoluteChange = newValue - oldValue;
|
|
1349
|
+
const percentChange = oldValue === 0 ? 0 : absoluteChange / Math.abs(oldValue) * 100;
|
|
1350
|
+
const multiplier = oldValue === 0 ? 1 : newValue / oldValue;
|
|
1351
|
+
let direction;
|
|
1352
|
+
if (absoluteChange > 0) direction = "increase";
|
|
1353
|
+
else if (absoluteChange < 0) direction = "decrease";
|
|
1354
|
+
else direction = "no change";
|
|
1355
|
+
return {
|
|
1356
|
+
oldValue,
|
|
1357
|
+
newValue,
|
|
1358
|
+
absoluteChange: round4(absoluteChange),
|
|
1359
|
+
percentChange: round4(percentChange),
|
|
1360
|
+
direction,
|
|
1361
|
+
multiplier: round4(multiplier)
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1340
1364
|
|
|
1341
|
-
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_TIP_PERCENTAGES, COMMON_VIEWPORTS, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateCompoundInterest, calculateLoan, calculateSimpleInterest, calculateTax, calculateTimeValue, calculateTipSplit, compareSemver, convert, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, units_exports, validateBarcode, validateCardNumber, validateIban, validateIsbn, viewportToPx };
|
|
1365
|
+
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_TIP_PERCENTAGES, COMMON_VIEWPORTS, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateCompoundInterest, calculateLoan, calculatePercentageChange, calculateSimpleInterest, calculateTax, calculateTimeValue, calculateTipSplit, compareSemver, convert, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, units_exports, validateBarcode, validateCardNumber, validateIban, validateIsbn, viewportToPx };
|
|
@@ -24,6 +24,7 @@ __export(json_exports, {
|
|
|
24
24
|
minifyJson: () => minifyJson,
|
|
25
25
|
parseJson: () => parseJson,
|
|
26
26
|
parseStructs: () => parseStructs,
|
|
27
|
+
resolveJsonPointer: () => resolveJsonPointer,
|
|
27
28
|
toPascalCase: () => toPascalCase,
|
|
28
29
|
toSnakeCase: () => toSnakeCase,
|
|
29
30
|
validateJson: () => validateJson,
|
|
@@ -1249,5 +1250,57 @@ function jsonToZod(json, options) {
|
|
|
1249
1250
|
|
|
1250
1251
|
export const ${rootName}Schema = ${schema}`;
|
|
1251
1252
|
}
|
|
1253
|
+
function _unescapePointerToken(token) {
|
|
1254
|
+
return token.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
1255
|
+
}
|
|
1256
|
+
function resolveJsonPointer(json, pointer) {
|
|
1257
|
+
let parsed;
|
|
1258
|
+
try {
|
|
1259
|
+
parsed = JSON.parse(json);
|
|
1260
|
+
} catch {
|
|
1261
|
+
return { pointer, found: false, tokens: [], error: "Invalid JSON input" };
|
|
1262
|
+
}
|
|
1263
|
+
let ptr = pointer;
|
|
1264
|
+
if (ptr.startsWith("#")) {
|
|
1265
|
+
ptr = ptr.slice(1);
|
|
1266
|
+
try {
|
|
1267
|
+
ptr = decodeURIComponent(ptr);
|
|
1268
|
+
} catch {
|
|
1269
|
+
return { pointer, found: false, tokens: [], error: "Invalid percent-encoding in URI-fragment pointer" };
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
if (ptr === "") {
|
|
1273
|
+
return { pointer, found: true, value: parsed, tokens: [] };
|
|
1274
|
+
}
|
|
1275
|
+
if (!ptr.startsWith("/")) {
|
|
1276
|
+
return { pointer, found: false, tokens: [], error: "Pointer must be empty or start with '/' (RFC 6901)" };
|
|
1277
|
+
}
|
|
1278
|
+
const tokens = ptr.split("/").slice(1).map(_unescapePointerToken);
|
|
1279
|
+
let current = parsed;
|
|
1280
|
+
for (const token of tokens) {
|
|
1281
|
+
if (Array.isArray(current)) {
|
|
1282
|
+
if (token === "-") {
|
|
1283
|
+
return { pointer, found: false, tokens, failedAt: token, reason: '"-" refers to the nonexistent element after the end of the array' };
|
|
1284
|
+
}
|
|
1285
|
+
if (!/^(0|[1-9][0-9]*)$/.test(token)) {
|
|
1286
|
+
return { pointer, found: false, tokens, failedAt: token, reason: `"${token}" is not a valid array index` };
|
|
1287
|
+
}
|
|
1288
|
+
const idx = Number(token);
|
|
1289
|
+
if (idx >= current.length) {
|
|
1290
|
+
return { pointer, found: false, tokens, failedAt: token, reason: `array index ${idx} is out of bounds (length ${current.length})` };
|
|
1291
|
+
}
|
|
1292
|
+
current = current[idx];
|
|
1293
|
+
} else if (current !== null && typeof current === "object") {
|
|
1294
|
+
const obj = current;
|
|
1295
|
+
if (!Object.prototype.hasOwnProperty.call(obj, token)) {
|
|
1296
|
+
return { pointer, found: false, tokens, failedAt: token, reason: `key "${token}" not found` };
|
|
1297
|
+
}
|
|
1298
|
+
current = obj[token];
|
|
1299
|
+
} else {
|
|
1300
|
+
return { pointer, found: false, tokens, failedAt: token, reason: `cannot descend into ${current === null ? "null" : typeof current} at "${token}"` };
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
return { pointer, found: true, value: current, tokens };
|
|
1304
|
+
}
|
|
1252
1305
|
|
|
1253
|
-
export { csvToJson, detectFormat, diffJson, evaluateJsonPath, formatDiffLine, formatJson, generateExample, getJsonStats, inferGoType, inferPythonType, inferType, jsonToCsv, jsonToGo, jsonToPython, jsonToTypescript, jsonToYaml, jsonToZod, json_exports, minifyJson, parseJson, parseStructs, toPascalCase, toSnakeCase, validateJson, validateJsonPath, validateJsonString, yamlToJson };
|
|
1306
|
+
export { csvToJson, detectFormat, diffJson, evaluateJsonPath, formatDiffLine, formatJson, generateExample, getJsonStats, inferGoType, inferPythonType, inferType, jsonToCsv, jsonToGo, jsonToPython, jsonToTypescript, jsonToYaml, jsonToZod, json_exports, minifyJson, parseJson, parseStructs, resolveJsonPointer, toPascalCase, toSnakeCase, validateJson, validateJsonPath, validateJsonString, yamlToJson };
|
package/dist/index.cjs
CHANGED
|
@@ -62,6 +62,7 @@ __export(json_exports, {
|
|
|
62
62
|
minifyJson: () => minifyJson,
|
|
63
63
|
parseJson: () => parseJson,
|
|
64
64
|
parseStructs: () => parseStructs,
|
|
65
|
+
resolveJsonPointer: () => resolveJsonPointer,
|
|
65
66
|
toPascalCase: () => toPascalCase,
|
|
66
67
|
toSnakeCase: () => toSnakeCase,
|
|
67
68
|
validateJson: () => validateJson,
|
|
@@ -1287,6 +1288,58 @@ function jsonToZod(json, options) {
|
|
|
1287
1288
|
|
|
1288
1289
|
export const ${rootName}Schema = ${schema}`;
|
|
1289
1290
|
}
|
|
1291
|
+
function _unescapePointerToken(token) {
|
|
1292
|
+
return token.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
1293
|
+
}
|
|
1294
|
+
function resolveJsonPointer(json, pointer) {
|
|
1295
|
+
let parsed;
|
|
1296
|
+
try {
|
|
1297
|
+
parsed = JSON.parse(json);
|
|
1298
|
+
} catch {
|
|
1299
|
+
return { pointer, found: false, tokens: [], error: "Invalid JSON input" };
|
|
1300
|
+
}
|
|
1301
|
+
let ptr = pointer;
|
|
1302
|
+
if (ptr.startsWith("#")) {
|
|
1303
|
+
ptr = ptr.slice(1);
|
|
1304
|
+
try {
|
|
1305
|
+
ptr = decodeURIComponent(ptr);
|
|
1306
|
+
} catch {
|
|
1307
|
+
return { pointer, found: false, tokens: [], error: "Invalid percent-encoding in URI-fragment pointer" };
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
if (ptr === "") {
|
|
1311
|
+
return { pointer, found: true, value: parsed, tokens: [] };
|
|
1312
|
+
}
|
|
1313
|
+
if (!ptr.startsWith("/")) {
|
|
1314
|
+
return { pointer, found: false, tokens: [], error: "Pointer must be empty or start with '/' (RFC 6901)" };
|
|
1315
|
+
}
|
|
1316
|
+
const tokens = ptr.split("/").slice(1).map(_unescapePointerToken);
|
|
1317
|
+
let current = parsed;
|
|
1318
|
+
for (const token of tokens) {
|
|
1319
|
+
if (Array.isArray(current)) {
|
|
1320
|
+
if (token === "-") {
|
|
1321
|
+
return { pointer, found: false, tokens, failedAt: token, reason: '"-" refers to the nonexistent element after the end of the array' };
|
|
1322
|
+
}
|
|
1323
|
+
if (!/^(0|[1-9][0-9]*)$/.test(token)) {
|
|
1324
|
+
return { pointer, found: false, tokens, failedAt: token, reason: `"${token}" is not a valid array index` };
|
|
1325
|
+
}
|
|
1326
|
+
const idx = Number(token);
|
|
1327
|
+
if (idx >= current.length) {
|
|
1328
|
+
return { pointer, found: false, tokens, failedAt: token, reason: `array index ${idx} is out of bounds (length ${current.length})` };
|
|
1329
|
+
}
|
|
1330
|
+
current = current[idx];
|
|
1331
|
+
} else if (current !== null && typeof current === "object") {
|
|
1332
|
+
const obj = current;
|
|
1333
|
+
if (!Object.prototype.hasOwnProperty.call(obj, token)) {
|
|
1334
|
+
return { pointer, found: false, tokens, failedAt: token, reason: `key "${token}" not found` };
|
|
1335
|
+
}
|
|
1336
|
+
current = obj[token];
|
|
1337
|
+
} else {
|
|
1338
|
+
return { pointer, found: false, tokens, failedAt: token, reason: `cannot descend into ${current === null ? "null" : typeof current} at "${token}"` };
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
return { pointer, found: true, value: current, tokens };
|
|
1342
|
+
}
|
|
1290
1343
|
|
|
1291
1344
|
// src/tools/encoding.ts
|
|
1292
1345
|
var encoding_exports = {};
|
|
@@ -6784,6 +6837,7 @@ __export(units_exports, {
|
|
|
6784
6837
|
calcSubnet: () => calcSubnet,
|
|
6785
6838
|
calculateCompoundInterest: () => calculateCompoundInterest,
|
|
6786
6839
|
calculateLoan: () => calculateLoan,
|
|
6840
|
+
calculatePercentageChange: () => calculatePercentageChange,
|
|
6787
6841
|
calculateSimpleInterest: () => calculateSimpleInterest,
|
|
6788
6842
|
calculateTax: () => calculateTax,
|
|
6789
6843
|
calculateTimeValue: () => calculateTimeValue,
|
|
@@ -8101,6 +8155,29 @@ function calculateTimeValue(amount, annualRatePercent, years, direction, compoun
|
|
|
8101
8155
|
interest: round23(futureValue - presentValue)
|
|
8102
8156
|
};
|
|
8103
8157
|
}
|
|
8158
|
+
function calculatePercentageChange(oldValue, newValue) {
|
|
8159
|
+
if (!Number.isFinite(oldValue)) return { error: "Original value must be a finite number" };
|
|
8160
|
+
if (!Number.isFinite(newValue)) return { error: "New value must be a finite number" };
|
|
8161
|
+
if (oldValue === 0 && newValue !== 0) {
|
|
8162
|
+
return { error: "Percentage change from zero is undefined (division by zero); use a nonzero original value" };
|
|
8163
|
+
}
|
|
8164
|
+
const round4 = (n) => Math.round(n * 1e4) / 1e4;
|
|
8165
|
+
const absoluteChange = newValue - oldValue;
|
|
8166
|
+
const percentChange = oldValue === 0 ? 0 : absoluteChange / Math.abs(oldValue) * 100;
|
|
8167
|
+
const multiplier = oldValue === 0 ? 1 : newValue / oldValue;
|
|
8168
|
+
let direction;
|
|
8169
|
+
if (absoluteChange > 0) direction = "increase";
|
|
8170
|
+
else if (absoluteChange < 0) direction = "decrease";
|
|
8171
|
+
else direction = "no change";
|
|
8172
|
+
return {
|
|
8173
|
+
oldValue,
|
|
8174
|
+
newValue,
|
|
8175
|
+
absoluteChange: round4(absoluteChange),
|
|
8176
|
+
percentChange: round4(percentChange),
|
|
8177
|
+
direction,
|
|
8178
|
+
multiplier: round4(multiplier)
|
|
8179
|
+
};
|
|
8180
|
+
}
|
|
8104
8181
|
|
|
8105
8182
|
// src/tools/network.ts
|
|
8106
8183
|
var network_exports = {};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { j as json } from './json-
|
|
1
|
+
export { j as json } from './json-DEVFIpsC.cjs';
|
|
2
2
|
export { e as encoding } from './encoding-Dk3wpmb3.cjs';
|
|
3
3
|
export { h as hashing } from './hashing-CnetQFD_.cjs';
|
|
4
4
|
export { t as text } from './text-DS70aMY5.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-pIRkHnsU.cjs';
|
|
9
9
|
export { n as network } from './network-BJOjJnmY.cjs';
|
|
10
10
|
export { a as api } from './api-Xl7OzIgq.cjs';
|
|
11
11
|
export { c as code } from './code-DaRvff2v.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { j as json } from './json-
|
|
1
|
+
export { j as json } from './json-DEVFIpsC.js';
|
|
2
2
|
export { e as encoding } from './encoding-Dk3wpmb3.js';
|
|
3
3
|
export { h as hashing } from './hashing-CnetQFD_.js';
|
|
4
4
|
export { t as text } from './text-DS70aMY5.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-pIRkHnsU.js';
|
|
9
9
|
export { n as network } from './network-BJOjJnmY.js';
|
|
10
10
|
export { a as api } from './api-Xl7OzIgq.js';
|
|
11
11
|
export { c as code } from './code-DaRvff2v.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { media_exports as media } from './chunk-XMKJYVKB.js';
|
|
2
|
-
export { units_exports as units } from './chunk-
|
|
2
|
+
export { units_exports as units } from './chunk-TFNCFD3E.js';
|
|
3
3
|
export { network_exports as network } from './chunk-Y5OOP6WN.js';
|
|
4
4
|
export { api_exports as api } from './chunk-Q3B3YWOA.js';
|
|
5
5
|
export { code_exports as code } from './chunk-LXKIPPDG.js';
|
|
@@ -7,7 +7,7 @@ export { color_exports as color } from './chunk-BPVAB4P2.js';
|
|
|
7
7
|
export { css_exports as css } from './chunk-6YPV2AB5.js';
|
|
8
8
|
export { misc_exports as misc } from './chunk-GX7H6TAX.js';
|
|
9
9
|
export { ai_agent_exports as ai_agent } from './chunk-265NPGKH.js';
|
|
10
|
-
export { json_exports as json } from './chunk-
|
|
10
|
+
export { json_exports as json } from './chunk-WO3LJMVV.js';
|
|
11
11
|
export { encoding_exports as encoding } from './chunk-DOWQZUTP.js';
|
|
12
12
|
export { hashing_exports as hashing } from './chunk-GEFVMGZR.js';
|
|
13
13
|
export { text_exports as text } from './chunk-2I4O5YCT.js';
|
|
@@ -148,6 +148,28 @@ interface ZodOptions {
|
|
|
148
148
|
declare function jsonToZod(json: string, options?: ZodOptions): string | {
|
|
149
149
|
error: string;
|
|
150
150
|
};
|
|
151
|
+
interface JsonPointerResult {
|
|
152
|
+
pointer: string;
|
|
153
|
+
found: boolean;
|
|
154
|
+
value?: unknown;
|
|
155
|
+
/** Decoded reference tokens (after ~1 -> / and ~0 -> ~ unescaping). */
|
|
156
|
+
tokens: string[];
|
|
157
|
+
/** Set when the input JSON is invalid or the pointer syntax is malformed. */
|
|
158
|
+
error?: string;
|
|
159
|
+
/** The reference token at which resolution stopped (found === false). */
|
|
160
|
+
failedAt?: string;
|
|
161
|
+
/** Why resolution stopped at `failedAt`. */
|
|
162
|
+
reason?: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Resolve an RFC 6901 JSON Pointer against a JSON document. Accepts both the
|
|
166
|
+
* plain form ("" for the whole document, or "/foo/0") and the URI-fragment
|
|
167
|
+
* form ("#/foo/0", percent-decoded). Distinguishes an invalid document /
|
|
168
|
+
* malformed pointer (`error`) from a syntactically valid pointer whose target
|
|
169
|
+
* is simply absent (`found: false` with `failedAt` + `reason`). Pure
|
|
170
|
+
* traversal, no external calls.
|
|
171
|
+
*/
|
|
172
|
+
declare function resolveJsonPointer(json: string, pointer: string): JsonPointerResult;
|
|
151
173
|
|
|
152
174
|
type json_ConvertOptions = ConvertOptions;
|
|
153
175
|
type json_CsvOptions = CsvOptions;
|
|
@@ -158,6 +180,7 @@ type json_GoStruct = GoStruct;
|
|
|
158
180
|
type json_JsonDiffResult = JsonDiffResult;
|
|
159
181
|
type json_JsonParseResult = JsonParseResult;
|
|
160
182
|
type json_JsonPathResult = JsonPathResult;
|
|
183
|
+
type json_JsonPointerResult = JsonPointerResult;
|
|
161
184
|
type json_ParseStatus = ParseStatus;
|
|
162
185
|
type json_PythonClass = PythonClass;
|
|
163
186
|
type json_PythonField = PythonField;
|
|
@@ -185,6 +208,7 @@ declare const json_jsonToZod: typeof jsonToZod;
|
|
|
185
208
|
declare const json_minifyJson: typeof minifyJson;
|
|
186
209
|
declare const json_parseJson: typeof parseJson;
|
|
187
210
|
declare const json_parseStructs: typeof parseStructs;
|
|
211
|
+
declare const json_resolveJsonPointer: typeof resolveJsonPointer;
|
|
188
212
|
declare const json_toPascalCase: typeof toPascalCase;
|
|
189
213
|
declare const json_toSnakeCase: typeof toSnakeCase;
|
|
190
214
|
declare const json_validateJson: typeof validateJson;
|
|
@@ -192,7 +216,7 @@ declare const json_validateJsonPath: typeof validateJsonPath;
|
|
|
192
216
|
declare const json_validateJsonString: typeof validateJsonString;
|
|
193
217
|
declare const json_yamlToJson: typeof yamlToJson;
|
|
194
218
|
declare namespace json {
|
|
195
|
-
export { type json_ConvertOptions as ConvertOptions, type json_CsvOptions as CsvOptions, type json_DiffNode as DiffNode, type json_DiffType as DiffType, type json_GoField as GoField, type json_GoStruct as GoStruct, type json_JsonDiffResult as JsonDiffResult, type json_JsonParseResult as JsonParseResult, type json_JsonPathResult as JsonPathResult, type json_ParseStatus as ParseStatus, type json_PythonClass as PythonClass, type json_PythonField as PythonField, type json_PythonMode as PythonMode, type json_ValidationError as ValidationError, type json_ValidationResult as ValidationResult, type json_ZodOptions as ZodOptions, json_csvToJson as csvToJson, json_detectFormat as detectFormat, json_diffJson as diffJson, json_evaluateJsonPath as evaluateJsonPath, json_formatDiffLine as formatDiffLine, json_formatJson as formatJson, json_generateExample as generateExample, json_getJsonStats as getJsonStats, json_inferGoType as inferGoType, json_inferPythonType as inferPythonType, json_inferType as inferType, json_jsonToCsv as jsonToCsv, json_jsonToGo as jsonToGo, json_jsonToPython as jsonToPython, json_jsonToTypescript as jsonToTypescript, json_jsonToYaml as jsonToYaml, json_jsonToZod as jsonToZod, json_minifyJson as minifyJson, json_parseJson as parseJson, json_parseStructs as parseStructs, json_toPascalCase as toPascalCase, json_toSnakeCase as toSnakeCase, json_validateJson as validateJson, json_validateJsonPath as validateJsonPath, json_validateJsonString as validateJsonString, json_yamlToJson as yamlToJson };
|
|
219
|
+
export { type json_ConvertOptions as ConvertOptions, type json_CsvOptions as CsvOptions, type json_DiffNode as DiffNode, type json_DiffType as DiffType, type json_GoField as GoField, type json_GoStruct as GoStruct, type json_JsonDiffResult as JsonDiffResult, type json_JsonParseResult as JsonParseResult, type json_JsonPathResult as JsonPathResult, type json_JsonPointerResult as JsonPointerResult, type json_ParseStatus as ParseStatus, type json_PythonClass as PythonClass, type json_PythonField as PythonField, type json_PythonMode as PythonMode, type json_ValidationError as ValidationError, type json_ValidationResult as ValidationResult, type json_ZodOptions as ZodOptions, json_csvToJson as csvToJson, json_detectFormat as detectFormat, json_diffJson as diffJson, json_evaluateJsonPath as evaluateJsonPath, json_formatDiffLine as formatDiffLine, json_formatJson as formatJson, json_generateExample as generateExample, json_getJsonStats as getJsonStats, json_inferGoType as inferGoType, json_inferPythonType as inferPythonType, json_inferType as inferType, json_jsonToCsv as jsonToCsv, json_jsonToGo as jsonToGo, json_jsonToPython as jsonToPython, json_jsonToTypescript as jsonToTypescript, json_jsonToYaml as jsonToYaml, json_jsonToZod as jsonToZod, json_minifyJson as minifyJson, json_parseJson as parseJson, json_parseStructs as parseStructs, json_resolveJsonPointer as resolveJsonPointer, json_toPascalCase as toPascalCase, json_toSnakeCase as toSnakeCase, json_validateJson as validateJson, json_validateJsonPath as validateJsonPath, json_validateJsonString as validateJsonString, json_yamlToJson as yamlToJson };
|
|
196
220
|
}
|
|
197
221
|
|
|
198
|
-
export {
|
|
222
|
+
export { jsonToYaml as A, jsonToZod as B, type ConvertOptions as C, type DiffNode as D, minifyJson as E, parseJson as F, type GoField as G, parseStructs as H, resolveJsonPointer as I, type JsonDiffResult as J, toPascalCase as K, toSnakeCase as L, validateJson as M, validateJsonPath as N, validateJsonString as O, type ParseStatus as P, yamlToJson as Q, type ValidationError as V, type ZodOptions as Z, type CsvOptions as a, type DiffType as b, type GoStruct as c, type JsonParseResult as d, type JsonPathResult as e, type JsonPointerResult as f, type PythonClass as g, type PythonField as h, type PythonMode as i, json as j, type ValidationResult as k, csvToJson as l, detectFormat as m, diffJson as n, evaluateJsonPath as o, formatDiffLine as p, formatJson as q, generateExample as r, getJsonStats as s, inferGoType as t, inferPythonType as u, inferType as v, jsonToCsv as w, jsonToGo as x, jsonToPython as y, jsonToTypescript as z };
|
|
@@ -148,6 +148,28 @@ interface ZodOptions {
|
|
|
148
148
|
declare function jsonToZod(json: string, options?: ZodOptions): string | {
|
|
149
149
|
error: string;
|
|
150
150
|
};
|
|
151
|
+
interface JsonPointerResult {
|
|
152
|
+
pointer: string;
|
|
153
|
+
found: boolean;
|
|
154
|
+
value?: unknown;
|
|
155
|
+
/** Decoded reference tokens (after ~1 -> / and ~0 -> ~ unescaping). */
|
|
156
|
+
tokens: string[];
|
|
157
|
+
/** Set when the input JSON is invalid or the pointer syntax is malformed. */
|
|
158
|
+
error?: string;
|
|
159
|
+
/** The reference token at which resolution stopped (found === false). */
|
|
160
|
+
failedAt?: string;
|
|
161
|
+
/** Why resolution stopped at `failedAt`. */
|
|
162
|
+
reason?: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Resolve an RFC 6901 JSON Pointer against a JSON document. Accepts both the
|
|
166
|
+
* plain form ("" for the whole document, or "/foo/0") and the URI-fragment
|
|
167
|
+
* form ("#/foo/0", percent-decoded). Distinguishes an invalid document /
|
|
168
|
+
* malformed pointer (`error`) from a syntactically valid pointer whose target
|
|
169
|
+
* is simply absent (`found: false` with `failedAt` + `reason`). Pure
|
|
170
|
+
* traversal, no external calls.
|
|
171
|
+
*/
|
|
172
|
+
declare function resolveJsonPointer(json: string, pointer: string): JsonPointerResult;
|
|
151
173
|
|
|
152
174
|
type json_ConvertOptions = ConvertOptions;
|
|
153
175
|
type json_CsvOptions = CsvOptions;
|
|
@@ -158,6 +180,7 @@ type json_GoStruct = GoStruct;
|
|
|
158
180
|
type json_JsonDiffResult = JsonDiffResult;
|
|
159
181
|
type json_JsonParseResult = JsonParseResult;
|
|
160
182
|
type json_JsonPathResult = JsonPathResult;
|
|
183
|
+
type json_JsonPointerResult = JsonPointerResult;
|
|
161
184
|
type json_ParseStatus = ParseStatus;
|
|
162
185
|
type json_PythonClass = PythonClass;
|
|
163
186
|
type json_PythonField = PythonField;
|
|
@@ -185,6 +208,7 @@ declare const json_jsonToZod: typeof jsonToZod;
|
|
|
185
208
|
declare const json_minifyJson: typeof minifyJson;
|
|
186
209
|
declare const json_parseJson: typeof parseJson;
|
|
187
210
|
declare const json_parseStructs: typeof parseStructs;
|
|
211
|
+
declare const json_resolveJsonPointer: typeof resolveJsonPointer;
|
|
188
212
|
declare const json_toPascalCase: typeof toPascalCase;
|
|
189
213
|
declare const json_toSnakeCase: typeof toSnakeCase;
|
|
190
214
|
declare const json_validateJson: typeof validateJson;
|
|
@@ -192,7 +216,7 @@ declare const json_validateJsonPath: typeof validateJsonPath;
|
|
|
192
216
|
declare const json_validateJsonString: typeof validateJsonString;
|
|
193
217
|
declare const json_yamlToJson: typeof yamlToJson;
|
|
194
218
|
declare namespace json {
|
|
195
|
-
export { type json_ConvertOptions as ConvertOptions, type json_CsvOptions as CsvOptions, type json_DiffNode as DiffNode, type json_DiffType as DiffType, type json_GoField as GoField, type json_GoStruct as GoStruct, type json_JsonDiffResult as JsonDiffResult, type json_JsonParseResult as JsonParseResult, type json_JsonPathResult as JsonPathResult, type json_ParseStatus as ParseStatus, type json_PythonClass as PythonClass, type json_PythonField as PythonField, type json_PythonMode as PythonMode, type json_ValidationError as ValidationError, type json_ValidationResult as ValidationResult, type json_ZodOptions as ZodOptions, json_csvToJson as csvToJson, json_detectFormat as detectFormat, json_diffJson as diffJson, json_evaluateJsonPath as evaluateJsonPath, json_formatDiffLine as formatDiffLine, json_formatJson as formatJson, json_generateExample as generateExample, json_getJsonStats as getJsonStats, json_inferGoType as inferGoType, json_inferPythonType as inferPythonType, json_inferType as inferType, json_jsonToCsv as jsonToCsv, json_jsonToGo as jsonToGo, json_jsonToPython as jsonToPython, json_jsonToTypescript as jsonToTypescript, json_jsonToYaml as jsonToYaml, json_jsonToZod as jsonToZod, json_minifyJson as minifyJson, json_parseJson as parseJson, json_parseStructs as parseStructs, json_toPascalCase as toPascalCase, json_toSnakeCase as toSnakeCase, json_validateJson as validateJson, json_validateJsonPath as validateJsonPath, json_validateJsonString as validateJsonString, json_yamlToJson as yamlToJson };
|
|
219
|
+
export { type json_ConvertOptions as ConvertOptions, type json_CsvOptions as CsvOptions, type json_DiffNode as DiffNode, type json_DiffType as DiffType, type json_GoField as GoField, type json_GoStruct as GoStruct, type json_JsonDiffResult as JsonDiffResult, type json_JsonParseResult as JsonParseResult, type json_JsonPathResult as JsonPathResult, type json_JsonPointerResult as JsonPointerResult, type json_ParseStatus as ParseStatus, type json_PythonClass as PythonClass, type json_PythonField as PythonField, type json_PythonMode as PythonMode, type json_ValidationError as ValidationError, type json_ValidationResult as ValidationResult, type json_ZodOptions as ZodOptions, json_csvToJson as csvToJson, json_detectFormat as detectFormat, json_diffJson as diffJson, json_evaluateJsonPath as evaluateJsonPath, json_formatDiffLine as formatDiffLine, json_formatJson as formatJson, json_generateExample as generateExample, json_getJsonStats as getJsonStats, json_inferGoType as inferGoType, json_inferPythonType as inferPythonType, json_inferType as inferType, json_jsonToCsv as jsonToCsv, json_jsonToGo as jsonToGo, json_jsonToPython as jsonToPython, json_jsonToTypescript as jsonToTypescript, json_jsonToYaml as jsonToYaml, json_jsonToZod as jsonToZod, json_minifyJson as minifyJson, json_parseJson as parseJson, json_parseStructs as parseStructs, json_resolveJsonPointer as resolveJsonPointer, json_toPascalCase as toPascalCase, json_toSnakeCase as toSnakeCase, json_validateJson as validateJson, json_validateJsonPath as validateJsonPath, json_validateJsonString as validateJsonString, json_yamlToJson as yamlToJson };
|
|
196
220
|
}
|
|
197
221
|
|
|
198
|
-
export {
|
|
222
|
+
export { jsonToYaml as A, jsonToZod as B, type ConvertOptions as C, type DiffNode as D, minifyJson as E, parseJson as F, type GoField as G, parseStructs as H, resolveJsonPointer as I, type JsonDiffResult as J, toPascalCase as K, toSnakeCase as L, validateJson as M, validateJsonPath as N, validateJsonString as O, type ParseStatus as P, yamlToJson as Q, type ValidationError as V, type ZodOptions as Z, type CsvOptions as a, type DiffType as b, type GoStruct as c, type JsonParseResult as d, type JsonPathResult as e, type JsonPointerResult as f, type PythonClass as g, type PythonField as h, type PythonMode as i, json as j, type ValidationResult as k, csvToJson as l, detectFormat as m, diffJson as n, evaluateJsonPath as o, formatDiffLine as p, formatJson as q, generateExample as r, getJsonStats as s, inferGoType as t, inferPythonType as u, inferType as v, jsonToCsv as w, jsonToGo as x, jsonToPython as y, jsonToTypescript as z };
|
package/dist/tools/json.cjs
CHANGED
|
@@ -1241,6 +1241,58 @@ function jsonToZod(json, options) {
|
|
|
1241
1241
|
|
|
1242
1242
|
export const ${rootName}Schema = ${schema}`;
|
|
1243
1243
|
}
|
|
1244
|
+
function _unescapePointerToken(token) {
|
|
1245
|
+
return token.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
1246
|
+
}
|
|
1247
|
+
function resolveJsonPointer(json, pointer) {
|
|
1248
|
+
let parsed;
|
|
1249
|
+
try {
|
|
1250
|
+
parsed = JSON.parse(json);
|
|
1251
|
+
} catch {
|
|
1252
|
+
return { pointer, found: false, tokens: [], error: "Invalid JSON input" };
|
|
1253
|
+
}
|
|
1254
|
+
let ptr = pointer;
|
|
1255
|
+
if (ptr.startsWith("#")) {
|
|
1256
|
+
ptr = ptr.slice(1);
|
|
1257
|
+
try {
|
|
1258
|
+
ptr = decodeURIComponent(ptr);
|
|
1259
|
+
} catch {
|
|
1260
|
+
return { pointer, found: false, tokens: [], error: "Invalid percent-encoding in URI-fragment pointer" };
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
if (ptr === "") {
|
|
1264
|
+
return { pointer, found: true, value: parsed, tokens: [] };
|
|
1265
|
+
}
|
|
1266
|
+
if (!ptr.startsWith("/")) {
|
|
1267
|
+
return { pointer, found: false, tokens: [], error: "Pointer must be empty or start with '/' (RFC 6901)" };
|
|
1268
|
+
}
|
|
1269
|
+
const tokens = ptr.split("/").slice(1).map(_unescapePointerToken);
|
|
1270
|
+
let current = parsed;
|
|
1271
|
+
for (const token of tokens) {
|
|
1272
|
+
if (Array.isArray(current)) {
|
|
1273
|
+
if (token === "-") {
|
|
1274
|
+
return { pointer, found: false, tokens, failedAt: token, reason: '"-" refers to the nonexistent element after the end of the array' };
|
|
1275
|
+
}
|
|
1276
|
+
if (!/^(0|[1-9][0-9]*)$/.test(token)) {
|
|
1277
|
+
return { pointer, found: false, tokens, failedAt: token, reason: `"${token}" is not a valid array index` };
|
|
1278
|
+
}
|
|
1279
|
+
const idx = Number(token);
|
|
1280
|
+
if (idx >= current.length) {
|
|
1281
|
+
return { pointer, found: false, tokens, failedAt: token, reason: `array index ${idx} is out of bounds (length ${current.length})` };
|
|
1282
|
+
}
|
|
1283
|
+
current = current[idx];
|
|
1284
|
+
} else if (current !== null && typeof current === "object") {
|
|
1285
|
+
const obj = current;
|
|
1286
|
+
if (!Object.prototype.hasOwnProperty.call(obj, token)) {
|
|
1287
|
+
return { pointer, found: false, tokens, failedAt: token, reason: `key "${token}" not found` };
|
|
1288
|
+
}
|
|
1289
|
+
current = obj[token];
|
|
1290
|
+
} else {
|
|
1291
|
+
return { pointer, found: false, tokens, failedAt: token, reason: `cannot descend into ${current === null ? "null" : typeof current} at "${token}"` };
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
return { pointer, found: true, value: current, tokens };
|
|
1295
|
+
}
|
|
1244
1296
|
|
|
1245
1297
|
exports.csvToJson = csvToJson;
|
|
1246
1298
|
exports.detectFormat = detectFormat;
|
|
@@ -1262,6 +1314,7 @@ exports.jsonToZod = jsonToZod;
|
|
|
1262
1314
|
exports.minifyJson = minifyJson;
|
|
1263
1315
|
exports.parseJson = parseJson;
|
|
1264
1316
|
exports.parseStructs = parseStructs;
|
|
1317
|
+
exports.resolveJsonPointer = resolveJsonPointer;
|
|
1265
1318
|
exports.toPascalCase = toPascalCase;
|
|
1266
1319
|
exports.toSnakeCase = toSnakeCase;
|
|
1267
1320
|
exports.validateJson = validateJson;
|
package/dist/tools/json.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as ConvertOptions, a as CsvOptions, D as DiffNode, b as DiffType, G as GoField, c as GoStruct, J as JsonDiffResult, d as JsonParseResult, e as JsonPathResult, P as ParseStatus,
|
|
1
|
+
export { C as ConvertOptions, a as CsvOptions, D as DiffNode, b as DiffType, G as GoField, c as GoStruct, J as JsonDiffResult, d as JsonParseResult, e as JsonPathResult, f as JsonPointerResult, P as ParseStatus, g as PythonClass, h as PythonField, i as PythonMode, V as ValidationError, k as ValidationResult, Z as ZodOptions, l as csvToJson, m as detectFormat, n as diffJson, o as evaluateJsonPath, p as formatDiffLine, q as formatJson, r as generateExample, s as getJsonStats, t as inferGoType, u as inferPythonType, v as inferType, w as jsonToCsv, x as jsonToGo, y as jsonToPython, z as jsonToTypescript, A as jsonToYaml, B as jsonToZod, E as minifyJson, F as parseJson, H as parseStructs, I as resolveJsonPointer, K as toPascalCase, L as toSnakeCase, M as validateJson, N as validateJsonPath, O as validateJsonString, Q as yamlToJson } from '../json-DEVFIpsC.cjs';
|
package/dist/tools/json.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as ConvertOptions, a as CsvOptions, D as DiffNode, b as DiffType, G as GoField, c as GoStruct, J as JsonDiffResult, d as JsonParseResult, e as JsonPathResult, P as ParseStatus,
|
|
1
|
+
export { C as ConvertOptions, a as CsvOptions, D as DiffNode, b as DiffType, G as GoField, c as GoStruct, J as JsonDiffResult, d as JsonParseResult, e as JsonPathResult, f as JsonPointerResult, P as ParseStatus, g as PythonClass, h as PythonField, i as PythonMode, V as ValidationError, k as ValidationResult, Z as ZodOptions, l as csvToJson, m as detectFormat, n as diffJson, o as evaluateJsonPath, p as formatDiffLine, q as formatJson, r as generateExample, s as getJsonStats, t as inferGoType, u as inferPythonType, v as inferType, w as jsonToCsv, x as jsonToGo, y as jsonToPython, z as jsonToTypescript, A as jsonToYaml, B as jsonToZod, E as minifyJson, F as parseJson, H as parseStructs, I as resolveJsonPointer, K as toPascalCase, L as toSnakeCase, M as validateJson, N as validateJsonPath, O as validateJsonString, Q as yamlToJson } from '../json-DEVFIpsC.js';
|
package/dist/tools/json.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { csvToJson, detectFormat, diffJson, evaluateJsonPath, formatDiffLine, formatJson, generateExample, getJsonStats, inferGoType, inferPythonType, inferType, jsonToCsv, jsonToGo, jsonToPython, jsonToTypescript, jsonToYaml, jsonToZod, minifyJson, parseJson, parseStructs, toPascalCase, toSnakeCase, validateJson, validateJsonPath, validateJsonString, yamlToJson } from '../chunk-
|
|
1
|
+
export { csvToJson, detectFormat, diffJson, evaluateJsonPath, formatDiffLine, formatJson, generateExample, getJsonStats, inferGoType, inferPythonType, inferType, jsonToCsv, jsonToGo, jsonToPython, jsonToTypescript, jsonToYaml, jsonToZod, minifyJson, parseJson, parseStructs, resolveJsonPointer, toPascalCase, toSnakeCase, validateJson, validateJsonPath, validateJsonString, yamlToJson } from '../chunk-WO3LJMVV.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
package/dist/tools/units.cjs
CHANGED
|
@@ -1264,6 +1264,29 @@ function calculateTimeValue(amount, annualRatePercent, years, direction, compoun
|
|
|
1264
1264
|
interest: round22(futureValue - presentValue)
|
|
1265
1265
|
};
|
|
1266
1266
|
}
|
|
1267
|
+
function calculatePercentageChange(oldValue, newValue) {
|
|
1268
|
+
if (!Number.isFinite(oldValue)) return { error: "Original value must be a finite number" };
|
|
1269
|
+
if (!Number.isFinite(newValue)) return { error: "New value must be a finite number" };
|
|
1270
|
+
if (oldValue === 0 && newValue !== 0) {
|
|
1271
|
+
return { error: "Percentage change from zero is undefined (division by zero); use a nonzero original value" };
|
|
1272
|
+
}
|
|
1273
|
+
const round4 = (n) => Math.round(n * 1e4) / 1e4;
|
|
1274
|
+
const absoluteChange = newValue - oldValue;
|
|
1275
|
+
const percentChange = oldValue === 0 ? 0 : absoluteChange / Math.abs(oldValue) * 100;
|
|
1276
|
+
const multiplier = oldValue === 0 ? 1 : newValue / oldValue;
|
|
1277
|
+
let direction;
|
|
1278
|
+
if (absoluteChange > 0) direction = "increase";
|
|
1279
|
+
else if (absoluteChange < 0) direction = "decrease";
|
|
1280
|
+
else direction = "no change";
|
|
1281
|
+
return {
|
|
1282
|
+
oldValue,
|
|
1283
|
+
newValue,
|
|
1284
|
+
absoluteChange: round4(absoluteChange),
|
|
1285
|
+
percentChange: round4(percentChange),
|
|
1286
|
+
direction,
|
|
1287
|
+
multiplier: round4(multiplier)
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1267
1290
|
|
|
1268
1291
|
exports.BASE_LABELS = BASE_LABELS;
|
|
1269
1292
|
exports.BASE_PREFIXES = BASE_PREFIXES;
|
|
@@ -1282,6 +1305,7 @@ exports.calcAspectRatio = calcAspectRatio;
|
|
|
1282
1305
|
exports.calcSubnet = calcSubnet;
|
|
1283
1306
|
exports.calculateCompoundInterest = calculateCompoundInterest;
|
|
1284
1307
|
exports.calculateLoan = calculateLoan;
|
|
1308
|
+
exports.calculatePercentageChange = calculatePercentageChange;
|
|
1285
1309
|
exports.calculateSimpleInterest = calculateSimpleInterest;
|
|
1286
1310
|
exports.calculateTax = calculateTax;
|
|
1287
1311
|
exports.calculateTimeValue = calculateTimeValue;
|
package/dist/tools/units.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as AmortizationRow, a as AspectRatioResult, B as BASE_LABELS, b as BASE_PREFIXES, c as BYTE_UNITS, d as BarcodeFormat, e as BarcodeValidationResult, f as BaseConvertResult, g as ByteConvertResult, h as ByteUnit, C as COMMON_CURRENCIES, i as COMMON_LOCALES, j as COMMON_PERMISSIONS, k as COMMON_RATIOS, l as COMMON_SIZES, m as COMMON_TAX_RATES, n as COMMON_TIP_PERCENTAGES, o as COMMON_VIEWPORTS, p as CardValidationResult, q as CompoundInterestResult, r as CompoundYearRow, D as Dimensions, F as FilePermissions, s as FormatOptions, I as IbanValidationResult, t as IpConversion, v as IsbnFormat, w as IsbnResult, L as LoanResult, N as NotationStyle, x as NumberBase, P as
|
|
1
|
+
export { A as AmortizationRow, a as AspectRatioResult, B as BASE_LABELS, b as BASE_PREFIXES, c as BYTE_UNITS, d as BarcodeFormat, e as BarcodeValidationResult, f as BaseConvertResult, g as ByteConvertResult, h as ByteUnit, C as COMMON_CURRENCIES, i as COMMON_LOCALES, j as COMMON_PERMISSIONS, k as COMMON_RATIOS, l as COMMON_SIZES, m as COMMON_TAX_RATES, n as COMMON_TIP_PERCENTAGES, o as COMMON_VIEWPORTS, p as CardValidationResult, q as CompoundInterestResult, r as CompoundYearRow, D as Dimensions, F as FilePermissions, s as FormatOptions, I as IbanValidationResult, t as IpConversion, v as IsbnFormat, w as IsbnResult, L as LoanResult, N as NotationStyle, x as NumberBase, P as PercentChangeDirection, y as PercentageChangeResult, z as Permission, E as PxConvertResult, S as SemverVersion, G as SimpleInterestResult, H as SubnetInfo, T as TaxDirection, J as TaxResult, K as TimeValueDirection, M as TimeValueResult, O as TipSplitResult, V as ViewportConvertResult, Q as autoFormat, R as bumpVersion, U as calcAspectRatio, W as calcSubnet, X as calculateCompoundInterest, Y as calculateLoan, Z as calculatePercentageChange, _ as calculateSimpleInterest, $ as calculateTax, a0 as calculateTimeValue, a1 as calculateTipSplit, a2 as compareSemver, a3 as convert, a4 as convertBytes, a5 as convertIp, a6 as coverBox, a7 as decimalToIp, a8 as decimalToIpCidr, a9 as describePermissions, aa as fitIntoBox, ab as formatNumber, ac as formatValue, ad as formatVwValue, ae as formatWithSeparator, af as gcd, ag as ipFromBinary, ah as ipFromDecimal, ai as ipFromHex, aj as ipToBinary, ak as ipToDecimal, al as ipToDecimalCidr, am as ipToHex, an as ipToOctal, ao as isValid, ap as isValidCidr, aq as isValidIp, ar as isValidIpv4, as as octalToPermissions, at as parseFileSize, au as parseInput, av as parseNumberString, aw as parseSemver, ax as permissionsToChmod, ay as permissionsToOctal, az as permissionsToSymbolic, aA as ptToPx, aB as pxToAll, aC as pxToViewport, aD as remToPx, aE as satisfiesRange, aF as scaleByHeight, aG as scaleByWidth, aH as sortVersions, aI as splitSubnet, aJ as symbolicToPermissions, aK as validateBarcode, aL as validateCardNumber, aM as validateIban, aN as validateIsbn, aO as viewportToPx } from '../units-pIRkHnsU.cjs';
|
package/dist/tools/units.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as AmortizationRow, a as AspectRatioResult, B as BASE_LABELS, b as BASE_PREFIXES, c as BYTE_UNITS, d as BarcodeFormat, e as BarcodeValidationResult, f as BaseConvertResult, g as ByteConvertResult, h as ByteUnit, C as COMMON_CURRENCIES, i as COMMON_LOCALES, j as COMMON_PERMISSIONS, k as COMMON_RATIOS, l as COMMON_SIZES, m as COMMON_TAX_RATES, n as COMMON_TIP_PERCENTAGES, o as COMMON_VIEWPORTS, p as CardValidationResult, q as CompoundInterestResult, r as CompoundYearRow, D as Dimensions, F as FilePermissions, s as FormatOptions, I as IbanValidationResult, t as IpConversion, v as IsbnFormat, w as IsbnResult, L as LoanResult, N as NotationStyle, x as NumberBase, P as
|
|
1
|
+
export { A as AmortizationRow, a as AspectRatioResult, B as BASE_LABELS, b as BASE_PREFIXES, c as BYTE_UNITS, d as BarcodeFormat, e as BarcodeValidationResult, f as BaseConvertResult, g as ByteConvertResult, h as ByteUnit, C as COMMON_CURRENCIES, i as COMMON_LOCALES, j as COMMON_PERMISSIONS, k as COMMON_RATIOS, l as COMMON_SIZES, m as COMMON_TAX_RATES, n as COMMON_TIP_PERCENTAGES, o as COMMON_VIEWPORTS, p as CardValidationResult, q as CompoundInterestResult, r as CompoundYearRow, D as Dimensions, F as FilePermissions, s as FormatOptions, I as IbanValidationResult, t as IpConversion, v as IsbnFormat, w as IsbnResult, L as LoanResult, N as NotationStyle, x as NumberBase, P as PercentChangeDirection, y as PercentageChangeResult, z as Permission, E as PxConvertResult, S as SemverVersion, G as SimpleInterestResult, H as SubnetInfo, T as TaxDirection, J as TaxResult, K as TimeValueDirection, M as TimeValueResult, O as TipSplitResult, V as ViewportConvertResult, Q as autoFormat, R as bumpVersion, U as calcAspectRatio, W as calcSubnet, X as calculateCompoundInterest, Y as calculateLoan, Z as calculatePercentageChange, _ as calculateSimpleInterest, $ as calculateTax, a0 as calculateTimeValue, a1 as calculateTipSplit, a2 as compareSemver, a3 as convert, a4 as convertBytes, a5 as convertIp, a6 as coverBox, a7 as decimalToIp, a8 as decimalToIpCidr, a9 as describePermissions, aa as fitIntoBox, ab as formatNumber, ac as formatValue, ad as formatVwValue, ae as formatWithSeparator, af as gcd, ag as ipFromBinary, ah as ipFromDecimal, ai as ipFromHex, aj as ipToBinary, ak as ipToDecimal, al as ipToDecimalCidr, am as ipToHex, an as ipToOctal, ao as isValid, ap as isValidCidr, aq as isValidIp, ar as isValidIpv4, as as octalToPermissions, at as parseFileSize, au as parseInput, av as parseNumberString, aw as parseSemver, ax as permissionsToChmod, ay as permissionsToOctal, az as permissionsToSymbolic, aA as ptToPx, aB as pxToAll, aC as pxToViewport, aD as remToPx, aE as satisfiesRange, aF as scaleByHeight, aG as scaleByWidth, aH as sortVersions, aI as splitSubnet, aJ as symbolicToPermissions, aK as validateBarcode, aL as validateCardNumber, aM as validateIban, aN as validateIsbn, aO as viewportToPx } from '../units-pIRkHnsU.js';
|
package/dist/tools/units.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_TIP_PERCENTAGES, COMMON_VIEWPORTS, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateCompoundInterest, calculateLoan, calculateSimpleInterest, calculateTax, calculateTimeValue, calculateTipSplit, compareSemver, convert, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, validateBarcode, validateCardNumber, validateIban, validateIsbn, viewportToPx } from '../chunk-
|
|
1
|
+
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_TIP_PERCENTAGES, COMMON_VIEWPORTS, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateCompoundInterest, calculateLoan, calculatePercentageChange, calculateSimpleInterest, calculateTax, calculateTimeValue, calculateTipSplit, compareSemver, convert, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, validateBarcode, validateCardNumber, validateIban, validateIsbn, viewportToPx } from '../chunk-TFNCFD3E.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
|
@@ -429,6 +429,25 @@ interface TimeValueResult {
|
|
|
429
429
|
declare function calculateTimeValue(amount: number, annualRatePercent: number, years: number, direction: TimeValueDirection, compoundsPerYear?: number): TimeValueResult | {
|
|
430
430
|
error: string;
|
|
431
431
|
};
|
|
432
|
+
type PercentChangeDirection = "increase" | "decrease" | "no change";
|
|
433
|
+
interface PercentageChangeResult {
|
|
434
|
+
oldValue: number;
|
|
435
|
+
newValue: number;
|
|
436
|
+
absoluteChange: number;
|
|
437
|
+
percentChange: number;
|
|
438
|
+
direction: PercentChangeDirection;
|
|
439
|
+
multiplier: number;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Percentage change from oldValue to newValue: ((new - old) / |old|) * 100.
|
|
443
|
+
* `absoluteChange` is the raw difference (new - old) and `multiplier` is
|
|
444
|
+
* new / old (how many times the original the new value is). The original
|
|
445
|
+
* value cannot be zero (division by zero) unless the new value is also zero.
|
|
446
|
+
* Pure arithmetic over user-supplied numbers.
|
|
447
|
+
*/
|
|
448
|
+
declare function calculatePercentageChange(oldValue: number, newValue: number): PercentageChangeResult | {
|
|
449
|
+
error: string;
|
|
450
|
+
};
|
|
432
451
|
|
|
433
452
|
type units_AmortizationRow = AmortizationRow;
|
|
434
453
|
type units_AspectRatioResult = AspectRatioResult;
|
|
@@ -461,6 +480,8 @@ type units_IsbnResult = IsbnResult;
|
|
|
461
480
|
type units_LoanResult = LoanResult;
|
|
462
481
|
type units_NotationStyle = NotationStyle;
|
|
463
482
|
type units_NumberBase = NumberBase;
|
|
483
|
+
type units_PercentChangeDirection = PercentChangeDirection;
|
|
484
|
+
type units_PercentageChangeResult = PercentageChangeResult;
|
|
464
485
|
type units_Permission = Permission;
|
|
465
486
|
type units_PxConvertResult = PxConvertResult;
|
|
466
487
|
type units_SemverVersion = SemverVersion;
|
|
@@ -478,6 +499,7 @@ declare const units_calcAspectRatio: typeof calcAspectRatio;
|
|
|
478
499
|
declare const units_calcSubnet: typeof calcSubnet;
|
|
479
500
|
declare const units_calculateCompoundInterest: typeof calculateCompoundInterest;
|
|
480
501
|
declare const units_calculateLoan: typeof calculateLoan;
|
|
502
|
+
declare const units_calculatePercentageChange: typeof calculatePercentageChange;
|
|
481
503
|
declare const units_calculateSimpleInterest: typeof calculateSimpleInterest;
|
|
482
504
|
declare const units_calculateTax: typeof calculateTax;
|
|
483
505
|
declare const units_calculateTimeValue: typeof calculateTimeValue;
|
|
@@ -532,7 +554,7 @@ declare const units_validateIban: typeof validateIban;
|
|
|
532
554
|
declare const units_validateIsbn: typeof validateIsbn;
|
|
533
555
|
declare const units_viewportToPx: typeof viewportToPx;
|
|
534
556
|
declare namespace units {
|
|
535
|
-
export { type units_AmortizationRow as AmortizationRow, type units_AspectRatioResult as AspectRatioResult, units_BASE_LABELS as BASE_LABELS, units_BASE_PREFIXES as BASE_PREFIXES, units_BYTE_UNITS as BYTE_UNITS, type units_BarcodeFormat as BarcodeFormat, type units_BarcodeValidationResult as BarcodeValidationResult, type units_BaseConvertResult as BaseConvertResult, type units_ByteConvertResult as ByteConvertResult, type units_ByteUnit as ByteUnit, units_COMMON_CURRENCIES as COMMON_CURRENCIES, units_COMMON_LOCALES as COMMON_LOCALES, units_COMMON_PERMISSIONS as COMMON_PERMISSIONS, units_COMMON_RATIOS as COMMON_RATIOS, units_COMMON_SIZES as COMMON_SIZES, units_COMMON_TAX_RATES as COMMON_TAX_RATES, units_COMMON_TIP_PERCENTAGES as COMMON_TIP_PERCENTAGES, units_COMMON_VIEWPORTS as COMMON_VIEWPORTS, type units_CardValidationResult as CardValidationResult, type units_CompoundInterestResult as CompoundInterestResult, type units_CompoundYearRow as CompoundYearRow, type units_Dimensions as Dimensions, type units_FilePermissions as FilePermissions, type units_FormatOptions as FormatOptions, type units_IbanValidationResult as IbanValidationResult, type units_IpConversion as IpConversion, type units_IsbnFormat as IsbnFormat, type units_IsbnResult as IsbnResult, type units_LoanResult as LoanResult, type units_NotationStyle as NotationStyle, type units_NumberBase as NumberBase, type units_Permission as Permission, type units_PxConvertResult as PxConvertResult, type units_SemverVersion as SemverVersion, type units_SimpleInterestResult as SimpleInterestResult, type units_SubnetInfo as SubnetInfo, type units_TaxDirection as TaxDirection, type units_TaxResult as TaxResult, type units_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_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 };
|
|
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 };
|
|
536
558
|
}
|
|
537
559
|
|
|
538
|
-
export {
|
|
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 };
|
|
@@ -429,6 +429,25 @@ interface TimeValueResult {
|
|
|
429
429
|
declare function calculateTimeValue(amount: number, annualRatePercent: number, years: number, direction: TimeValueDirection, compoundsPerYear?: number): TimeValueResult | {
|
|
430
430
|
error: string;
|
|
431
431
|
};
|
|
432
|
+
type PercentChangeDirection = "increase" | "decrease" | "no change";
|
|
433
|
+
interface PercentageChangeResult {
|
|
434
|
+
oldValue: number;
|
|
435
|
+
newValue: number;
|
|
436
|
+
absoluteChange: number;
|
|
437
|
+
percentChange: number;
|
|
438
|
+
direction: PercentChangeDirection;
|
|
439
|
+
multiplier: number;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Percentage change from oldValue to newValue: ((new - old) / |old|) * 100.
|
|
443
|
+
* `absoluteChange` is the raw difference (new - old) and `multiplier` is
|
|
444
|
+
* new / old (how many times the original the new value is). The original
|
|
445
|
+
* value cannot be zero (division by zero) unless the new value is also zero.
|
|
446
|
+
* Pure arithmetic over user-supplied numbers.
|
|
447
|
+
*/
|
|
448
|
+
declare function calculatePercentageChange(oldValue: number, newValue: number): PercentageChangeResult | {
|
|
449
|
+
error: string;
|
|
450
|
+
};
|
|
432
451
|
|
|
433
452
|
type units_AmortizationRow = AmortizationRow;
|
|
434
453
|
type units_AspectRatioResult = AspectRatioResult;
|
|
@@ -461,6 +480,8 @@ type units_IsbnResult = IsbnResult;
|
|
|
461
480
|
type units_LoanResult = LoanResult;
|
|
462
481
|
type units_NotationStyle = NotationStyle;
|
|
463
482
|
type units_NumberBase = NumberBase;
|
|
483
|
+
type units_PercentChangeDirection = PercentChangeDirection;
|
|
484
|
+
type units_PercentageChangeResult = PercentageChangeResult;
|
|
464
485
|
type units_Permission = Permission;
|
|
465
486
|
type units_PxConvertResult = PxConvertResult;
|
|
466
487
|
type units_SemverVersion = SemverVersion;
|
|
@@ -478,6 +499,7 @@ declare const units_calcAspectRatio: typeof calcAspectRatio;
|
|
|
478
499
|
declare const units_calcSubnet: typeof calcSubnet;
|
|
479
500
|
declare const units_calculateCompoundInterest: typeof calculateCompoundInterest;
|
|
480
501
|
declare const units_calculateLoan: typeof calculateLoan;
|
|
502
|
+
declare const units_calculatePercentageChange: typeof calculatePercentageChange;
|
|
481
503
|
declare const units_calculateSimpleInterest: typeof calculateSimpleInterest;
|
|
482
504
|
declare const units_calculateTax: typeof calculateTax;
|
|
483
505
|
declare const units_calculateTimeValue: typeof calculateTimeValue;
|
|
@@ -532,7 +554,7 @@ declare const units_validateIban: typeof validateIban;
|
|
|
532
554
|
declare const units_validateIsbn: typeof validateIsbn;
|
|
533
555
|
declare const units_viewportToPx: typeof viewportToPx;
|
|
534
556
|
declare namespace units {
|
|
535
|
-
export { type units_AmortizationRow as AmortizationRow, type units_AspectRatioResult as AspectRatioResult, units_BASE_LABELS as BASE_LABELS, units_BASE_PREFIXES as BASE_PREFIXES, units_BYTE_UNITS as BYTE_UNITS, type units_BarcodeFormat as BarcodeFormat, type units_BarcodeValidationResult as BarcodeValidationResult, type units_BaseConvertResult as BaseConvertResult, type units_ByteConvertResult as ByteConvertResult, type units_ByteUnit as ByteUnit, units_COMMON_CURRENCIES as COMMON_CURRENCIES, units_COMMON_LOCALES as COMMON_LOCALES, units_COMMON_PERMISSIONS as COMMON_PERMISSIONS, units_COMMON_RATIOS as COMMON_RATIOS, units_COMMON_SIZES as COMMON_SIZES, units_COMMON_TAX_RATES as COMMON_TAX_RATES, units_COMMON_TIP_PERCENTAGES as COMMON_TIP_PERCENTAGES, units_COMMON_VIEWPORTS as COMMON_VIEWPORTS, type units_CardValidationResult as CardValidationResult, type units_CompoundInterestResult as CompoundInterestResult, type units_CompoundYearRow as CompoundYearRow, type units_Dimensions as Dimensions, type units_FilePermissions as FilePermissions, type units_FormatOptions as FormatOptions, type units_IbanValidationResult as IbanValidationResult, type units_IpConversion as IpConversion, type units_IsbnFormat as IsbnFormat, type units_IsbnResult as IsbnResult, type units_LoanResult as LoanResult, type units_NotationStyle as NotationStyle, type units_NumberBase as NumberBase, type units_Permission as Permission, type units_PxConvertResult as PxConvertResult, type units_SemverVersion as SemverVersion, type units_SimpleInterestResult as SimpleInterestResult, type units_SubnetInfo as SubnetInfo, type units_TaxDirection as TaxDirection, type units_TaxResult as TaxResult, type units_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_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 };
|
|
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 };
|
|
536
558
|
}
|
|
537
559
|
|
|
538
|
-
export {
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utilix-tech/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.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",
|