Bump to v4.0.0.

This commit is contained in:
John-David Dalton
2015-12-16 17:53:20 -08:00
parent 94d714007e
commit 8c26e6fd4c
656 changed files with 16423 additions and 11602 deletions

View File

@@ -1,29 +1,46 @@
define(['../string/repeat', './root'], function(repeat, root) {
define(['../repeat', './stringSize', './stringToArray', '../toInteger'], function(repeat, stringSize, stringToArray, toInteger) {
/* Native method references for those with the same name as other `lodash` methods. */
var nativeCeil = Math.ceil,
nativeIsFinite = root.isFinite;
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ = '\\u200d';
/** 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 + rsComboRange + rsVarRange + ']');
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeCeil = Math.ceil;
/**
* Creates the padding required for `string` based on the given `length`.
* The `chars` string is truncated if the number of characters exceeds `length`.
* Creates the padding for `string` based on `length`. The `chars` string
* is truncated if the number of characters exceeds `length`.
*
* @private
* @param {string} string The string to create padding for.
* @param {number} [length=0] The padding length.
* @param {string} [chars=' '] The string used as padding.
* @returns {string} Returns the pad for `string`.
* @returns {string} Returns the padding for `string`.
*/
function createPadding(string, length, chars) {
var strLength = string.length;
length = +length;
length = toInteger(length);
if (strLength >= length || !nativeIsFinite(length)) {
var strLength = stringSize(string);
if (!length || strLength >= length) {
return '';
}
var padLength = length - strLength;
chars = chars == null ? ' ' : (chars + '');
return repeat(chars, nativeCeil(padLength / chars.length)).slice(0, padLength);
chars = chars === undefined ? ' ' : (chars + '');
var result = repeat(chars, nativeCeil(padLength / stringSize(chars)));
return reHasComplexSymbol.test(chars)
? stringToArray(result).slice(0, padLength).join('')
: result.slice(0, padLength);
}
return createPadding;