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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@twyzle/core-utils

v2.0.9

Published

Typed utility functions for web apps

Readme

🛠️ Twyzle TypeScript Core Utilities

npm version npm downloads MIT License

A lightweight utility toolkit built for modern TypeScript projects. This library provides reusable, typed helpers for manipulating objects, arrays, forms, strings, and more. Powered by Lodash for consistent, reliable performance.


✨ Features

  • 🔁️ Deep cloning and safe copies
  • 🧱 Object/array transformation helpers
  • 📄 Form data serialization
  • 🌤️ String normalization and ID generation
  • 🧪 Shallow diffing (getTopLevelChanges)
  • ✅ Branded types like PositiveInt
  • ⚙️ Tree-shakable with lodash-es by default
  • 📦 Dual ESM + CommonJS output
  • 🧹 Consumer-controlled lodash variant (via alias or peer install)

📦 Installation

npm install @twyzle/core-utils

Then also install a lodash flavor based on your setup:

🖐 ESM (tree-shakable):

npm install lodash-es

🖐 CommonJS:

npm install lodash

🚀 Usage

import { camelizeObject, safeClone, buildFormData } from '@twyzle/core-utils'

const raw = { first_name: 'John', last_name: 'Doe' }
const camelized = camelizeObject(raw)
// { firstName: 'John', lastName: 'Doe' }

const cloned = safeClone(camelized)
// Shallow clones the object safely

const formData = new FormData()
buildFormData(formData, camelized)

📚 API Highlights

camelizeObject(obj: any): any

Converts all keys in an object from snake_case to camelCase.

buildFormData(formData: FormData, data: any, parentKey?: string): void

Serializes a nested object into FormData, recursively.

safeClone<T>(value: T): T | null

Returns a shallow clone or null if the value is null or undefined.

getTopLevelChanges<T>(newVal: T, oldVal: T): Partial<T>

Returns an object containing keys that changed between two objects.

prependWithLimit(arr: string[], newItem: string | string[], maxLength: PositiveInt, mutate?: boolean): string[]

Prepends an item while enforcing uniqueness, prefix constraints, and a max length.


⚙️ Build Output

This package includes dual module support:

| Format | Path | Use case | | -------- | ----------------- | --------------- | | ESM | dist/index.mjs | Modern bundlers | | CommonJS | dist/index.cjs | Node.js, CJS | | Types | dist/index.d.ts | TypeScript apps |

Consumers can alias lodash-es to lodash during build if needed.


⚠️ Requirements

  • TypeScript 4.5+
  • Node 14+
  • A bundler that supports dual ESM/CJS (vite, webpack, etc.)

📁 Folder Structure

src/
  arrays/              # Array utilities
  dom/                 # DOM-specific helpers
  form/                # FormData utilities
  objects/             # Object transformation/deep utils
  strings/             # String utilities
  types/               # Shared branded types like PositiveInt
  index.ts             # Barrel exports
tsup.config.ts         # Dual ESM + CJS build config

📝 License

MIT © Twyzle