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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Show HN: Go-promise – Golang's style to handle promises/error in JavaScript

4 点作者 docuru超过 3 年前

1 comment

docuru超过 3 年前
I feel handling Promises in JavaScript is not nice with `then&#x2F;catch`. It gets messy when there are multiple promises (I often use `async&#x2F;await` and wrap in a huge `try&#x2F;catch` block in this case), or there is a huge chunk of code in the resolve function<p>I notice how Golang handle errors. The error is returned in the same line of code. We handle it, then move on to the next problem. That makes the code easier to read and is more convenient to handle error.<p>So I make this tiny `go-promise` util library to handle promise better in JavaScript. Feedback are welcome!