string-capitalizer
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -5,3 +5,2 @@ export class StringManipulator { | ||
constructor (newString) { | ||
this.#validateString(newString) | ||
this.#stringToBeManipulated = newString | ||
@@ -15,2 +14,6 @@ } | ||
capitalizeString() { | ||
if (this.#stringToBeManipulated === null || typeof(this.#stringToBeManipulated) !== 'string') { | ||
throw new Error('Invalid string') | ||
} | ||
const capitalizedString = this.#stringToBeManipulated.charAt(0).toUpperCase() + this.#stringToBeManipulated.slice(1) | ||
@@ -20,12 +23,2 @@ | ||
} | ||
#validateString(newString) { | ||
if (newString === null || typeof(newString) !== 'string') { | ||
throw new Error('Invalid string') | ||
} | ||
if (newString.length === 0) { | ||
throw new Error('String cannot be empty') | ||
} | ||
} | ||
} |
{ | ||
"name": "string-capitalizer", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -7,6 +7,13 @@ # String Capitalizer | ||
capitalizeString() method capitalizes the first letter of a string and returns the capitalized string. | ||
If invalid string is inputted, 'invalid string'-error will be thrown. | ||
### Use instructions | ||
Start by importing StringManipulator. Create a new instance of StringManipulator and invoke the method you wish to use. | ||
```javascript | ||
import StringManipulator from 'string-capitalizer' | ||
const stringManipulator = new StringManipulator() | ||
const stringManipulator = new StringManipulator(stringToManipulate) | ||
@@ -18,7 +25,6 @@ const capitalizedString = stringManipulator.capitalizeString('hello world') | ||
capitalizeString() method capitalizes the first letter of a string and returns the capitalized string. | ||
If invalid string is inputted, 'invalid string'-error will be thrown. | ||
### Disclaimer | ||
### Use instructions | ||
This library is still in development and is not yet ready for production use. Use at your own risk. | ||
Start by importing StringManipulator. Create a new instance of StringManipulator (new StringManipulator()) and invoke the method you wish to use. | ||
It is a practice project for learning purposes. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3149
29
32