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

@jhecht/arktype-utils

v1.1.2

Published

[ArkType](https://www.npmjs.com/package/arktype) is a TypeScript validator that delivers highly optimized validators.

Readme

Arktype Utils

ArkType is a TypeScript validator that delivers highly optimized validators.

I created some wrappers around ArkType's validators.

This is still an early version, the shape might change. I will attempt to keep a nice deprecation path.

Turning FormData into an object

This is a helper method, primarily for Node-based backends that need to turn FormData values into a JS object.

NOTE: This does no validation, it just turns the values into an object

import { formDataToObject } from '@jhecht/arktype-utils';

const fd = new FormData();
fd.append('name', 'Bob');
fd.append('surname', 'Surbob');
fd.append('age', '31');

const obj = formDataToObject(fd);

For repeated entries, if there is more than 1 value found, it will be turned into an array

import { formDataToObject } from '@jhecht/arktype-utils';
const fd = new FormData();
fd.append('name', 'Bob');
fd.append('name', 'John');

const obj = formDataToObject(fd);

// { name: ['Bob', 'John']}
console.info(obj);

This method all does it's best guess for JSON-parsible values, including BigInt

import { formDataToObject } from '@jhecht/arktype-utils';

const fd = new FormData();
fd.append('number', '13');
fd.append('otherNumber', '3.1415');
fd.append('bigNumber', '300n');

const obj = formDataToObject(fd);

// { number: 13, otherNumber: 3.1415, bigNumber: 300n } -- no strings!
console.info(obj);

You can also for an element to always be an array by ending it with []:

import { formDataToObject } from '@jhecht/arktype-utils';

const fd = new FormData();
fd.append('email[]', '[email protected]');

const obj = formDataToObject(fd);

// { email: ['[email protected]'] }
console.info(obj);

You can also specify a nested key value, turning the result into either an object or an array depending on whether or not those keys are numerical.

import { formDataToObject } from '@jhecht/artktype-utils';

const fd = new FormData();
fd.append('obj[id]', 'uuid');
fd.append('obj[name]', "J'onn");
fd.append('obj[age]', '307');

const obj = formDataToObject(fd);
/**
 * {
 *  obj: {
 *    id: 'uuid',
 *    name: 'J\'onn',
 *    age: 307,
 *  }
 * }
 */
console.info(obj);
import { formDataToObject } from '@jhecht/artktype-utils';

const fd = new FormData();
fd.append('name[0]', 'Bruce');
fd.append('name[1]', 'Clark');
fd.append('name[3]', 'Barry');
fd.append('name[2]', "J'onn");

const obj = formDataToObject(fd);

/**
 * {
 *  name: ['Bruce', 'Clark', 'J\'onn', 'Barry']
 * }
 */
console.info(obj);

Deeply Nested Objects and Arrays

formDataToObject supports advanced dot and bracket notation for deeply nested structures, including arrays of objects and nested arrays:

const fd = new FormData();
fd.append('payments.id1.location', 'England');
fd.append('payments.id1.age', '37');
fd.append('payments.id2.location', 'New York');
fd.append('payments.id2.age', '81');
fd.append('payments.id2.name', 'Steve');

const obj = formDataToObject(fd);
// {
//   payments: {
//     id1: { location: 'England', age: 37 },
//     id2: { location: 'New York', age: 81, name: 'Steve' },
//   }
// }

const fd2 = new FormData();
fd2.append('locations[].name', 'England');
fd2.append('locations[].members[]', 'John');
fd2.append('locations[].members[]', 'Joe');
fd2.append('locations[].name', 'France');
fd2.append('locations[].members[]', 'Francis');
fd2.append('locations[].members[]', 'Joe2');

const obj2 = formDataToObject(fd2);
// {
//   locations: [
//     { name: 'England', members: ['John', 'Joe'] },
//     { name: 'France', members: ['Francis', 'Joe2'] }
//   ]
// }

Validating Data with ArkType

I created this wrapper, which throws if there are any error values. It takes two arguments, one being a FormData object, and the other a type or scope call from ArkType, which serves as the validator for the object-ified FormData.

import { validateFormData } from '@jhecht/arktype-utils';
import { type } from 'arktype';

const fd = new FormData();
// Assume `fd` is gotten from the request body here

try {
  const obj = validateFormData(
    fd,
    type({
      name: 'string>=2',
      age: '13<=number',
      favoriteMovies: 'string[]',
    }),
  );
  // If this code is ran we know that the value of the `fd` variables passes the above validations when turned into an object
  console.info(obj);
} catch (e) {
  // If we end up here, `e` will be the `Problems` object returned by ArkType's validator
  console.error(e);
}