@multipart/append-field
v1.0.1
Published
[fork] W3C HTML JSON form compliant field appender Written In ES6 And Optimised With JavaScript Compiler.
Downloads
13
Maintainers
Readme
@goa/append-field
@goa/append-field
is a fork of W3C HTML JSON form compliant field appender Written In ES6 And Optimised With JavaScript Compiler.
A W3C HTML JSON forms spec compliant field appender (for lack of a better name). Useful for people implementing application/x-www-form-urlencoded
and multipart/form-data parsers
.
yarn add @goa/append-field
Table Of Contents
API
The package is available by importing its default function:
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.
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)
{ pets:
[ { species: 'Dahut', name: 'Hypatia' },
{ species: 'Felis Stultus', name: 'Billie' } ] }
Copyright
Original Work by Linus Unnebäck.