tunnckoCore/parse-function

Function with named parameters is not parsed correctly

GaikwadPratik opened this issue · 1 comments

I have code as below:

const parseFunction = require('parse-function');
const app = parseFunction({
  ecmaVersion: 2017
});

const result = app.parse(async ({ firstName, lastName }) => {
  console.log(`Received input at Server ${JSON.stringify(firstName)}`);
  return { 'Test': `Hi ${lastName}` };
});

console.log({result});

The result object looks like:


[[StableObjectId]]:2
args:Array(1) [false]
body:"\n  console.log(`Received input at Server ${JSON.stringify(firstName)}`);\n  return { 'Test': `Hi ${lastName}` };\n"
defaults:Object {false: undefined}
isAnonymous:true
isArrow:true
isAsync:true
isExpression:false
isGenerator:false
isNamed:false
isValid:true
name:null
params:"false"
value:"async ({ firstName, lastName }) => {\n  console.log(`Received input at Server ${JSON.stringify(firstName)}`);\n  return { 'Test': `Hi ${lastName}` };\n}"
__proto__:Object {constructor: , __defineGetter__: , __defineSetter__: , …}

params in output returns as false instead of firstName, lastName

Kind of known bug, yes.

Check #47. Closing this as "duplicate".