From 06ab879e3759466e0756d30ba6600b5658ee393e Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Fri, 10 Aug 2018 07:50:02 +0000 Subject: [PATCH] Travis build: 210 --- README.md | 8 +++----- docs/function.html | 6 ++---- snippets/bindKey.md | 3 ++- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 249221388..da1f64dc8 100644 --- a/README.md +++ b/README.md @@ -4467,13 +4467,11 @@ console.log(freddyBound('hi', '!')); // 'hi fred!' Creates a function that invokes the method at a given key of an object, optionally adding any additional supplied parameters to the beginning of the arguments. Return a `function` that uses `Function.apply()` to bind `context[fn]` to `context`. -Use `Array.concat()` to prepend any additional supplied parameters to the arguments. +Use the spread operator (`...`) to prepend any additional supplied parameters to the arguments. ```js -const bindKey = (context, fn, ...args) => - function() { - return context[fn].apply(context, args.concat(...arguments)); - }; +const bindKey = (context, fn, ...boundArgs) => (...args) => + context[fn].apply(context, [...boundArgs, ...args]); ```
diff --git a/docs/function.html b/docs/function.html index a74ab6151..76e32be6f 100644 --- a/docs/function.html +++ b/docs/function.html @@ -97,10 +97,8 @@ const freddy = { user: 'fred' }; const freddyBound = bind(greet, freddy); console.log(freddyBound('hi', '!')); // 'hi fred!' -

bindKey

Creates a function that invokes the method at a given key of an object, optionally adding any additional supplied parameters to the beginning of the arguments.

Return a function that uses Function.apply() to bind context[fn] to context. Use Array.concat() to prepend any additional supplied parameters to the arguments.

const bindKey = (context, fn, ...args) =>
-  function() {
-    return context[fn].apply(context, args.concat(...arguments));
-  };
+

bindKey

Creates a function that invokes the method at a given key of an object, optionally adding any additional supplied parameters to the beginning of the arguments.

Return a function that uses Function.apply() to bind context[fn] to context. Use the spread operator (...) to prepend any additional supplied parameters to the arguments.

const bindKey = (context, fn, ...boundArgs) => (...args) =>
+  context[fn].apply(context, [...boundArgs, ...args]);
 
const freddy = {
   user: 'fred',
   greet: function(greeting, punctuation) {
diff --git a/snippets/bindKey.md b/snippets/bindKey.md
index faa193364..32fd8838e 100644
--- a/snippets/bindKey.md
+++ b/snippets/bindKey.md
@@ -6,7 +6,8 @@ Return a `function` that uses `Function.apply()` to bind `context[fn]` to `conte
 Use the spread operator (`...`) to prepend any additional supplied parameters to the arguments.
 
 ```js
-const bindKey = (context, fn, ...boundArgs) => (...args) => context[fn].apply(context, [...boundArgs, ...args]);
+const bindKey = (context, fn, ...boundArgs) => (...args) =>
+  context[fn].apply(context, [...boundArgs, ...args]);
 ```
 
 ```js