{"version":3,"file":"isNot.cjs","names":[],"sources":["../src/isNot.ts"],"sourcesContent":["import type { IsUnknown } from \"type-fest\";\nimport type { GuardType } from \"./internal/types/GuardType\";\nimport type { Not } from \"./internal/types/Not\";\n\n/**\n * A function that takes a guard function as predicate and returns a guard that negates it.\n *\n * @param predicate - The guard function to negate.\n * @signature\n *    isNot(isTruthy)(data)\n * @example\n *    isNot(isTruthy)(false) //=> true\n *    isNot(isTruthy)(true) //=> false\n * @dataLast\n * @category Guard\n */\nexport function isNot<T extends (data: unknown) => data is unknown>(\n  // Guards whose guarded type is `unknown` would make the `Exclude` below\n  // collapse to `never`, so they are rejected here and handled by the next\n  // signature instead. The rejection is spelled as a guard narrowing to `never`\n  // (rather than as a bare `never`) so that this position stays function-shaped\n  // and keeps mentioning `T`: against a bare `never` no candidate is inferred\n  // for `T`, so every generic guard (`isString`, `isNullish`, ...) falls back\n  // to the constraint, whose guarded type is `unknown`, and gets rejected too.\n  predicate: IsUnknown<GuardType<T>> extends true\n    ? (data: unknown) => data is never\n    : T,\n): <Wide>(data: Wide) => data is Exclude<Wide, GuardType<T>>;\n\nexport function isNot<T, Narrow extends T>(\n  // Fallback for guards the signature above rejects: those whose guarded type\n  // is `unknown` (e.g. `isTruthy`), and those whose parameter is narrower than\n  // `unknown` (e.g. `startsWith`), which the constraint above can't accept.\n  predicate: (data: T) => data is Narrow,\n): (data: T) => data is Exclude<T, Narrow>;\n\nexport function isNot<T, Result extends boolean>(\n  // Fallback for trivial (non-narrowing) boolean predicates.\n  predicate: (data: T) => Result,\n): (data: T) => Not<Result>;\n\nexport function isNot<T>(\n  predicate: (data: T) => boolean,\n): (data: T) => boolean {\n  return (data) => !predicate(data);\n}\n"],"mappings":"mEAyCA,SAAgB,EACd,EACsB,CACtB,MAAQ,IAAS,CAAC,EAAU,CAAI,CAClC"}