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

coreutilsts

v2.0.1

Published

Library with some utility functions

Readme

CoreUtilsTS

CoreUtilsTS is a TypeScript utility library offering a comprehensive suite of helper functions to simplify common development tasks. Built with clarity and reusability in mind, it works seamlessly in both browser and non-browser environments.

Note: Verify functionality for your specific use case before deploying in production.

Some functions act as wrappers around standard TypeScript operations to improve code readability and consistency.

Whether you need to perform object validations, string case transformations, encoding/decoding, hashing, or line-based manipulations, CoreUtilsTS is designed to streamline your workflow.


Table of Contents


Key Features

  • Object Utilities

    • isNull(), isUndefined(), isNullOrUndefined()
    • getDefaultOnNull() for fallback values
    • isEmptyArray() checks for empty or missing arrays
  • Case Utilities

    • Determine string case: determineCase()
    • Transform between cases: toLowerCase(), toUpperCase(), toSentenceCase(), toTitleCase(), toCamelCase(), toPascalCase(), toSnakeCase(), toKebabCase(), and more
    • Swap, capitalize, and uncapitalize functions
  • Encoding & Cryptography

    • Base64 encoding/decoding: encodeBase64(), decodeBase64()
    • URL-safe Base64: encodeBase64Url()
    • Hashing algorithms: encodeSHA1(), encodeSHA256(), encodeSHA384(), encodeSHA512(), encodeMD5()
  • Line Utilities

    • Split strings into lines and remove empty entries: splitLines(), splitStringIntoLines()
    • Sort (sortLines()), shuffle (shuffleLines()), and deduplicate (removeDuplicates()) arrays of lines
  • String Utilities

    • Type and content checks: isString(), isEmptyString(), isBlankString(), isNullOrBlankString(), isAlphanumeric(), isNotAlphanumeric()
    • Search: startsWith(), endsWith(), contains()
    • Join and split: joinStrings(), splitString()
    • Conditional modifications: addSuffixIfMissing(), addPrefixIfMissing(), removePrefixIfPresent(), removeSuffixIfPresent()
    • Replacements and safe extraction: replaceSubstring(), safeExtractText()
    • URL utilities: slugifyString(), encodeUrl(), decodeUrl()
  • Logging

    • Configurable logger via setLogger()
    • Built-in ConsoleLogger and SilentLogger

Installation

Install CoreUtilsTS via npm or yarn:

npm install coreutilsts

or

yarn add coreutilsts

Usage

Import only the modules you need to keep your bundle lean.

Object Utilities

import { ObjectUtils } from 'coreutilsts';

const value = null;
const safe = ObjectUtils.getDefaultOnNull(value, 'fallback');

Case Utilities

import { CaseUtils } from 'coreutilsts';

const text = 'example_string';
const title = CaseUtils.toTitleCase(text);

Encoding & Cryptography

import { EncodingUtils, HashingUtils } from 'coreutilsts';

const b64 = EncodingUtils.encodeBase64('hello');
HashingUtils.encodeSHA256('password').then((hash) => console.log(hash));

Line Utilities

import { LineUtils } from 'coreutilsts';

const lines = LineUtils.splitLines('first\n\nsecond');
const unique = LineUtils.removeDuplicates(lines);

String Utilities

import { StringUtils } from 'coreutilsts';

const slug = StringUtils.slugifyString('My Blog Post Title');
const url = StringUtils.encodeUrl('https://example.com/?q=a b');

API Reference

Object & Type Guards

  • isNull(value: unknown): value is null
  • isUndefined(value: unknown): value is undefined
  • isNullOrUndefined(value: unknown): value is null | undefined
  • getDefaultOnNull(value: unknown, defaultValue: unknown): unknown
  • isEmptyArray(value: undefined | null | unknown[]): boolean

Case Utilities API

  • determineCase(input: string, props?: DetermineStringCaseProps): StringCaseTypes
  • toLowerCase(input: string): string, toUpperCase(input: string): string
  • toLowerCaseStrict(input: string): string, toUpperCaseStrict(input: string): string
  • toSentenceCase(input: string): string, toTitleCase(input: string): string
  • toCamelCase(input: string): string, toPascalCase(input: string): string
  • toSnakeCase(input: string): string, toKebabCase(input: string): string
  • Other cases: toScreamingSnakeCase(), toCobolCase(), toTrainCase(), toDotCase(), toSlashCase()
  • swapCase(input: string): string, capitalize(input: string): string, uncapitalize(input: string): string

Encoding & Cryptography API

  • encodeBase64(input: string): string
  • encodeBase64Url(input: string): string
  • decodeBase64(input: string): string
  • encodeSHA1(input: string): Promise<string>
  • encodeSHA256(input: string): Promise<string>
  • encodeSHA384(input: string): Promise<string>
  • encodeSHA512(input: string): Promise<string>
  • encodeMD5(input: string): Promise<string>

Line Utilities API

  • splitStringIntoLines(data: string, splitter: string | RegExp): string[]
  • splitLines(data: string | null | undefined): string[]
  • sortLines(arr: string[], sortType?: SortingTypes): string[]
  • shuffleLines(arr: string[]): string[]
  • removeDuplicates(strings: string[], ignoreCase?: boolean): string[]

String Utilities API

  • Type Checks: isString(), isEmptyString(), isBlankString(), isNullOrBlankString(), isAlphanumeric(), isNotAlphanumeric()
  • Search: startsWith(inputString: string, value: string), endsWith(), contains()
  • Split & Join: splitString(value: string, separator?: LineSeparator), joinStrings(strings: string[], joinSymbol?: LineSeparator)
  • Conditional Mods: addSuffixIfMissing(), addPrefixIfMissing(), removePrefixIfPresent(), removeSuffixIfPresent()
  • Transform & Replace: replaceSubstring(), safeExtractText()
  • URL Utilities: slugifyString(value: string, separator?: string, lower?: boolean, locale?: string), encodeUrl(value: string), decodeUrl(value: string)

Enumerations & Constants

  • Enums: EncoderAlg, Encodings, LineSeparators, SortingTypes
  • Constants: EMPTY, SPACE

Logging

  • setLogger(logger: LibLogger): void
  • Built-in: ConsoleLogger, SilentLogger

Testing

Run the comprehensive test suite:

npm run test

Local Build

Build and verify locally:

npm install
npm run verify

Dependencies

This library depends on:

  • crc
  • js-base64
  • js-md5
  • slugify

License

This project is licensed under the MIT License.


Enjoy using CoreUtilsTS to streamline your development process with powerful, focused utilities!