1. parse-function-string
parse function string
parse-function-string
Package: parse-function-string
Created by: rajeshsegu
Last modified: Thu, 23 Jun 2022 10:41:30 GMT
Version: 0.1.1
License: MIT
Downloads: 5
Repository: https://github.com/rajeshsegu/parse-function-string

Install

npm install parse-function-string
yarn add parse-function-string

Build Status
Coverage Status

parse-function-string

Parse a given function / function string to identify its structure.

####Attributes:

  • name => name of the function
  • params => param passed to function
  • args => array of params
  • body => body of the function
  • called => method call
  • defn => function definition

Installation

npm install --save parse-function-string

Usage

Function Call

var parseFnString = require('parse-function-string');
var fn = 'sample(arg1, arg2, arg3)';

parseFnString(fn);
Output:
{
  name: 'sample',
  params: 'arg1, arg2, arg3',
  args: ['arg1', 'arg2', 'arg3'],
  body: '',
  called: true,
  defn: false
}

Function Definition

You can pass a function or a function string

var parseFnString = require('parse-function-string');
var fn = 'function sample(arg1, arg2, arg3) { return true; }';

parseFnString(fn);
Output:
{
  name: 'sample',
  params: 'arg1, arg2, arg3',
  args: ['arg1', 'arg2', 'arg3'],
  body: ' return true; ',
  called: false,
  defn: true
}

See tests for different sets of functions to parse.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin