Skip to content

negate() function

조건자 함수의 반대 결과를 반환하는 함수를 생성합니다.

Signature:

typescript
declare function negate<T, N extends T>(
  predicate: (input: T) => input is N,
): (input: T) => input is Exclude<T, N>;

Example

ts
const isDefined: (input: string | undefined) => input is string = negate(isUndefined)<string | undefined>

const isDefined: (input: unknown) => boolean = negate((input) => input === undefined)

Open Source Code

Released under the Apache-2.0 License.