Skip to content

Commit e619afc

Browse files
committed
make option to enable allowAccessToMethodsOnFunctions namely to be used by cwise transform
1 parent 36587c2 commit e619afc

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

index.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
var unparse = require('escodegen').generate;
22

3-
module.exports = function (ast, vars) {
3+
module.exports = function (ast, vars, opts) {
4+
if(!opts) opts = {};
5+
var rejectAccessToMethodsOnFunctions = !opts.allowAccessToMethodsOnFunctions;
6+
47
if (!vars) vars = {};
58
var FAIL = {};
69

@@ -119,8 +122,9 @@ module.exports = function (ast, vars) {
119122
}
120123
else if (node.type === 'MemberExpression') {
121124
var obj = walk(node.object, noExecute);
122-
// do not allow access to methods on Function
123-
if((obj === FAIL) || (typeof obj == 'function')){
125+
if((obj === FAIL) || (
126+
(typeof obj == 'function') && rejectAccessToMethodsOnFunctions
127+
)){
124128
return FAIL;
125129
}
126130
if (node.property.type === 'Identifier' && !node.computed) {

0 commit comments

Comments
 (0)