Description
Line 12 in 1c8305b
Hi, I was just wondering why eval is being used here instead of just hard-coding the values? Is this done in order to avoid, say, throwing uncatchable parser/syntax errors that would otherwise occur in older ECMA environments? If that is the reason, I think it would at least be useful to maybe have another version of this package (whether internal, or external via a separate package) that would always be able to query all intrinsics in any modern environment (say esnext) regardless of whether eval is allowed or not.
I think it would also be nice if there were a way to access all of these intrinsics at once, say in a collection or array, or even a plain object/hash whose keys could be iterated over.
Instead of doing it all from scratch, I've been trying to find a package that would be able to take in any unknown
value where:
((typeof value === "object" || typeof value === "function") && value !== null)
and then test it in order to see if it is a is a builtin/intrinsic object (e.g. Math), or builtin/intrinsic Function (e.g. Date). It is this issue that led me here to this package. I suppose most or many of these values simply exist on the global object (in which case one could perhaps simply test against every value in globalThis
), but that doesn't seem to be the case for all of them...
Finally, I was just wondering what the benefit is of querying these builtins/intrinsics by their language spec name/syntax? Is it just done that way to have a one-to-one mapping in regards to how they are listed in the spec? I'm honestly just curious to know if there's something additional that I might be missing here, that's all.
Sorry for being a bit of a noob, and thank you beforehand for hearing out my concerns and any information you can provide regarding these questions!