camelcase
Advanced tools
Comparing version 1.2.1 to 2.0.0
@@ -13,3 +13,7 @@ 'use strict'; | ||
if (str.length === 1 || !(/[_.\- ]+/).test(str) ) { | ||
if (str.length === 1) { | ||
return str; | ||
} | ||
if (!(/[_.\- ]+/).test(str)) { | ||
if (str[0] === str[0].toLowerCase() && str.slice(1) !== str.slice(1).toLowerCase()) { | ||
@@ -16,0 +20,0 @@ return str; |
{ | ||
"name": "camelcase", | ||
"version": "1.2.1", | ||
"version": "2.0.0", | ||
"description": "Convert a dash/dot/underscore/space separated string to camelCase: foo-bar → fooBar", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "node test.js" | ||
"test": "xo && ava" | ||
}, | ||
@@ -37,4 +37,5 @@ "files": [ | ||
"devDependencies": { | ||
"ava": "0.0.4" | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
} |
@@ -8,3 +8,3 @@ # camelcase [![Build Status](https://travis-ci.org/sindresorhus/camelcase.svg?branch=master)](https://travis-ci.org/sindresorhus/camelcase) | ||
```sh | ||
``` | ||
$ npm install --save camelcase | ||
@@ -17,32 +17,32 @@ ``` | ||
```js | ||
var camelCase = require('camelcase'); | ||
const camelCase = require('camelcase'); | ||
camelCase('foo-bar'); | ||
//=> fooBar | ||
//=> 'fooBar' | ||
camelCase('foo_bar'); | ||
//=> fooBar | ||
//=> 'fooBar' | ||
camelCase('Foo-Bar'); | ||
//=> fooBar | ||
//=> 'fooBar' | ||
camelCase('--foo.bar'); | ||
//=> fooBar | ||
//=> 'fooBar' | ||
camelCase('__foo__bar__'); | ||
//=> fooBar | ||
//=> 'fooBar' | ||
camelCase('foo bar'); | ||
//=> fooBar | ||
//=> 'fooBar' | ||
console.log(process.argv[3]); | ||
//=> --foo-bar | ||
//=> '--foo-bar' | ||
camelCase(process.argv[3]); | ||
//=> fooBar | ||
//=> 'fooBar' | ||
camelCase('foo', 'bar'); | ||
//=> fooBar | ||
//=> 'fooBar' | ||
camelCase('__foo__', '--bar'); | ||
//=> fooBar | ||
//=> 'fooBar' | ||
``` | ||
@@ -53,3 +53,4 @@ | ||
See [`decamelize`](https://github.com/sindresorhus/decamelize) for the inverse. | ||
- [decamelize](https://github.com/sindresorhus/decamelize) - The inverse of this module | ||
- [uppercamelcase](https://github.com/SamVerschueren/uppercamelcase) - Like this module, but to PascalCase instead of camelCase | ||
@@ -56,0 +57,0 @@ |
3447
26
58
2