/** * String parsing utilities for ProtoPedia API responses. * * @module fetcher/utils/string-parsers */ /** * Split a pipe-separated string into an array of trimmed segments. * * The ProtoPedia API returns certain fields (tags, users, awards, events, * materials) as pipe-delimited strings. This helper parses such a string * into a clean array. * * **Behavior:** * - Splits by pipe character (`|`) * - Trims whitespace from each segment * - **Filters out empty segments** (empty strings after trimming) * - Returns empty array for null, undefined, or empty string input * * @param value - The pipe-separated string to split. Returns empty array * for null, undefined, or empty string. * @returns An array of non-empty trimmed string segments. * * @example * ```ts * splitPipeSeparatedString('tag1|tag2|tag3'); * // => ['tag1', 'tag2', 'tag3'] * * splitPipeSeparatedString('tag1 | tag2'); * // => ['tag1', 'tag2'] (whitespace trimmed) * * splitPipeSeparatedString('a||b'); * // => ['a', 'b'] (empty segment filtered out) * * splitPipeSeparatedString('tag1| |tag2'); * // => ['tag1', 'tag2'] (whitespace-only segment filtered out) * * splitPipeSeparatedString(''); * // => [] * * splitPipeSeparatedString(null); * // => [] * ``` */ export declare const splitPipeSeparatedString: (value: string | null | undefined) => string[]; /** * Split the pipe-separated `users` field into an array of usernames. * * The ProtoPedia API encodes `users` as `displayName@profileId` values joined * with `|`, and the `|` is **not escaped** when it appears inside a * `displayName`. A plain {@link splitPipeSeparatedString} therefore fragments * any username whose display name contains `|` (see issue #112, real data * prototype id 3571: `nisshi.dev | にっし@nishida24|...`). * * Instead of splitting on every `|`, this helper scans the string left to right * and decides, per `|`, whether it is a username delimiter. The recognizable * pattern (guaranteed by the encoding: a username is always `displayName@profileId`, * so it always contains `@`): * * > A `|` is a **username delimiter** iff an `@` has already appeared in the * > current (not-yet-closed) username. A `|` seen *before* the `@` is part of the * > `displayName` (literal), not a delimiter. * * Each username is emitted as the **exact substring** between delimiters, so * whitespace and display-name `|` are preserved verbatim — **nothing is trimmed**. * ProtoPedia itself keeps leading spaces (it renders `