Socket
Socket
Sign inDemoInstall

to-camel-case

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

to-camel-case - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

2

component.json

@@ -5,3 +5,3 @@ {

"description": "Converts a string to camelCase",
"version": "0.1.0",
"version": "0.2.0",
"keywords": [],

@@ -8,0 +8,0 @@ "dependencies": {},

@@ -0,1 +1,6 @@

0.2.0 / 2013-04-06
==================
Add `first` option for PascalCase
0.1.0 / 2013-04-02

@@ -2,0 +7,0 @@ ==================

/**
* Converts a string to camel case
* Convert a string to camel case
*
* @param {String} str
* @param {Boolean} first upper-case first too ? (PascalCase)
*/
module.exports = function (str) {
return str.replace(/[_-]([a-z])/g, function (l) {
module.exports = function (str, first) {
str = str.replace(/[_-]([a-z])/g, function (l) {
return l[1].toUpperCase()
})
if (first)
str = str.charAt(0).toUpperCase() + str.slice(1)
return str
}
{
"name": "to-camel-case",
"repo": "Nami-Doc/to-camel-case",
"version": "0.1.0",
"version": "0.2.0",
"keywords": ["camel-case", "camelCase", "string", "case"],

@@ -6,0 +6,0 @@ "devDependencies": {

@@ -14,3 +14,3 @@

### toCamelCase
### toCamelCase(string, first = false)

@@ -21,2 +21,4 @@ ```js

toCamelCase("chocolate-rain").should.equal("chocolateRain")
toCamelCase("hello-howare-ya", true).should.equal("HelloHowareYa")
```

@@ -23,0 +25,0 @@

@@ -5,7 +5,13 @@ var toCamelCase = require('..')

it('should convert dashes to camel case', function () {
toCamelCase("hello-ya").should.equal("helloYa")
toCamelCase("hello-howare-ya").should.equal("helloHowareYa")
})
it('should convert underscores to camel case', function () {
toCamelCase("chocolate-rain").should.equal("chocolateRain")
toCamelCase("the_chocolate_rain").should.equal("theChocolateRain")
})
})
describe('toCamelCase(str, first=true)', function () {
it('should upper case first and convert dashes to camel case', function () {
toCamelCase("hello-howare-ya", true).should.equal("HelloHowareYa")
})
})

Sorry, the diff of this file is not supported yet

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