New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

get-function-params

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-function-params - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

54

index.js

@@ -1,37 +0,39 @@

const cache = []
var cache = []
const prePatterns = [
/'.*?'/g,
/".*?"/g,
/`.*?`/g,
/{.*?}/g,
/=>\s*?\(.*?\)/g,
var prePatterns = [
/'.*?'/,
/".*?"/,
/`.*?`/,
/\[.*?\]/,
/{.*?}/,
/=>\s*?\(.*?\)/,
]
const postPatterns = [
/\(.*?\)/g,
var postPatterns = [
/\(.*?\)/,
]
const encode = (string, patterns) => {
patterns.forEach((pattern) => {
;(string.match(pattern) || [])
.forEach((value) => {
string = string.replace(value, `:~:${cache.push(value)}:~:`)
})
var delim = function (id) { return [':~:', id, ':~:'].join('') }
var encode = function (string, patterns) {
patterns.forEach(function (pattern) {
while (pattern.test(string)) {
var match = pattern.exec(string)[0]
string = string.replace(match, delim(cache.push(match)))
}
})
return string
}
const decode = (string) => {
const pattern = /:~:(\d+?):~:/
var decode = function (string) {
var pattern = /:~:(\d+?):~:/
while (pattern.test(string)) {
const id = pattern.exec(string)[1]
string = string.replace(`:~:${id}:~:`, cache[id-1])
var id = pattern.exec(string)[1]
string = string.replace(delim(id), cache[id-1])
}
return eval(`(${string})`)
return eval('('+string+')')
}
module.exports = function (fn) {
let params = encode(fn.toString().replace(/\/\*.*?\*\//g, ''), prePatterns)
var params = encode(fn.toString().replace(/\/\*.*?\*\//g, ''), prePatterns)
.match(/(?:function\s*\((.*)\)|\((.*)\))/)

@@ -43,6 +45,6 @@

.split(',')
.filter((i) => i)
.map((i) => {
const data = i.split('=')
const obj = {
.filter(function (i) { return i }) // filter empty results
.map(function (i) {
var data = i.split('=')
var obj = {
param: data[0].trim()

@@ -49,0 +51,0 @@ }

{
"name": "get-function-params",
"version": "2.0.0",
"version": "2.0.1",
"description": "Get list of function params, including default values (if any)",

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

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