英文:
Unicode character to be used as an ellipsis in TypeScript function names?
问题
我正在开发一个代码生成器。它的源是为其他目的创建的特定XML文档。有时生成的函数名称太长了。我尝试了几种解决方案,但最终只能截断它们。现在我需要在名称中添加一些指示,表示发生了这种截断。
比如用省略号作为后缀:selectGrade1RestrictedInPhysicallyStrenuousActi…()
但在TypeScript函数中,省略号和点都不允许作为字符。有什么其他替代方法吗?
英文:
I am in the process of developing a code generator. Its sources are certain XML documents created for other purposes. Sometimes the generated function names are way too long. I have experimented with several solutions, but in the end I just have to crop them. Now I need some indicator in the name that such a cut happened.
Like an ellipsis as suffix: selectGrade1RestrictedInPhysicallyStrenuousActi…()
But neither ellipsis nor dots are allowed as characters in a TypeScript function. Any idea what to use instead?
答案1
得分: 0
我找到的目前最好的是希腊字符 ·
,看起来像一个点。用法:selectGrade1RestrictedInPhysicallyStrenuousActi···()
。
根据 ECMAScript 6 / Unicode 8.0.0,这是一个有效的标识符。
但是,根据 ES5 的标准,这不是一个有效的标识符。如果要支持旧版本的 JavaScript 引擎,您可能希望避免使用它。
https://mothereff.in/js-variables#selectGrade1RestrictedInPhysicallyStrenuousActi%C2%B7%C2%B7%C2%B7
幸运的是,Visual Studio Code 对这个字符没有任何投诉。不像 ͺ
。
英文:
The best I found so far is the greek character ·
which looks like a dot. Usage:
selectGrade1RestrictedInPhysicallyStrenuousActi···()
> That’s a valid identifier according to ECMAScript 6 / Unicode 8.0.0.
>
> However, it is not a valid identifier as per ES5. You may want to avoid it if support for older JavaScript engines is a concern.
https://mothereff.in/js-variables#selectGrade1RestrictedInPhysicallyStrenuousActi%C2%B7%C2%B7%C2%B7
Fortunately Visual Studio Code does not complain at all about that character. Unlike e. g. ͺ
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论