@stll/calculations 0.1.1 → 0.1.2

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/dist/index.d.ts +11 -11
  2. package/package.json +7 -7
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { CentsAmount, MoneyTotalsEntry } from "@stll/money";
2
2
  //#region src/index.d.ts
3
- declare const CALCULATION_KINDS: readonly ["count", "count-unique", "count-empty", "count-filled", "percent-empty", "percent-filled", "sum", "average", "median", "min", "max", "range", "percent-of-total"];
4
- type CalculationKind = (typeof CALCULATION_KINDS)[number];
3
+ export declare const CALCULATION_KINDS: readonly ["count", "count-unique", "count-empty", "count-filled", "percent-empty", "percent-filled", "sum", "average", "median", "min", "max", "range", "percent-of-total"];
4
+ export type CalculationKind = (typeof CALCULATION_KINDS)[number];
5
5
  /** Kinds that reduce the values themselves rather than counting rows. */
6
- declare const NUMERIC_CALCULATION_KINDS: readonly ["sum", "average", "median", "min", "max", "range", "percent-of-total"];
7
- type NumericCalculationKind = (typeof NUMERIC_CALCULATION_KINDS)[number];
8
- declare const isNumericCalculationKind: (kind: CalculationKind) => kind is NumericCalculationKind;
6
+ export declare const NUMERIC_CALCULATION_KINDS: readonly ["sum", "average", "median", "min", "max", "range", "percent-of-total"];
7
+ export type NumericCalculationKind = (typeof NUMERIC_CALCULATION_KINDS)[number];
8
+ export declare const isNumericCalculationKind: (kind: CalculationKind) => kind is NumericCalculationKind;
9
9
  /**
10
10
  * One row's contribution to a calculation.
11
11
  *
@@ -13,7 +13,7 @@ declare const isNumericCalculationKind: (kind: CalculationKind) => kind is Numer
13
13
  * rather than a null value so "no value" is never confused with the number
14
14
  * zero, which is what makes count-empty and average disagree correctly.
15
15
  */
16
- type CalculationValue = {
16
+ export type CalculationValue = {
17
17
  type: "empty";
18
18
  } | {
19
19
  type: "number";
@@ -26,7 +26,7 @@ type CalculationValue = {
26
26
  type: "text";
27
27
  value: string;
28
28
  };
29
- type CalculationUnsupportedReason =
29
+ export type CalculationUnsupportedReason =
30
30
  /** A numeric reduction over values that are not numbers. */
31
31
  "non-numeric" |
32
32
  /** Numbers mixed with money, or money the reduction cannot combine. */
@@ -35,7 +35,7 @@ type CalculationUnsupportedReason =
35
35
  "no-values" |
36
36
  /** A share of the whole, asked without being told what the whole is. */
37
37
  "no-scope";
38
- type CalculationResult =
38
+ export type CalculationResult =
39
39
  /** A number of rows. */
40
40
  {
41
41
  type: "count";
@@ -64,7 +64,7 @@ type CalculationResult =
64
64
  kind: CalculationKind;
65
65
  reason: CalculationUnsupportedReason;
66
66
  };
67
- type RunCalculationParams = {
67
+ export type RunCalculationParams = {
68
68
  kind: CalculationKind;
69
69
  /** The values in the column, in row order. */
70
70
  values: readonly CalculationValue[];
@@ -76,6 +76,6 @@ type RunCalculationParams = {
76
76
  */
77
77
  scopeValues?: readonly CalculationValue[] | undefined;
78
78
  };
79
- declare const runCalculation: ({ kind, values, scopeValues }: RunCalculationParams) => CalculationResult;
79
+ export declare const runCalculation: ({ kind, values, scopeValues }: RunCalculationParams) => CalculationResult;
80
80
  //#endregion
81
- export { CALCULATION_KINDS, CalculationKind, CalculationResult, CalculationUnsupportedReason, CalculationValue, type CentsAmount, type MoneyTotalsEntry, NUMERIC_CALCULATION_KINDS, NumericCalculationKind, RunCalculationParams, isNumericCalculationKind, runCalculation };
81
+ export type { CentsAmount, MoneyTotalsEntry };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/calculations",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Typed, unit-safe reducers for workspace column calculations.",
5
5
  "keywords": [
6
6
  "calculations",
@@ -39,23 +39,23 @@
39
39
  "build": "tsdown",
40
40
  "pack:dry-run": "bun pm pack --dry-run",
41
41
  "test": "bun test src",
42
- "test:property": "bun test --preload @stll/property-testing/preload $(grep -rlF 'fc.assert' src)",
42
+ "test:property": "bun test --preload @stll/property-testing/preload $(grep -rlE 'fc\\.assert|assertProperty' src)",
43
43
  "typecheck": "bun ../../packages/scripts/src/tsc-native.ts --noEmit",
44
- "lint": "cd ../.. && bun --bun oxlint -c oxlint.config.ts --report-unused-disable-directives-severity=error --deny-warnings --type-aware packages/calculations",
44
+ "lint": "cd ../.. && bun --bun oxlint -c oxlint.config.ts --report-unused-disable-directives-severity=error --type-aware --type-check packages/calculations",
45
45
  "lint:fix": "cd ../.. && bun --bun oxlint -c oxlint.config.ts --type-aware --fix packages/calculations",
46
46
  "format": "bun ../../scripts/run-oxfmt.ts .",
47
47
  "prepack": "bun run build"
48
48
  },
49
49
  "dependencies": {
50
- "@stll/money": "^0.2.0",
51
- "better-result": "3.0.0"
50
+ "@stll/money": "^0.3.0",
51
+ "better-result": "3.0.1"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@stll/property-testing": "0.0.0",
55
55
  "@stll/typescript-config": "0.0.0",
56
56
  "bun-types": "1.4.2",
57
- "fast-check": "^4.9.0",
58
- "tsdown": "0.22.14"
57
+ "fast-check": "^4.10.1",
58
+ "tsdown": "0.23.0"
59
59
  },
60
60
  "main": "./dist/index.js",
61
61
  "types": "./dist/index.d.ts"