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

swap-case

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swap-case - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

13

package.json
{
"name": "swap-case",
"version": "1.0.2",
"version": "1.1.0",
"description": "Swap the case of a string",
"main": "swap-case.js",
"files": [
"swap-case.js",
"LICENSE"
],
"scripts": {

@@ -31,4 +35,9 @@ "test": "istanbul cover _mocha -- -R spec"

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

9

README.md

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

[![Test coverage][coveralls-image]][coveralls-url]
[![Gittip][gittip-image]][gittip-url]
Swap the case of a string with non-ASCII character support. 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.
Swap the case of a string.
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

@@ -26,2 +27,4 @@

swapCase('Iñtërnâtiônàlizætiøn'); //=> "iÑTËRNÂTIÔNÀLIZÆTIØN"
swapCase('My String', 'tr'); //=> "mY sTRİNG"
```

@@ -39,3 +42,1 @@

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

@@ -0,1 +1,4 @@

var upperCase = require('upper-case');
var lowerCase = require('lower-case');
/**

@@ -6,5 +9,6 @@ * Swap the case of a string. Manually iterate over every character and check

* @param {String} str
* @param {String} [locale]
* @return {String}
*/
module.exports = function (str) {
module.exports = function (str, locale) {
if (str == null) {

@@ -18,5 +22,5 @@ return '';

var c = str[i];
var u = c.toUpperCase();
var u = upperCase(c, locale);
result += u === c ? c.toLowerCase() : u;
result += u === c ? lowerCase(c, locale) : u;
}

@@ -23,0 +27,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