Skip to content

Commit

Permalink
Remove remaining rest helper use.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Jan 10, 2017
1 parent 648722f commit aacfefc
Show file tree
Hide file tree
Showing 25 changed files with 53 additions and 165 deletions.
14 changes: 0 additions & 14 deletions _castRest.js

This file was deleted.

5 changes: 2 additions & 3 deletions _createAssigner.js
@@ -1,4 +1,3 @@
import baseRest from './_baseRest.js';
import isIterateeCall from './_isIterateeCall.js';

/**
Expand All @@ -9,7 +8,7 @@ import isIterateeCall from './_isIterateeCall.js';
* @returns {Function} Returns the new assigner function.
*/
function createAssigner(assigner) {
return baseRest((object, sources) => {
return (object, ...sources) => {
let index = -1;
let length = sources.length;
let customizer = length > 1 ? sources[length - 1] : undefined;
Expand All @@ -31,7 +30,7 @@ function createAssigner(assigner) {
}
}
return object;
});
};
}

export default createAssigner;
5 changes: 2 additions & 3 deletions _createFlow.js
@@ -1,5 +1,4 @@
import LodashWrapper from './_LodashWrapper.js';
import flatRest from './_flatRest.js';
import getData from './_getData.js';
import getFuncName from './_getFuncName.js';
import isArray from './isArray.js';
Expand All @@ -22,7 +21,7 @@ const WRAP_REARG_FLAG = 256;
* @returns {Function} Returns the new flow function.
*/
function createFlow(fromRight) {
return flatRest(funcs => {
return (...funcs) => {
const length = funcs.length;
const prereq = LodashWrapper.prototype.thru;

Expand Down Expand Up @@ -74,7 +73,7 @@ function createFlow(fromRight) {
}
return result;
};
});
};
}

export default createFlow;
10 changes: 4 additions & 6 deletions _createOver.js
@@ -1,9 +1,7 @@
import apply from './_apply.js';
import arrayMap from './_arrayMap.js';
import baseIteratee from './_baseIteratee.js';
import baseRest from './_baseRest.js';
import baseUnary from './_baseUnary.js';
import flatRest from './_flatRest.js';

/**
* Creates a function like `_.over`.
Expand All @@ -13,13 +11,13 @@ import flatRest from './_flatRest.js';
* @returns {Function} Returns the new over function.
*/
function createOver(arrayFunc) {
return flatRest(iteratees => {
return (...iteratees) => {
iteratees = arrayMap(iteratees, baseUnary(baseIteratee));
return baseRest(function(args) {
return (...args) => {
const thisArg = this;
return arrayFunc(iteratees, iteratee => apply(iteratee, thisArg, args));
});
});
};
};
}

export default createOver;
16 changes: 0 additions & 16 deletions _flatRest.js

This file was deleted.

36 changes: 0 additions & 36 deletions _overRest.js

This file was deleted.

5 changes: 3 additions & 2 deletions at.js
@@ -1,5 +1,4 @@
import baseAt from './_baseAt.js';
import flatRest from './_flatRest.js';

/**
* Creates an array of values corresponding to `paths` of `object`.
Expand All @@ -18,6 +17,8 @@ import flatRest from './_flatRest.js';
* _.at(object, ['a[0].b.c', 'a[1]']);
* // => [3, 4]
*/
const at = flatRest(baseAt);
function at(...paths) {
return baseAt(paths);
}

export default at;
5 changes: 2 additions & 3 deletions attempt.js
@@ -1,5 +1,4 @@
import apply from './_apply.js';
import baseRest from './_baseRest.js';
import isError from './isError.js';

/**
Expand All @@ -24,12 +23,12 @@ import isError from './isError.js';
* elements = [];
* }
*/
const attempt = baseRest((func, args) => {
function attempt(func, ...args) {
try {
return apply(func, undefined, args);
} catch (e) {
return isError(e) ? e : new Error(e);
}
});
}

export default attempt;
5 changes: 2 additions & 3 deletions bind.js
@@ -1,4 +1,3 @@
import baseRest from './_baseRest.js';
import createWrap from './_createWrap.js';
import getHolder from './_getHolder.js';
import replaceHolders from './_replaceHolders.js';
Expand Down Expand Up @@ -42,15 +41,15 @@ const WRAP_PARTIAL_FLAG = 32;
* bound('hi');
* // => 'hi fred!'
*/
const bind = baseRest((func, thisArg, partials) => {
function bind(func, thisArg, ...partials) {
let holders;
let bitmask = WRAP_BIND_FLAG;
if (partials.length) {
holders = replaceHolders(partials, getHolder(bind));
bitmask |= WRAP_PARTIAL_FLAG;
}
return createWrap(func, bitmask, thisArg, partials, holders);
});
}

// Assign default placeholders.
bind.placeholder = {};
Expand Down
5 changes: 2 additions & 3 deletions bindAll.js
@@ -1,7 +1,6 @@
import arrayEach from './_arrayEach.js';
import baseAssignValue from './_baseAssignValue.js';
import bind from './bind.js';
import flatRest from './_flatRest.js';
import toKey from './_toKey.js';

/**
Expand Down Expand Up @@ -30,12 +29,12 @@ import toKey from './_toKey.js';
* jQuery(element).on('click', view.click);
* // => Logs 'clicked docs' when clicked.
*/
const bindAll = flatRest((object, methodNames) => {
function bindAll(object, ...methodNames) {
arrayEach(methodNames, key => {
key = toKey(key);
baseAssignValue(object, key, bind(object[key], object));
});
return object;
});
}

export default bindAll;
5 changes: 2 additions & 3 deletions bindKey.js
@@ -1,4 +1,3 @@
import baseRest from './_baseRest.js';
import createWrap from './_createWrap.js';
import getHolder from './_getHolder.js';
import replaceHolders from './_replaceHolders.js';
Expand Down Expand Up @@ -53,15 +52,15 @@ const WRAP_PARTIAL_FLAG = 32;
* bound('hi');
* // => 'hiya fred!'
*/
const bindKey = baseRest((object, key, partials) => {
function bindKey(object, key, ...partials) {
let holders;
let bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
if (partials.length) {
holders = replaceHolders(partials, getHolder(bindKey));
bitmask |= WRAP_PARTIAL_FLAG;
}
return createWrap(key, bitmask, object, partials, holders);
});
}

// Assign default placeholders.
bindKey.placeholder = {};
Expand Down
5 changes: 2 additions & 3 deletions cond.js
@@ -1,7 +1,6 @@
import apply from './_apply.js';
import arrayMap from './_arrayMap.js';
import baseIteratee from './_baseIteratee.js';
import baseRest from './_baseRest.js';

/** Error message constants. */
const FUNC_ERROR_TEXT = 'Expected a function';
Expand Down Expand Up @@ -46,15 +45,15 @@ function cond(pairs) {
return [toIteratee(pair[0]), pair[1]];
});

return baseRest(function(args) {
return (...args) => {
let index = -1;
while (++index < length) {
const pair = pairs[index];
if (apply(pair[0], this, args)) {
return apply(pair[1], this, args);
}
}
});
};
}

export default cond;
5 changes: 2 additions & 3 deletions defaults.js
@@ -1,6 +1,5 @@
import apply from './_apply.js';
import assignInWith from './assignInWith.js';
import baseRest from './_baseRest.js';
import customDefaultsAssignIn from './_customDefaultsAssignIn.js';

/**
Expand All @@ -24,9 +23,9 @@ import customDefaultsAssignIn from './_customDefaultsAssignIn.js';
* _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
* // => { 'a': 1, 'b': 2 }
*/
const defaults = baseRest(args => {
function defaults(...args) {
args.push(undefined, customDefaultsAssignIn);
return apply(assignInWith, undefined, args);
});
}

export default defaults;
5 changes: 2 additions & 3 deletions defaultsDeep.js
@@ -1,5 +1,4 @@
import apply from './_apply.js';
import baseRest from './_baseRest.js';
import customDefaultsMerge from './_customDefaultsMerge.js';
import mergeWith from './mergeWith.js';

Expand All @@ -22,9 +21,9 @@ import mergeWith from './mergeWith.js';
* _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
* // => { 'a': { 'b': 2, 'c': 3 } }
*/
const defaultsDeep = baseRest(args => {
function defaultsDeep(...args) {
args.push(undefined, customDefaultsMerge);
return apply(mergeWith, undefined, args);
});
}

export default defaultsDeep;
5 changes: 3 additions & 2 deletions invoke.js
@@ -1,5 +1,4 @@
import baseInvoke from './_baseInvoke.js';
import baseRest from './_baseRest.js';

/**
* Invokes the method at `path` of `object`.
Expand All @@ -19,6 +18,8 @@ import baseRest from './_baseRest.js';
* _.invoke(object, 'a[0].b.c.slice', 1, 3);
* // => [2, 3]
*/
const invoke = baseRest(baseInvoke);
function invoke(object, path, ...args) {
return baseInvoke(object, path, args);
}

export default invoke;
5 changes: 3 additions & 2 deletions method.js
@@ -1,5 +1,4 @@
import baseInvoke from './_baseInvoke.js';
import baseRest from './_baseRest.js';

/**
* Creates a function that invokes the method at `path` of a given object.
Expand All @@ -25,6 +24,8 @@ import baseRest from './_baseRest.js';
* _.map(objects, _.method(['a', 'b']));
* // => [2, 1]
*/
const method = baseRest((path, args) => object => baseInvoke(object, path, args));
function method(path, ...args) {
return object => baseInvoke(object, path, args);
}

export default method;
5 changes: 3 additions & 2 deletions methodOf.js
@@ -1,5 +1,4 @@
import baseInvoke from './_baseInvoke.js';
import baseRest from './_baseRest.js';

/**
* The opposite of `_.method`; this method creates a function that invokes
Expand All @@ -24,6 +23,8 @@ import baseRest from './_baseRest.js';
* _.map([['a', '2'], ['c', '0']], _.methodOf(object));
* // => [2, 0]
*/
const methodOf = baseRest((object, args) => path => baseInvoke(object, path, args));
function methodOf(object, ...args) {
return path => baseInvoke(object, path, args);
}

export default methodOf;
3 changes: 1 addition & 2 deletions nthArg.js
@@ -1,5 +1,4 @@
import baseNth from './_baseNth.js';
import baseRest from './_baseRest.js';
import toInteger from './toInteger.js';

/**
Expand All @@ -24,7 +23,7 @@ import toInteger from './toInteger.js';
*/
function nthArg(n) {
n = toInteger(n);
return baseRest(args => baseNth(args, n));
return (...args) => baseNth(args, n);
}

export default nthArg;
5 changes: 3 additions & 2 deletions pick.js
@@ -1,5 +1,4 @@
import basePick from './_basePick.js';
import flatRest from './_flatRest.js';

/**
* Creates an object composed of the picked `object` properties.
Expand All @@ -18,6 +17,8 @@ import flatRest from './_flatRest.js';
* _.pick(object, ['a', 'c']);
* // => { 'a': 1, 'c': 3 }
*/
const pick = flatRest((object, paths) => object == null ? {} : basePick(object, paths));
function pick(object, ...paths) {
return object == null ? {} : basePick(object, paths);
}

export default pick;

0 comments on commit aacfefc

Please sign in to comment.