本文整理汇总了TypeScript中tsmonad.Maybe.maybe方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Maybe.maybe方法的具体用法?TypeScript Maybe.maybe怎么用?TypeScript Maybe.maybe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tsmonad.Maybe
的用法示例。
在下文中一共展示了Maybe.maybe方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getFirstMemberName
//////////
function getFirstMemberName(state: State): string | undefined {
return Maybe.maybe<Data>(state.data!)
.bind(data => Maybe.maybe(data.members[0]))
.bind(member => Maybe.just(member.name))
.caseOf({
just: name => name,
nothing: () => undefined
})
/*
return Maybe.maybe<Data>(state.data!)
.bind(data => Maybe.maybe(data.members[0]))
.caseOf({
just: member => member.name,
nothing: () => undefined
})
*/
}
示例2:
.bind(data => Maybe.maybe(data.members[0]))