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

caffeinated-strings

v1.3.0

Published

A coffee-themed JavaScript string utilty library made with TypeScript

Readme

☕ Coffee-Themed String Library

Welcome to caffeinated-strings, a JavaScript library with a coffee-inspired twist. This library is built with TypeScript and provides a collection of custom-built functions for string manipulation, all named after coffee-related terms. It's perfect for developers who love both coffee and clean code!

📖 Table of Contents

📦 Installation

To install caffeinated-strings, run the following command:

   npm install caffeinated-strings

📚 Functions

| Traditional Name | Coffee Name | Description | | ---------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | | .charAt() | sipAt | Returns the character of a string at given index (like taking a single sip of coffee). | | .concat() | addMilk | Concatenates a string to another separated with delimiter (like pouring milk into a cup of coffee). | | .includes() | hasMilk | Returns true if given string is found within this string and false if not (like checking if coffee has milk or not). | | .length | brewLength | Returns the length of a string (how "long" the brew is). | | = | pourCoffee | Copies one string to another (like pouring coffee into a new cup). | | ===, >, < | compareBeans | Compares two strings (like comparing coffee beans for quality). | | .indexOf() | findFirstSip | Finds the first occurrence of a character in a string (like the first sip of coffee). | | .indexOf() | findFlavor | Finds the first occurrence of a substring inside a string (like detecting flavors in coffee). | | .repeat() | refillCup | Constructs a new string which contains a specified number of copies of the input string (like refilling a coffee cup a specific amount of times). | | .toLowerCase() | coolDown | Transforms the string to lowercase (like cooling down a cup of coffee). | | .toUpperCase() | froth | Transforms the string to uppercase (like frothing the milk to create a creamy top). | | .trim() | sip | Removes whitespace from both ends of string (like sipping away the excess on top). |

🔧 Usage

Once installed, you can import and use the functions in your JavaScript or TypeScript projects:

  1. sipAt(str, index) Finds the character in a string at given index (like taking a single sip of coffee). Returns the character as string:
let brew = "coffee";
console.log(sipAt(brew, 2)); // f
  1. addMilk(str1, str2, delimiter) Concatenates a string to another separated with delimiter (like pouring milk into a cup of coffee). Returns a string:
let brew = "coffee";
let milk = "tastes very good with milk";
let delimiter = ", ";
console.log(addMilk(brew, milk, delimiter)); // coffee, tastes very good with milk
  1. hasMilk(str, word) Checks if word is found within string (like checking if coffee has milk or not). Returns true if word is in string, false if not:
let sentence = "coffee tastes good with milk";
let word = "good";
console.log(hasMilk(sentence, word)); // true
  1. brewLength(str) Calculates the length of the input string (how "long" the brew is). Returns the length as number:
let brew = "coffee";
console.log(brewLength(brew)); // 6
  1. pourCoffee(str) Copies one string to another (like pouring coffee into a new cup). Returns the copy as string:
let original = "latte";
let cup = pourCoffee(original);
console.log(cup); // "latte"
  1. compareBeans(str1, str2) Compares two strings (like comparing coffee beans for quality). Returns a number:
  • 0 if the strings are identical.
  • 1 if str1 is lexicographically greater.
  • -1 if str1 is lexicographically less.
let result = compareBeans("espresso", "latte");
console.log(result); // 1 ('e' > 'l')
  1. findFirstSip(str, char) Finds the first occurrence of a character in a string (like the first sip of coffee). Returns the substring from the first occurrence of the character as string:
let coffee = "macchiato";
console.log(findFirstSip(coffee, "c")); // "cchiato"
  1. findFlavor(str, substr) Finds a substring inside a string (like detecting flavors in coffee). Returns the substring starting from the first match as string:
let drink = "cappuccino";
console.log(findFlavor(drink, "cc")); // "ccuccino"
  1. refillCup(str, count) Constructs a new string with copies of input string the amount of times specified. Returns the new string concatenated together:
let coffee = "cappuccino ";
console.log(refillCup(drink, 3)); // "cappuccino cappuccino cappuccino "
  1. coolDown(str) Transforms the string to lowercase (like cooling down a cup of coffee). Returns the input in lowercase as string:
let drink = "ESPRESSO";
console.log(coolDown(drink)); // "espresso"
  1. froth(str) Transforms the string to uppercase (like frothing the milk to create a creamy top). Returns the input in uppercase as string:
let drink = "espresso";
console.log(froth(drink)); // "ESPRESSO"
  1. sip(str) Removes whitespace from both ends of the string (like sipping away the excess on top). Returns a new string without modifying the original:
let drink = "   espresso is lovely!!     ";
console.log(sip(drink)); // "espresso is lovely!!"