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

function-names-at-line

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

function-names-at-line

Name the functions found at a particular line number in some JavaScript source

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
76
increased by58.33%
Maintainers
1
Weekly downloads
 
Created
Source

function-names-at-line

I was working on this run test by line number feature for teenytest, and needed a way to tell what functions might be described by a given line number.

For example, say you have this file:

                        // 1
var foo = function () { // 2
  var baz = 'lol'       // 3
  function bar () {}    // 4
}                       // 5
                        // 6

And read the file into a string named someSource, then you can:

var functionNamesAtLine = require('function-names-at-line')

functionNamesAtLine(someSource, 1) // []
functionNamesAtLine(someSource, 2) // ['foo']
functionNamesAtLine(someSource, 3) // ['foo']
functionNamesAtLine(someSource, 4) // ['bar', 'foo']
functionNamesAtLine(someSource, 5) // ['foo']
functionNamesAtLine(someSource, 6) // []

This is a pretty naive implementation, focused just on getting basic (not nested) names of functions.

Keywords

FAQs

Package last updated on 09 May 2020

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