New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

strtoolkit

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strtoolkit

A lightweight toolkit for common string manipulation tasks.

  • 0.4.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by400%
Maintainers
1
Weekly downloads
 
Created
Source

strtoolkit

strtoolkit is a lightweight toolkit for common string manipulation tasks, offering functions to truncate strings and check for the presence of special characters or numbers.

Installation

Install the package using npm:

npm i strtoolkit

Usage

Truncate a String

import { strTruncator } from "strtoolkit";

const truncatedString = strTruncator("Lorem ipsum dolor sit amet", 10);
console.log(truncatedString); // Output: Lorem ipsu ...

The strTruncator function truncates a given string to a specified maximum length, appending "..." if the original string exceeds the limit.

Check for Special Characters or Numbers

const { hasCharOrNumber } = require("strtoolkit");

const hasSpecialCharOrNumber = hasCharOrNumber("Hello@World123");
console.log(hasSpecialCharOrNumber); // Output: true

The hasCharOrNumber function checks whether a string contains either special characters or numbers.

API

strTruncator(str: string, maxLength: number): string

Truncate a given string to a specified maximum length.

  • str: The input string to be truncated.
  • maxLength: The maximum length of the truncated string.

Returns the truncated string with an appended "..." if the original string exceeds the limit.

hasCharOrNumber(str: string): boolean

Check if a string contains either special characters or numbers.

  • str: The input string to be checked.

Returns true if the string contains either special characters or numbers; otherwise, returns false.

Contributing

Feel free to contribute by opening issues or submitting pull requests on GitHub.

License

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


Make sure to replace "Etzshally" with your actual GitHub username, and adjust the paths and details as needed for your project.

Keywords

FAQs

Package last updated on 11 Jan 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc