Nikolai Kim
Nikolai Kim

Reputation: 705

Find accessor methods in JavaScript code (node_modules)

I'm using a number of libraries in a project. One of them uses accessor methods get and/or set methods, that can't be translated or polyfilled in Internet Explorer 8.

How can I find which library uses the accessors; are there any tools that could help? I guess the only thing one could do is to parse every .js file and then analyze it's syntax tree to find the methods.

Upvotes: 0

Views: 22

Answers (1)

ilyaigpetrov
ilyaigpetrov

Reputation: 3883

You may use grep -r with /^\s*(?:get|set)\s+\S+/ but this regex should be converted to syntax of grep with which I'm not familiar. Also node_modules may be huge to search, so you may need to exclude some sub-trees.

Here is my try: grep -r "^\s*\(get\|set\)\s\+\w" --include \*.js ./
Output only files: grep -r "^\s*\(get\|set\)\s\+\w" --include \*.js ./ | cut -d: -f1

Upvotes: 1

Related Questions