UNPKG

stringzy

Version:

A versatile string manipulation library providing a range of text utilities for JavaScript and Node.js applications.

17 lines (16 loc) 504 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.characterFrequency = characterFrequency; function characterFrequency(str) { if (typeof str !== "string") { throw new TypeError("Input must be a string"); } const frequency = {}; for (const char of str.toLowerCase()) { if (char !== " ") { // Exclude spaces for cleaner analysis frequency[char] = (frequency[char] || 0) + 1; } } return frequency; }