James Williams
LinkedInMastodonGithub

CoffeeScript Library for Todo.txt

Tags: General

You may have read my posts about todo.txt (here and here) and know how much I like it. I was a little unhappy with the ramp-up time when running it in Groovy and wanted to see if I could get it faster. Also, though Groovy can be a crucial tool for Java developers, generally devs are more likely to have Node.js installed. It's the new hotness you know.

So I set about creating a CoffeeScript library for use with Node. This library closely tracks to todo.txt-gem in terms of features though it does change the function names to camel-case. When I'm less lazy, the following will find itself into a proper README file.

Installation

    npm install todotxt-coffee

Loading Tasks

    {TodoList} = require ('todotxt-coffee')

    # Instantiate list of Tasks
    tasks = new TodoList(["(A) stop +p +c", "@c @b blah +c"])

    # Load tasks from done file
    tasks = new TodoList("/Users/jwilliams/Dropbox/todo/done.txt")

Querying Individual Tasks

    task.contexts()     # => ['@context1', '@context2'] 
    task.date()             # => 'YYYY-MM-DD'
    task.priority()     # => "(A)"
    task.projects()     # => ['+project', '+project2']
    task.raw()              # => "Full text of task"

Querying Todo Lists

    tasks.byContext('@context')
    tasks.byPriority("A")
    tasks.byProject('+project')

It's on Github here.

Enjoy.