lodash.capitalize
Advanced tools
Comparing version 4.1.1 to 4.2.0
269
index.js
/** | ||
* lodash 4.1.1 (Custom Build) <https://lodash.com/> | ||
* lodash (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/> | ||
* Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
* Released under MIT license <https://lodash.com/license> | ||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | ||
* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
* Available under MIT license <https://lodash.com/license> | ||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
*/ | ||
var toString = require('lodash.tostring'), | ||
upperFirst = require('lodash.upperfirst'); | ||
/** Used as references for various `Number` constants. */ | ||
var INFINITY = 1 / 0; | ||
/** `Object#toString` result references. */ | ||
var symbolTag = '[object Symbol]'; | ||
/** Used to compose unicode character classes. */ | ||
var rsAstralRange = '\\ud800-\\udfff', | ||
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23', | ||
rsComboSymbolsRange = '\\u20d0-\\u20f0', | ||
rsVarRange = '\\ufe0e\\ufe0f'; | ||
/** Used to compose unicode capture groups. */ | ||
var rsAstral = '[' + rsAstralRange + ']', | ||
rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']', | ||
rsFitz = '\\ud83c[\\udffb-\\udfff]', | ||
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', | ||
rsNonAstral = '[^' + rsAstralRange + ']', | ||
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', | ||
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', | ||
rsZWJ = '\\u200d'; | ||
/** Used to compose unicode regexes. */ | ||
var reOptMod = rsModifier + '?', | ||
rsOptVar = '[' + rsVarRange + ']?', | ||
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', | ||
rsSeq = rsOptVar + reOptMod + rsOptJoin, | ||
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; | ||
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ | ||
var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); | ||
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ | ||
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']'); | ||
/** Detect free variable `global` from Node.js. */ | ||
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; | ||
/** Detect free variable `self`. */ | ||
var freeSelf = typeof self == 'object' && self && self.Object === Object && self; | ||
/** Used as a reference to the global object. */ | ||
var root = freeGlobal || freeSelf || Function('return this')(); | ||
/** | ||
* Converts `string` to an array. | ||
* | ||
* @private | ||
* @param {string} string The string to convert. | ||
* @returns {Array} Returns the converted array. | ||
*/ | ||
function stringToArray(string) { | ||
return string.match(reComplexSymbol); | ||
} | ||
/** Used for built-in method references. */ | ||
var objectProto = Object.prototype; | ||
/** | ||
* Used to resolve the | ||
* [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objectToString = objectProto.toString; | ||
/** Built-in value references. */ | ||
var Symbol = root.Symbol; | ||
/** Used to convert symbols to primitives and strings. */ | ||
var symbolProto = Symbol ? Symbol.prototype : undefined, | ||
symbolToString = symbolProto ? symbolProto.toString : undefined; | ||
/** | ||
* The base implementation of `_.slice` without an iteratee call guard. | ||
* | ||
* @private | ||
* @param {Array} array The array to slice. | ||
* @param {number} [start=0] The start position. | ||
* @param {number} [end=array.length] The end position. | ||
* @returns {Array} Returns the slice of `array`. | ||
*/ | ||
function baseSlice(array, start, end) { | ||
var index = -1, | ||
length = array.length; | ||
if (start < 0) { | ||
start = -start > length ? 0 : (length + start); | ||
} | ||
end = end > length ? length : end; | ||
if (end < 0) { | ||
end += length; | ||
} | ||
length = start > end ? 0 : ((end - start) >>> 0); | ||
start >>>= 0; | ||
var result = Array(length); | ||
while (++index < length) { | ||
result[index] = array[index + start]; | ||
} | ||
return result; | ||
} | ||
/** | ||
* The base implementation of `_.toString` which doesn't convert nullish | ||
* values to empty strings. | ||
* | ||
* @private | ||
* @param {*} value The value to process. | ||
* @returns {string} Returns the string. | ||
*/ | ||
function baseToString(value) { | ||
// Exit early for strings to avoid a performance hit in some environments. | ||
if (typeof value == 'string') { | ||
return value; | ||
} | ||
if (isSymbol(value)) { | ||
return symbolToString ? symbolToString.call(value) : ''; | ||
} | ||
var result = (value + ''); | ||
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; | ||
} | ||
/** | ||
* Casts `array` to a slice if it's needed. | ||
* | ||
* @private | ||
* @param {Array} array The array to inspect. | ||
* @param {number} start The start position. | ||
* @param {number} [end=array.length] The end position. | ||
* @returns {Array} Returns the cast slice. | ||
*/ | ||
function castSlice(array, start, end) { | ||
var length = array.length; | ||
end = end === undefined ? length : end; | ||
return (!start && end >= length) ? array : baseSlice(array, start, end); | ||
} | ||
/** | ||
* Creates a function like `_.lowerFirst`. | ||
* | ||
* @private | ||
* @param {string} methodName The name of the `String` case method to use. | ||
* @returns {Function} Returns the new case function. | ||
*/ | ||
function createCaseFirst(methodName) { | ||
return function(string) { | ||
string = toString(string); | ||
var strSymbols = reHasComplexSymbol.test(string) | ||
? stringToArray(string) | ||
: undefined; | ||
var chr = strSymbols | ||
? strSymbols[0] | ||
: string.charAt(0); | ||
var trailing = strSymbols | ||
? castSlice(strSymbols, 1).join('') | ||
: string.slice(1); | ||
return chr[methodName]() + trailing; | ||
}; | ||
} | ||
/** | ||
* Checks if `value` is object-like. A value is object-like if it's not `null` | ||
* and has a `typeof` result of "object". | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is object-like, else `false`. | ||
* @example | ||
* | ||
* _.isObjectLike({}); | ||
* // => true | ||
* | ||
* _.isObjectLike([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isObjectLike(_.noop); | ||
* // => false | ||
* | ||
* _.isObjectLike(null); | ||
* // => false | ||
*/ | ||
function isObjectLike(value) { | ||
return !!value && typeof value == 'object'; | ||
} | ||
/** | ||
* Checks if `value` is classified as a `Symbol` primitive or object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`. | ||
* @example | ||
* | ||
* _.isSymbol(Symbol.iterator); | ||
* // => true | ||
* | ||
* _.isSymbol('abc'); | ||
* // => false | ||
*/ | ||
function isSymbol(value) { | ||
return typeof value == 'symbol' || | ||
(isObjectLike(value) && objectToString.call(value) == symbolTag); | ||
} | ||
/** | ||
* Converts `value` to a string. An empty string is returned for `null` | ||
* and `undefined` values. The sign of `-0` is preserved. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to process. | ||
* @returns {string} Returns the string. | ||
* @example | ||
* | ||
* _.toString(null); | ||
* // => '' | ||
* | ||
* _.toString(-0); | ||
* // => '-0' | ||
* | ||
* _.toString([1, 2, 3]); | ||
* // => '1,2,3' | ||
*/ | ||
function toString(value) { | ||
return value == null ? '' : baseToString(value); | ||
} | ||
/** | ||
* Converts the first character of `string` to upper case and the remaining | ||
@@ -18,2 +255,3 @@ * to lower case. | ||
* @memberOf _ | ||
* @since 3.0.0 | ||
* @category String | ||
@@ -31,2 +269,21 @@ * @param {string} [string=''] The string to capitalize. | ||
/** | ||
* Converts the first character of `string` to upper case. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category String | ||
* @param {string} [string=''] The string to convert. | ||
* @returns {string} Returns the converted string. | ||
* @example | ||
* | ||
* _.upperFirst('fred'); | ||
* // => 'Fred' | ||
* | ||
* _.upperFirst('FRED'); | ||
* // => 'FRED' | ||
*/ | ||
var upperFirst = createCaseFirst('toUpperCase'); | ||
module.exports = capitalize; |
{ | ||
"name": "lodash.capitalize", | ||
"version": "4.1.1", | ||
"version": "4.2.0", | ||
"description": "The lodash method `_.capitalize` exported as a module.", | ||
@@ -12,11 +12,7 @@ "homepage": "https://lodash.com/", | ||
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", | ||
"Blaine Bublitz <blaine@iceddev.com> (https://github.com/phated)", | ||
"Blaine Bublitz <blaine.bublitz@gmail.com> (https://github.com/phated)", | ||
"Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)" | ||
], | ||
"repository": "lodash/lodash", | ||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" }, | ||
"dependencies": { | ||
"lodash.tostring": "^4.0.0", | ||
"lodash.upperfirst": "^4.0.0" | ||
} | ||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" } | ||
} |
@@ -1,2 +0,2 @@ | ||
# lodash.capitalize v4.1.1 | ||
# lodash.capitalize v4.2.0 | ||
@@ -18,2 +18,2 @@ The [lodash](https://lodash.com/) method `_.capitalize` exported as a [Node.js](https://nodejs.org/) module. | ||
See the [documentation](https://lodash.com/docs#capitalize) or [package source](https://github.com/lodash/lodash/blob/4.1.1-npm-packages/lodash.capitalize) for more details. | ||
See the [documentation](https://lodash.com/docs#capitalize) or [package source](https://github.com/lodash/lodash/blob/4.2.0-npm-packages/lodash.capitalize) for more details. |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
11118
0
256
1
1
- Removedlodash.tostring@^4.0.0
- Removedlodash.upperfirst@^4.0.0
- Removedlodash.tostring@4.1.4(transitive)
- Removedlodash.upperfirst@4.3.1(transitive)