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

Bound functions and other gibberish #14

@rkaw92

Description

@rkaw92

Apparently, this is considered valid (at least on 2.3.1):

var parseFunction = require('parse-function');

function equals(a, b) {
    return a === b || (isNaN(a) && isNaN(b));
}
var boundEquals = equals.bind(global);

// Prints "true"
console.log(parseFunction(boundEquals).valid);

I'm not quite sure if this is the result everyone expects, given that the returned body is " [native code] ".
Even more mind-boggling is this:

parseFunction('function(a, b) { @(!)$!#$E+F#$+#%)$+#OOo.__ - + = = = + // }').valid

In which parallel universe can V8 execute this? The "valid" flag seems misleading. Might be worth adding some warnings to the README.

In particular, assuming " [native code] " is valid may be risky, since a user might not expect their argument information to go away after a .bind(). It may be better to consider unparseable function bodies as invalid as a whole, or provide a run-time flag to enable such behavior (so that the API remains compatible with whatever weird flavor of JS / JSX the user needs).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions