本文整理匯總了TypeScript中funds/data.right函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript right函數的具體用法?TypeScript right怎麽用?TypeScript right使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了right函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('with setters', () => {
const labelledToNum = mkSetter(
(f: (label: string) => number) => (ln: Labelled<number>) => f(ln.label) + ln.x)
const comp = lp.compose(labelledToNum)
const strlen = (s: string) => s.length
expect(comp.modify(strlen, left(7))).to.eql('Extraction failed: 7')
expect(comp.modify(strlen, right(lab4))).to.eql('Upcasted 8')
expect(comp.set(7, left(5))).to.eql('Extraction failed: 5')
expect(comp.set(7, right(lab4))).to.eql('Upcasted 11')
})
示例2: describe
describe('Either', () => {
const r5 = right(5)
const l5 = left(5)
it('gets mapped', () => {
expect(r5.map(t => t+1)).to.eql(right(6))
expect(l5.map(t => t.toString())).to.eql(left(5))
})
it('flatmaps', () => {
expect(r5.flatMap(t => left(t+1))).to.eql(left(6))
expect(l5.flatMap(t => right(t.toString()))).to.eql(left(5))
})
it('cats', () => {
expect(r5.cata(null, identity)).to.eql(5)
expect(l5.cata(identity, null)).to.eql(5)
})
})
示例3: it
it('gets mapped', () => {
expect(r5.map(t => t+1)).to.eql(right(6))
expect(l5.map(t => t.toString())).to.eql(left(5))
})
示例4: expect
expect(l5.flatMap(t => right(t.toString()))).to.eql(left(5))
示例5: right
(ln: Labelled<number>) => ln.x === 0 ? right(ln.label) : left(ln.x),