當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript monapt.Option類代碼示例

本文整理匯總了TypeScript中monapt.Option的典型用法代碼示例。如果您正苦於以下問題:TypeScript Option類的具體用法?TypeScript Option怎麽用?TypeScript Option使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Option類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: headOption

 .reduce((accumulator: List<[string, List<GitHubCommit>]>, currentCommit: GitHubCommit, currentIndex: number): List<[string, List<GitHubCommit>]> => {
     const isNotEmpty: boolean = ! accumulator.isEmpty();
     const previousGroup = accumulator.last();
     const maybePreviousAuthorName: Option<string> = isNotEmpty ? headOption(previousGroup) : None;
     return maybePreviousAuthorName
         .flatMap(previousAuthorName => {
             if (previousAuthorName === currentCommit.authorName) {
                 const currentCommitsByAuthor = previousGroup[1];
                 const index = accumulator.indexOf(previousGroup);
                 return new Some(accumulator.set(index, [ previousAuthorName, currentCommitsByAuthor.push(currentCommit) ]))
             } else {
                 return None;
             }
         })
         .getOrElse(() => accumulator.push([ currentCommit.authorName, List([ currentCommit ]) ]))
 }, List<[string, List<GitHubCommit>]>())
開發者ID:,項目名稱:,代碼行數:16,代碼來源:

示例2: headOption

 .map(commits => headOption(commits.toArray()).map(commit => commit.authorName).getOrElse(() => ''))
開發者ID:katebee,項目名稱:frontend,代碼行數:1,代碼來源:render.ts

示例3: h

 .map(commit => (
     h('li', [
         h('a', { href: commit.url }, headOption(commit.message.split('\n')).getOrElse(() => '')),
         ` by ${commit.authorName}`
     ]))
開發者ID:,項目名稱:,代碼行數:5,代碼來源:


注:本文中的monapt.Option類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。