This package has been deprecated

Author message:

This package will be deprecated and unmaintained unless someone takes over development. Open an issue on github if you would like to continue maintainance of this module

stdtodo

1.2.2 • Public • Published

stdtodo

io.js compatibility NPM version

Dependency Status Dev Dependency Status Code Climate Build Status Coverage Status

This package will be deprecated and unmaintained unless someone takes over development. Open an issue on github if you would like to continue maintainance of this module

stdtodo is a development module to help in the logging of asynchronous tasks. The difference between this and other list loggers it that this will actually print out all of the initial list in it's incomplete state, then you can mark of tasks by their index as complete (or mark as errored) so you can see a realtime list of which tasks haven't been completed yet. After it's done, it will print out all of the errors that happened at once.

NOTICE: This is a highly experimental module. Please see caveats below.

Installation

$ npm install stdtodo --save

Usage

Todo is an object prototype in which you pass in options to create a new Todo list

var Todo = require('stdtoto');

You need an array of strings to define the list you wish to check off

var data = ['item 1', 'item 2', 'item 3'];

Then you instantiate your todo list

var todo = new Todo({data: todo});

To 'start' your todo list:

todo.start();

To check off the first item:

todo.check(0);

To mark an item as errored out:

todo.error(1, 'Some error occured');

Example

var Todo = require('stdtodo')
  , data = []
  , todo
  ;
 
data.push(
  'copy files',
  'lint files',
  'delete all the stuffs'
);
 
todo = new Todo({data: data});
 
// Start the task list
todo.start();
 
// Do some async task...
todo.check(0);
setTimeout(function () {
  todo.check(2);
}, 5000);
 
// Some error happened
todo.error(1, 'Error when linting files!');

Which outputs:

✓ copy files
x lint files
✓ delete all the stuffs
-------
Errors
lint files: Error when linting files!
-------

Caveats

You need to make sure you don't console.log anything while the todo list is running. If you do, the list will become misaligned.

Also, your list items shouldn't exceed the width of your terminal.

You list length shouldn't exceed the number of rows in your terminal window. If it does, it will just sequentially print out each of the tasks as they are completed.

Development

This project uses gulp for task automation.

$ npm install -g gulp

Here are the three tasks available to use:

  • gulp hint: runs all pertinent code against jshint. The rules are the ones defined in .jshintrc

  • gulp test: runs all tests with mocha for passing and instanbul for code coverage. It generates html files showing the code coverage.

  • gulp docs: builds out all of the documentation using docco. Note that you need to have docco installed (npm install -g docco). I at one time at docco part of the dev dependencies, but now I don't. I may be open to putting it back, but I just wanted to keep the package as small as possible.

You can also run npm test, and it does basically does the same thing as gulp test, but an error will be thrown because it does some more istanbul stuff to send data to the coverage server. When this project runs through travis, it also sends coverage data to coveralls.io.

When forking and doing pull requests, work off of the develop branch. I won't be super strict on this, but it's what I would prefer. That way we can keep master clean.

Readme

Keywords

Package Sidebar

Install

npm i stdtodo

Weekly Downloads

2

Version

1.2.2

License

MIT

Last publish

Collaborators

  • ksmithut