MCPcopy Create free account
hub / github.com/denoland/std / assertExists

Function assertExists

assert/exists.ts:21–31  ·  view source on GitHub ↗
(
  actual: T,
  msg?: string,
)

Source from the content-addressed store, hash-verified

19 * @param msg The optional message to include in the error if the assertion fails.
20 */
21export function assertExists<T>(
22 actual: T,
23 msg?: string,
24): asserts actual is NonNullable<T> {
25 if (actual === undefined || actual === null) {
26 const msgSuffix = msg ? `: ${msg}` : ".";
27 msg =
28 `Expected actual: "${actual}" to not be null or undefined${msgSuffix}`;
29 throw new AssertionError(msg);
30 }
31}

Callers 9

fnFunction · 0.90
exists_test.tsFile · 0.90
assertDirectoryFunction · 0.90
fnFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected