Spaces:
Configuration error
Configuration error
File size: 2,682 Bytes
3dee94a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | /**
* Wrap a function or class to show a deprecation message when first called.
*
* > π **Important**: only shows a message when the `development` condition is
* > used, does nothing in production.
*
* When the resulting wrapped `fn` is called, emits a warning once to
* `console.error` (`stderr`).
* If a code is given, one warning message will be emitted in total per code.
*
* @template {Function} T
* Function or class kind.
* @param {T} fn
* Function or class.
* @param {string} message
* Message explaining deprecation.
* @param {string | null | undefined} [code]
* Deprecation identifier (optional); deprecation messages will be generated
* only once per code.
* @returns {T}
* Wrapped `fn`.
*/
export function deprecate<T extends Function>(
fn: T,
message: string,
code?: string | null | undefined
): T
/**
* Assert deep strict equivalence.
*
* > π **Important**: only asserts when the `development` condition is used,
* > does nothing in production.
*
* @template {unknown} T
* Expected kind.
* @param {unknown} actual
* Value.
* @param {T} expected
* Baseline.
* @param {Error | string | null | undefined} [message]
* Message for assertion error (default: `'Expected values to be deeply equal'`).
* @returns {asserts actual is T}
* Nothing; throws when `actual` is not deep strict equal to `expected`.
* @throws {AssertionError}
* Throws when `actual` is not deep strict equal to `expected`.
*/
export function equal<T extends unknown>(
actual: unknown,
expected: T,
message?: Error | string | null | undefined
): asserts actual is T
/**
* Assert if `value` is truthy.
*
* > π **Important**: only asserts when the `development` condition is used,
* > does nothing in production.
*
* @param {unknown} value
* Value to assert.
* @param {Error | string | null | undefined} [message]
* Message for assertion error (default: `'Expected value to be truthy'`).
* @returns {asserts value}
* Nothing; throws when `value` is falsey.
* @throws {AssertionError}
* Throws when `value` is falsey.
*/
export function ok(
value: unknown,
message?: Error | string | null | undefined
): asserts value
/**
* Assert that a code path never happens.
*
* > π **Important**: only asserts when the `development` condition is used,
* > does nothing in production.
*
* @param {Error | string | null | undefined} [message]
* Message for assertion error (default: `'Unreachable'`).
* @returns {never}
* Nothing; always throws.
* @throws {AssertionError}
* Throws when `value` is falsey.
*/
export function unreachable(message?: Error | string | null | undefined): never
|