Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fnhelp

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fnhelp

Get some fn' help from your functions (parse for comments!)

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

fnhelp

Get some fn' help from your functions (parse for comments!). This is an experiment in making JS more self-explanatory while playing around, similar to R's ?something or python's docblock.

This might be a horrible idea.

Build Status

Examples

Somewhere in your code...

function Corgi() {

  /**
   * This class does some cool stuff, and is apparently complicated enough
   * that comments are useful.
   */

  this.shedding = 'all the time';
}

Corgi.prototype.croissant = function() {

  // It's just really quite ridiculous. He forms nearly an entire circle.
  // Long dog is long.
  var isLong = true;

  // At the end are where the tail should be but isn't.
}

And then maybe from a repl?

> Function.prototype.help = require('fnhelp');
[Function: help]
> Corgi.help()
' This class does some cool stuff, and is apparently complicated enough\n that comments are useful.'
> Corgi.prototype.croissant.help()
' It\'s just really quite ridiculous. He forms nearly an entire circle.\n Long dog is long.'
> var c = new Corgi; c.croissant.help();
' It\'s just really quite ridiculous. He forms nearly an entire circle.\n Long dog is long.'
> c.croissant.help(true);
' It\'s just really quite ridiculous. He forms nearly an entire circle.\n Long dog is long.\n At the end are where the tail should be but isn\'t.'

Usage

fnhelp()

Calls toString() on the current this and returns the first comments it finds.

fnhelp(true)

Calls toString() on the current this and returns all comments it finds.

fnhelp(thing)

Calls toString() on thing and returns the first comments it finds.

fnhelp(thing, true)

Calls toString() on thing and returns all comments it finds.

For ease of use this might be neat:

Function.prototype.help = require('fnhelp');

More Details

fnhelp is a function that will toString another function and then do minimal parsing to grab the comments. By default it returns the first set of comments it finds. If given a single non-function or second truthy argument, it will return all the comments it finds in the function.

By default, fnhelp supports the following styles of comments:

Double slash:

// This is a comment

Multiline

/** This is a comment */
/***** what
 * this is fine too
 */
/*
 * this is fine too
 */
/*****
 * are you getting it yet
 *****/
/*
  I hope you get it by now
*/

Stripping

fnhelp will also strip leading * if within a multiline comment, and strip // if within a single line comment.

LICENSE

MIT

Keywords

FAQs

Package last updated on 22 Mar 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc