New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

caffeinated-strings

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

caffeinated-strings

A coffee-themed JavaScript string utilty library made with TypeScript

latest
Source
npmnpm
Version
1.3.0
Version published
Maintainers
0
Created
Source

☕ 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
  • Functions
  • Usage

📦 Installation

To install caffeinated-strings, run the following command:

   npm install caffeinated-strings

📚 Functions

Traditional NameCoffee NameDescription
.charAt()sipAtReturns the character of a string at given index (like taking a single sip of coffee).
.concat()addMilkConcatenates a string to another separated with delimiter (like pouring milk into a cup of coffee).
.includes()hasMilkReturns true if given string is found within this string and false if not (like checking if coffee has milk or not).
.lengthbrewLengthReturns the length of a string (how "long" the brew is).
=pourCoffeeCopies one string to another (like pouring coffee into a new cup).
===, >, <compareBeansCompares two strings (like comparing coffee beans for quality).
.indexOf()findFirstSipFinds the first occurrence of a character in a string (like the first sip of coffee).
.indexOf()findFlavorFinds the first occurrence of a substring inside a string (like detecting flavors in coffee).
.repeat()refillCupConstructs 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()coolDownTransforms the string to lowercase (like cooling down a cup of coffee).
.toUpperCase()frothTransforms the string to uppercase (like frothing the milk to create a creamy top).
.trim()sipRemoves 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:

  • 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
  • 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
  • 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
  • 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
  • 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"
  • 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')
  • 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"
  • 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"
  • 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 "
  • 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"
  • 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"
  • 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!!"

FAQs

Package last updated on 09 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts