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

@simpill/data.utils

v1.0.0

Published

Data utilities: validate, prepare, lifecycle, extend, config (Node and Edge).

Readme

Features: Type-safe · Node & Edge · Tree-shakeable. The API groups helpers under a dot prefix (e.g. data.extend, data.validate, data.prepare, data.lifecycle); import the functions you need from the main entry or /shared.


Installation

From npm

npm install @simpill/data.utils

From GitHub

To use this package from the monorepo source:

git clone https://github.com/SkinnnyJay/simpill.git
cd simpill/utils/@simpill-data.utils
npm install && npm run build

In your project you can then install from the local path: npm install /path/to/simpill/utils/@simpill-data.utils or use npm link from the package directory.


Quick Start

import {
  valid,
  invalid,
  validateNumber,
  withDefaults,
  mergeConfigLayers,
  deepClone,
  addCreatedAt,
  touchUpdatedAt,
} from "@simpill/data.utils";

const r = validateNumber(42);
const full = withDefaults({ a: 1 }, { b: 2 });
const merged = mergeConfigLayers([{ port: 3000 }, { host: "localhost" }]);

Features

| Feature | Description | |---------|-------------| | Validation | valid, invalid, validateString, validateNumber, validateRecord, isString, isNumber, isRecord | | Prepare | withDefaults, coerceNumber, coerceBoolean, coerceString, sanitizeForJson | | Config | mergeConfigLayers, requireKeys, configFromEnv | | Lifecycle | addCreatedAt, touchUpdatedAt, withNextVersion, isNewerVersion | | Extend | deepDefaults, getByPath, setByPath | | Utils | deepClone, pickKeys, omitKeys, ensureKeys | | Search | searchObject, searchString, StringSearchAlgorithm, ObjectSearchMatch, SearchObjectOptions |


Import Paths

import { ... } from "@simpill/data.utils";         // Everything
import { ... } from "@simpill/data.utils/client";  // Client
import { ... } from "@simpill/data.utils/server";  // Server
import { ... } from "@simpill/data.utils/shared"; // Shared only

API Reference

  • ValidationResult<T>, valid, invalid, validateString, validateNumber, validateRecord
  • withDefaults, coerceNumber, coerceBoolean, coerceString, sanitizeForJson
  • mergeConfigLayers, requireKeys, configFromEnv
  • addCreatedAt, touchUpdatedAt, withNextVersion, isNewerVersion
  • deepDefaults, getByPath, setByPathdeepDefaults uses an internal Record<string, unknown> implementation; the public API casts at the boundary so callers get T back. For custom helpers that merge or extend generics, use the same pattern: cast input to Record for the implementation, cast the result back to T.
  • deepClone, pickKeys, omitKeys, ensureKeys
  • searchObject(obj, options?) — walks object and returns matches (path + value). Options: maxDepth (default Infinity; set to limit traversal depth for large or deep trees), predicate(path, value). Returns ObjectSearchMatch[].
  • searchString(haystack, needle, algorithm?) — returns first index of needle or -1. StringSearchAlgorithm: IndexOf, Includes, Kmp.

configFromEnv / requireKeys

configFromEnv builds a config object from environment variables (key mapping and optional coercion). requireKeys(obj, keys) throws if any of the given keys are missing from the object — use for startup validation of required config. Check package source or tests for exact signatures and error shape.

deepClone / sanitizeForJson

deepClone performs a deep copy; behavior with circular references, non-JSON values (Date, Map, Set), or functions is implementation-dependent — validate for your use case. sanitizeForJson prepares values for JSON serialization; see implementation for how non-serializable or circular values are handled.

Schema validation layer (Zod / Joi)

This package does not integrate with Zod or Joi. It provides ValidationResult<T> and simple validators (validateString, validateNumber, validateRecord). For schema-based validation use Zod (or Joi) directly; you can wrap their results in valid/invalid or use @simpill/patterns.utils Result type if you want a unified shape.

Array and enum validators

There are no dedicated validateArray or validateEnum helpers. For arrays, use validateRecord on objects or implement a small predicate (e.g. Array.isArray + element checks). For enums, use a record check or a Zod enum. The package stays minimal; combine with your schema lib as needed.

Validation errors

ValidationResult is { ok: true, value: T } | { ok: false, message: string }. There are no rich validation errors (e.g. field paths, multiple issues). Use the message string for logging or user feedback; for structured errors use Zod’s .safeParse or .flatten() and map to your API shape.

Refine / composition helpers

There are no built-in refine or compose helpers for validators. Chain validations manually (e.g. validateString then check format) or use Zod’s .refine() / .transform(). This package focuses on simple predicates and result wrappers.

Merge strategy (config layers)

mergeConfigLayers(layers) merges from left to right: each layer is deep-merged into the previous result. For each key, if both sides are plain objects (not arrays), they are recursively merged; otherwise the right-hand value wins. There is no option for “replace entire key” or “concat arrays”; for different strategies, merge layers in a custom order or preprocess layers before passing them in.

Delete / update by path

getByPath and setByPath are re-exported from @simpill/object.utils. Use object.utils for path-only access; use data.utils when you need deepDefaults or config (mergeConfigLayers, configFromEnv). There is no deleteByPath or updateByPath. To delete a key, use getByPath to reach the parent object and delete the key yourself, or implement a small helper that splits the path and mutates the parent. setByPath can “update” by setting a new value at a path.

What we don't provide

  • Zod/Joi integration — No schema layer; use ValidationResult and simple validators, or Zod/Joi directly and wrap with valid/invalid if needed.
  • validateArray / validateEnum — Use validateRecord or custom predicates; for enums use a record or Zod enum.
  • Rich validation errors — Only message string on invalid; for field paths or multiple issues use Zod’s .flatten() or similar.
  • refine / compose — Chain validations manually or use Zod’s .refine() / .transform().
  • deleteByPath / updateByPath — Use getByPath to parent and delete the key, or setByPath for updates.
  • Merge strategy optionsmergeConfigLayers uses right-wins deep merge; for “replace key” or “concat arrays” preprocess layers or merge in custom order.

When to use

| Use case | Recommendation | |----------|----------------| | Simple runtime checks (string, number, record) | Use validateString / validateNumber / validateRecord and valid / invalid. | | Layered config (defaults + env) | Use mergeConfigLayers and configFromEnv; requireKeys for startup checks. | | Lifecycle timestamps / versions | Use addCreatedAt, touchUpdatedAt, withNextVersion, isNewerVersion. | | Nested path read/write | Use getByPath / setByPath (no delete helper). | | Full schema validation | Use Zod (or Joi) and optionally wrap with this package’s result type. | | Search in objects/strings | Use searchObject / searchString with optional algorithm. |


Examples

npx ts-node examples/01-basic-usage.ts

| Example | Description | |---------|-------------| | 01-basic-usage.ts | validate, withDefaults, mergeConfigLayers, lifecycle (addCreatedAt, touchUpdatedAt), searchObject/searchString |


Development

npm install
npm test
npm run build
npm run verify

Documentation


License

ISC