Skip to main content

Melon.std.shift()

Creates a callback chain that will execute one or more callbacks based in a condition that is related to the initial specified value.

Status: stable
Returns: typeof(shift) | void

Parameters

Valid calling shift().option(...)

NameTypeDescription
conditionbooleanThe condition to be analyzed in order to execute the action
actionFunctionAction meant to be executed if condition is true
finishOnTrueboolean?The condition to finish the chain if the last condition is true

Example usage

shift()
.option(a === 1, () => console.log(1))
.option(a === 2, () => console.log(2))
.option(a === 3, () => console.log(2), true);

Extra behaviors