Class Item

Represents a single line in a todo.txt file.

Hierarchy

  • Item

Constructors

Properties

#body: string = ''
#complete: boolean = false
#completed: null | Date = null
#contexts: TrackedTag[] = []
#created: null | Date = null
#extensions: TrackedExtension[] = []
#priority: Priority = null
#projects: TrackedTag[] = []

Methods

  • Add a new context to the task. Will append to the end. If the context is already present, it will not be added.

    Parameters

    • tag: string

      A valid context, without the @

    Returns void

  • Parameters

    • key: string
    • value: string

    Returns void

  • Add a new project to the task. Will append to the end. If the project is already present, it will not be added.

    Parameters

    • tag: string

      A valid project, without the +

    Returns void

  • Get the body of the task.

    Returns

    The body portion of the task.

    Returns string

  • Remove the completed date from the task.

    Returns void

  • Remove the created date from the task.

    Side Effect

    Clearing the created date will also unset the completed date.

    Returns void

  • Remove the priority from this task.

    Returns void

  • Is this task complete?

    Returns boolean

  • Get the completed date of this task.

    Returns

    The completed date, or null if not set.

    Returns null | Date

  • Get the completed date as string, or an empty string if not set.

    Returns

    The completed date as a string formatted for todo.txt (YYYY-MM-DD)

    Returns string

  • Get all of the context tags on the task.

    Returns

    Context tags, without the @

    Returns string[]

  • Get the creation date of this task.

    Returns

    The creation date, or null if not set.

    Returns null | Date

  • Get the creation date as string, or an empty string if not set.

    Returns

    The creation date as a string formatted for todo.txt (YYYY-MM-DD)

    Returns string

  • Get all of the project tags on the task.

    Returns

    Project tags, without the +

    Returns {
        key: string;
        value: string;
    }[]

  • Parse in a full todo.txt line, replacing and resetting all fields.

    Parameters

    • line: string

      A full todo.txt task line

    Returns void

  • Get the priority of this Item, or null if not present.

    Returns null | string

  • Get all of the project tags on the task.

    Returns

    Project tags, without the +

    Returns string[]

  • Remove a context from the task, if present.

    Parameters

    • tag: string

      A valid context, without the @

    Returns void

  • Parameters

    • key: string
    • value: null | string = null

    Returns void

  • Remove a project from the task, if present.

    Parameters

    • tag: string

      A valid project, without the +

    Returns void

  • Parse and set the body and body elements.

    Side Effect

    This will clear and re-load contexts, projects and extensions.

    Parameters

    • body: string

      A todo.txt description string.

    Returns void

  • Set if this task is complete.

    Side Effect

    Setting this to false will clear the completed date.

    Parameters

    • complete: boolean

      True if the task is complete.

    Returns void

  • Set the completed date for the task. Passing null or no argument clears the completed date.

    Side Effect

    Setting completed will set complete to true.

    Throws

    An Error when the date is provided as a string and is invalid.

    Throws

    An Error when the created date is not set.

    Parameters

    • date: null | string | Date = null

    Returns void

  • Set the created date for the task. Passing null or no argument clears the created date.

    Side Effect

    Clearing the created date will also unset the completed date.

    Throws

    An Error when the date is provided as a string and is invalid.

    Parameters

    • date: null | string | Date = null

    Returns void

  • Parameters

    • key: string
    • value: string

    Returns void

  • Set the priority of the task. Passing null or no argument clears priority.

    Throws

    An Error when the input is invalid.

    Parameters

    • priority: Priority = null

      A priority from A-Z or null to clear priority.

    Returns void

  • Generate the full todo.txt line of this Item, as well as spans describing the location of all of it's component parts.

    Returns AnnotatedItem

  • Generate a full todo.txt line out of this Item.

    Returns string

Generated using TypeDoc