本文整理汇总了TypeScript中funds/data.left函数的典型用法代码示例。如果您正苦于以下问题:TypeScript left函数的具体用法?TypeScript left怎么用?TypeScript left使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了left函数的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(r5.flatMap(t => left(t+1))).to.eql(left(6))
示例5: right
(ln: Labelled<number>) => ln.x === 0 ? right(ln.label) : left(ln.x),