function curry(len, f) {
    for (var _len = arguments.length, initArgs = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
      initArgs[_key - 2] = arguments[_key];
    }

    var _ref = function () {
      switch (true) {
        case _extractHiddenClass(len) === 'Function':
          var args = f == null ? [] : [f].concat(initArgs);
          return [len, len.length, args];
        case _extractHiddenClass(len) === 'Number':
          return [f, len, initArgs];
        default:
          throw new TypeError('Unrecognized arguments ' + len + ' and ' + f + ' to function curry.');
      }
    }(),
        _ref2 = _slicedToArray(_ref, 3),
        fn = _ref2[0],
        arity = _ref2[1],
        fnArgs = _ref2[2];

    if (!fn) {
      return function (fn) {
        for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
          args[_key2 - 1] = arguments[_key2];
        }

        return curry.apply(this, [arity, fn].concat(args));
      };
    }

    var helper = function helper(args) {
      return function () {
        for (var _len3 = arguments.length, rest = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
          rest[_key3] = arguments[_key3];
        }

        return currier.call(this, arity, fn, [].concat(_toConsumableArray(args), rest));
      };
    };

    var currier = function currier(length, f, args) {
      if (args.length >= length) {

        // ES 6 classes and built-ins, real or polyfilled, throw a TypeError if you try to call them
        // as a function.
        try {
          return f.apply(this, args);
        } catch (e) {
          if (e instanceof TypeError) {
            return _applyConstructor(f, args);
          } else {
            throw e;
          }
        }
      } else {
        return helper(args);
      }
    };

    return currier.call(this, arity, fn, fnArgs);
  }
function curry(len, f) {
    for (var _len = arguments.length, initArgs = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
      initArgs[_key - 2] = arguments[_key];
    }

    var _ref = function () {
      switch (true) {
        case _extractHiddenClass(len) === 'Function':
          var args = f == null ? [] : [f].concat(initArgs);
          return [len, len.length, args];
        case _extractHiddenClass(len) === 'Number':
          return [f, len, initArgs];
        default:
          throw new TypeError('Unrecognized arguments ' + len + ' and ' + f + ' to function curry.');
      }
    }(),
        _ref2 = _slicedToArray(_ref, 3),
        fn = _ref2[0],
        arity = _ref2[1],
        fnArgs = _ref2[2];

    if (!fn) {
      return function (fn) {
        for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
          args[_key2 - 1] = arguments[_key2];
        }

        return curry.apply(this, [arity, fn].concat(args));
      };
    }

    var helper = function helper(args) {
      return function () {
        for (var _len3 = arguments.length, rest = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
          rest[_key3] = arguments[_key3];
        }

        return currier.call(this, arity, fn, [].concat(_toConsumableArray(args), rest));
      };
    };

    var currier = function currier(length, f, args) {
      if (args.length >= length) {

        
        
        try {
          return f.apply(this, args);
        } catch (e) {
          if (e instanceof TypeError) {
            return _applyConstructor(f, args);
          } else {
            throw e;
          }
        }
      } else {
        return helper(args);
      }
    };

    return currier.call(this, arity, fn, fnArgs);
  }
function curry ( len , f ) { for ( var _len = arguments . length , initArgs = Array ( _len > 2 ? _len - 2 : 0 ) , _key = 2 ; _key < _len ; _key ++ ) { initArgs [ _key - 2 ] = arguments [ _key ] ; } var _ref = function ( ) { switch ( true ) { case _extractHiddenClass ( len ) === 'Function' : var args = f == null ? [ ] : [ f ] . concat ( initArgs ) ; return [ len , len . length , args ] ; case _extractHiddenClass ( len ) === 'Number' : return [ f , len , initArgs ] ; default : throw new TypeError ( 'Unrecognized arguments ' + len + ' and ' + f + ' to function curry.' ) ; } } ( ) , _ref2 = _slicedToArray ( _ref , 3 ) , fn = _ref2 [ 0 ] , arity = _ref2 [ 1 ] , fnArgs = _ref2 [ 2 ] ; if ( ! fn ) { return function ( fn ) { for ( var _len2 = arguments . length , args = Array ( _len2 > 1 ? _len2 - 1 : 0 ) , _key2 = 1 ; _key2 < _len2 ; _key2 ++ ) { args [ _key2 - 1 ] = arguments [ _key2 ] ; } return curry . apply ( this , [ arity , fn ] . concat ( args ) ) ; } ; } var helper = function helper ( args ) { return function ( ) { for ( var _len3 = arguments . length , rest = Array ( _len3 ) , _key3 = 0 ; _key3 < _len3 ; _key3 ++ ) { rest [ _key3 ] = arguments [ _key3 ] ; } return currier . call ( this , arity , fn , [ ] . concat ( _toConsumableArray ( args ) , rest ) ) ; } ; } ; var currier = function currier ( length , f , args ) { if ( args . length >= length ) { // ES 6 classes and built-ins, real or polyfilled, throw a TypeError if you try to call them // as a function. try { return f . apply ( this , args ) ; } catch ( e ) { if ( e instanceof TypeError ) { return _applyConstructor ( f , args ) ; } else { throw e ; } } } else { return helper ( args ) ; } } ; return currier . call ( this , arity , fn , fnArgs ) ; }
NOTE: the 'this' context will be determined at the time the curried function receives its **final** argument.
NOTE : the this context will be determined at the time the curried function receives its ** final ** argument .