npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

js-todos

v1.1.1

Published

Finds todos in JS source-code

Downloads

13

Readme

JS-TODOs

Find todos in JS code. Uses espree, so won't give you false positives like 'grep -r TODO', but is as easy to use.

# ./node_modules/.bin on path? if not, install with --global / -g
npm install js-todos
js-todos *.js

Options

  • --outputter - set output -- json: outputs as list of todos -- default: human readable format
  • --nostatus - disable exit status (to invoke via process spawing)

API

jsTodos(source)

Main function - takes javascript source, parses, return todos.

jsTodos.findTodo(comment)

Takes an Espree AST comment and parses for TODO/FIXME. Returns comment with added todo type field, or undefined if no todo was found.

jsTodos.commentsToTodos(comments)

Runs findTodo on each comment, returns an array of all todos found.

jsTodos.readAll(paths,output)

Runs jsTodos() over JS source found at each path, and calls output(). output is a function with parameters output(todo,path). It'll be called once for each path before todos are found: output(path). Once for each todo with path: output(path,todo). Finally it'll be called once with the string "complete" after all paths have been read: output("complete"). This is to allow outputters to either output on the go, or cache all data and output a formatted display on complete.

See below for how to add a custom outputter.

Configuration

jsTodos.outputters

To define an outputter add it to jsTodos.outputter. It should be a function that takes an options object (the command line options defined above) and returns a function that responds to the above calls. See the JSON outputter for an example of how to write an outputter.

jsTodos.types

Add functions to this array that take a comment and return an todo if found. A todo contains the same fields (value, loc etc) with an added type field - by default 'TODO' and 'FIXME', but add your own.

Example:

jsTodos.types.push(function(comment) {
  if(/WTF/.test(comment.value)) {
    comment.type = "WTF"
    return comment
  }
})