@refactorlabs/recount 0.10.0 → 0.11.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/dist/index.cjs +15 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -25
- package/dist/index.d.ts +10 -25
- package/dist/index.js +15 -24
- package/dist/index.js.map +1 -1
- package/llms.md +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -474,9 +474,9 @@ var CalculationBuilder = class {
|
|
|
474
474
|
return __privateMethod(this, _CalculationBuilder_instances, kindLine_fn).call(this, "info", key, label, formula, options);
|
|
475
475
|
}
|
|
476
476
|
/**
|
|
477
|
-
* A tiered charge: per band, a
|
|
478
|
-
*
|
|
479
|
-
*
|
|
477
|
+
* A tiered charge: a charge per band, then a subtotal keyed `key` that's
|
|
478
|
+
* checked against `value`. Band n's quantity is the formula
|
|
479
|
+
* `clamp(quantity - before_n, 0, size_n) * periods`.
|
|
480
480
|
*/
|
|
481
481
|
tiers(key, options) {
|
|
482
482
|
return __privateMethod(this, _CalculationBuilder_instances, push_fn).call(this, { type: "tiers", key, options });
|
|
@@ -890,19 +890,19 @@ function addTiers(s, rawKey, options) {
|
|
|
890
890
|
const formula = p === void 0 || p === 1 || p === "1" ? amount : `${amount} * ${operandText(p)}`;
|
|
891
891
|
const range = size === null ? before === "0" ? `all${unitText}${perText}` : `over ${before}${unitText}${perText}` : i === 0 ? `first ${size}${unitText}${perText}` : `next ${size}${unitText}${perText}`;
|
|
892
892
|
const bandLabel = band?.label ?? `${base} tier ${n} (${range})`;
|
|
893
|
-
const
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
}
|
|
893
|
+
const bandKey = `${key}_${n}`;
|
|
894
|
+
const tooLong = formula.length > MAX_FORMULA;
|
|
895
|
+
if (tooLong) {
|
|
896
|
+
s.problems.push(
|
|
897
|
+
`${s.calcKey}.${bandKey}: quantity: the formula is ${formula.length} characters, over ${MAX_FORMULA}; the band isn't calculated`
|
|
898
|
+
);
|
|
899
|
+
}
|
|
900
900
|
charges.push(
|
|
901
901
|
addLine(s, {
|
|
902
|
-
key:
|
|
902
|
+
key: bandKey,
|
|
903
903
|
label: bandLabel,
|
|
904
904
|
kind: "charge",
|
|
905
|
-
quantity:
|
|
905
|
+
quantity: tooLong ? null : formula,
|
|
906
906
|
rate: band?.rate,
|
|
907
907
|
options: {
|
|
908
908
|
...band?.value !== void 0 && { value: band.value },
|
|
@@ -1418,24 +1418,15 @@ function fromPlain(calc) {
|
|
|
1418
1418
|
return b;
|
|
1419
1419
|
}
|
|
1420
1420
|
var units = {
|
|
1421
|
+
/** A fraction shown as a percentage: `0.03` is `3%`. */
|
|
1421
1422
|
percent: "%",
|
|
1423
|
+
/** Counts: singular at 1 ("1 day"), and per one in a rate ("$0.67/day"). */
|
|
1422
1424
|
days: "days",
|
|
1423
1425
|
months: "months",
|
|
1424
1426
|
years: "years",
|
|
1425
1427
|
hours: "hours",
|
|
1426
|
-
kWh: "kWh",
|
|
1427
|
-
MWh: "MWh",
|
|
1428
|
-
MJ: "MJ",
|
|
1429
|
-
GJ: "GJ",
|
|
1430
|
-
kW: "kW",
|
|
1431
|
-
kVA: "kVA",
|
|
1432
|
-
kWhPerYear: "kWh/yr",
|
|
1433
|
-
m2: "m\xB2",
|
|
1434
|
-
panels: "panels",
|
|
1435
1428
|
/** A rate per something: `units.per('AUD', 'kWh')` is `'AUD/kWh'`. */
|
|
1436
|
-
per: (unit, per) => `${unit}/${per}
|
|
1437
|
-
/** `units.perDay('AUD')` is `'AUD/day'`. */
|
|
1438
|
-
perDay: (unit) => `${unit}/day`
|
|
1429
|
+
per: (unit, per) => `${unit}/${per}`
|
|
1439
1430
|
};
|
|
1440
1431
|
|
|
1441
1432
|
// src/trace.ts
|