Skip to content

StormExecute/fn-arg-names

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fn-arg-names NPM version

Get any arguments from any function.

Description

This module will help you extract absolutely all valid arguments from functions and pass them to you as an array.

Table of Contents

Install

$ npm install fn-arg-names

Usage

const fnArgNames = require("fn-arg-names");

const result = fnArgNames("async function * a({a, b, c: d}, r = function(a,b) { return (a + b) }, {t = {}}, [e, f, [g, h], {i}, [j, {k}, [l, m, n]], ...args], o, /*p,*/ ...q){}");

console.log(result);

const simple = fnArgNames(function(a, b, c = (1 + 2 + 3), ...d) {});

console.log(simple);
[
  [ 'a', 'b', 'c', origin: 'object' ],
  'r',
  [ 't', origin: 'object' ],
  [
    'e',
    'f',
    [ 'g', 'h', origin: 'array' ],
    [ 'i', origin: 'object' ],
    [ 'j', [Array], [Array], origin: 'array' ],
    '...args',
    origin: 'array'
  ],
  'o',
  '...q'
]

[ 'a', 'b', 'c', '...d' ]

API

Types: HERE!

fnArgNames(fn: string | Function) => answer

The main function.

fnArgNames.default(fn: string | Function) => answer

The same as fnArgNames.

fnArgNames.strict(fn: string | Function) => answer

The same as fnArgNames, but in case of syntax errors in string function will return a detailed analysis of the error.

fnArgNames.auto(fn: string | Function) => answer

If a string is passed, it returns the result of fnArgNames.strict, otherwise it returns the result of fnArgNames.default .

Contacts

Yandex Mail - vladimirvsevolodovi@yandex.ru

Github - https://github.com/StormExecute/

Platforms

Github - https://github.com/StormExecute/fn-arg-names/

NPM - https://www.npmjs.com/package/fn-arg-names/

License

MIT - https://mit-license.org/

About

Get any arguments from any function

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published