@abadi199/maybe 中文文档教程

发布于 6年前 浏览 27 项目主页 更新于 3年前

Maybe for TypeScript

灵感来自 Maybe Elm

Example

function logText(Maybe<string> text) {
    switch (text.kind) {
      case MaybeKind.Nothing:
        break;
      case MaybeKind.Just:
        console.log(text.value);
        break;
    }
} 

function main() {
    logText(nothing()); // no log message
    logText(just("Hello World")); // "Hello World"
}

Install

npm install -S @abadi199/maybe

Contributing

  • Submit a pull request! If you're missing a feature you want to have, or just found a bug, or found an error in the docs, please submit a pull request.
  • Create an issue! If you found a bug or want a new feature that you think will make the library better, but don't have time to do it yourself, please submit an issue.

Maybe for TypeScript

Inspired by Maybe in Elm

Example

function logText(Maybe<string> text) {
    switch (text.kind) {
      case MaybeKind.Nothing:
        break;
      case MaybeKind.Just:
        console.log(text.value);
        break;
    }
} 

function main() {
    logText(nothing()); // no log message
    logText(just("Hello World")); // "Hello World"
}

Install

npm install -S @abadi199/maybe

Contributing

  • Submit a pull request! If you're missing a feature you want to have, or just found a bug, or found an error in the docs, please submit a pull request.
  • Create an issue! If you found a bug or want a new feature that you think will make the library better, but don't have time to do it yourself, please submit an issue.
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文