@adamjanicki/ui 1.5.2 → 1.5.3

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.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Assert a condition
3
+ *
4
+ * @param predicate the condition to assert
5
+ * @param message optional error message
6
+ */
7
+ export default function assert<T>(predicate: T, message?: string): void;
8
+ /**
9
+ * Assert a value is defined
10
+ *
11
+ * @param value the value to assert presence of
12
+ * @param message optional error message
13
+ * @returns the present value
14
+ */
15
+ export declare function assertDefined<T>(value: T | undefined, message?: string): T;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Assert a condition
3
+ *
4
+ * @param predicate the condition to assert
5
+ * @param message optional error message
6
+ */
7
+ export default function assert(predicate, message) {
8
+ if (!predicate) {
9
+ throw new Error(message || "Assertion error");
10
+ }
11
+ }
12
+ /**
13
+ * Assert a value is defined
14
+ *
15
+ * @param value the value to assert presence of
16
+ * @param message optional error message
17
+ * @returns the present value
18
+ */
19
+ export function assertDefined(value, message) {
20
+ if (value === undefined) {
21
+ throw new Error(message || "Unexpected undefined value");
22
+ }
23
+ return value;
24
+ }
@@ -1,3 +1,4 @@
1
1
  import classNames from "./classNames";
2
2
  import scrollToId from "./scrollToId";
3
- export { classNames, scrollToId };
3
+ import assert, { assertDefined } from "./assert";
4
+ export { classNames, scrollToId, assert, assertDefined };
@@ -1,3 +1,4 @@
1
1
  import classNames from "./classNames";
2
2
  import scrollToId from "./scrollToId";
3
- export { classNames, scrollToId };
3
+ import assert, { assertDefined } from "./assert";
4
+ export { classNames, scrollToId, assert, assertDefined };
@@ -11,7 +11,6 @@ var useScrollToHash = function (config) {
11
11
  if (!active || (hash === null || hash === void 0 ? void 0 : hash.length) <= 1)
12
12
  return;
13
13
  var id = hash.substring(1);
14
- scrollToId(id, behavior);
15
14
  if (delay !== undefined) {
16
15
  var timeout_1 = setTimeout(function () { return scrollToId(id, behavior); }, delay);
17
16
  return function () { return clearTimeout(timeout_1); };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamjanicki/ui",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "Basic UI components and hooks for React in TypeScript",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",