shelving 1.34.0 → 1.35.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/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "state-management",
12
12
  "query-builder"
13
13
  ],
14
- "version": "1.34.0",
14
+ "version": "1.35.0",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",
package/util/number.d.ts CHANGED
@@ -11,6 +11,11 @@ export declare const IS_NUMBER: (v: unknown) => v is number;
11
11
  * - Everything else returns `null`
12
12
  */
13
13
  export declare function toNumber(value: unknown): number | null;
14
+ /**
15
+ * Assertively convert an unknown value to a finite number.
16
+ * @throws `AssertionError` if the value cannot be converted.
17
+ */
18
+ export declare function getNumber(value: unknown): number;
14
19
  /**
15
20
  * Round numbers to a given step.
16
21
  *
package/util/number.js CHANGED
@@ -21,6 +21,16 @@ export function toNumber(value) {
21
21
  return null;
22
22
  }
23
23
  const NUMERIC = /[^0-9-.]/g;
24
+ /**
25
+ * Assertively convert an unknown value to a finite number.
26
+ * @throws `AssertionError` if the value cannot be converted.
27
+ */
28
+ export function getNumber(value) {
29
+ const num = toNumber(value);
30
+ if (num === null)
31
+ throw new AssertionError("Must be number", value);
32
+ return num;
33
+ }
24
34
  /**
25
35
  * Round numbers to a given step.
26
36
  *