@nexusbloom/cli 0.9.7 → 0.9.8

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/values.js +18 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexusbloom/cli",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "description": "NexusBloom CLI — run tools and workflows from your terminal",
5
5
  "type": "module",
6
6
  "bin": {
package/src/values.js CHANGED
@@ -274,8 +274,22 @@ export const TRANSFORMS = {
274
274
  const nums = v.filter((n) => typeof n === "number");
275
275
  return nums.length ? nums.reduce((a, b) => a + b, 0) / nums.length : MISSING;
276
276
  },
277
- min: (v) => (Array.isArray(v) && v.length ? Math.min(...v.filter((n) => typeof n === "number")) : v),
278
- max: (v) => (Array.isArray(v) && v.length ? Math.max(...v.filter((n) => typeof n === "number")) : v),
277
+ // These collapse an *array*; they do not compare against a bound. `clamp(lo,hi)`
278
+ // is the one that takes bounds. Ignoring a second argument silently was the
279
+ // reason `min(120, 60)` returned 120 instead of erroring, so it now returns the
280
+ // value untouched rather than pretending to have clamped anything.
281
+ min: (v, ...ignored) =>
282
+ ignored.length
283
+ ? v
284
+ : Array.isArray(v) && v.length
285
+ ? Math.min(...v.filter((n) => typeof n === "number"))
286
+ : v,
287
+ max: (v, ...ignored) =>
288
+ ignored.length
289
+ ? v
290
+ : Array.isArray(v) && v.length
291
+ ? Math.max(...v.filter((n) => typeof n === "number"))
292
+ : v,
279
293
  // Sum one field across an array of objects — the common "total of the column".
280
294
  sumBy: (v, key) => {
281
295
  if (!Array.isArray(v)) return v;
@@ -535,8 +549,8 @@ export const TRANSFORM_DOCS = {
535
549
  clamp: "keep a number between a low and a high",
536
550
  sum: "add up every number in an array",
537
551
  avg: "average of every number in an array",
538
- min: "smallest number in an array",
539
- max: "largest number in an array",
552
+ min: "smallest number in an array (to bound a single number use clamp)",
553
+ max: "largest number in an array (to bound a single number use clamp)",
540
554
  sumBy: "add up one field across an array of objects",
541
555
  eq: "is it equal to a value",
542
556
  ne: "is it different from a value",