core.if
0.000001

Calls a composition for truthy inputs.

Arguments
procrequired
The composition to execute for truthy inputs.
Return Value
The result of the given composition, or null if the input is falsey.
something went wrong :(
Conditionally echoing a value
Setup
authorization=PROCAUTH
require "proc"

client = Proc.connect("PROCAUTH")
const Proc = require("@proc.dev/client");
const client = Proc.connect("PROCAUTH");
client.core.if {
  client.core.echo("is true")
}.call(true)
client.core.if(undefined, {}, () => {
  return client.core.echo("is true");
}).call(true);
curl "https://proc.run/core/if" --silent \
--header "authorization: bearer $authorization" \
--header "content-type: application/vnd.proc+json" \
--header "accept: text/plain" \
--data '[[">>", ["%%", true]], ["$$", "proc", ["{}", ["()", "core.echo", [">>", ["%%", "is true"]]]]]]'
 

is true

Note that core.if can be composed with core.else to create "if-else" branches in composition logic.


Stuck? Want to chat about an idea? Join the community on Discord.