Skip to content

Commit

Permalink
Remove apply.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Feb 25, 2017
1 parent b9c61ee commit 37f168d
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 45 deletions.
21 changes: 0 additions & 21 deletions .internal/apply.js

This file was deleted.

3 changes: 1 addition & 2 deletions attempt.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import apply from './.internal/apply.js'
import isError from './isError.js'

/**
Expand All @@ -22,7 +21,7 @@ import isError from './isError.js'
*/
function attempt(func, ...args) {
try {
return apply(func, undefined, args)
return func.apply(undefined, args)
} catch (e) {
return isError(e) ? e : new Error(e)
}
Expand Down
5 changes: 2 additions & 3 deletions cond.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import apply from './.internal/apply.js'
import arrayMap from './.internal/arrayMap.js'

/**
Expand Down Expand Up @@ -42,8 +41,8 @@ function cond(pairs) {
let index = -1
while (++index < length) {
const pair = pairs[index]
if (apply(pair[0], this, args)) {
return apply(pair[1], this, args)
if (pair[0].apply(this, args)) {
return pair[1].apply(this, args)
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions defaultsDeep.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import apply from './.internal/apply.js'
import customDefaultsMerge from './.internal/customDefaultsMerge.js'
import mergeWith from './mergeWith.js'

Expand All @@ -21,7 +20,7 @@ import mergeWith from './mergeWith.js'
*/
function defaultsDeep(...args) {
args.push(undefined, customDefaultsMerge)
return apply(mergeWith, undefined, args)
return mergeWith.apply(undefined, args)
}

export default defaultsDeep
3 changes: 1 addition & 2 deletions invoke.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import apply from './.internal/apply.js'
import castPath from './.internal/castPath.js'
import last from './last.js'
import parent from './.internal/parent.js'
Expand All @@ -24,7 +23,7 @@ function invoke(object, path, args) {
path = castPath(path, object)
object = parent(object, path)
const func = object == null ? object : object[toKey(last(path))]
return func == null ? undefined : apply(func, object, args)
return func == null ? undefined : func.apply(object, args)
}

export default invoke
3 changes: 1 addition & 2 deletions invokeMap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import apply from './.internal/apply.js'
import baseEach from './.internal/baseEach.js'
import invoke from './invoke.js'
import isArrayLike from './isArrayLike.js'
Expand Down Expand Up @@ -30,7 +29,7 @@ function invokeMap(collection, path, args) {
const result = isArrayLike(collection) ? Array(collection.length) : []

baseEach(collection, value => {
result[++index] = isFunc ? apply(path, value, args) : invoke(value, path, args)
result[++index] = isFunc ? path.apply(value, args) : invoke(value, path, args)
})
return result
}
Expand Down
4 changes: 1 addition & 3 deletions over.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import apply from './.internal/apply.js'
import arrayMap from './.internal/arrayMap.js'

/**
Expand All @@ -19,8 +18,7 @@ import arrayMap from './.internal/arrayMap.js'
*/
function over(iteratees) {
return function(...args) {
const thisArg = this
return arrayMap(iteratees, iteratee => apply(iteratee, thisArg, args))
return arrayMap(iteratees, iteratee => iteratee.apply(this, args))
}
}

Expand Down
3 changes: 1 addition & 2 deletions overArgs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import apply from './.internal/apply.js'

/**
* Creates a function that invokes `func` with its arguments transformed.
Expand Down Expand Up @@ -35,7 +34,7 @@ function overArgs(func, transforms) {
while (++index < length) {
args[index] = transforms[index].call(this, args[index])
}
return apply(func, this, args)
return func.apply(this, args)
}
}

Expand Down
4 changes: 1 addition & 3 deletions overEvery.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import apply from './.internal/apply.js'
import arrayEvery from './.internal/arrayEvery.js'

/**
Expand All @@ -25,8 +24,7 @@ import arrayEvery from './.internal/arrayEvery.js'
*/
function overEvery(iteratees) {
return function(...args) {
const thisArg = this
return arrayEvery(iteratees, iteratee => apply(iteratee, thisArg, args))
return arrayEvery(iteratees, iteratee => iteratee.apply(this, args))
}
}

Expand Down
4 changes: 1 addition & 3 deletions overSome.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import apply from './.internal/apply.js'
import arraySome from './.internal/arraySome.js'

/**
Expand All @@ -25,8 +24,7 @@ import arraySome from './.internal/arraySome.js'
*/
function overSome(iteratees) {
return function(...args) {
const thisArg = this
return arraySome(iteratees, iteratee => apply(iteratee, thisArg, args))
return arraySome(iteratees, iteratee => iteratee.apply(this, args))
}
}

Expand Down
3 changes: 1 addition & 2 deletions unzipWith.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import apply from './.internal/apply.js'
import arrayMap from './.internal/arrayMap.js'
import unzip from './unzip.js'

Expand Down Expand Up @@ -26,7 +25,7 @@ function unzipWith(array, iteratee) {
return []
}
const result = unzip(array)
return arrayMap(result, group => apply(iteratee, undefined, group))
return arrayMap(result, group => iteratee.apply(undefined, group))
}

export default unzipWith

0 comments on commit 37f168d

Please sign in to comment.