![]() | Name | Last modified | Size | Description |
---|---|---|---|---|
![]() | Parent Directory | - | ||
![]() | lib/ | 2 years ago | - | |
![]() | test/ | 2 years ago | - | |
![]() | LICENSE | 2 years ago | 1.1K | f0d2fc9 test post-receive hook [كارل مبارك] |
![]() | README.md | 2 years ago | 1.0K | 15de0e0 styling, texts [كارل مبارك] |
![]() | index.js | 2 years ago | 307 | 15de0e0 styling, texts [كارل مبارك] |
![]() | package.json | 2 years ago | 416 | 120707f added node version q18.16 to dependincies [كارل مبارك] |
append-field
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.
It works best on objects created with Object.create(null)
. Otherwise it might
conflict with variables from the prototype (e.g. hasOwnProperty
).
npm install --save append-field
var appendField = require('append-field')
var 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)
{ pets:
[ { species: 'Dahut', name: 'Hypatia' },
{ species: 'Felis Stultus', name: 'Billie' } ] }
appendField(store, key, value)
Adds the field named key
with the value value
to the object store
.
MIT