[fabric/core] Add ensureValue utility function and export utils

This commit is contained in:
Pablo Baleztena 2024-10-15 15:10:37 -03:00
parent 0ac04a839f
commit 76af85a496
3 changed files with 10 additions and 0 deletions

View File

@ -5,4 +5,5 @@ export * from "./result/index.js";
export * from "./run/index.js";
export * from "./time/index.js";
export * from "./types/index.js";
export * from "./utils/index.js";
export * from "./variant/index.js";

View File

@ -0,0 +1,8 @@
import { UnexpectedError } from "../error/unexpected-error.js";
export function ensureValue<T>(value?: T): T {
if (!value) {
throw new UnexpectedError("Value is undefined");
}
return value;
}

View File

@ -0,0 +1 @@
export * from "./ensure-value.js";