import { pair } from './index.js'
import type { Duplex, Source } from 'it-stream-types'

/**
 * Two duplex streams that are attached to each other
 */
export function duplexPair <T> (): [Duplex<AsyncGenerator<T>, Source<T>, Promise<void>>, Duplex<AsyncGenerator<T>, Source<T>, Promise<void>>] {
  const a = pair<T>()
  const b = pair<T>()
  return [
    {
      source: a.source,
      sink: b.sink
    },
    {
      source: b.source,
      sink: a.sink
    }
  ]
}
