Skip to content
← Volver al catálogo
Desarrollomediocommunity

fp-pipe-ref

Referencia rápida para pipe y flow. Úsalo cuando necesites encadenar funciones, componer operaciones o construir tuberías de datos en fp-ts.

El contenido de este skill está en su idioma original (a menudo inglés).

pipe & flow Quick Reference

pipe - Transform a Value

import { pipe } from 'fp-ts/function'

// pipe(startValue, fn1, fn2, fn3)
// = fn3(fn2(fn1(startValue)))

const result = pipe(
  '  hello world  ',
  s => s.trim(),
  s => s.toUpperCase(),
  s => s.split(' ')
)
// ['HELLO', 'WORLD']

flow - Create Reusable Pipeline

import { flow } from 'fp-ts/function'

// flow(fn1, fn2, fn3) returns a new function
const process = flow(
  (s: string) => s.trim(),
  s => s.toUpperCase(),
  s => s.split(' ')
)

process('  hello world  ') // ['HELLO', 'WORLD']
process('  foo bar  ')     // ['FOO', 'BAR']

When to Use

UseWhen
pipeTransform a specific value now
flowCreate reusable transformation

With fp-ts Types

import * as O from 'fp-ts/Option'
import * as A from 'fp-ts/Array'

// Option chain
pipe(
  O.fromNullable(user),
  O.map(u => u.email),
  O.getOrElse(() => 'no email')
)

// Array chain
pipe(
  users,
  A.filter(u => u.active),
  A.map(u => u.name)
)

Common Pattern

// Data last enables partial application
const getActiveNames = flow(
  A.filter((u: User) => u.active),
  A.map(u => u.name)
)

// Reuse anywhere
getActiveNames(users1)
getActiveNames(users2)

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
— Field Manual

Las 1.441 skills, desmitificadas en un PDF.

Una guía editorial gratuita que escribimos para Skills Atlas: taxonomía, las 25 skills imprescindibles, antipatrones, rutas de aprendizaje por perfil.

  • 70+ páginas, índice, lista para imprimir.
  • Enviado por email — enlace válido 7 días.
  • Cancela suscripción en un clic cuando quieras.

Sin spam. Nunca compartimos tu email. Cancelación en un clic.