open-index/open-npm huggingface dataset:
npm package: @olan88/js-string-methods
Description: A TypeScript library that extends the native `String` prototype with useful utility methods like camelCase conversion, reversing strings, and more.
Latest version: 1.0.0


# @codebyolan/js-string-methods

A TypeScript library that extends the native `String` prototype with useful utility methods like camelCase conversion, reversing strings, and more.

## Installation

Install the package via npm:

```bash
npm install @olan88/js-string-methods
```

## Usage

Import the library in your TypeScript or JavaScript file:

```typescript
import '@olan/js-string-methods';
```

### Example Methods

#### 1. Convert to camelCase
```typescript
console.log("hello_world-example".toCamelCase()); // Output: "helloWorldExample"
```

#### 2. Capitalize the first letter
```typescript
console.log("hello world".capitalize()); // Output: "Hello world"
```

#### 3. Reverse a string
```typescript
console.log("hello".reverse()); // Output: "olleh"
```

#### 4. Check if a string is a palindrome
```typescript
console.log("A man a plan a canal Panama".isPalindrome()); // Output: true
```

#### 5. Count occurrences of a substring
```typescript
console.log("hello world hello".countOccurrences("hello")); // Output: 2
```

#### 6. Truncate a string
```typescript
console.log("This is a long string".truncate(10)); // Output: "This is..."
```

#### 7. Convert to Title Case
```typescript
console.log("this is a test".toTitleCase()); // Output: "This Is A Test"
```

#### 8. Remove all whitespace
```typescript
console.log("  hello   world  ".removeWhitespace()); // Output: "helloworld"
```

#### 9. Mask a portion of a string
```typescript
console.log("1234567890".mask(2, 8)); // Output: "12******90"
```

#### 10. Convert to a slug
```typescript
console.log("Hello World!".toSlug()); // Output: "hello-world"
```

#### 11. Check if a string contains only specific characters
```typescript
console.log("12345".containsOnly("0123456789")); // Output: true
```

## Contributing

Contributions are welcome! Open an issue or a pull request to suggest improvements.

## License

This project is licensed under the MIT License.
# js-string-methods