Hierarchy

  • EventEmitter
    • LeetCode

Constructors

  • If a credential is provided, the LeetCode API will be authenticated. Otherwise, it will be anonymous.

    Parameters

    Returns LeetCode

Properties

cache: Cache

The internal cache.

credential: Credential

The credential this LeetCode instance is using.

initialized: Promise<boolean>

Used to ensure the LeetCode instance is initialized.

limiter: RateLimiter = ...

Rate limiter

prefixed: string | boolean

Methods

  • Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns this

  • Parameters

    • event: "receive-graphql"
    • res: Response

    Returns boolean

  • Parameters

    Returns boolean

  • Parameters

    • event: string
    • Rest ...args: unknown[]

    Returns boolean

  • Return an array listing the events for which the emitter has registered listeners.

    Returns (string | symbol)[]

  • Return the number of listeners listening to a given event.

    Parameters

    • event: string | symbol

    Returns number

  • Return the listeners registered for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T

    Returns ((...args) => void)[]

  • Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Optional fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns this

  • Parameters

    • event: "receive-graphql"
    • listener: ((res) => void)
        • (res): void
        • Parameters

          • res: Response

          Returns void

    Returns this

  • Parameters

    • event: "update-csrf"
    • listener: ((credential) => void)
        • (credential): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: string
    • listener: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: unknown[]

          Returns void

    Returns this

  • Parameters

    • event: "receive-graphql"
    • listener: ((res) => void)
        • (res): void
        • Parameters

          • res: Response

          Returns void

    Returns this

  • Parameters

    • event: "update-csrf"
    • listener: ((credential) => void)
        • (credential): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: string
    • listener: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: unknown[]

          Returns void

    Returns this

  • Get information of a problem by its slug.

    Parameters

    • slug: string

      Problem slug

    Returns Promise<Problem>

    const leetcode = new LeetCode();
    const problem = await leetcode.problem("two-sum");
  • Get a list of problems by tags and difficulty.

    Parameters

    • option: {
          category?: string;
          filters?: {
              difficulty?: "EASY" | "MEDIUM" | "HARD";
              tags?: string[];
          };
          limit?: number;
          offset?: number;
      } = {}
      • Optional category?: string
      • Optional filters?: {
            difficulty?: "EASY" | "MEDIUM" | "HARD";
            tags?: string[];
        }
        • Optional difficulty?: "EASY" | "MEDIUM" | "HARD"
        • Optional tags?: string[]
      • Optional limit?: number
      • Optional offset?: number

    Returns Promise<ProblemList>

  • Get recent submissions of a user. (max: 20 submissions)

    Parameters

    • username: string
    • limit: number = 20

    Returns Promise<RecentSubmission[]>

    const leetcode = new LeetCode();
    const submissions = await leetcode.recent_submissions("jacoblincool");
  • Remove all listeners, or those of the specified event.

    Parameters

    • Optional event: string | symbol

    Returns this

  • Remove the listeners of a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Optional fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns this

  • Get submissions of the credential user. Need to be authenticated.

    Parameters

    • __namedParameters: {
          limit?: number;
          offset?: number;
          slug?: string;
      } = {}
      • Optional limit?: number
      • Optional offset?: number
      • Optional slug?: string

    Returns Promise<Submission[]>

    const credential = new Credential();
    await credential.init("SESSION");
    const leetcode = new LeetCode(credential);
    const submissions = await leetcode.submissions({ limit: 100, offset: 0 });
  • Get public profile of a user.

    Parameters

    • username: string

    Returns Promise<UserProfile>

    const leetcode = new LeetCode();
    const profile = await leetcode.user("jacoblincool");
  • Get public contest info of a user.

    Parameters

    • username: string

    Returns Promise<UserContestInfo>

    const leetcode = new LeetCode();
    const profile = await leetcode.user_contest_info("jacoblincool");

Generated using TypeDoc