coffeescript下划线方法从何而来?

Where does the coffeescript underline method come from?

我一直在 atom/apm code 中寻找函数定义或包依赖项的位置。它在第 93

行的 src/view.coffee 中被调用
items.push(repository.underline)
items.push(pack.description.replace(/\s+/g, ' ')) if pack.description

但我不确定该方法来自何处,或者我如何能够在节点 REPL 中重现它。它来自哪里?

repository.underline 不是方法(没有括号),它是 repository 变量的 属性。

repository variable comes from pack.repository.url or pack.repository.

pack is populated from a JSON HTTP API response. repository is in the metadata which comes from the JSON in versions[version]. version is decided by getLatestCompatibleVersion.

采用 sample response for the minimap package 显示特定版本的所有 repository 值都是纯字符串,因此 .underline 属性 并非来自那里的对象。因为它们是普通字符串,所以可能已经扩展了 javascript 字符串原型以包含 underline 属性,但是什么?

来自你的sample search it looks like .underline is used for terminal type output. Looking at the package.json dependencies, the colors package works in that space.

colors adds a number of properties to the string prototype, including underline.

这是一个很好的例子,说明为什么扩展原型会让人困惑。