Can I use this to extend JavaScript functionalities?
See original GitHub issueI tried the live editor but I’m not sure if what I’m doing it’s correct or not: I would like, for example, use “func” instead of “function” into my code, so parse the token and replace with the valid JS one, but it outs always syntax error, also using “acorn” with “loose” checked.
I tried with this
module.exports.replace = () => ({
'func': 'function',
});
Is what I would like to do buildable or not?
Issue Analytics
- State:
- Created a year ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Javascript: Extend a Function - Stack Overflow
Use extendFunction.js ... init = extendFunction(init, function(args) { doSomethingHereToo(); });. But in your specific case, it's easier to extend ...
Read more >extends - JavaScript - MDN Web Docs - Mozilla
The extends keyword can be used to subclass custom classes as well as built-in objects. Any constructor that can be called with new...
Read more >How to Extend Legacy Functions in JavaScript Without ...
Let's fix that and we will see how we can support both types of parameters at once: the legacy single input parameters for...
Read more >6 Ways to Implement the JavaScript Extends Keyword
The extends keyword is mainly used in class declarations or class expressions to create a class that is a subclass of another class....
Read more >Extending a JavaScript Function - Corey Maynard
Wrapper/Extension Function ... // Create an anonymous function to wrap everything in. This gets called immediately // on script load. ... log("Before"); //...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just created the repository, we can move there and continue to add new keywords 😃.
It already has ability to write tests, and extend in any way using TDD.
If you want to use
func
inside your code, like this:This will not be correct JavaScript, so
@babel/parser
, and any otherESTree
-parser cannot parse it toFunctionDeclaration
node.Anyways you can extend
acorn
to have support offunc
, and produceFunctionDeclaration
, and use it in 🐊Putout with changes in.putout.json
:This will work!
But not in 🐊Putout Editor, since it has preconfigured set of parsers.
Also you can use API:
But remember, that you cannot use Replacer for this purpose, because it uses Babel parser inside. Anyways Traverser can handle it 😃.
Why do you need it?