Add fp.restFrom and fp.spreadFrom.

This commit is contained in:
John-David Dalton
2016-03-13 15:13:39 -07:00
parent 81ee5d76b8
commit 4d185ae7b5
2 changed files with 42 additions and 7 deletions

View File

@@ -59,13 +59,14 @@ exports.aryMethod = {
'map', 'mapKeys', 'mapValues', 'matchesProperty', 'maxBy', 'merge', 'minBy',
'omit', 'omitBy', 'overArgs', 'pad', 'padEnd', 'padStart', 'parseInt', 'partial',
'partialRight', 'partition', 'pick', 'pickBy', 'pull', 'pullAll', 'pullAt',
'random', 'range', 'rangeRight', 'rearg', 'reject', 'remove', 'repeat', 'result',
'sampleSize', 'some', 'sortBy', 'sortedIndex', 'sortedIndexOf', 'sortedLastIndex',
'sortedLastIndexOf', 'sortedUniqBy', 'split', 'startsWith', 'subtract', 'sumBy',
'take', 'takeRight', 'takeRightWhile', 'takeWhile', 'tap', 'throttle', 'thru',
'times', 'trimChars', 'trimCharsEnd', 'trimCharsStart', 'truncate', 'union',
'uniqBy', 'uniqWith', 'unset', 'unzipWith', 'without', 'wrap', 'xor', 'zip',
'zipObject', 'zipObjectDeep'
'random', 'range', 'rangeRight', 'rearg', 'reject', 'remove', 'repeat',
'restFrom', 'result', 'sampleSize', 'some', 'sortBy', 'sortedIndex',
'sortedIndexOf', 'sortedLastIndex', 'sortedLastIndexOf', 'sortedUniqBy',
'split', 'spreadFrom', 'startsWith', 'subtract', 'sumBy', 'take', 'takeRight',
'takeRightWhile', 'takeWhile', 'tap', 'throttle', 'thru', 'times', 'trimChars',
'trimCharsEnd', 'trimCharsStart', 'truncate', 'union', 'uniqBy', 'uniqWith',
'unset', 'unzipWith', 'without', 'wrap', 'xor', 'zip', 'zipObject',
'zipObjectDeep'
],
'3': [
'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith',
@@ -219,6 +220,8 @@ exports.remap = {
'curryN': 'curry',
'curryRightN': 'curryRight',
'getOr': 'get',
'restFrom': 'rest',
'spreadFrom': 'spread',
'trimChars': 'trim',
'trimCharsEnd': 'trimEnd',
'trimCharsStart': 'trimStart'

View File

@@ -1447,6 +1447,22 @@
/*--------------------------------------------------------------------------*/
QUnit.module('fp.restFrom');
(function() {
QUnit.test('should accept a `start` param', function(assert) {
assert.expect(1);
var actual = fp.restFrom(2)(function() {
return slice.call(arguments);
})('a', 'b', 'c', 'd');
assert.deepEqual(actual, ['a', 'b', ['c', 'd']]);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('fp.runInContext');
(function() {
@@ -1466,6 +1482,22 @@
/*--------------------------------------------------------------------------*/
QUnit.module('fp.spreadFrom');
(function() {
QUnit.test('should accept a `start` param', function(assert) {
assert.expect(1);
var actual = fp.spreadFrom(2)(function() {
return slice.call(arguments);
})('a', 'b', ['c', 'd']);
assert.deepEqual(actual, ['a', 'b', 'c', 'd']);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('fp.trimChars');
_.each(['trimChars', 'trimCharsStart', 'trimCharsEnd'], function(methodName, index) {