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

@razomy/string

v0.0.1-alpha.5

Published

[![License](https://img.shields.io/npm/l/@razomy/string)](https://github.com/razomy/js/blob/main/LICENSE) [![CI Status](https://github.com/razomy/js/actions/workflows/release.yml/badge.svg)](https://github.com/razomy/js/actions) [![minzipped size](https:/

Downloads

55

Readme

@razomy/string

License CI Status minzipped size TypeScript Node.js Version npm version npm downloads GitHub stars

Npm | Npmx | GitHub | Io

🚀 Start

Install

npm i @razomy/string

Import

import * as string from "@razomy/string";
// or
import { addByIndexString } from "@razomy/string";

📑 Table of Contents

Functions

📚 Documentation

Functions

addByIndexString

addByIndexString(text: string, index: number, insertion: string): string

Insert a string into another string at a specific index.

Examples

addByIndexString('-text', 0, 'prefix'); // prefix-text
addByIndexString('hello ', 6, 'world'); // hello world
addByIndexString('foo baz', 4, 'bar '); // foo bar baz

contains

contains(text: string, search: string): boolean

Checks if a string contains a specific substring.

Examples

contains('razomy', 'zo'); // true
contains('razomy', 'bar'); // false
contains('hello world', 'hello'); // true

countOccurrences

countOccurrences(text: string, substring: string): number

Counts the number of occurrences of a substring within a text.

Examples

countOccurrences('hello world', 'l'); // 3
countOccurrences('aaaa', 'aa'); // 2
countOccurrences('apple', 'z'); // 0

countSpaceMargin

countSpaceMargin(string: string): number

Count leading space margin of a string.

Counts the number of leading space characters before the first non-space character in a string.

Examples

countSpaceMargin('hello'); // 0
countSpaceMargin('   hello'); // 3
countSpaceMargin('     '); // 5

countSpaceMarginByArray

countSpaceMarginByArray(): number[]

Examples

countString

countString(strings: string[], equalString: string, offset: number, maxOffset: number): number

Count occurrences of a string within a subarray of strings.

Counts how many times equalString appears in the strings array between index offset (inclusive) and maxOffset (exclusive).

Examples

countString(['a', 'b', 'a', 'c'], 'a', 0, 4); // 2
countString(['hello', 'world', 'hello'], 'hello', 1, 3); // 1
countString(['x', 'y', 'z'], 'w', 0, 3); // 0

create

create(value: unknown): string

Convert any value to a string.

Examples

string(100); // 100
string(true); // true
string(null); // null

escapeByString

escapeByString(): string

Examples

getWords

getWords(value: string): string[]

Splits string into an array of its words.

Examples

getWords('fred, barney, & pebbles'); // [fred, barney, pebbles]
getWords('camelCase'); // [camel, Case]
getWords('nested_snake_case'); // [nested, snake, case]

indentLines

indentLines(): string

Examples

isEndsWith

isEndsWith(text: string, target: string, position: number | undefined): boolean

Checks if string ends with the given target string.

Examples

isEndsWith('abc', 'c'); // true
isEndsWith('abc', 'b'); // false
isEndsWith('abc', 'b', 2); // true

isEndsWithAny

isEndsWithAny(text: string, targets: string[], position: number | undefined): boolean

Checks if string ends with any of the given target strings.

Examples

isEndsWithAny('image.jpg', ['.jpg', '.png']); // true
isEndsWithAny('image.gif', ['.jpg', '.png']); // false
isEndsWithAny('abc', ['a', 'b'], 2); // true

isNullOrEmpty

isNullOrEmpty(str: string | null | undefined): boolean

Check if the string is null, undefined, or empty (including whitespace).

Examples

isNullOrEmpty(null); // true
isNullOrEmpty('   '); // true
isNullOrEmpty('razomy'); // false

isStartsWith

isStartsWith(string: string, target: string, position: number): boolean

Checks if string starts with the given target string.

Examples

isStartsWith('razomy', 'r'); // true
isStartsWith('razomy', 'z'); // false
isStartsWith('razomy', 'z', 2); // true

isString

isString(value: unknown): boolean

Check if the value is a string.

Examples

isString('razomy'); // true
isString(123); // false
isString(null); // false

join

join(items: string[], separator: string): string

Joins an array of strings into a single string using a separator.

Examples

join(['a', 'b', 'c'], '-'); // a-b-c
join(['hello', 'world'], ' '); // hello world
join(['one'], ','); // one

levenshteinDistance

levenshteinDistance(a: string, b: string): number

Calculates the Levenshtein distance between two strings using the iterative approach with memory optimization.

Examples

levenshteinDistance('kitten', 'sitting'); // 3
levenshteinDistance('test', 'text'); // 1
levenshteinDistance('razomy', 'razomy'); // 0

merge

merge(): string

Examples

padEnd

padEnd(input: string, length: number, chars: string): string

Pads the end of a string with a given string (repeated, if needed) so that the resulting string reaches a given length.

Examples

padEnd('abc', 6); // abc
padEnd('abc', 6, '0'); // abc000
padEnd('abc', 2); // abc

padStart

padStart(input: string, length: number, chars: string): string

Pads the start of a string with another string until it reaches the given length.

Examples

padStart('a', 3); // a
padStart('a', 3, '0'); // 00a
padStart('abc', 2); // abc

prefixLines

prefixLines(text: string, prefix: string): string

Add margin to every line of the string.

Examples

prefixLines('Hello', '  '); // Hello
prefixLines('Line 1\nLine 2', '> '); // > Line 1\n> Line 2
prefixLines('Code', '\t'); // \tCode

removeIndex

removeIndex(string: string, index: number, length: number): string

Remove characters from a string at a given index.

Removes a specified number of characters from a string starting at the given index, returning the resulting string.

Examples

removeIndex('hello', 1, 1); // hllo
removeIndex('abcdef', 2, 3); // abf
removeIndex('world', 0, 2); // rld

repeat

repeat(content: string, count: number): string

Repeats a string a specified number of times.

Examples

repeat('a', 3); // aaa
repeat('razomy', 2); // razomyrazomy
repeat('test', 0); // 

replace

replace(): string

Examples

similarity

similarity(): number

Examples

split

split(text: string, splitter: string | RegExp, limit: number | undefined): string[]

Split string by splitter characters.

Examples

split('Line 1\nLine 2', '\n'); // [Line 1, Line 2]
split('A\nB\nC', /[\n]/); // [A, B, C]
split('One', ''); // [O,n,e]

splitLines

splitLines(text: string): string[]

Split string by newline characters.

Examples

splitLines('Line 1\nLine 2'); // [Line 1, Line 2]
splitLines('A\r\nB\nC'); // [A, B, C]
splitLines('One'); // [One]

stripTags

stripTags(content: string): string

Strip HTML tags from a string.

Examples

stripTags('<p>Hello world</p>'); // Hello world
stripTags('<a href="https://example.com">Link</a>'); // Link
stripTags('<div><span>content</span></div>'); // content

takeAfter

takeAfter(text: string, separator: string): string

Get the substring after the first occurrence of a separator.

Examples

takeAfter('foo.bar', '.'); // bar
takeAfter('foo.bar.baz', '.bar.'); // baz
takeAfter('foo', ','); // foo

takeBefore

takeBefore(text: string, separator: string): string

Gets the substring before the first occurrence of a separator.

Examples

takeBefore('@razomy/string', '.'); // razomy
takeBefore('[email protected]', '@'); // user
takeBefore('atomic', ' '); // atomic

takeBetween

takeBetween(text: string, start: string, end: string): string

Extracts a substring found between a start string and an end string.

Examples

takeBetween('The quick brown fox', 'quick ', ' fox'); // brown
takeBetween('key="value";', '"', '"'); // value
takeBetween('<div>content</div>', '<div>', '</div>'); // content

toBuffer

toBuffer(value: string, encoding: BufferEncoding): Buffer<ArrayBufferLike>

Convert string to buffer using specified encoding.

Examples

toBuffer('abc', 'utf8'); // <Buffer 61 62 63>
toBuffer('YWJj', 'base64'); // <Buffer 61 62 63>
toBuffer('616263', 'hex'); // <Buffer 61 62 63>

trim

trim(text: string): string

Removes whitespace from both ends of the string.

Examples

trim('  foo  '); // foo
trim('\nbar\t'); // bar
trim('   '); // 

truncate

truncate(text: string, length: number, omission: string): string

Truncates string if it's longer than the given maximum string length.

Examples

truncate('hello world', 5); // he...
truncate('hello', 10); // hello
truncate('hello world', 7, '...'); // hello...

unescapeByString

unescapeByString(): string

Examples

🕊️ Vision

"Razomy" means Together—you and me.
We act as catalysts, turning natural chaos into clarity through open collaboration.
By building honest, reliable systems, we empower humanity and create a foundation for peace.
We foster a borderless environment driven by quality code and mutual support.
Join us to build this future—one commit at a time.

💖 Fuel Our Shared Future

We can't build this without you. If this library has saved you time or helped turn chaos into clarity in your own projects, please consider backing the developers behind it. Building reliable, open-source tools takes immense time and energy. Your sponsorship isn't just a donation; it’s the fuel that keeps this project actively maintained, bug-free, and thriving for everyone who relies on it.

Help us keep the momentum going. Choose how you want to light the way:

🤝 Contributing

Contributions, issues and feature requests are welcome! Feel free to check issues page.

📝 License

Copyright © 2026 Razomy. This project is MIT licensed.

🐛 Reporting Issues

We use GitHub Issues as the official bug tracker for this project.

Before opening a new issue, please check if your problem has already been reported. If it hasn't, please open a new issue here: GitHub Issues: razomy/js

When reporting a bug, please include:

  • A brief description of the issue.
  • Steps to reproduce the bug.
  • Your current environment (Node version, OS, etc.).