@appshare/bob2
v1.20.1
Published
````markdown # String Helpers
Readme
# String Helpers
String transformation helpers such as casing converters, slug generation, truncation, and padding utilities.
## Installation
```bash
npm install @appshare/bob2
```
## Usage
```javascript
import {
camelCase,
titleCase,
slugify,
truncate,
} from '@appshare/bob2/src/back.js';
const slug = slugify('Café Con Leche!');
console.log(slug); // "cafe-con-leche"
const camel = camelCase('make this camel case');
console.log(camel); // "makeThisCamelCase"
const heading = titleCase('the rise of string helpers', {
minorWords: ['of'],
});
console.log(heading); // "The Rise of String Helpers"
const preview = truncate('The quick brown fox jumps over the lazy dog', 20, {
wholeWords: true,
});
console.log(preview); // "The quick brown..."
```
## API Reference
- `capitalize(value)` – Capitalize the first character and lower-case the remainder.
- `titleCase(value, options?)` – Title case a string with optional minor words and casing options.
- `camelCase(value)` – Convert to lower camelCase.
- `pascalCase(value)` – Convert to UpperCamelCase.
- `snakeCase(value)` – Convert to lower snake_case.
- `kebabCase(value)` – Convert to lower kebab-case.
- `slugify(value, options?)` – Produce URL-safe slugs with configurable separators.
- `truncate(value, maxLength, options?)` – Truncate text with optional word boundaries and omission markers.
- `pad(value, targetLength, options?)` – Pad text to a target length across start, end, or both sides.