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

xfunc

v0.7.0

Published

A lightweight JavaScript utility library with common functions

Readme

xfunc

██╗   ██╗███╗   ██╗███████╗██╗   ██╗███╗   ██╗████████╗
██║   ██║████╗  ██║██╔════╝██║   ██║████╗  ██║╚══██╔══╝
██║   ██║██╔██╗ ██║█████╗  ██║   ██║██╔██╗ ██║   ██║   
██║   ██║██║╚██╗██║██╔══╝  ██║   ██║██║╚██╗██║   ██║   
╚██████╔╝██║ ╚████║██║     ╚██████╔╝██║ ╚████║   ██║   
 ╚═════╝ ╚═╝  ╚═══╝╚═╝      ╚═════╝ ╚═╝  ╚═══╝   ╚═╝

A modern collection of utility functions for TypeScript/JavaScript projects.

Features

  • 🚀 TypeScript First - Built with TypeScript, providing excellent type safety
  • 📦 Tree Shaking - Only import what you need
  • 🔧 Zero Dependencies - Lightweight and self-contained
  • Well Tested - Comprehensive test coverage with Vitest
  • 📚 Full Documentation - Complete API reference with examples
  • 🎯 Modern Tooling - ESM, CJS, and UMD builds

Installation

# npm
npm install xfunc

# yarn
yarn add xfunc

# pnpm
pnpm add xfunc

Usage

// Import specific functions (recommended for tree shaking)
import { debounce, isArray } from 'xfunc'

// Or import everything
import * as xfunc from 'xfunc'

// Usage examples
const debouncedHandler = debounce(() => {
  console.log('Called after 300ms delay')
}, 300)

if (isArray(data)) {
  console.log('data is an array')
}

API Categories

Array Methods

  • toArray - Convert value to array
  • unionBy - Merge arrays and remove duplicates by iteratee
  • range - Generate numeric range arrays
  • sortBy - Sort array by iteratee functions
  • orderBy - Sort array by multiple criteria with order
  • uniq - Create deduplicated array
  • uniqWith - Create deduplicated array with custom comparator
  • castArray - Convert value to array (wrap if needed)
  • remove - Remove first occurrence of item from array

Function Methods

  • debounce - Create debounced function
  • throttle - Create throttled function
  • memoize - Create memoized function with cache

Number Methods

  • toNumber - Convert value to number
  • randomInt - Generate random integer in range

Object Methods

  • omit / omitBy - Create object excluding properties
  • pick / pickBy - Create object with only specified properties
  • mapEntries - Transform object key-value pairs
  • forEachEntry - Iterate over object entries
  • forOwn - Iterate over own object properties
  • hasOwn - Check for own property
  • clone - Create shallow clone
  • cloneDeep - Create deep clone

String Methods

  • capitalize - Capitalize first character, lowercase rest
  • lowerFirst - Convert first character to lowercase
  • upperFirst - Convert first character to uppercase
  • camelize - Convert hyphenated string to camelCase
  • hyphenate - Convert camelCase string to hyphenated

Type Check Methods

22 type checking utilities including:

  • isArray, isString, isNumber, isBoolean
  • isEmpty, isNil, isFunction, isObject
  • isDate, isRegExp, isPromise, isError
  • isMap, isSet, isBigInt, isSymbol
  • And more...

Structure Methods

  • QueueMap - Map-based queue with insertion order

Quick Examples

Debounce Function Calls

import { debounce } from 'xfunc'

const searchHandler = debounce((query: string) => {
  // API call will only happen 300ms after user stops typing
  searchAPI(query)
}, 300)

input.addEventListener('input', (e) => {
  searchHandler(e.target.value)
})

Type-Safe Object Manipulation

import { pick, omit, isObject } from 'xfunc'

const user = { id: 1, name: 'John', email: '[email protected]', password: 'secret' }

// Pick only safe properties for API response
const safeUser = pick(user, ['id', 'name', 'email'])
// { id: 1, name: 'John', email: '[email protected]' }

// Omit sensitive data
const publicUser = omit(user, ['password'])
// { id: 1, name: 'John', email: '[email protected]' }

// Type-safe checking
if (isObject(data) && !isEmpty(data)) {
  // Process the object safely
}

Array and Type Utilities

import { toArray, range, uniq, isNumber } from 'xfunc'

// Convert various types to arrays
toArray('hello')     // ['h', 'e', 'l', 'l', 'o']
toArray(42)          // [42]
toArray([1, 2, 3])   // [1, 2, 3]
toArray(null)        // []

// Generate numeric ranges
range(5)           // [0, 1, 2, 3, 4]
range(1, 5)        // [1, 2, 3, 4]
range(0, 20, 5)    // [0, 5, 10, 15]

// Remove duplicates
uniq([1, 2, 2, 3, 3, 3])        // [1, 2, 3]

// Safe type checking
isNumber('42')     // false
isNumber(42)       // true

Documentation

Visit our documentation site for:

  • 📖 Complete API reference
  • 💡 Usage examples
  • 🎯 Best practices
  • 📝 Type definitions

Development

# Install dependencies
pnpm install

# Run tests in watch mode
pnpm test

# Run tests once
pnpm test:run

# Build the library
pnpm build

# Lint and fix code
pnpm lint

# Start documentation site
pnpm docs:dev

# Build documentation
pnpm docs:build

License

MIT

Contributing

Contributions are welcome! Please read our contributing guidelines and submit a pull request.


xfunc - Utility functions that just work