Socket
Socket
Sign inDemoInstall

camel-case

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

camel-case - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

14

camel-case.js

@@ -1,2 +0,3 @@

var sentence = require('sentence-case');
var upperCase = require('upper-case');
var sentenceCase = require('sentence-case');

@@ -7,12 +8,13 @@ /**

* @param {String} string
* @param {String} [locale]
* @return {String}
*/
module.exports = function (string) {
return sentence(string)
module.exports = function (string, locale) {
return sentenceCase(string, locale)
// Replace periods between numeric entities with an underscore.
.replace(/(\d) (?=\d)/g, '$1_')
// Replace spaces between words with a string upper cased character.
.replace(/ (\w)/g, function (_, $1) {
return $1.toUpperCase();
// Replace spaces between words with an upper cased character.
.replace(/ (.)/g, function (m, $1) {
return upperCase($1, locale);
});
};
{
"name": "camel-case",
"version": "1.0.2",
"version": "1.1.0",
"description": "Camel case a string",

@@ -15,3 +15,14 @@ "main": "camel-case.js",

"camel",
"case"
"case",
"camelcase",
"camel-case",
"dash",
"hyphen",
"dot",
"underscore",
"lodash",
"separator",
"string",
"text",
"convert"
],

@@ -30,7 +41,9 @@ "author": {

"istanbul": "^0.3.0",
"mocha": "^1.18.2"
"mocha": "^1.18.2",
"pre-commit": "0.0.9"
},
"dependencies": {
"sentence-case": "^1.0.2"
"sentence-case": "^1.1.1",
"upper-case": "^1.1.1"
}
}

@@ -6,6 +6,7 @@ # Camel Case

[![Test coverage][coveralls-image]][coveralls-url]
[![Gittip][gittip-image]][gittip-url]
Camel case a string.
Camel case a string. Explicitly adds a single underscore between groups of numbers to keep readability (E.g. `1.20.5` becomes `1_20_5`, not `1205`).
Supports Unicode (non-ASCII characters) and non-string entities, such as objects with a `toString` property, numbers and booleans. Empty values (`null` and `undefined`) will result in an empty string.
## Installation

@@ -28,2 +29,4 @@

camelCase('version 1.2.10'); //=> "version1_2_10"
camelCase('STRING 1.2', 'tr'); //=> "strıng1_2"
```

@@ -41,3 +44,1 @@

[coveralls-url]: https://coveralls.io/r/blakeembrey/camel-case?branch=master
[gittip-image]: https://img.shields.io/gittip/blakeembrey.svg?style=flat
[gittip-url]: https://www.gittip.com/blakeembrey

@@ -29,2 +29,10 @@ /* global describe, it */

});
it('should camel case non-latin strings', function () {
assert.equal(camelCase('simple éxample'), 'simpleÉxample');
});
it('should support locale', function () {
assert.equal(camelCase('STRING 1.2', 'tr'), 'strıng1_2');
});
});
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