# tofd

> tofd converts an object to FormData

Latest version **1.0.7** (published 2018-07-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install tofd
pnpm add tofd
yarn add tofd
bun add tofd
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2018-07-23 |
| First published | 2017-04-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 28.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | tugorez |
| Maintainers | tugorez |

## Links

- npm: https://www.npmjs.com/package/tofd
- Repository: https://github.com/tugorez/tofd
- Homepage: https://github.com/tugorez/tofd#readme
- Issues: https://github.com/tugorez/tofd/issues
- npm.io page: https://npm.io/package/tofd

## Dependencies (2)

- [buffer](https://npm.io/package/buffer.md) ^5.1.0
- [form-data](https://npm.io/package/form-data.md) ^2.1.2

## Recent versions

- 1.0.7 (latest) — 2018-07-23
- 1.0.6 — 2018-07-23
- 1.0.5 — 2018-07-21
- 1.0.4 — 2018-07-21
- 1.0.3 — 2017-04-09
- 1.0.2 — 2017-04-05
- 1.0.1 — 2017-04-05
- 1.0.0 — 2017-04-05

## README

# tofd

Converts an object to a `FormData` representation. Also supports nested arrays, objects, `File`, and `Buffer`s.

## Installation
```bash
npm i tofd --save
```

## Why
This library allows you to declaratively create a `FormData` instead of having to `append` each property.

```diff
- const payload = new FormData()
- payload.append('first_name', firstName)
- payload.append('last_name', lastName)
+ const payload = tofd({
+   first_name: firstName,
+   last_name: lastName
+ })
fetch('/user', { method: 'POST', body: payload })
```

## Usage
```js
const payload = tofd({
  // Basic data types
  first_name: 'hello',
  last_name: 'hello',
  // Nested arrays and objects
  tags: [{ id: 1 } , { id: 2 }],
  // Files and Buffers
  attachments: [File, File],
  avatar: File
})
```

## API
```
tofd(obj: Object): FormData
```
Accepts an object that gets converted into `FormData`.

---
_Source: https://npm.io/package/tofd · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
