Pipeline

advanced8 of 8

Learn about pipeline in fp-ts record

Code Editor

08-pipeline.exercise.ts

💻
Loading editor...
Preparing Monaco Editor with TypeScript support

Test Results

Requirements

describe('Record real-world pipeline', () => {
  it('processes user data', () => {
    const users: Record<string, UserData> = {
      u1: { name: 'Alice', email: 'alice@example.com', age: 25, active: true },
      u2: { name: 'Bob', email: 'bob@example.com', age: 17, active: true },
      u3: { name: 'Charlie', email: 'charlie@example.com', age: 30, active: false },
      u4: { name: 'David', email: 'david@example.com', age: 22, active: true },
    }

    const result = processUserData(users)
    expect(result).toEqual({
      u1: 'Alice (alice@example.com)',
      u4: 'David (david@example.com)',
    })
  })

  it('aggregates by category', () => {
    const items = {
      item1: { category: 'food', value: 10 },
      item2: { category: 'tech', value: 50 },
      item3: { category: 'food', value: 15 },
      item4: { category: 'tech', value: 30 },
      item5: { category: 'books', value: 20 },
    }

    const result = aggregateByCategory(items)
    expect(result).toEqual({
      food: 25,
      tech: 80,
      books: 20,
    })
  })
})
🧪

Ready to Test?

Click "Run Tests" to see how your code performs

Pro Tips

💡 Stuck? Here's what to try:

  • • Read the comments in the code carefully
  • • Run tests frequently to get feedback
  • • Check the fp-ts documentation
  • • Use the solution if you need help

🚀 Learning Approach:

  • • Focus on understanding, not just solving
  • • Experiment with different approaches
  • • Think about real-world applications
  • • Build on previous exercises