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

@azizbecha/strkit

v1.1.1

Published

strkit is a utility library offering a collection of essential string functions including validation, case conversion, truncation, and more. Ideal for both JavaScript and TypeScript developers to simplify string operations in their applications.

Readme

strkit is a utility library that provides a collection of commonly used string functions in JavaScript/TypeScript. Whether you need to validate emails, convert case styles, trim spaces, or manipulate strings in other ways, strkit has got you covered. The goal of this library is to make string handling easier and more efficient across all your projects.


Features

  • String Validation: Functions like isEmail and isURL to validate strings.
  • String Manipulation: Functions for trimming, reversing, truncating, and more.
  • Case Conversion: Convert strings between different case styles.
  • Easy to Use: Just import the required function and get started.

Installation

You can install strkit as an NPM package:

npm install @azizbecha/strkit

Usage

CommonJS

const { isEmail, truncate } = require("@azizbecha/strkit");

console.log(isEmail("[email protected]")); // true
console.log(truncate("This is a very long string", 10)); // 'This is a...'

ES6

import strkit, { isEmail } from "@azizbecha/strkit";

console.log(isEmail("[email protected]")); // true
console.log(strkit.truncate("This is a very long string", 10)); // 'This is a...'

Functions

| Function | Description | Example Usage | Type Signature | | ---------------------------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------ | | capitalize | Capitalizes the first letter of a string. | capitalize('hello') // 'Hello' | (str: string) => string | | compareVersion | Compares two versions Returns 0 if equal, 1 if v1 > v2, or -1 if v2 > v1. | compareVersion('1.2.0', '1.3.0') // -1 | (v1: string, v2: string) => number | | countWordsMatching | Counts the words in a string matching a specific pattern. | countWordsMatching('hello world', /o/) // 2 | (str: string, pattern: RegExp) => number | | decodeURL | Decodes a URL-encoded string. | decodeURL('hello%20world') // 'hello world' | (str: string) => string | | diffStrings | Compares two strings and returns an array of differences. | diffStrings('hello world', 'hello there'); // [{ type: 'equal', value: 'hello ' }, { type: 'removed', value: 'world' }, { type: 'added', value: 'there' }] | (str1: string, str2: string) => [{type, value}}] | | encodeURL | Encodes a string into a URL-safe format. | encodeURL('hello world') // 'hello%20world' | (str: string) => string | | endsWith | Checks if a string ends with a given suffix. | endsWith('hello', 'lo') // true | (str: string, suffix: string) => boolean | | extractHashtags | Extracts all hashtags from a string. | extractHashtags('#hello #world') // ['#hello', '#world'] | (str: string) => string[] | | extractMentions | Extracts all mentions (e.g., @username) from a string. | extractMentions('@user @test') // ['@user', '@test'] | (str: string) => string[] | | formatNumber | Formats numbers into abbreviated form (e.g., 1.2k). | formatNumber(1200) // '1.2k' | (num: number, digits?: number) => string | | generateId | Generates a random alphanumeric ID. | generateId() // 'abc123xyz' | (length = 15: number) => string | | invertCase | Inverts the case of each character in a string. | invertCase('Hello') // 'hELLO' | (str: string) => string | | isAnagram | Checks if two strings are anagrams. | isAnagram('listen', 'silent') // true | (str1: string, str2: string) => boolean | | isBoolean | Checks if a value is a boolean-like (e.g., true, "yes", 1). | isBoolean('yes') // true | (value: number) => boolean | | isBtcAddress | Checks if a string is a valid Bitcoin address. | isBtcAddress('1A1zP...DivfNa') // true | (str: string) => boolean | | isCreditCard | Checks if a string is a valid credit card number. | isCreditCard('4111...1111') // true | (str: string) => boolean | | isEmail | Checks if a string is a valid email address. | isEmail('[email protected]') // true | (email: string) => boolean | | isEmoji | Checks if a string contains emojis. | isEmoji('😊') // true | (str: string) => boolean | | isIPv4Address | Checks if a string is a valid IPv4 address. | isIPv4Address('192.168.0.1') // true | (str: string) => boolean | | isIPv6Address | Checks if a string is a valid IPv6 address. | isIPv6Address('::1') // true | (str: string) => boolean | | isJSON | Checks if a string is valid JSON. | isJSON('{"key": 42}') // true | (str: string) => boolean | | isJWT | Checks if a string is a valid JSON Web Token (JWT). | isJWT('eyJhbGci...') // true | (str: string) => boolean | | isPalindrome | Checks if a string is a palindrome. | isPalindrome('racecar') // true | (str: string) => boolean | | isURL | Checks if a string is a valid URL. | isURL('https://example.com'); // true | (str: string) => boolean | | maskEmail | Masks an email address for privacy by replacing part of the email with asterisks.. | maskEmail('[email protected]'); // "t***@example.com" | (str: string) => string | | readingTime | Estimates reading time for a given string. | readingTime('Lorem ipsum...') // '1 min' | (str: string, wpm = 200: number) => string | | removeSpaces | Removes all spaces from a string. | removeSpaces('hello world') // 'helloworld' | (str: string) => string | | reverse | Reverses the characters in a given string. | reverse('hello') // 'olleh' | (str: string) => string | | startsWith | Checks if a string starts with a given prefix. | startsWith('hello', 'he') // true | (str: string, prefix: string) => boolean | | truncate | Truncates a string to a specific length, appending ellipses if needed. | truncate('hello world', 5) // 'hello...' | (str: string, maxLength?: number) => string | | truncateMiddle | Truncates the middle of a string to fit within a length, adding ellipses. | truncateMiddle('abcdef', 4) // 'a...f' | (str: string, maxLength: number) => string | | toCamelCase | Converts a string to camel case. | toCamelCase('hello_world') // 'helloWorld' | (str: string) => string | | toOrdinal | Converts a number to its ordinal form. | toOrdinal(1) // '1st' | (num: number) => string | | clamp | Clamps a number between a minimum and maximum value. | clamp(15, 0, 10); // 10 | (value: number, min: number, max: number) => number | | getDistanceBetweenPoints | Calculates the distance between two points in a 2D plane. | getDistanceBetweenPoints({ lon: 0, lat: 0 }, { lon: 3, lat: 4 }) // 5 | ({ lon: number, lat: number }, { lon: number, lat: number }) => number | | toDegrees | Converts radians to degrees. | toDegrees(Math.PI) // 180 | (radians: number) => number | | toRadians | Converts degrees to radians. | toRadians(180) // Math.PI | (degrees: number) => number | | roundTo | Rounds a number to a specified number of decimal places. | roundTo(1.2345, 2) // 1.23 | (num: number, decimalPlaces: number) => number | | randomBetween | Generates a random number between a minimum and maximum value. | randomBetween(1, 10) // 7 | (min: number, max: number) => number | | startsWith | Checks if a string starts with a given prefix. | startsWith('hello', 'he') // true | (str: string, prefix: string) => boolean | | endsWith | Checks if a string ends with a given suffix. | endsWith('hello', 'lo') // true | (str: string, suffix: string) => boolean |

Development

If you'd like to contribute or modify the library, you can clone the repository and run the following commands to build the project:

1. Clone the repository

git clone https://github.com/azizbecha/strkit

2. Install dependencies

npm install

3. Build the project

npm run build

License

This project is licensed under the MIT License - see the LICENSE file for details.


Contributing

Feel free to fork the repository, create an issue, or submit a pull request to contribute improvements or new features.


Acknowledgments

  • Thanks to all contributors who make this library possible!

Aziz Becha.