Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The regExp of IS_PURE_FUNCTION & IS_ARROW_FUNCTION seem to be extra??? #147

Open
zhtyytg opened this issue Aug 2, 2022 · 0 comments
Open

Comments

@zhtyytg
Copy link

zhtyytg commented Aug 2, 2022

source code :

var IS_PURE_FUNCTION = /function.?(/;
var IS_ARROW_FUNCTION = /.
?=>.*?/;

// pure functions, example: {key: function() {}}
if(IS_PURE_FUNCTION.test(serializedFn)) {
return serializedFn;
}

// arrow functions, example: arg1 => arg1+5
if(IS_ARROW_FUNCTION.test(serializedFn)) {
return serializedFn;
}

Q:
when I use serialize like:
{
name: "aa",
attrname: "bb",
render(item, row) {
return JSON.parse(item) .map((it) => it.name).join("");
},
}

the regExp will catch this and cause problem, not when it's commented.
then I test the normal way like this:
{
name: "aa",
attrname: "bb",
render: (item, row) => {
return JSON.parse(item) .map((it) => it.name).join("");
},
}

and:

{
name: "aa",
attrname: "bb",
render: function(item, row) {
return JSON.parse(item) .map((it) => it.name).join("");
},
}

without the regExps, these are also correct.

could you please explain me?

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

No branches or pull requests

1 participant