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

kt-common

v1.0.1

Published

Common Utilities

Downloads

6

Readme

kt-common

A compact TypeScript/JavaScript utility library providing a collection of useful helpers for Node.js and Bun environments. It includes helpers for formatting, paths, JSON manipulation, math, async locking, file downloading, and more.

📦 Installation

npm install kt-common async-lock axios

or

yarn add kt-common async-lock axios

🚀 Usage

import * as kt from "kt-common";
// or import specific utilities
import { clip, dashDateFormatter, downloadFile } from "kt-common";

🧩 API Reference

numberToI32Hex(10); // "0000000a"  
numberToI32Hex(0xFFFFFFFF); // "ffffffff"  

dashDateFormatter(new Date(), { getDate: true, getTime: true, dateFormat: "yyyy-mm-dd" }); // "2025-11-04 09:05:03"  

const data = loadJson("./config.json");  

type BasicTypes = boolean | number | string | null | undefined;  
type RecursiveReadable = BasicTypes | { [key: string]: RecursiveReadable } | RecursiveReadable[];  
type JSONObject = { [key: string]: RecursiveReadable };  
type Merge<T, U> = T & Omit<U, keyof T>;  
type OmitFunctions<T> = Pick<T, { [K in keyof T]: T[K] extends Function ? never : K }[keyof T]>;  
type NestedType<EndType> = EndType | NestedType<EndType>[];  
type SearchBase = { search?: string; skip?: number; take?: number };  
type RemoveNull<T> = T extends null ? never : T;  

surfaceNestedType([1, [2, [3, 4], 5], 6]); // [1, 2, 3, 4, 5, 6]  

compareShallowRecord({ a: 1, b: 2 }, { a: 1, b: 2 }); // true  
compareShallowRecord({ b: 2, a: 1 }, { a: 1, b: 2 }); // false  

isBun(); // true if running in Bun  

resolveTs("src/main.ts"); // "src/main.js"  

const critical = async (x: number) => x * 2;  
const locked = lockMethod(critical, { lockName: "my-lock" });  
await Promise.all([locked(1), locked(2)]); // Executes sequentially  

resolvePath("./file.txt", "file:///home/user/"); // "/home/user/file.txt"  

await downloadFile({ method: "GET", url: "<https://example.com/image.png>", outputPath: "/tmp/image.png" });  

clip("hello world", 8); // "hello..."  

recursiveSelect("a.b.c", { a: { b: { c: 5 } } }); // 5  

padId(42); // "#0000000042"  

math.fixed(1.2345, 2); // 1.23  
math.min([1, 3, NaN, 2]); // 1  
math.max([1, 3, 2, NaN]); // 3  

cap("hello world from kt-common"); // "Hello World From Kt-Common"  

notEmptyValues({ a: 1, b: null, c: 0 }); // [1, 0]  

isNumber(3); // true  
isNumber("4.5"); // true  
isNumber("abc"); // false  

readVolatileJSON("./config.json", { createIfNotExists: true, defaultValue: { foo: "bar" } });  

await sleep(500);  
console.log("0.5s later");  

selectRandom([1, 2, 3, 4]); // e.g., 3  

trimSlashes("/foo/bar/"); // "foo/bar"  
trimSlashes("/"); // "/"  

import {
  dashDateFormatter,
  numberToI32Hex,
  downloadFile,
  clip,
  padId,
  math,
  sleep,
  selectRandom,
  surfaceNestedType
} from "kt-common";

async function demo() {
  console.log("hex:", numberToI32Hex(255)); // "000000ff"
  console.log(dashDateFormatter(new Date(), { getDate: true, getTime: true, dateFormat: "yyyy-mm-dd" }));
  console.log("clip:", clip("this is a long text", 10)); // "this i..."
  console.log("padId:", padId(42)); // "#0000000042"
  console.log("math.max:", math.max([1, 5, 3])); // 5
  console.log("flattened:", surfaceNestedType([1, [2, [3]], 4])); // [1,2,3,4]
}