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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

FxTS – A functional and using lazy evaluation and concurrency for JavaScript/TS

4 点作者 xodltus超过 3 年前

1 comment

xodltus超过 3 年前
There are already good functional programming libraries in the JS&#x2F;TS ecosystem, but FxTS has the following advantages:<p>1. Lazy-evaluation Many functions in FxTS handle AsyncIterables and Iterables well and are designed to default to lazy evaluation. And since it operates only with a combination of functions that return standard `Iterable` and `AsyncIterable` without creating a separate wrapper object for lazy evaluation, the composability of the code is higher.<p>2. Easy and declarative asynchronous programming FxTS is designed to make it easier to control asynchronous programming, especially concurrency, declaratively. For example) <a href="https:&#x2F;&#x2F;codesandbox.io&#x2F;s&#x2F;fxts-example-ofm0b?file=&#x2F;src&#x2F;index.ts" rel="nofollow">https:&#x2F;&#x2F;codesandbox.io&#x2F;s&#x2F;fxts-example-ofm0b?file=&#x2F;src&#x2F;index....</a><p>3. Type Inference As in the example code above, we have made good type inference even if we synthesize functions that deal with `AsyncIterable` and `Iterable`. In the example code above, the value returned by pipe is inferred well as an `Array&lt;number&gt;` type, and type inference works well even when several functions that change types are combined.<p>4. Error handling FxTS considers not only the compile time of TypeScript, but also usability at runtime after conversion to JavaScript as important. Because it propagates errors according to the ECMAScript standard, you can easily handle errors with try-catch and await+try-catch, and it is good to use with Sentry or various 3rd party error logging and debugging tools.