sign static method

Value sign(
  1. Object argument
)

Creates a sign() calculation with the given argument.

The argument must be either a SassNumber, a SassCalculation, an unquoted SassString, or a CalculationOperation.

This automatically simplifies the calculation, so it may return a SassNumber rather than a SassCalculation. It throws an exception if it can determine that the calculation will definitely produce invalid CSS.

Implementation

static Value sign(Object argument) {
  argument = _simplify(argument);
  return switch (argument) {
    SassNumber(value: double(isNaN: true) || 0) => argument,
    SassNumber arg when !arg.hasUnit('%') =>
      SassNumber(arg.value.sign).coerceToMatch(argument),
    _ => SassCalculation._("sign", [argument]),
  };
}