https://github.com/idiocc/append-field
[fork] W3C HTML JSON form compliant field appender Written In ES6 And Optimised With JavaScript Compiler.
https://github.com/idiocc/append-field
Last synced: about 1 year ago
JSON representation
[fork] W3C HTML JSON form compliant field appender Written In ES6 And Optimised With JavaScript Compiler.
- Host: GitHub
- URL: https://github.com/idiocc/append-field
- Owner: idiocc
- License: other
- Created: 2019-07-03T10:39:33.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-04T13:30:29.000Z (almost 7 years ago)
- Last Synced: 2025-03-17T07:09:24.912Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://idio.cc
- Size: 31.3 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @goa/append-field
[](https://npmjs.org/package/@goa/append-field)
`@goa/append-field` is a fork of [W3C HTML JSON form compliant field appender](https://github.com/LinusU/node-append-field) Written In ES6 And Optimised With [JavaScript Compiler](https://compiler.page).
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`.
```sh
yarn add @goa/append-field
```
## Table Of Contents
- [Table Of Contents](#table-of-contents)
- [API](#api)
- [`appendField(store: Object, key: string, value: string)`](#appendfieldstore-objectkey-stringvalue-string-void)
- [Copyright](#copyright)
## API
The package is available by importing its default function:
```js
import appendField from '@goa/append-field'
```
## `appendField(`
`store: Object,`
`key: string,`
`value: string,`
`): void`
Adds the field named `key` with the value `value` to the object store.
```js
import appendField from '@goa/append-field'
const obj = {}
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)
```
```js
{ pets:
[ { species: 'Dahut', name: 'Hypatia' },
{ species: 'Felis Stultus', name: 'Billie' } ] }
```
## Copyright
Original Work by [Linus Unnebäck](https://github.com/LinusU/node-append-field).
---
© Art Deco for Idio 2019
Tech Nation Visa Sucks