Skip to main content
Module

x/silicon/deps.ts>setAssertMessageFactory

Deno module to generate images from source code using Aloxaf/silicon.
Latest
function setAssertMessageFactory
import { setAssertMessageFactory } from "https://deno.land/x/silicon@v1.0.0/deps.ts";

Sets the factory function used to generate assertion error messages.

Examples

Example 1

import { setAssertMessageFactory } from "./util.ts";
import is from "./is.ts";

setAssertMessageFactory((x, pred) => {
  if (pred === is.String) {
    return `Expected a string, got ${typeof x}`;
  } else if (pred === is.Number) {
    return `Expected a number, got ${typeof x}`;
  } else if (pred === is.Boolean) {
    return `Expected a boolean, got ${typeof x}`;
  } else {
    return `Expected a value that satisfies the predicate, got ${typeof x}`;
  }
});

Parameters

The factory function.