Skip to content

Commit

Permalink
Export universal CreateBody types
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Apr 11, 2018
1 parent 0a0c5d5 commit e1af825
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/body/universal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ import { Readable } from 'stream' // tslint:disable-line
import { createBody as createNodeBody, CreateBody as CreateNodeBody, Body as NodeBody } from './node'
import { CreateBody as CreateBrowserBody, Body as BrowserBody } from './browser'

export { NodeBody as Body }
/**
* Export mapped `Body` (e.g. `NodeBody` or `BrowserBody`).
*/
export { NodeBody as Body, NodeBody, BrowserBody }

export type CreateBodyFn = (value?: CreateNodeBody | CreateBrowserBody) => NodeBody | BrowserBody
/**
* Supported `CreateBody` types.
*/
export type CreateBody = CreateNodeBody | CreateBrowserBody

/**
* This function is changed at bundle time by tools like Browserify to
* `./browser`. Unfortunately TypeScript doesn't support this so we do an
* interesting hack by intersecting the valid return classes.
*/
export const createBody: CreateBodyFn = createNodeBody
export const createBody: (value?: CreateBody) => NodeBody | BrowserBody = createNodeBody

0 comments on commit e1af825

Please sign in to comment.