@nodescript/core
Advanced tools
Comparing version 7.3.1 to 7.3.2
@@ -16,2 +16,6 @@ import { NodeSpec } from '../types/model.js'; | ||
readonly nodeSpec: NodeSpec; | ||
/** | ||
* Returns nodes in right-to-left order based on topology. | ||
*/ | ||
static orderNodes(nodes: Iterable<NodeView>): NodeView[]; | ||
private _moduleSpec; | ||
@@ -18,0 +22,0 @@ private _nodeUid; |
@@ -18,2 +18,20 @@ import { coerce } from 'airtight'; | ||
} | ||
/** | ||
* Returns nodes in right-to-left order based on topology. | ||
*/ | ||
static orderNodes(nodes) { | ||
const result = [...nodes]; | ||
for (let i = 0; i < result.length; i++) { | ||
const node = result[i]; | ||
for (const link of node.inboundLinks()) { | ||
const index = result.findIndex(_ => _.nodeUid === link.linkNode.nodeUid); | ||
if (index > -1 && index < i) { | ||
result.splice(i, 1); | ||
result.splice(index, 0, node); | ||
i = index; | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
toJSON() { | ||
@@ -20,0 +38,0 @@ return clone(this.nodeSpec); |
{ | ||
"name": "@nodescript/core", | ||
"version": "7.3.1", | ||
"version": "7.3.2", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "Visual programming language for Browser and Node", |
Sorry, the diff of this file is not supported yet
192762
218
3371