npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

form-collect

v1.1.2

Published

Collect form data following the WHATWG form submission algorithm

Readme

Form Collect

Collects form data in the same way specified by WHATWG; this data should be the same as the data that would get submitted to the server by a plain form submission.

This means you can gracefully degrade your js form submission, knowing the front and back end will recieve the same data sets.

How to use

npm install form-collect
const collect = require('form-collect');

// This is the form you want to collect data from
const form = document.querySelector('#my-form');
// Optional; this is the button that was clicked to submit the form
const submitter = document.querySelector('#submit-button');

const data = collect(form, submitter);

The data object that is returned is an array of entries, each entry being a two-element array, of key/name and value. This is because the form may have multiple inputs with the same name, creating mutliple entries with the same key, and this is the most generic way of handling such a case in Javascript.

An example for form with one text input called text_input and two checkboxes both with the name checkbox[]. Of course field naming convention is totally up to you; the brackets on the end are optional.

[
  ["text_input", "input value"],
  ["checkbox[]", "checked_value_1"],
  ["checkbox[]", "checked_value_2"],
]

It's not hard to get data from this structure:

const matchKey = key => ([k]) => k === key;

const get = (data, key) => (data.find(matchKey(key)) || [])[1];
const getAll = (data, key) => data.filter(matchKey(key));
const has = (data, key) => data.some(matchKey(key));
const entries = data => data[Symbol.iterator]();
const keys = data => data.map([k] => k)[Symbol.iterator]();
const values = data => data.map([,v] => v)[Symbol.iterator]();
const append = (data, key, value) => {
  data.push(key, value);
};
const del = (data, key) => {
  let ix;
  while(ix = data.findIndex(matchKey(key)), ix > -1)
    data.splice(ix, 1);
};
const set = (data, key) => {
  del(data, key);
  append(data, key, value);
};

Maybe simpler still, create a FormData object:

const formData = data.reduce((fd, e) => (fd.append(...e), fd), new FormData());

Known issues

I need to double check to make sure it's rigorous, but for certain I know that image input don't capture your mouse coördinates currently. Instead it submits (0,0) as the x and y values.