aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/search.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/search.js b/tools/search.js
index fc9817a..38a1124 100644
--- a/tools/search.js
+++ b/tools/search.js
@@ -6,6 +6,7 @@ const bs = require('binary-search');
const Space = require('../space');
const comb = require('../utils/comb')
const vec = require('../utils/vec');
+const raster = require('../utils/raster');
function getComp(index){
return (element,needle) => (element[index] - needle[index] || element[1-index] - needle[1-index])
@@ -75,6 +76,14 @@ function Search(searchBlock){ // searchBlock should be a Space object.
// bs returns negative if not found.
else return true;
}
+
+ this.update = function(space){ // Must be a space w/ valid loc; allows overlay of some arbitrary text (in the space) mostly for recording updates from the server without directly cataloguing them
+ let tiles = raster(space); // Returns a this.tiles-style binding: {'2,-3':Space object}
+ for (tile in tiles){
+ if (this.tiles[tile]) this.tiles[tile].comb(tiles[tile], comb.flip(comb.add));
+ else this.add(tile, tiles[tile]);
+ }
+ }
}
module.exports = Search;