UNPKG

detect-shells

Version:

Detect shells installed on a system

41 lines (40 loc) 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.forceUnwrap = exports.assertNever = exports.fatalError = void 0; /** Throw an error. */ function fatalError(msg) { throw new Error(msg); } exports.fatalError = fatalError; /** * Utility function used to achieve exhaustive type checks at compile time. * * If the type system is bypassed or this method will throw an exception * using the second parameter as the message. * * @param x Placeholder parameter in order to leverage the type * system. Pass the variable which has been type narrowed * in an exhaustive check. * * @param message The message to be used in the runtime exception. * */ function assertNever(x, message) { throw new Error(message); } exports.assertNever = assertNever; /** * Unwrap a value that, according to the type system, could be null or * undefined, but which we know is not. If the value _is_ null or undefined, * this will throw. The message should contain the rationale for knowing the * value is defined. */ function forceUnwrap(message, x) { if (x == null) { return fatalError(message); } else { return x; } } exports.forceUnwrap = forceUnwrap;