todotxt4js
    Preparing search index...

    Class Todo

    Class representing a single todo in the todo.txt format. A todo includes completion status, priority, dates, descriptions, and metadata like projects, contexts, and key-value pairs.

    Index

    Constructors

    • Creates a new Todo instance.

      Parameters

      • Optionaloptions: {
            completed?: boolean;
            completionDate?: string;
            contexts?: string[];
            creationDate?: string;
            description?: string;
            due?: string;
            keyValues?: { [key: string]: any };
            priority?: string;
            projects?: string[];
            [key: string]: any;
        } = {}

        Optional configuration for the new todo.

        • [key: string]: any
        • Optionalcompleted?: boolean

          Whether the todo is completed.

        • OptionalcompletionDate?: string

          When the todo was completed.

        • Optionalcontexts?: string[]

          Array of context tags starting with "@".

        • OptionalcreationDate?: string

          When the todo was created.

        • Optionaldescription?: string

          The description text.

        • Optionaldue?: string

          Due date in YYYY-MM-DD format.

        • OptionalkeyValues?: { [key: string]: any }

          Key-value metadata.

        • Optionalpriority?: string

          The priority of the todo (A-Z or in format "(A)").

        • Optionalprojects?: string[]

          Array of project tags starting with "+".

      Returns Todo

    Accessors

    • get completed(): boolean

      Get completed status

      Returns boolean

    • set completed(value: boolean): void

      Set completed status

      Parameters

      • value: boolean

      Returns void

    • get completionDate(): undefined | string

      Get completion date

      Returns undefined | string

    • set completionDate(value: undefined | string): void

      Set the completion date

      Parameters

      • value: undefined | string

      Returns void

    • get contexts(): readonly string[]

      Get contexts

      Returns readonly string[]

    • get creationDate(): undefined | string

      Get creation date

      Returns undefined | string

    • set creationDate(value: undefined | string): void

      Set the creation date

      Parameters

      • value: undefined | string

      Returns void

    • get description(): string

      Get description

      Returns string

    • get id(): string

      Get the unique identifier

      Returns string

    • get keyValues(): Readonly<{ [key: string]: any }>

      Get key-value pairs

      Returns Readonly<{ [key: string]: any }>

    • get priority(): undefined | string

      Get priority

      Returns undefined | string

    • get projects(): readonly string[]

      Get projects

      Returns readonly string[]

    Methods

    • Adds a context tag to the todo.

      Parameters

      • context: string

        Context tag to add (with or without the @ symbol).

      Returns void

    • Adds a project tag to the todo.

      Parameters

      • project: string

        Project tag to add (with or without the + symbol).

      Returns void

    • Creates a deep copy of this todo.

      Returns Todo

      A new todo with the same properties.

    • Calculates the number of days until the todo is due.

      Returns undefined | number

      Number of days, or undefined if no due date.

    • Decreases priority by one level (e.g., A -> B). If the priority is already Z, removes the priority.

      Returns void

    • Generates a new todo based on the recurrence pattern.

      Returns undefined | Todo

      A new todo with updated due date, or undefined if not recurring.

    • Gets the due date of the todo, if any.

      Returns undefined | string

      The due date in YYYY-MM-DD format or undefined.

    • Increases priority by one level (e.g., B -> A). If the todo has no priority, sets it to (Z).

      Returns void

    • Checks if the todo is due today.

      Returns boolean

      True if the todo is due today.

    • Checks if the todo is overdue.

      Returns boolean

      True if the todo is overdue and not completed.

    • Marks the todo as completed.

      Parameters

      • OptionalcompletionDate: string

        Optional completion date in YYYY-MM-DD format. Defaults to today if not provided.

      Returns void

    • Marks the todo as incomplete, removing any completion date.

      Returns void

    • Removes a context tag from the todo.

      Parameters

      • context: string

        Context tag to remove (with or without the @ symbol).

      Returns void

    • Removes a key-value pair from the todo.

      Parameters

      • key: string

        The key name to remove.

      Returns void

    • Removes a project tag from the todo.

      Parameters

      • project: string

        Project tag to remove (with or without the + symbol).

      Returns void

    • Sets the description text of the todo.

      Parameters

      • newDescription: string

        The new description text.

      Returns void

    • Sets the due date for the todo.

      Parameters

      • dueDate: string

        The due date in YYYY-MM-DD format.

      Returns void

    • Sets a key-value pair on the todo.

      Parameters

      • key: string

        The key name.

      • value: any

        The value to store.

      Returns void

    • Sets the priority of the todo.

      Parameters

      • priority: null | string

        Priority letter (A-Z) or null to remove priority.

      Returns void

    • Toggles completion status of the todo.

      Returns boolean

      The new completion status.

    • Converts the todo to its string representation.

      Returns string

      The todo in todo.txt format.