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

@ferrow/json-transformer

v2.0.0

Published

Chainable, immutable JSON transformer: pick/omit/rename by dot-path, map, defaults, and flatten/unflatten. Zero runtime dependencies.

Readme

json-transformer

CI

A small, chainable, immutable JSON transformer for TypeScript/Node. Build a pipeline of pick/omit/rename/map/defaults/flatten steps once, then run it against a single object or an array of objects. The input is never mutated — every step returns a new object. Zero runtime dependencies.

Install

Copy src/index.ts into your project, or build this repo (npm run build) and depend on the compiled dist/.

Quickstart

import { transform } from 'json-transformer';

const pipeline = transform()
  .omit(['internal_id'])
  .rename({ 'user.name': 'user.fullName' })
  .map('user.email', (e) => String(e).toLowerCase())
  .defaults({ 'user.address.country': 'UK' });

const result = pipeline.run(input);       // single object
const results = pipeline.runMany(inputs); // array of objects

The same pipeline object can be reused across many inputs — building the chain does no work; .run()/.runMany() is what executes it.

API

All methods return a new JSONTransformer (the chain is immutable too) and accept dot-notation paths ('user.address.city') for nested access.

  • transform() — start a new empty chain.
  • .pick(paths: string[]) — keep only these dot-paths, drop everything else.
  • .omit(paths: string[]) — drop these dot-paths, keep everything else.
  • .rename(mapping: Record<string, string>) — move a value from one dot-path to another ({ 'old.path': 'new.path' }); the old key is removed.
  • .map(path: string, fn: (value) => value) — replace the value at a dot-path with fn(value). No-op if the path is absent.
  • .defaults(values: Record<string, unknown>) — set dot-paths to a default only where currently absent.
  • .flatten() — nested objects to dot-notation keys: { a: { b: 1 } }{ 'a.b': 1 }.
  • .unflatten() — the inverse of .flatten().
  • .pipe(fn: (obj) => obj) — drop in a custom step.
  • .run(input: object) — execute the chain on one object.
  • .runMany(inputs: object[]) — execute the chain on each object in an array.

Scope and limits

  • Operates on plain JSON-shaped objects (Record<string, unknown>); arrays are treated as leaf values by pick/flatten/unflatten, not recursed into by dot-path (no items.0.name-style indexing).
  • flatten()/unflatten() use . as the path separator; keys that legitimately contain a literal . will collide with nested paths.
  • Not a validation or schema library — pair with a validator if you need to enforce shape as well as reshape it.

Sponsored by Ferrow


Part of the ferrow-toolkit collection · Sponsored by Ferrow