# append-field

> A [W3C HTML JSON forms spec](http://www.w3.org/TR/html-json-forms/) compliant field appender (for lack of a better name). Useful for people implementing `application/x-www-form-urlencoded` and `multipart/form-data` parsers.

Latest version **2.0.0** (published 2021-07-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install append-field
pnpm add append-field
yarn add append-field
bun add append-field
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2021-07-24 |
| First published | 2015-05-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 0 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | linusu |

## Links

- npm: https://www.npmjs.com/package/append-field
- Repository: https://github.com/LinusU/node-append-field
- Homepage: https://github.com/LinusU/node-append-field#readme
- Issues: https://github.com/LinusU/node-append-field/issues
- npm.io page: https://npm.io/package/append-field

## Recent versions

- 2.0.0 (latest) — 2021-07-24
- 1.0.0 — 2016-02-14
- 0.1.0 — 2015-05-03

## README

# `append-field`

A [W3C HTML JSON forms spec](http://www.w3.org/TR/html-json-forms/) compliant
field appender (for lack of a better name). Useful for people implementing
`application/x-www-form-urlencoded` and `multipart/form-data` parsers.

It works best on objects created with `Object.create(null)`. Otherwise it might
conflict with variables from the prototype (e.g. `hasOwnProperty`).

## Installation

```sh
npm install --save append-field
```

## Usage

```javascript
import appendField from 'append-field'

const obj = Object.create(null)

appendField(obj, 'pets[0][species]', 'Dahut')
appendField(obj, 'pets[0][name]', 'Hypatia')
appendField(obj, 'pets[1][species]', 'Felis Stultus')
appendField(obj, 'pets[1][name]', 'Billie')

console.log(obj)
```

```text
{ pets:
   [ { species: 'Dahut', name: 'Hypatia' },
     { species: 'Felis Stultus', name: 'Billie' } ] }
```

## API

### `appendField(store, key, value)`

- `store` (`object`, required)
- `key` (`string`, required)
- `value` (`any`, required)

Adds the field named `key` with the value `value` to the object `store`.

## License

MIT

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