Message from JavaScript discussions
April 2017
— I replaced that weird null
stuff with an easier way... done
was if the iterator's done
property is true
which means it's value
is not set, thus you cannot send anything if done
is true
. Instead now the DFS predict when it is currently iterating the last node, and sends an additional property in it's shared state object called isLast
.
Like this
if (condition allowing new node in stack) {
// Add new nodes to stack
} else if (stack is empty) {
isLast = true;
}
— Https://pastebin.com/ux7ntFpG
— Oh, I notice an old comment about cloning... haha
— These are generic, no cloning going on :p
— What now
—
var myAlg = new Strategy(null,
function (state) {
console.log(state);
}
);
myAlg.traverseAlg = function* (object) {
for (var loc in object) {
yield object[loc];
}
};
myAlg.run({property: "Hello World!"});
bam
— Needs some tweaking, but this is looking nice
— Allows decoupled behavior from the main algorithm
— I have no clue what that means, but it sounds cool.
— Im sure I can get this more efficient, but here it is https://github.com/Floofies/Differentia.js/blob/master/differentia.js#L200
— Nice, didn't have github link before