本文整理匯總了TypeScript中jsverify.fn函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript fn函數的具體用法?TypeScript fn怎麽用?TypeScript fn使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了fn函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: describe
describe('Chain instance', () => {
jsv.property('associativity', jsv.nat, jsv.fn(jsv.nat), jsv.fn(jsv.nat), (a, f, g) => {
function fn(a: number) {
return T.pure(f(a));
}
function gn(a: number) {
return T.pure(g(a));
}
return T.toPromise(T.bothPar(
T.pure(a)['fantasy-land/chain'](fn)['fantasy-land/chain'](gn),
T.pure(a)['fantasy-land/chain'](x => fn(x)['fantasy-land/chain'](gn))
).map(tEquals));
});
jsv.property('#chain(f) ignore failure', jsv.string, jsv.nat, jsv.fn(jsv.nat), (m, a, f) => {
function transform(n: number) {
return T.pure(f(n));
}
const err = new Error(m);
return T.toPromise(T.bothPar(
T.attempt(T.raise(err)['fantasy-land/chain'](transform)),
T.attempt(T.raise(err))
).map(tEquals));
});
});
示例2: describe
describe('mapMaybe', () => {
jsv.property('functor identity', maybeArb(jsv.nat), t => deepEq(t, M.mapMaybe(t, id)));
jsv.property('functor compose', maybeArb(jsv.nat), jsv.fn(jsv.nat), jsv.fn(jsv.nat), (t, f, g) =>
deepEq(M.mapMaybe(t, x => f(g(x))), M.mapMaybe(M.mapMaybe(t, g), f))
);
});
示例3: describe
describe('bimapEither', () => {
jsv.property('maps the first function over the left value', leftArb(jsv.nat), jsv.fn(jsv.nat),
jsv.fn(jsv.nat), (t, f, g) => deepEq(E.bimapEither(t, f, g).value, f(t.value)));
jsv.property('maps the second function over the right value', rightArb(jsv.nat), jsv.fn(jsv.nat),
jsv.fn(jsv.nat), (t, f, g) => deepEq(E.bimapEither(t, g, g), E.mapEither(t, g)));
});