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

cme-utils

v5.5.3

Published

A collection of utility functions for TypeScript/JavaScript

Readme

cme-utils

neostandard javascript style

A comprehensive collection of utility functions for TypeScript and JavaScript projects. Includes typed guards, conversion utilities, validation functions, and more to streamline development.

Features

  • Type Safety: Fully typed with TypeScript for better development experience.
  • Zero Dependencies: No runtime dependencies, keeping your bundle size minimal.
  • Modular Exports: Organized by categories for easy importing.
  • ES Modules & CommonJS: Supports both ESM and CJS builds.
  • Custom ESLint Plugins: Includes plugins for code quality (e.g., max return statements per function).

Installation

npm i cme-utils
pnpm i cme-utils
bun i cme-utils

Usage

Import specific utilities as needed:

import { UUID_V7 } from 'cme-utils'
const id = UUID_V7()

Quick Examples

Array Operations

import { ARRAY_MAX, ARRAY_MEDIAN, ARRAY_SUM } from 'cme-utils'

const numbers = [1, 5, 3, 9, 2]
ARRAY_MAX(numbers)    // 9
ARRAY_MEDIAN(numbers) // 3
ARRAY_SUM(numbers)    // 20

Type Conversion

import { TO_NUMBER } from 'cme-utils'

TO_NUMBER('123')      // 123
TO_NUMBER('123abc')   // NaN (invalid)
TO_NUMBER(true)       // 1
TO_NUMBER(new Date()) // timestamp

UUID Generation

import { UUID_V4, UUID_V7, UUID_V7_TO_TIMESTAMP_MS } from 'cme-utils'

const id = UUID_V7()
const timestamp = UUID_V7_TO_TIMESTAMP_MS(id) // Extract embedded timestamp

Object Sorting

import { SORT_OBJECTS } from 'cme-utils'

const users = [{name: 'Alice', age: 25}, {name: 'Bob', age: 30}]
users.sort(SORT_OBJECTS({ on: u => u.age }))                    // Sort by age asc
users.sort(SORT_OBJECTS({ on: u => u.name, order: 'desc' }))   // Sort by name desc

Value Normalization

import { NORMALIZE_N_1 } from 'cme-utils'

// Pagination bounds checking
NORMALIZE_N_1({ n: 5, min: 1, max: 10 })    // '5' (valid)
NORMALIZE_N_1({ n: 15, min: 1, max: 10 })   // '10' (clamped)
NORMALIZE_N_1({ n: 'invalid', def: 1 })     // '1' (default)

CSV Export

import { TO_CSV_VALUE } from 'cme-utils'

TO_CSV_VALUE(42)              // '42'
TO_CSV_VALUE('Hello, World')  // '"Hello, World"' (quoted)
TO_CSV_VALUE(null)            // '' (empty)

API Overview

The library is organized into the following categories:

  • aes: AES encryption utilities (e.g., CIPHER_AES_GCM_TO_BUFFER, DECIPHER_AES_GCM_TO_UTF8)
  • array: Array operations (e.g., ARRAY_SUM, ARRAY_AVERAGE, ARRAY_MIN_MAX)
  • async: Asynchronous utilities (e.g., ALL_SETTLED, THROW_IF_ERROR)
  • bigint: BigInt division operations (e.g., BIGINT_DIV, BIGINT_DIV_CEIL, BIGINT_DIV_FLOOR, BIGINT_DIV_ROUND, BIGINT_DIV_TRUNC)
  • chart: Charting helpers (e.g., time series functions)
  • check: Type guards and validators (e.g., IS_A_STRING, IS_NUMERIC, IS_BOOL)
  • compare: Comparison functions (e.g., SAME_DATE, SAME_DATETIME)
  • constant: Constants (e.g., MAX_SAFE_INTEGER, SYMBOLS)
  • convert: Conversion utilities (e.g., TO_NUMBER, STRING_TO_UUID, BASE64_TO_HEX)
  • factory: Object factories (e.g., GET_ANY_ARRAY)
  • file: File operations (e.g., DOWNLOAD_FILE, GET_FILE_FULL_TEXT_CONTENT)
  • filter: Filtering helpers (e.g., GET_FILTER_BY_FROM_FILTER_LIST)
  • form: Form validators (e.g., IS_NUMERIC_POSITIVE_INTEGER_VALIDATOR)
  • functional: Functional programming (e.g., IDENTITY, NOOP)
  • http: HTTP status codes and utilities (e.g., HTTP_OK, HTTP_BAD_REQUEST)
  • microsoft: Microsoft-specific utilities (e.g., MSAL endpoints)
  • number: Number formatting (e.g., TO_LOCAL_NUMBER)
  • object: Object utilities (e.g., GET_OBJECT_KEY_LIST, TRIM_OBJECT)
  • password: Password handling (e.g., ENCRYPT_PASSWORD, COMPARE_PASSWORD)
  • query: Query builders (e.g., WHERE, OR_WHERE_IN)
  • regex: Regular expressions (e.g., REGEX_EMAIL, REGEX_UUID_MATCH_A_SUBSTRING)
  • sort: Sorting functions (e.g., SORT_BY_LABEL, SORT_OBJECTS)
  • space: Localization (e.g., SET_LOCALE, GET_LANG)
  • string: String manipulations (e.g., STRING_UCF, EXTRACT_UUID_FROM_STRING)
  • time: Date/time utilities (e.g., NOW, FROM_ISO_TO_LOCAL_DT)
  • uuid: UUID operations (e.g., UUID_V4, UUID_V7)
  • ws: WebSocket helpers (e.g., WS_AXIOS_SP_REQUEST)

For full API details, see the source code or generated type definitions.

Development

Building

bun run build        # Transpile ts/ → esm/ (tsc)

Linting

bun run lint         # Check code style (ESLint + neostandard)
bun run lint:fix     # Auto-fix linting issues

Testing

bun test             # Run all tests
bun test:coverage    # Run tests with coverage
bun test:watch       # Run tests in watch mode

Contributing

Contributions are welcome! Please ensure code follows the neostandard style and includes appropriate TypeScript types.

License

MIT - see LICENSE for details.