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

ts-scribe

v0.5.5

Published

A collection of utility functions and types for TypeScript projects in Node.js

Downloads

281

Readme

TS-Scribe

npm Module type: CJS+ESM

A TypeScript utility library tailored for Node.js and Bun development. It provides a rich set of utility functions and advanced types to enhance productivity and code quality.

Installation

npm install ts-scribe
bun add ts-scribe

Functions

Core

  • run: Helper to run a function or block of code in a cleaner way.
  • parseBoolean: Parses various values into a boolean.
  • parseNumber: Parses various values into a number.
  • safeJsonParse: Safely parses a string without throwing.
  • safeJsonStringify: Safely stringifies a JSON object without throwing (handles issues like circular references).

Array

  • arrChunk: Splits an array into chunks of a specified size.
  • arrDifference: Returns the difference between two arrays.
  • arrGroupBy: Groups an array of objects by a specified key.
  • arrIntersection: Returns the intersection of two arrays.
  • arrIntersectionDeep: Deep intersection between arrays of objects or values.
  • arrPluck: Extracts a list of property values from an array of objects.
  • arrPowerset: Returns the powerset of an array.
  • arrShuffle: Shuffles an array randomly.
  • arrUniqueBy: Returns an array of unique values based on a specified key.
  • toArray: Converts almost anything into an array.

Async

  • asyncForEach: Runs async operations over an array in parallel.
  • asyncMap: Similar to asyncForEach but with the behavior of Array.map function.
  • debounce: Debounces a function or promise.
  • maybe: Maybe monad for null-safe operations.
  • retry: Retries a promise a specified number of times.
  • sleep: Pauses execution for a specified time.
  • waterfall: Chains functions that pass results to each other.

List

  • SortedList: Maintains a sorted list.
  • WeightedList: Selects items based on weight/probability.

Math

  • clamp: Clamps a number between min and max.
  • greatestCommonDivisor: Finds the GCD of multiple numbers.
  • smallestCommonMultiple: Finds the LCM of multiple numbers.

Object

  • objectDeepClone: Deeply clones an object.
  • objectDeepEquals: Deeply compares two objects or arrays.
  • objectDeepFreeze: Deep freezes an object recursively.
  • objectFlatten: Flattens an object into dot notation.
  • objectPrune: Removes properties with undefined values.
  • objectRemoveKeys: Removes specified keys from an object.

Deepmerge

Exposes the API of deepmerge-ts, check their documentation for more details.

Random

  • randomBool: Generates a random boolean, optionally biased.
  • randomInt: Generates a random integer in a given range.
  • randomSample: Randomly samples values from an array.
  • randomString: Generates a random string of given length/charset.

String

  • strCamelCase: Converts a string to camelCase.
  • strDotCase: Converts a string to dot.case.
  • strHeaderCase: Converts a string to Header Case.
  • strKebabCase: Converts a string to kebab-case.
  • strPascalCase: Converts a string to PascalCase.
  • strSnakeCase: Converts a string to snake_case.
  • strTruncate: Truncates a string with configurable options.
  • strSlugify: Slugifies a string, converting it into a URL-friendly format with customizable options.

System

  • isBrowser: Returns true if running in a browser environment.
  • isNode: Returns true if running in Node.js.
  • getEnvironment: Returns 'Browser', 'Bun', 'Node', or 'Unknown' depending on the context it's run in.

Typeguards

  • isDefined: Checks if a value is not null/undefined/NaN.
  • isEmptyObject: Checks if an object has no own properties.
  • isEmptyValue: Checks for null, undefined, NaN, empty string/array/object.
  • isNumber: Validates numeric values or strings that can be parsed as numbers.
  • isString: Validates if a value is a string.

Types

  • Primitive: JavaScript primitive types.
  • Nullish: Represents null | undefined.
  • NonNullish: Excludes null | undefined.
  • Mandatory<T>: Removes nullish from all properties of T.
  • Nestable<T>: A type that can nest recursively.
  • GenericFunction: A generic function type.
  • TypeOfString: Valid typeof operator string values.
  • TypeOfType<T>: Infers the typeof type string from a value.
  • UnionToIntersection<U>: Converts a union to an intersection.
  • SmartPartial<T>: Only makes properties optional if their type includes undefined.
  • Simplify<T>: Flattens complex types for better readability.
  • OverloadUnion<T>: Turns a union of functions into a single overloaded function type.
  • DeepReadonly<T>: Deep version of Readonly<T>.
  • DeepPartial<T>: Deep version of Partial<T>.
  • Serializable: Represents a type that can be serialized to a JSON-compatible format.

Development

  • benchmark: Wrap around a function to benchmark it's performance without affecting app behavior.

Credits

License

MIT