{"version":3,"file":"AbortError-MRQMLewH.cjs","names":["isNonEmptyString"],"sources":["../src/errors/AbortError.ts"],"sourcesContent":["import { isNonEmptyString } from \"@/predicates\";\n\ntype AbortErrorOptions = {\n  /** -------------------------------------------------------------------\n   * * ***Optional text inserted before `\"AbortError\"`.***\n   * --------------------------------------------------------------------\n   * Empty strings and whitespace-only values are ignored.\n   *\n   * ---\n   * @default \"\"\n   */\n  prefix?: string;\n\n  /** -------------------------------------------------------------------\n   * * ***Optional text inserted after `\"AbortError\"`.***\n   * --------------------------------------------------------------------\n   *\n   * Empty strings and whitespace-only values are ignored.\n   *\n   * ---\n   * @default \"\"\n   */\n  suffix?: string;\n};\n\n/** ---------------------------------------------------------------------\n * * ***Class: `AbortError`.***\n * ----------------------------------------------------------------------\n * **Custom error type used for cancellation-related operations.**\n *\n * ---\n * - **Behavior:**\n *     - Extends the native ***`Error`*** class.\n *     - Provides a consistent abort error shape across runtimes.\n *     - Useful for Promise-based utilities that support\n *       cancellation via ***`AbortSignal`***.\n *     - Uses `\"AbortError\"` as the base error name.\n *     - Supports optional `prefix` and `suffix`\n *       for contextual error naming.\n *\n * ---\n *\n * @extends Error - Extending `Error` Class.\n *\n * ---\n * @param {string} [message=\"The operation was aborted\"]\n * The error message describing the abort reason.\n *\n * @param {object} [options]\n * Optional configuration object.\n *\n * @param {string} [options.prefix]\n * Optional text inserted before `\"AbortError\"`.\n * Empty strings and whitespace-only values are ignored.\n *\n * @param {string} [options.suffix]\n * Optional text inserted after `\"AbortError\"`.\n * Empty strings and whitespace-only values are ignored.\n *\n * ---\n * @example\n * ```ts\n * throw new AbortError();\n * ```\n *\n * @example\n * ```ts\n * throw new AbortError(\n *   \"Delay cancelled\",\n *   {\n *     prefix: \"Delay\"\n *   }\n * );\n *\n * // Result:\n * // name -> \"DelayAbortError\"\n * ```\n *\n * @example\n * ```ts\n * throw new AbortError(\n *   \"Queue cancelled\",\n *   {\n *     suffix: \":Queue\"\n *   }\n * );\n *\n * // Result:\n * // name \"AbortError:Queue\"\n * ```\n *\n * @example\n * ```ts\n * try {\n *   await delay(\n *     5000,\n *     controller.signal\n *   );\n * } catch (error) {\n *   if (error instanceof AbortError) {\n *     console.log(error.message);\n *   }\n * }\n * ```\n */\nexport class AbortError extends Error {\n  /** ------------------------------------------------------------\n   * * ***Constructor: `AbortError`.***\n   * -------------------------------------------------------------\n   * **Creates a new `AbortError` instance with optional\n   * contextual error name customization.**\n   *\n   * ---\n   * - **Behavior:**\n   *     - Initializes the native ***`Error`*** base class.\n   *     - Uses `\"AbortError\"` as the default error name.\n   *     - Automatically trims `prefix` and `suffix` values.\n   *     - Ignores empty or whitespace-only values.\n   *     - Generates a contextual error name using:\n   *       `prefix + \"AbortError\" + suffix`.\n   *\n   * ---\n   * @param {string} [message=\"The operation was aborted\"]\n   * The error message describing the abort reason.\n   *\n   * @param {AbortErrorOptions} [options]\n   * Optional configuration object.\n   *\n   * @param {string} [options.prefix]\n   * Optional text inserted before `\"AbortError\"`.\n   * Empty strings and whitespace-only values are ignored.\n   *\n   * @param {string} [options.suffix]\n   * Optional text inserted after `\"AbortError\"`.\n   * Empty strings and whitespace-only values are ignored.\n   *\n   * ---\n   * @example\n   * ```ts\n   * new AbortError();\n   *\n   * // Result:\n   * // name -> \"AbortError\"\n   * // message -> \"The operation was aborted\"\n   * ```\n   *\n   * @example\n   * ```ts\n   * new AbortError(\n   *   \"Delay cancelled\",\n   *   {\n   *     prefix: \"Delay\"\n   *   }\n   * );\n   *\n   * // Result:\n   * // name -> \"DelayAbortError\"\n   * ```\n   *\n   * @example\n   * ```ts\n   * new AbortError(\n   *   \"Queue cancelled\",\n   *   {\n   *     suffix: \":Queue\"\n   *   }\n   * );\n   *\n   * // Result:\n   * // name -> \"AbortError:Queue\"\n   * ```\n   */\n  constructor(\n    message: string = \"The operation was aborted\",\n    options?: AbortErrorOptions\n  ) {\n    super(message);\n\n    const prefix = isNonEmptyString(options?.prefix)\n      ? `${options.prefix.trim()}`\n      : \"\";\n\n    const suffix = isNonEmptyString(options?.suffix)\n      ? `${options.suffix.trim()}`\n      : \"\";\n\n    this.name = `${prefix}AbortError${suffix}`;\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGA,IAAa,aAAb,cAAgC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmEpC,YACE,UAAkB,6BAClB,SACA;EACA,MAAM,OAAO;EAEb,MAAM,SAASA,gCAAiB,SAAS,MAAM,IAC3C,GAAG,QAAQ,OAAO,KAAK,MACvB;EAEJ,MAAM,SAASA,gCAAiB,SAAS,MAAM,IAC3C,GAAG,QAAQ,OAAO,KAAK,MACvB;EAEJ,KAAK,OAAO,GAAG,OAAO,YAAY;CACpC;AACF"}
