-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Description
- Version: v9.11.1
- Platform: windows, linux, mac, wt
- Subsystem: require
Hi. I really like node.js and the concept behind it, but one thing that I find very disturbing is that require function doesn't allow templated arguments.
For example, how about
const util = require`util`;instead of
const util = require('util');All native functions* allow templated call. Of course, it is not a syntax error to templately call even require, but unfortunately require doesn't recognize the string properly. It throws assertion error (path must be a string).
Templated call not only to save 2 extra characters of typing effort, but it also makes the code more readable and it would make require consistent with other native functions which allow such call. Also, since the only argument of require is a string, therefore it is the one reason more to implement such call.
Of course, it is very easy to make a polyfill for it in JavaScript, but why not implement it natively, since I don't see a hindrance for it.
Any opinions? Thanks.
*every function where it makes sense (for example if it accepts only one argument which can only be a string or a number)