forked from auxolotl/core
add functionArgs
This commit is contained in:
parent
415acdce94
commit
2613fed53e
|
@ -77,6 +77,25 @@ let
|
|||
isFunction = f: builtins.isFunction f ||
|
||||
(f ? __functor && isFunction (f.__functor f));
|
||||
|
||||
/**
|
||||
Extract the expected function arguments from a function.
|
||||
This works both with nix-native { a, b ? foo, ... }: style
|
||||
functions and functions with args set with 'setFunctionArgs'. It
|
||||
has the same return type and semantics as builtins.functionArgs.
|
||||
setFunctionArgs : (a → b) → Map String Bool.
|
||||
|
||||
|
||||
# Inputs
|
||||
|
||||
`f`
|
||||
|
||||
: 1\. Function argument
|
||||
*/
|
||||
functionArgs = f:
|
||||
if f ? __functor
|
||||
then f.__functionArgs or (functionArgs (f.__functor f))
|
||||
else builtins.functionArgs f;
|
||||
|
||||
/**
|
||||
Print a warning before returning the second argument. This function behaves
|
||||
like `builtins.trace`, but requires a string message and formats it as a
|
||||
|
@ -110,5 +129,6 @@ in
|
|||
loadStatic = loadStatic;
|
||||
foldr = foldr;
|
||||
isFunction = isFunction;
|
||||
functionArgs = functionArgs;
|
||||
warn = warn;
|
||||
}
|
Loading…
Reference in a new issue