jstodotxt

Build Status codecov Netlify Status

jsTodoTxt

jsTodoTxt is a library for working with todo.txt formatted files in JavaScript.

🚨 This Will Be Version 1.0.0 🚨

This branch contains a major rewrite of jsTodoTxt. It is currently in alpha on NPM, you can install it with npm install jstodotxt@next

If you are looking for the current latest code, that is available on the 0.10.x branch.

Format

jsTodoTxt attempts to match the todo.txt format exactly.

To do so, this library relies heavily on tests and strives for 100% coverage.

Usage

The core of jsTodoTxt is the Item class.

An Item breaks a single todo.txt line into two logical parts and treats them independently, what we call the header and the body.

There are accessors and mutators for all parts of the item. API documentation is available online and the package ships with type definition files.

        Header                                     Body
 .-----------------------.   .----------------------------------------------------.
'                         ' '                                                      '
x (A) 2016-05-20 2016-04-30 measure space for +chapelShelving @chapel due:2016-05-30
|  |  '----.---' '----.---'                   '------.------' '--.--' '------.-----'
|  |   completed   created                        project     context    extension
|  |
|   ' priority
|
 ' completed

Example

const item = new Item('Paint the kitchen @home +reno due:2022-12-01');

console.log(item.contexts());
// ['home']

item.setExtension('color', 'red');
console.log(item.extensions());
// [{key: 'due', value: '2022-12-01'}, {key: 'color', value: 'red'}]

item.setCreated('2022-10-19');
console.log(item.toString());
// 2022-10-19 Paint the kitchen @home +reno due:2022-12-01 color:red

item.setBody('Paint the kitchen color:red @home +reno due:2022-12-01')
console.log(item.toString());
// 2022-10-19 Paint the kitchen color:red @home +reno due:2022-12-01

Testing

Run npm test to run the suite.

jsTodoTxt is tested with ava

About todo.txt

todo.txt is a format for storing todo lists in a future-proof format.

http://todotxt.com/

Generated using TypeDoc