If maybe_fn is a function, curries it and passes in first_arg. Otherwise
    returns maybe_fn.
163694
def maybe_curry(maybe_fn, first_arg) -> 'Function | Any':
    
    if not callable(maybe_fn):
        return maybe_fn
    return tz.curry(maybe_fn)(first_arg)
933281
function flip(f, x, y) {
  if(!isFunction(f)) {
    throw new TypeError(
      'flip: Function required for first argument'
    )
  }

  return curry(f)(y, x)
}
22706
function callOnce(fn) {
  var called = false

  return calledOnceShim

  //-----------------------------------
  function calledOnceShim() {
    if (called) return
    called = true

    fn.apply(this, arguments)
  }
}
1066745
def sometimesish(fn):
    
    def wrapped(*args, **kwargs):
        if random.randint(1, 2) == 1:
            return fn(*args, **kwargs)

    return wrapped
1118160
def check(f):
    
    if hasattr(f, 'wrapped_fn'):
        return f
    else:
        @wraps(f)
        def decorated(*args, **kwargs):
            return check_conditions(f, args, kwargs)
        decorated.wrapped_fn = f
        return decorated
922849
def _function_has_n_args(self, func, n):
        
        if inspect.ismethod(func):
            n += 1

        argspec = inspect.getargspec(func)
        defaults = argspec.defaults or ()

        return len(argspec.args) - len(defaults) == n
448073
function(fn) {
		return function() {
			var realArgs = [];
			var fnArgs = arguments;
			each(fnArgs, function(val, i) {
				if (i <= fnArgs.length) {
					while (val && val.isComputed) {
						val = val();
					}
					realArgs.push(val);
				}
			});
			return fn.apply(this, realArgs);
		};
	}
1324119
def is_decorated(cls, f):
        ''''''
        real_func = inspect.unwrap(f)
        return real_func in cls.DECORATED_FUNCTIONS
621074
def make_context_aware(func, numargs):
    
    try:
        if inspect.ismethod(func):
            arg_count = len(inspect.getargspec(func).args) - 1
        elif inspect.isfunction(func):
            arg_count = len(inspect.getargspec(func).args)
        elif inspect.isclass(func):
            arg_count = len(inspect.getargspec(func.__init__).args) - 1
        else:
            arg_count = len(inspect.getargspec(func.__call__).args) - 1
    except TypeError:
        arg_count = numargs

    if arg_count <= numargs:
        def normalized(*args):
            return func(*args[:-1])

        return normalized

    return func
685422
function tryFn(fn, args) {
  try {
    return Promise.resolve(fn.apply(null, args));
  } catch (e) {
    return Promise.reject(e);
  }
}
865995
def maybe_wait(func):
    
    def wrapper(self, *args, **kwargs):
        if self.slow:
            time.sleep(random.randint(5, 15))
        return func(self, *args, **kwargs)

    return wrapper
1030058
def onlyOnce(fn):
    ''
    def wrap(*args, **kwargs):
        if hasattr(fn, 'called'):
            return
        fn.called = 1
        return fn(*args, **kwargs)
    util.mergeFunctionMetadata(fn, wrap)
    return wrap
528471
function(curried, src) {
  /* eslint-disable no-param-reassign */
  curried.toString = () => src.toString();
  curried.src = src;
  /* eslint-enable no-param-reassign */
  return curried;
}
20669
def is_mod_function(mod, fun):
    
    return inspect.isfunction(fun) and inspect.getmodule(fun) == mod
353309
def is_function_or_method(obj):
    
    return inspect.isfunction(obj) or inspect.ismethod(obj) or is_cython(obj)
1073824
function curry(fn, obj) {
  // create a local copy of the function. don't apply anything yet
  // optionally bind an object to the `this` of the function.
  var newFunction = _.bind(fn, (obj || null));

  // curried functions always take one argument
  return function () {
    // create another copy of the function with the arguments applied
    var me = _.partial(newFunction, arguments);

    // take advantage of the fact that bind changes the method signature:
    // if we have no arguments left, run the method
    if (!me.length) return me();

    // otherwise, curry again and return that.
    return curry(me);
  };
}
1243309
def command(func_or_args=None):
    
    def decorator(f):
        f.__args__ = args
        return f
    if type(func_or_args) == type(decorator):
        args = {}
        return decorator(func_or_args)
    args = func_or_args
    return decorator