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

abstract-utxo

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstract-utxo

A collection of useful string manipulation and validation utilities

  • 1.0.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

String Utils Helper

A lightweight and efficient collection of string manipulation and validation utilities for JavaScript.

Installation

npm install string-utils-helper

Usage

String Manipulation

const { toCamelCase, toSnakeCase, truncate, toTitleCase, removeWhitespace, reverse, countOccurrences } = require('string-utils-helper');

// Convert to camelCase
toCamelCase('hello-world');  // 'helloWorld'
toCamelCase('hello_world');  // 'helloWorld'
toCamelCase('Hello World');  // 'helloWorld'

// Convert to snake_case
toSnakeCase('helloWorld');   // 'hello_world'
toSnakeCase('hello world');  // 'hello_world'
toSnakeCase('hello-world');  // 'hello_world'

// Truncate strings
truncate('hello world', 8);  // 'hel...'
truncate('short', 10);       // 'short'

// Convert to Title Case
toTitleCase('hello world');  // 'Hello World'
toTitleCase('HELLO WORLD');  // 'Hello World'

// Remove whitespace
removeWhitespace('hello world');      // 'helloworld'
removeWhitespace('  hello  world  '); // 'helloworld'

// Reverse strings
reverse('hello');       // 'olleh'
reverse('hello world'); // 'dlrow olleh'

// Count occurrences
countOccurrences('hello hello world', 'hello'); // 2
countOccurrences('world', 'hello');            // 0

String Validation

const { isValidEmail, isValidUrl, isAlphanumeric } = require('string-utils-helper/validation');

// Validate email addresses
isValidEmail('user@example.com');     // true
isValidEmail('invalid-email');        // false

// Validate URLs
isValidUrl('https://example.com');    // true
isValidUrl('not-a-url');             // false

// Check for alphanumeric strings
isAlphanumeric('abc123');            // true
isAlphanumeric('hello world');       // false

API

String Manipulation

toCamelCase(str)

Converts a string to camelCase format.

toSnakeCase(str)

Converts a string to snake_case format.

truncate(str, length)

Truncates a string to the specified length, adding '...' if truncated.

toTitleCase(str)

Capitalizes the first letter of each word in a string.

removeWhitespace(str)

Removes all whitespace from a string.

reverse(str)

Reverses a string.

countOccurrences(str, substr)

Counts the number of occurrences of a substring in a string.

String Validation

isValidEmail(email)

Checks if a string is a valid email address.

isValidUrl(url)

Checks if a string is a valid URL.

isAlphanumeric(str)

Checks if a string contains only alphanumeric characters.

Testing

Run the tests:

npm test

License

MIT

Keywords

FAQs

Package last updated on 28 Jan 2025

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