From ecb3c108d1aa9c87a7f5c408dc837805882aaac5 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 23 Mar 2017 23:19:55 -0700 Subject: [PATCH] Simplify `flip`. --- flip.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flip.js b/flip.js index 5662563b7..3c1cb3865 100644 --- a/flip.js +++ b/flip.js @@ -1,8 +1,3 @@ -import createWrap from './.internal/createWrap.js' - -/** Used to compose bitmasks for function metadata. */ -const WRAP_FLIP_FLAG = 512 - /** * Creates a function that invokes `func` with arguments reversed. * @@ -19,7 +14,12 @@ const WRAP_FLIP_FLAG = 512 * // => ['d', 'c', 'b', 'a'] */ function flip(func) { - return createWrap(func, WRAP_FLIP_FLAG) + if (typeof func != 'function') { + throw new TypeError('Expected a function') + } + return function(...args) { + return func.apply(this, args.reverse()) + } } export default flip