TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Using EventEmitters in Node.js + CoffeeScript to decouple modules

2 点作者 TrevorBurnham将近 14 年前

1 comment

TrevorBurnham将近 14 年前
"I'm the author, ask me anything," as they say.<p>One of the interesting and/or frustrating things about Node.js is that, although it's based on a very dynamic language where you can modify (nearly) any object at any time, it also encourages strict modularization where, if "x" requires "foo," "bar," and "baz," then it's got to explicitly `require` all of those scripts.<p>Bringing dependencies in with `require` makes testing a pain. I don't think anyone's quite cut the Gordion knot of how testing should be done in Node; it's an open problem, and I certainly don't think I have the full solution. My intent with this article is to get people to realize just how much flexibility they have in organizing their Node apps. The "best practices" haven't emerged yet, and that's kind of cool.