Package detail

@multipart/append-field

idiocc11MIT1.0.1

[fork] W3C HTML JSON form compliant field appender Written In ES6 And Optimised With JavaScript Compiler.

append-field, multipart, form-data, x-www-form-urlencoded

readme

@goa/append-field

npm version

@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.


Art Deco © Art Deco for Idio 2019 Idio Tech Nation Visa Tech Nation Visa Sucks

changelog

4 July 2019

1.0.1

  • [package] Republish in the @multipart scope.
  • [deps] Use test data from @multipart/test-form-data.

3 July 2019

1.0.0

  • [package] Publish v1 of the package.

0.0.0-pre