mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.5 KiB
51 lines
1.5 KiB
10 years ago
|
/**
|
||
10 years ago
|
* lodash 3.1.1 (Custom Build) <https://lodash.com/>
|
||
10 years ago
|
* Build: `lodash modern modularize exports="npm" -o ./`
|
||
|
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
||
10 years ago
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||
10 years ago
|
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||
|
* Available under MIT license <https://lodash.com/license>
|
||
|
*/
|
||
|
var baseToString = require('lodash._basetostring'),
|
||
10 years ago
|
createPadding = require('lodash._createpadding');
|
||
10 years ago
|
|
||
|
/**
|
||
10 years ago
|
* Creates a function for `_.padLeft` or `_.padRight`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {boolean} [fromRight] Specify padding from the right.
|
||
|
* @returns {Function} Returns the new pad function.
|
||
|
*/
|
||
|
function createPadDir(fromRight) {
|
||
|
return function(string, length, chars) {
|
||
|
string = baseToString(string);
|
||
10 years ago
|
return (fromRight ? string : '') + createPadding(string, length, chars) + (fromRight ? '' : string);
|
||
10 years ago
|
};
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Pads `string` on the left side if it is shorter than `length`. Padding
|
||
|
* characters are truncated if they exceed `length`.
|
||
10 years ago
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @category String
|
||
|
* @param {string} [string=''] The string to pad.
|
||
|
* @param {number} [length=0] The padding length.
|
||
|
* @param {string} [chars=' '] The string used as padding.
|
||
|
* @returns {string} Returns the padded string.
|
||
|
* @example
|
||
|
*
|
||
|
* _.padLeft('abc', 6);
|
||
|
* // => ' abc'
|
||
|
*
|
||
|
* _.padLeft('abc', 6, '_-');
|
||
|
* // => '_-_abc'
|
||
|
*
|
||
|
* _.padLeft('abc', 3);
|
||
|
* // => 'abc'
|
||
|
*/
|
||
10 years ago
|
var padLeft = createPadDir();
|
||
10 years ago
|
|
||
|
module.exports = padLeft;
|