Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

capitalize

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

capitalize - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

.github/workflows/nodejs.yml

13

index.js

@@ -1,10 +0,15 @@

module.exports = function (string) {
string = string.toLowerCase();
module.exports = function (string, preserve) {
if (!preserve) {
string = string.toLowerCase();
}
return string.charAt(0).toUpperCase() + string.substring(1);
}
module.exports.words = function (string) {
return string.toLowerCase().replace(/(^|[^a-zA-Z\u00C0-\u017F'])([a-zA-Z\u00C0-\u017F])/g, function (m) {
module.exports.words = function (string, preserve) {
if (!preserve) {
string = string.toLowerCase();
}
return string.replace(/(^|[^a-zA-Z\u00C0-\u017F'])([a-zA-Z\u00C0-\u017F])/g, function (m) {
return m.toUpperCase()
})
}
{
"name": "capitalize",
"version": "2.0.0",
"version": "2.0.1",
"description": "capitalize the first letter of a string, or all words in a string",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -81,2 +81,16 @@ # capitalize

and thanks to [@sergejkaravajnij](https://github.com/grncdr/js-capitalize/pull/9), capitalize also supports a second boolean parameter to preserve casing of the rest of the strings content:
```javascript
test('Capitalize a string, preserving the original case of other letters', function (t) {
t.plan(1)
t.equal(capitalize('canDoItRight', true), 'CanDoItRight')
})
test('Capitalize words, preserving the case', function (t) {
t.plan(1)
t.equal(capitalize.words('on gitHub', true), 'On GitHub')
})
```
## Install

@@ -83,0 +97,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc