
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
abstract-eth
Advanced tools
A collection of useful string manipulation and validation utilities
A lightweight and efficient collection of string manipulation and validation utilities for JavaScript.
npm install string-utils-helper
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
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
Converts a string to camelCase format.
Converts a string to snake_case format.
Truncates a string to the specified length, adding '...' if truncated.
Capitalizes the first letter of each word in a string.
Removes all whitespace from a string.
Reverses a string.
Counts the number of occurrences of a substring in a string.
Checks if a string is a valid email address.
Checks if a string is a valid URL.
Checks if a string contains only alphanumeric characters.
Run the tests:
npm test
MIT
FAQs
A collection of useful string manipulation and validation utilities
We found that abstract-eth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.