1. 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.
append-field
Package: append-field
Created by: LinusU
Last modified: Mon, 13 Jun 2022 03:17:36 GMT
Version: 2.0.0
License: MIT
Downloads: 17,915,575
Repository: https://github.com/LinusU/node-append-field

Install

npm install append-field
yarn add append-field

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

Installation

 npm install --save append-field

Usage

 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)
 { 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

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code