from.Array(threads) .where(function(t) { return t.id == threadID }) .besides(function(t) { t.isValid = false; }) .remove();// you could also do `from.Object(obj)` to query keys, or just plain `from()` to determine// the enumeration mode from the type of the argument.
I'm experimenting with simplifying things some more for my experimental "from" script. One thing I notice that link does is to call the points recursively. While this is in line with the chain metaphor, it ends up duplicating effort because every single point (except endpoints) needs to have a call to this.next.exec(). My idea was to instead have points return true to continue, and false to drop the current value, filtering it out.Endpoints would work similarly - return true to continue with the next value, or false to short-circuit. I think this is overall a better separation of concerns.
Also what does coalesce do? It says it merges modified results back into the array, but I'm not sure what that means in practical terms. Link already has update()...
var nums = Link.range(5);Link(nums) .map(function(n) { return n * n; }) .coalesce();// 'nums' is now -> [ 1, 4, 9, 16, 25 ]
Link.js idea: make an option for it to go backwards... Could be interesting...
const link = require('link');const random = require('random');// insta-kill attacklink(battlers) .where(function(b) { return b.isEnemyOf(attacker) }) .where(function(b) { return b.level % 5 == 0; }) // level is multiple of 5 .where(function() { return random.chance(0.35); }) // 35% hit rate .each(function(b) { b.die(); });
// get all items for the first party member:itemQuery = items.Where(v => v.owner == partyChars[0]);// get items to show on the current pageitemsOnPage = itemQuery .Skip(pageSize * pageIndex) .Take(10) // 10 items per page .ToArray();