Created
September 20, 2015 20:49
-
-
Save Killavus/dd2be6445f83b32cc345 to your computer and use it in GitHub Desktop.
Processing graph-data. Each of node has a type. I leverage this knowledge to not 'ask', but tell what I want to do.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function emptyFn() {} | |
function matchNode(node, typeFunctions) { | |
return (typeFunctions[node.type] || emptyFn)(node); | |
} | |
// Example usage: | |
neighbourList.forEach(function(node) { | |
result = result.concat( | |
matchNode(node, { | |
Type1: continuationForType1, | |
Type2: continuationForType2... | |
}) | |
) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment