Socket
Socket
Sign inDemoInstall

upper-case

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.3 to 1.1.0

5

package.json
{
"name": "upper-case",
"version": "1.0.3",
"version": "1.1.0",
"description": "Upper case a string",

@@ -31,4 +31,5 @@ "main": "upper-case.js",

"istanbul": "^0.3.0",
"mocha": "^1.21.4"
"mocha": "^1.21.4",
"pre-commit": "0.0.9"
}
}

12

README.md

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

[![Test coverage][coveralls-image]][coveralls-url]
[![Gittip][gittip-image]][gittip-url]
Upper 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.
Upper case 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

@@ -22,4 +23,5 @@

upperCase(null); //=> ""
upperCase('string'); //=> "STRING"
upperCase(null); //=> ""
upperCase('string'); //=> "STRING"
upperCase('string', 'tr'); //=> "STRİNG"

@@ -39,3 +41,1 @@ upperCase({ toString: function () { return 'test'; } }); //=> "TEST"

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

@@ -10,3 +10,12 @@ /* global describe, it */

assert.equal(upperCase('TEST'), 'TEST');
assert.equal(upperCase('string'), 'STRING');
});
it('should support unicode', function () {
assert.equal(upperCase('\u0131'), 'I');
});
it('should support locale override', function () {
assert.equal(upperCase('i', 'tr'), '\u0130');
});
});

@@ -1,3 +0,35 @@

var upperCase = String.prototype.toUpperCase;
/**
* Special language-specific overrides.
*
* Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
*
* @type {Object}
*/
var languages = {
tr: {
regexp: /[\u0069]/g,
map: {
'\u0069': '\u0130',
}
},
az: {
regexp: /[\u0069]/g,
map: {
'\u0069': '\u0130'
}
},
lt: {
regexp: /[\u0069\u006A\u012F]\u0307|\u0069\u0307[\u0300\u0301\u0303]/g,
map: {
'\u0069\u0307': '\u0049',
'\u006A\u0307': '\u004A',
'\u012F\u0307': '\u012E',
'\u0069\u0307\u0300': '\u00CC',
'\u0069\u0307\u0301': '\u00CD',
'\u0069\u0307\u0303': '\u0128'
}
}
};
/**

@@ -9,4 +41,12 @@ * Upper case a string.

*/
module.exports = function (str) {
return str == null ? '' : upperCase.call(str);
module.exports = function (str, locale) {
var lang = languages[locale];
str = str == null ? '' : String(str);
if (lang) {
str = str.replace(lang.regexp, function (m) { return lang.map[m]; });
}
return str.toUpperCase();
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc