mirror of
https://github.com/litruv/picoGraph.git
synced 2026-07-24 10:46:06 +10:00
Initial commit
moved from private version control
This commit is contained in:
47
scripts/nodes/library/compare.js
Normal file
47
scripts/nodes/library/compare.js
Normal file
@@ -0,0 +1,47 @@
|
||||
import { createNodeModule } from "../nodeTypes.js";
|
||||
|
||||
/**
|
||||
* Compares two values using a selected operator.
|
||||
*/
|
||||
export const compareNode = createNodeModule(
|
||||
{
|
||||
id: "compare",
|
||||
title: "Compare",
|
||||
category: "Logic",
|
||||
description: "Compare two values with a selected operator.",
|
||||
searchTags: ["compare", "logic", "condition", "branch"],
|
||||
inputs: [
|
||||
{ id: "a", name: "A", direction: "input", kind: "any" },
|
||||
{ id: "b", name: "B", direction: "input", kind: "any" },
|
||||
],
|
||||
outputs: [
|
||||
{ id: "res", name: "Result", direction: "output", kind: "boolean" },
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
key: "operator",
|
||||
label: "Operator",
|
||||
type: "enum",
|
||||
defaultValue: "==",
|
||||
options: [
|
||||
{ label: "Equal", value: "==" },
|
||||
{ label: "Not Equal", value: "!=" },
|
||||
{ label: "Greater", value: ">" },
|
||||
{ label: "Less", value: "<" },
|
||||
{ label: "Greater Or Equal", value: ">=" },
|
||||
{ label: "Less Or Equal", value: "<=" },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
evaluateValue: ({ node, resolveValueInput, sanitizeOperator }) => {
|
||||
const a = resolveValueInput("a", "0");
|
||||
const b = resolveValueInput("b", "0");
|
||||
const operator = sanitizeOperator(
|
||||
String(node.properties.operator ?? "==")
|
||||
);
|
||||
return `(${a}) ${operator} (${b})`;
|
||||
},
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user