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

@bemoje/string

v3.0.0

Published

String manipulation utilities for casing, wrapping, line processing, and character analysis.

Readme

@mono/string

String manipulation utilities for casing, wrapping, line processing, and character analysis.

TypeScript Module

Exports

  • countFloatDecimals: Counts the number of decimal places in a floating-point number.
  • endsWithIncompleteUtfPairSurrogate: Returns true if the string ends with an incomplete UTF-16 surrogate pair. This is useful for determining if a string can be safely concatenated with another string.
  • strCountCharOccurances: Counts the number of occurrences of a specific character in a string.
  • strCountChars: Counts the number of occurrences of each character in a string and returns a Map where the keys are the characters and the values are their counts.
  • strEnsureEndsWith: Ensures that a string ends with a specified substring. If the string already ends with the specified substring, it is returned as is. Otherwise, the substring is appended to the end of the string.
  • strEnsureStartsWith: Ensures that a string starts with a specified substring. If the string already starts with the specified substring, it is returned as is. Otherwise, the substring is appended to the end of the string.
  • strIsLowerCase: Checks if the given string is in lower case.
  • strIsMultiLine: Checks if a string contains multiple lines.
  • strIsUpperCase: Checks if the given string is in upper case.
  • strMaxTwoConsecutiveEmptyLines: Replaces all occurrences of more than two consecutive empty lines with two empty lines.
  • strNoConsecutiveEmptyLines: Removes consecutive empty lines from a given string.
  • strNoConsecutiveWhitespace: Removes consecutive whitespace characters in a string and replaces them with a single space.
  • strParseBoolean: Parses a string into a boolean.
  • strPrefixCamelCased: Prepend a camelCased string. Examples:
  • strPrependLines: Prepend each line of a string with a specified string.
  • strRemoveDuplicateChars: Removes duplicate characters from a string.
  • strRemoveEmptyLines: Removes all empty lines from a given string.
  • strRemoveFirstAndLastLine: Removes the first and last line from a given string.
  • strRemoveNewLines: Removes all new line characters from a string.
  • strRepeat: Repeats the given string n times.
  • strReplaceAll: Replaces all occurrences of a substring in a string with a specified replacement.
  • strSortChars: Sorts the characters in a string in alphabetical order.
  • strSplitAndTrim: Splits a string by a specified delimiter and trims each resulting substring. Optionally, it can also remove empty lines.
  • strSplitCamelCase: Returns an array of words in the string
  • strToCharCodes: Converts a string to an array of character codes.
  • strToCharSet: Converts a string to a set of unique characters.
  • strToGetterMethodName: Prepend a camelCased string with 'get'.
  • strToSetterMethodName: Prepend a camelCased string with 'set'.
  • strToSortedCharSet: Converts a string to a sorted set of unique characters.
  • strTrimLines: Trims leading and trailing whitespace from each line in a string.
  • strTrimLinesLeft: Trims the leading whitespace from each line in a string.
  • strTrimLinesRight: Trims trailing whitespace from each line in a string.
  • strUnwrap: Removes the specified left and right substrings from the input string.
  • strWrapBetween: Wraps a string between two other strings.
  • strWrapIn: Wraps a given string with another string.
  • strWrapInAngleBrackets: Wraps a string in angle brackets.
  • strWrapInBraces: Wraps a given string in braces.
  • strWrapInBrackets: Wraps a string in brackets.
  • strWrapInDoubleQuotes: Wraps a given string in double quotes.
  • strWrapInParenthesis: Wraps a given string in parenthesis.
  • strWrapInSingleQuotes: Wraps a given string in single quotes.
  • stringLineCount: Count the number of lines in a string.
  • unwrapDoubleQuotes: Remove double quote from the beginning and end of a string and trims whitespace at the beginning and end of the string

Usage

Case & Casing

import { strFirstCharToUpperCase, strFirstCharToLowerCase, titleCaseWord, strSplitCamelCase } from '@mono/string'

strFirstCharToUpperCase('hello')
// => 'Hello'

strFirstCharToLowerCase('Hello')
// => 'hello'

titleCaseWord('hello')
// => 'Hello'

strSplitCamelCase('someCamel10Case')
// => ['some', 'Camel10', 'Case']

Wrapping & Unwrapping

import { strWrapBetween, strWrapIn, strWrapInBraces, strUnwrap, unwrapDoubleQuotes } from '@mono/string'

strWrapBetween('Hello', '<', '>')
// => '<Hello>'

strWrapIn('hello', '*')
// => '*hello*'

strWrapInBraces('key')
// => '{key}'

strUnwrap('[value]', '[', ']')
// => 'value'

unwrapDoubleQuotes('"hello"')
// => 'hello'

Ensure Prefix & Suffix

import { strEnsureStartsWith, strEnsureEndsWith, strPrefixCamelCased } from '@mono/string'

strEnsureEndsWith('52', ' kg')
// => '52 kg'

strEnsureStartsWith('/path', '/')
// => '/path'

strPrefixCamelCased('name', 'get')
// => 'getName'

Line Processing

import {
  stringLineCount,
  strPrependLines,
  strTrimLines,
  strRemoveEmptyLines,
  strNoConsecutiveEmptyLines,
} from '@mono/string'

stringLineCount('a\nb\nc')
// => 3

strPrependLines('line1\nline2', '> ')
// => '> line1\n> line2'

strTrimLines('  hello  \n  world  ')
// => 'hello\nworld'

strRemoveEmptyLines('a\n\nb\n\nc')
// => 'a\nb\nc'

strNoConsecutiveEmptyLines('a\n\n\n\nb')
// => 'a\n\nb'

Character Analysis

import { strCountChars, strCountCharOccurances, strToCharSet, strToCharCodes } from '@mono/string'

strCountChars('hello')
// => Map { 'h' => 1, 'e' => 1, 'l' => 2, 'o' => 1 }

strCountCharOccurances('banana', 'a')
// => 3

strToCharSet('hello')
// => Set { 'h', 'e', 'l', 'o' }

strToCharCodes('abc')
// => [97, 98, 99]

Search & Replace

import { strReplaceAll, strSplitAndTrim } from '@mono/string'

strReplaceAll('a-b-c', '-', '.')
// => 'a.b.c'

strSplitAndTrim('a , b , c', ',')
// => ['a', 'b', 'c']

Inspection

import { strIsLowerCase, strIsUpperCase, strIsMultiLine, strParseBoolean } from '@mono/string'

strIsLowerCase('hello')
// => true

strIsUpperCase('HELLO')
// => true

strIsMultiLine('a\nb')
// => true

strParseBoolean('true')
// => true