@jiminp/tooltool
    Preparing search index...

    Function substringBefore

    • Returns the substring before the first occurrence of the delimiter.

      Type Parameters

      • T extends string | null = null

      Parameters

      • s: Nullish

        Input string, or null/undefined.

      • delimiter: string | RegExp

        String or regex marking where to end.

      • Optionalon_missing: T

        Returned if s is nullish or delimiter not found (default: null).

      Returns T

      The substring before the delimiter, or on_missing.

      substringBefore("path/to/file.txt", '/');     // "path"
      substringBefore("abc123xyz", /\d+/); // "abc"
      substringBefore(undefined, ':'); // null
      substringBefore("no-needle", ':', 'default'); // 'default'
    • Returns the substring before the first occurrence of the delimiter.

      Type Parameters

      • T extends string | null = null

      Parameters

      • s: Nullable<string>

        Input string, or null/undefined.

      • delimiter: string | RegExp

        String or regex marking where to end.

      • Optionalon_missing: T

        Returned if s is nullish or delimiter not found (default: null).

      Returns string | T

      The substring before the delimiter, or on_missing.

      substringBefore("path/to/file.txt", '/');     // "path"
      substringBefore("abc123xyz", /\d+/); // "abc"
      substringBefore(undefined, ':'); // null
      substringBefore("no-needle", ':', 'default'); // 'default'