Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Extracts all the functions from a Javascript file into an array of objects.
JavaScript
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
README.md
index.js
package.json

README.md

function-extractor

Provides an array of objects listing the names and types of functions found in a Javascript file.

Based on fn-extractor, except this one works with the latest Esprima, catches more corner cases, reports errors, and isn't in Coffeescript.

Used by Panino to report doc coverage.

Installation

npm install function-extractor

Usage

Esprima is required by this tool.

You can use this module in two ways. If you don't already have an Esprima AST of your code, do this:

var functionExtractor = require("./javascript/jsd/function_extractor");

var functions = functionExtractor.parse(source);

where source is the text read from your Javascript file.

Otherwise, if you've already parsed the file, do this:

var functionExtractor = require("./javascript/jsd/function_extractor");

var functions = functionExtractor.parse(ast);

where ast is the Esprima.parse() result. Note that you must pass the range and loc options to Esprima.

Something went wrong with that request. Please try again.