Socket
Book a DemoInstallSign in
Socket

list-methods

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

list-methods

Easily generate a JSON or markdown list (sorted array) of property names of all enumerable properties, own and inherited, of objects that have function values.

Source
npmnpm
Version
0.2.4
Version published
Weekly downloads
12
33.33%
Maintainers
1
Weekly downloads
 
Created
Source

list-methods NPM version

Easily generate a JSON or markdown list (sorted array) of property names of all enumerable properties, own and inherited, of objects that have function values.

Quickstart

Install with npm:

npm i -g list-methods

Next, run the methods command without any arguments and a markdown file will be generated for the first javascript file found in the current directory.

Params

methods [src] [dest] [template]
  • src [String]: (require) The name of the file or npm module for which to list methods
  • dest [String]: (optional) The destination file. Specify a file with a valid extension (.md, .json or .yml) and the file will automatically be saved with the correct format.
  • template [String]: (optional) The template to use for the generated list. See the default, or the example below.

Usage

src only

methods [src]

The first argument is the target source file or npm module. For example, methods foo will generate markdown file named foo.md in the current directory.

Either of the following will work:

// local lib
methods path/to/foo.js

// npm module
methods my_npm_module

src and dest

methods [src] [dest]

The second argument is the destination path. For example, methods foo docs.md will generate markdown file named docs.md in the current directory. Also note that the destination path is "extension-sensitive", meaning that if a .yml or .json extensions are used, the generated file will be formatted in YAML or JSON instead of markdown.

src, dest and template

methods [src] [dest] [template]

The third argument is the template to use. By default, a simple markdown list is generated. Additional templates are:

  • docs
  • yaml

See templates for additional options.

Templates

See examples of generated files.

base

The base template does not need to be specified and will generate a simple, markdown-formatted list of methods.

Try running methods lodash in the command line (assuming Lo-Dash is already installed locally). If successful, a markdown file, lodash.md, will have been saved to the current directory, and inside will be something like:

image

If the destination path ends in a .json file extension, a JSON file will be generated instead, e.g.:

image

docs

The docs template, specified with methods lodash lodash.md docs, will generate a markdown-formatted "starter" file for documentation. Using the Lo-Dash example from the last section, the resuls would look something like this:

image

yaml

Like the other templates, the yaml template is specified as a fourth paramter. Also, this template will automatically be used if the destination file path ends in a .yml extension.

The output for the Lo-Dash example would look something like:

image

Custom templates

Easily customize the output by creating a custom template. The template can either be a local file or npm module. Like the included templates, custom templates should also be specified as a fourth parameter.

For example, to use my-custom-template.js, you would enter the following in the command line:

methods lodash lodash.md my_custom_template.js

Or if my-template is in node_modules:

methods lodash lodash.md my_custom_template

Example template

These are just Lo-Dash templates, keeping in mind that the only context passed into the templates is the array of properties generated.

module.exports = [
  '# <%= data.name %> properties\n\n',
  '<% _.forEach(data, function(fn) { %>',
  '* <%- fn %>\n',
  '<% }); %>'
].join('');

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, Brian Woodward, contributors. Released under the MIT license

Keywords

lodash

FAQs

Package last updated on 09 Feb 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts