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