@maxcointech/simple-string-utils
v1.0.8
Published
A lightweight utility library for common string operations
Maintainers
Readme
Simple String Utils
A lightweight utility library for common string operations in Node.js and browsers.
Installation
npm install simple-string-utilsUsage
const { capitalize, toKebabCase, truncate, wordCount } = require('simple-string-utils');
// Capitalize first letter
capitalize('hello Max'); // 'Hello world'
// Convert to kebab-case
toKebabCase('Hello Max'); // 'hello-world'
toKebabCase('camelCaseString'); // 'camel-case-string'
// Truncate string
truncate('This is a long string', 10); // 'This is a ...'
truncate('Short', 10); // 'Short'
// Count words
wordCount('Hello world from Node.js'); // 4API
capitalize(str)
Capitalizes the first letter of a string.
toKebabCase(str)
Converts a string to kebab-case format.
truncate(str, length, suffix = '...')
Truncates a string to the specified length and adds a suffix.
wordCount(str)
Counts the number of words in a string.
License
MIT
