本文整理汇总了TypeScript中folktale/maybe.of函数的典型用法代码示例。如果您正苦于以下问题:TypeScript of函数的具体用法?TypeScript of怎么用?TypeScript of使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了of函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('getFilledArray', () => {
const tests = [[Maybe.of([]), false], [Maybe.of([1]), [1]]];
tests.forEach(([mArr, result]) =>
expect(getFilledArray(mArr).getOrElse(false)).toEqual(result)
);
});
示例2: test
test('getOrElse', () => {
const tests = [['default', Maybe.empty()], ['value1', Maybe.of('value1')]];
tests.forEach(([result, data]) => {
expect(getOrElse('default')(data)).toEqual(result);
});
});
示例3: buildJoiSpec
(acc, [method, spec]) =>
Maybe.of(concat)
.ap(parseSecuritySpec(spec))
.ap(parseRouteSpec(spec, routeHandlers))
.map(handler => [
{
method,
path,
handler,
validate: buildJoiSpec(Joi, spec),
meta: pick(['summary', 'description'], spec)
}
])
.fold(always(acc), concat(acc)),
示例4: getRouteMapping
.map(([head, ...tail]) =>
getRouteMapping(
concat(acc, mapMethods(head.route, maybeProp('verbs', head), handlers)),
handlers,
getFilledArray(Maybe.of(tail).concat(maybeProp('paths', head)))
)
示例5: liftN
liftN(2, (moduleContents, config) =>
getRouteMapping(
Maybe.of([]),
prop('routeHandlers', moduleContents),
maybeProp('paths', config)
).chain(routeBinder)
示例6:
const maybeFunction = (value: any) => (isFunction(value) ? Maybe.of(value) : Maybe.Nothing());