Rename _.trunc to _.truncate.

This commit is contained in:
Xotic750
2015-10-26 21:16:43 +01:00
committed by John-David Dalton
parent accb8e9b07
commit 5218fd2c24
4 changed files with 31 additions and 31 deletions

View File

@@ -62,8 +62,8 @@ module.exports = {
'modArgsSet,omit,pad,padLeft,padRight,parseInt,partition,pick,pull,pullAll,' +
'pullAt,random,range,rearg,reject,remove,repeat,result,sampleSize,set,some,' +
'sortBy,sortByOrder,sortedIndexBy,sortedLastIndexBy,sortedUniqBy,startsWith,' +
'sumBy,take,takeRight,takeRightWhile,takeWhile,throttle,times,trunc,union,' +
'uniqBy,uniqueId,without,wrap,xor,zip').split(','),
'sumBy,take,takeRight,takeRightWhile,takeWhile,throttle,times,truncate,' +
'union,uniqBy,uniqueId,without,wrap,xor,zip').split(','),
3: (
'assignWith,clamp,differenceBy,extendWith,inRange,intersectionBy,isEqualWith,' +
'isMatchWith,mergeWith,omitBy,pickBy,pullAllBy,reduce,reduceRight,slice,' +

View File

@@ -30,7 +30,7 @@
var UNORDERED_COMPARE_FLAG = 1,
PARTIAL_COMPARE_FLAG = 2;
/** Used as default options for `_.trunc`. */
/** Used as default options for `_.truncate`. */
var DEFAULT_TRUNC_LENGTH = 30,
DEFAULT_TRUNC_OMISSION = '...';
@@ -1452,7 +1452,7 @@
* `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`,
* `sortedLastIndex`, `sortedLastIndexBy`, `startCase`, `startsWith`, `sum`,
* `sumBy`, `template`, `toLower`, `toInteger`, `toSafeInteger`, `toString`,
* `toUpper`, `trim`, `trimLeft`, `trimRight`, `trunc`, `unescape`, `uniqueId`,
* `toUpper`, `trim`, `trimLeft`, `trimRight`, `truncate`, `unescape`, `uniqueId`,
* `upperCase`, `upperFirst`, `value`, and `words`
*
* @name _
@@ -11891,27 +11891,27 @@
* @returns {string} Returns the truncated string.
* @example
*
* _.trunc('hi-diddly-ho there, neighborino');
* _.truncate('hi-diddly-ho there, neighborino');
* // => 'hi-diddly-ho there, neighbo...'
*
* _.trunc('hi-diddly-ho there, neighborino', {
* _.truncate('hi-diddly-ho there, neighborino', {
* 'length': 24,
* 'separator': ' '
* });
* // => 'hi-diddly-ho there,...'
*
* _.trunc('hi-diddly-ho there, neighborino', {
* _.truncate('hi-diddly-ho there, neighborino', {
* 'length': 24,
* 'separator': /,? +/
* });
* // => 'hi-diddly-ho there...'
*
* _.trunc('hi-diddly-ho there, neighborino', {
* _.truncate('hi-diddly-ho there, neighborino', {
* 'omission': ' [...]'
* });
* // => 'hi-diddly-ho there, neig [...]'
*/
function trunc(string, options) {
function truncate(string, options) {
var length = DEFAULT_TRUNC_LENGTH,
omission = DEFAULT_TRUNC_OMISSION;
@@ -13264,7 +13264,7 @@
lodash.trim = trim;
lodash.trimLeft = trimLeft;
lodash.trimRight = trimRight;
lodash.trunc = trunc;
lodash.truncate = truncate;
lodash.unescape = unescape;
lodash.uniqueId = uniqueId;
lodash.upperCase = upperCase;

View File

@@ -268,7 +268,7 @@ function isJobId(value) {
*/
function logInline(text) {
var blankLine = _.repeat(' ', _.size(prevLine));
prevLine = text = _.trunc(text, { 'length': 40 });
prevLine = text = _.truncate(text, { 'length': 40 });
process.stdout.write(text + blankLine.slice(text.length) + '\r');
}

View File

@@ -18499,7 +18499,7 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.trunc');
QUnit.module('lodash.truncate');
(function() {
var string = 'hi-diddly-ho there, neighborino';
@@ -18507,46 +18507,46 @@
QUnit.test('should truncate to a length of `30` by default', function(assert) {
assert.expect(1);
assert.strictEqual(_.trunc(string), 'hi-diddly-ho there, neighbo...');
assert.strictEqual(_.truncate(string), 'hi-diddly-ho there, neighbo...');
});
QUnit.test('should not truncate if `string` is <= `length`', function(assert) {
assert.expect(2);
assert.strictEqual(_.trunc(string, { 'length': string.length }), string);
assert.strictEqual(_.trunc(string, { 'length': string.length + 2 }), string);
assert.strictEqual(_.truncate(string, { 'length': string.length }), string);
assert.strictEqual(_.truncate(string, { 'length': string.length + 2 }), string);
});
QUnit.test('should truncate string the given length', function(assert) {
assert.expect(1);
assert.strictEqual(_.trunc(string, { 'length': 24 }), 'hi-diddly-ho there, n...');
assert.strictEqual(_.truncate(string, { 'length': 24 }), 'hi-diddly-ho there, n...');
});
QUnit.test('should support a `omission` option', function(assert) {
assert.expect(1);
assert.strictEqual(_.trunc(string, { 'omission': ' [...]' }), 'hi-diddly-ho there, neig [...]');
assert.strictEqual(_.truncate(string, { 'omission': ' [...]' }), 'hi-diddly-ho there, neig [...]');
});
QUnit.test('should support a `length` option', function(assert) {
assert.expect(1);
assert.strictEqual(_.trunc(string, { 'length': 4 }), 'h...');
assert.strictEqual(_.truncate(string, { 'length': 4 }), 'h...');
});
QUnit.test('should support a `separator` option', function(assert) {
assert.expect(2);
assert.strictEqual(_.trunc(string, { 'length': 24, 'separator': ' ' }), 'hi-diddly-ho there,...');
assert.strictEqual(_.trunc(string, { 'length': 24, 'separator': /,? +/ }), 'hi-diddly-ho there...');
assert.strictEqual(_.truncate(string, { 'length': 24, 'separator': ' ' }), 'hi-diddly-ho there,...');
assert.strictEqual(_.truncate(string, { 'length': 24, 'separator': /,? +/ }), 'hi-diddly-ho there...');
});
QUnit.test('should treat negative `length` as `0`', function(assert) {
assert.expect(2);
lodashStable.each([0, -2], function(length) {
assert.strictEqual(_.trunc(string, { 'length': length }), '...');
assert.strictEqual(_.truncate(string, { 'length': length }), '...');
});
});
@@ -18555,21 +18555,21 @@
lodashStable.each(['', NaN, 4.6, '4'], function(length, index) {
var actual = index > 1 ? 'h...' : '...';
assert.strictEqual(_.trunc(string, { 'length': { 'valueOf': lodashStable.constant(length) } }), actual);
assert.strictEqual(_.truncate(string, { 'length': { 'valueOf': lodashStable.constant(length) } }), actual);
});
});
QUnit.test('should coerce `string` to a string', function(assert) {
assert.expect(2);
assert.strictEqual(_.trunc(Object(string), { 'length': 4 }), 'h...');
assert.strictEqual(_.trunc({ 'toString': lodashStable.constant(string) }, { 'length': 5 }), 'hi...');
assert.strictEqual(_.truncate(Object(string), { 'length': 4 }), 'h...');
assert.strictEqual(_.truncate({ 'toString': lodashStable.constant(string) }, { 'length': 5 }), 'hi...');
});
QUnit.test('should work as an iteratee for methods like `_.map`', function(assert) {
assert.expect(1);
var actual = lodashStable.map([string, string, string], _.trunc),
var actual = lodashStable.map([string, string, string], _.truncate),
truncated = 'hi-diddly-ho there, neighbo...';
assert.deepEqual(actual, [truncated, truncated, truncated]);
@@ -19752,20 +19752,20 @@
assert.strictEqual(_.trimLeft(trimString, chars), string + trimChars);
assert.strictEqual(_.trimRight(trimString, chars), trimChars + string);
assert.strictEqual(_.trunc(string, { 'length': 13 }), string);
assert.strictEqual(_.trunc(string, { 'length': 6 }), 'A ' + leafs + '...');
assert.strictEqual(_.truncate(string, { 'length': 13 }), string);
assert.strictEqual(_.truncate(string, { 'length': 6 }), 'A ' + leafs + '...');
assert.deepEqual(_.words(string), ['A', leafs, comboGlyph, 'and', rocket]);
lodashStable.times(2, function(index) {
var separator = index ? RegExp(hearts) : hearts,
options = { 'length': 4, 'separator': separator },
actual = _.trunc(string, options);
actual = _.truncate(string, options);
assert.strictEqual(actual, 'A...');
assert.strictEqual(actual.length, 4);
actual = _.trunc(allHearts, options);
actual = _.truncate(allHearts, options);
assert.strictEqual(actual, hearts + '...');
assert.strictEqual(actual.length, 5);
});
@@ -21746,7 +21746,7 @@
'trim',
'trimLeft',
'trimRight',
'trunc',
'truncate',
'unescape',
'upperCase',
'upperFirst'
@@ -21881,7 +21881,7 @@
'trim',
'trimLeft',
'trimRight',
'trunc',
'truncate',
'unescape',
'upperCase',
'upperFirst'