Skip to main content

call-or-reference ()

Allows a function to return its reference when no parameters are provided, otherwise maintaining its regular behavior.

Parameters

$function
The function to call or reference.
Type
Function
$args
The arguments to apply to the invocation of the function.
Type
ArgList<*>

Return Value

Function | *
The given function is returned when no arguments are given; otherwise, supplied with the given arguments, the value returned by the invocation of the given function is returned.

Example

my-custom/module.scss
@use 'sass:math';
@use '@sass-fairy/meta/meta';

@function _predicate($value, $args...) {
@return meta.type-of($value) == 'number' and not math.is-unitless($value);
}

@function is-number-and-not-unitless($args...) {
$ref: meta.get-function('_predicate');
@return meta.call-or-reference($ref, $args...);
}
my-custom/site.scss
@use '@sass-fairy/list';
@use 'module';

// 1. As a call
@debug module.is-number-and-not-unitless(10);
// false

// 2. As a reference
$list: a 1 5 b 20px 10 30px;

@debug list.find($list, module.is-number-and-not-unitless());
// 20px