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

function-extractor

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

function-extractor - npm Package Compare versions

Comparing version 0.0.2 to 0.0.4

27

index.js
(function() {
var util = require('util');
var esprima, getFunctions, traverse;
esprima = require('esprima');
var util = require('util'),
esprima = require('esprima'),
traverse = function(object, visitor, master) {

@@ -22,3 +20,3 @@ var parent;

});
};
},

@@ -168,2 +166,3 @@ getFunctions = function(tree, code) {

});
return list;

@@ -173,9 +172,9 @@ };

exports.parse = function(code) {
var functions, tree;
tree = esprima.parse(code, {
var tree = esprima.parse(code, {
loc: true,
range: true
});
functions = getFunctions(tree, code);
}),
functions = getFunctions(tree);
functions = functions.filter(function(fn) {

@@ -188,13 +187,11 @@ return fn.name !== '[Anonymous]';

exports.interpret = function(code, tree) {
var functions;
exports.interpret = function(tree) {
var functions = getFunctions(tree);
functions = getFunctions(tree, code);
functions = functions.filter(function(fn) {
return fn.name !== '[Anonymous]';
});
return functions;
};
}).call(this);
{
"name": "function-extractor",
"version" : "0.0.2",
"version" : "0.0.4",
"description": "Extracts all the functions from a Javascript file into an array of objects.",

@@ -5,0 +5,0 @@ "main" : "./index.js",

@@ -35,5 +35,5 @@ function-extractor

var functions = functionExtractor.parse(source, ast);
var functions = functionExtractor.parse(ast);
```
where `source` is the text read from your Javascript file, and `ast` is the `Esprima.parse()` result. Note that you must pass the `range` and `loc` options to Esprima.
where `ast` is the `Esprima.parse()` result. Note that you must pass the `range` and `loc` options to Esprima.
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