4.0.5 • Published 7 years ago

parse-form v4.0.5

Weekly downloads
482
License
MIT
Repository
github
Last release
7 years ago

Utility convert a form to a javascript object in the way that a browser might. Supports files, and every type of native input.

Installation

npm install parse-form

Example

<form id="my-form">
  <input type="text" name="a[b][c]" value="hello world"/>
  <input type="file" name="myFyle" value=.../>
  <button type="submit">Submit</button>
</form>
import { parse } from "parse-form";

const form = document.getElementById("my-form");
parse(form);
/**
 * {
 *     body: { a: { b: { c: "hello world" } } },
 *     files: { myFile: [...] }
 * }
 */

API

parse(form: HTMLFormElement, shallow: boolean): { body: object, files: object }

  • Parses a form into a javascript object.
  • If shallow is true then nested keys such as ab won't be expanded.

Contributions

  • Use npm test to build and run tests.

Please feel free to create a PR!

4.0.5

7 years ago

4.0.4

7 years ago

4.0.3

7 years ago

4.0.2

7 years ago

4.0.1

7 years ago

4.0.0

7 years ago

3.2.0

7 years ago

3.1.0

7 years ago

3.0.0

7 years ago

2.1.0

7 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.1.0

8 years ago