From 5218fd2c2491e37c6780155e6229a98cac66a5f5 Mon Sep 17 00:00:00 2001 From: Xotic750 Date: Mon, 26 Oct 2015 21:16:43 +0100 Subject: [PATCH] Rename `_.trunc` to `_.truncate`. --- lib/fp/mapping.js | 4 ++-- lodash.js | 16 ++++++++-------- test/saucelabs.js | 2 +- test/test.js | 40 ++++++++++++++++++++-------------------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/fp/mapping.js b/lib/fp/mapping.js index 45ebcf655..66800a838 100644 --- a/lib/fp/mapping.js +++ b/lib/fp/mapping.js @@ -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,' + diff --git a/lodash.js b/lodash.js index 1007ab41b..7f819eca3 100644 --- a/lodash.js +++ b/lodash.js @@ -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; diff --git a/test/saucelabs.js b/test/saucelabs.js index 35ab6969f..55a001486 100644 --- a/test/saucelabs.js +++ b/test/saucelabs.js @@ -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'); } diff --git a/test/test.js b/test/test.js index 273901f0d..b15da8547 100644 --- a/test/test.js +++ b/test/test.js @@ -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'