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

sentence-case

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sentence-case - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "sentence-case",
"version": "1.0.0",
"version": "1.0.1",
"description": "Sentence case a string",

@@ -5,0 +5,0 @@ "main": "sentence-case.js",

@@ -8,3 +8,3 @@ # Sentence Case

Sentence case a string.
Sentence case a string. Also handles non-string entities, such as objects with a `toString` property, numbers and booleans. Empty values (`null` and `undefined`) will come out as an empty string.

@@ -22,2 +22,3 @@ ## Installation

sentenceCase(null); //=> ""
sentenceCase('string'); //=> "string"

@@ -24,0 +25,0 @@ sentenceCase('dot.case'); //=> "dot case"

/**
* Sentence case a string.
*
* @param {String} string
* @param {String} str
* @return {String}
*/
module.exports = function (string) {
return String(string)
module.exports = function (str) {
if (str == null) {
return '';
}
return String(str)
// Add camel case support.

@@ -10,0 +14,0 @@ .replace(/([a-z])([A-Z0-9])/g, '$1 $2')

@@ -33,6 +33,11 @@ /* global describe, it */

it('should not fail with odd input', function () {
assert.equal(sentenceCase(null), 'null');
assert.equal(sentenceCase(null), '');
assert.equal(sentenceCase(undefined), '');
assert.equal(sentenceCase(10), '10');
assert.equal(sentenceCase(undefined), 'undefined');
assert.equal(sentenceCase({ toString: function () { return 'test'; } }), 'test');
});
it('should trim whitespace', function () {
assert.equal(sentenceCase(' test '), 'test');
});
});
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