effect-tree - v1.0.36
    Preparing search index...

    Function matchPart

    • Match part by type.

      Type Parameters

      • R

      Parameters

      Returns (p: Draw.Part) => R

      import {Draw} from 'effect-tree'

      const emptyPart = Draw.empty
      const textPart = Draw.text('foo')
      const rowPart = Draw.row.top.right([textPart])
      const columnPart = Draw.column.right([textPart])

      const match = Draw.matchPart(
      'empty',
      s => `text=${s}`,
      () => 'row',
      () => 'column',
      )

      expect(match(emptyPart), 'empty').toBe('empty')
      expect(match(textPart), 'text').toBe('text=foo')
      expect(match(rowPart), 'row').toBe('row')
      expect(match(columnPart), 'column').toBe('column')