tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

assert.ts (434B)


      1 /**
      2 * @license
      3 * Copyright 2020 Google Inc.
      4 * SPDX-License-Identifier: Apache-2.0
      5 */
      6 
      7 /**
      8 * Asserts that the given value is truthy.
      9 * @param value - some conditional statement
     10 * @param message - the error message to throw if the value is not truthy.
     11 *
     12 * @internal
     13 */
     14 export const assert: (value: unknown, message?: string) => asserts value = (
     15  value,
     16  message,
     17 ) => {
     18  if (!value) {
     19    throw new Error(message);
     20  }
     21 };