Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

Function with named parameters is not parsed correctly #191

Closed
GaikwadPratik opened this issue Jul 28, 2019 · 1 comment
Closed

Function with named parameters is not parsed correctly #191

GaikwadPratik opened this issue Jul 28, 2019 · 1 comment

Comments

@GaikwadPratik
Copy link

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

@tunnckoCore
Copy link
Owner

tunnckoCore commented Jul 28, 2019

Kind of known bug, yes.

Check #47. Closing this as "duplicate".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants