close
The Wayback Machine - https://web.archive.org/web/20190825205010/https://github.com/github/form-data-entries
Skip to content
Image
Please note that GitHub no longer supports your web browser.

We recommend upgrading to the latest Google Chrome or Firefox.

Learn more
FormData.entries ponyfill
JavaScript HTML
Branch: master
Clone or download
Cannot retrieve the latest commit at this time.
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Image test Warn about serializing file inputs Mar 1, 2018
Image .eslintignore
Image .eslintrc.json Initial commit Feb 28, 2018
Image .gitignore Initial commit Feb 28, 2018
Image .travis.yml Add travis config Mar 1, 2018
Image LICENSE Initial commit Feb 28, 2018
Image README.md docs: fix minor typos Feb 28, 2018
Image index.d.ts Remove declare Aug 23, 2019
Image index.js Warn about serializing file inputs Mar 1, 2018
Image index.js.flow Set flow strict Aug 28, 2018
Image index.umd.js Warn about serializing file inputs Mar 1, 2018
Image index.umd.js.flow Set flow strict Aug 28, 2018
Image package.json form-data-entries 1.0.4 Aug 23, 2019
Image prettier.config.js
Image rollup.config.js Rename UMD output to index.umd.js Mar 1, 2018

README.md

FormData.entries ponyfill

This ponyfill implements the FormData serialization algorithm. It aims to be compatible with calling the native new FormData(form).entries(). jQuery's serializeArray is another implementation example.

Usage

import formDataEntries from 'form-data-entries'

for (const [name, value] of formDataEntries(myForm)) {
  console.log(`${name}=${value}`)
}

Why ponyfill?

This package implements FormData.entries as a module ponyfill rather than a polyfill. FormData.entries was a later addition to the FormData specification. Therefore browsers may support FormData but not the entries method. It would be dangerous to attempt to fill just this additional entries method in browsers that have partial support. This module only implements entries as a standalone function which will even work in browsers with no FormData support.

However, once FormData.entries is widely supported this package should be considered obsolete.

Undefined Behavior

This module makes a best effort to match the behavior of native FormData.entries. It should be possible in the future to replace calls to formDataEntries(form) with new FormData(form).entries(). However, there are some cases where this module can not fully match the native behavior. If the form contains any <input type=file> elements, the behavior is considered undefined and should not be relied upon.

Test Suite

You can’t perform that action at this time.