From 790a01a32aa37684a5c39e5af6cb17d892212e79 Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Fri, 27 Dec 2019 14:13:48 -0500 Subject: added proto-.loc functionality to space.js --- examples/jarvis.js | 2 +- space.js | 25 +++++++++++++++---------- tests/space_fromfetch.js | 3 ++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/examples/jarvis.js b/examples/jarvis.js index 9d4bb91..a78024b 100644 --- a/examples/jarvis.js +++ b/examples/jarvis.js @@ -43,7 +43,7 @@ function identity(sender){ let loc = locs[i]; if (read.has(loc)) clearTimeout(expire[loc]); let locspace = new Space(); - locspace.fromfetch(tiles, [loc[0][0], loc[0][1], loc[1][0], loc[1][1]], conform=false); + locspace.fromfetch(tiles, [loc, loc], conform=false); let results = read.add(locspace); if (! results) respond(results); expire[loc] = setTimeout(()=>{read.del(loc)}, 30000); diff --git a/space.js b/space.js index 50ae16c..c0cce60 100644 --- a/space.js +++ b/space.js @@ -3,6 +3,7 @@ // It provides combination between Spaces. [DONE] // It also gives a search utility and a utility to grab an arbitrary section [DONE] [DONE] const fs = require('fs') +const vec = require('./utils/vec'); function chop(string, n){ // chops a string into n-sized chunks. Assumed to be perfect multiple let arr = []; @@ -11,6 +12,7 @@ function chop(string, n){ // chops a string into n-sized chunks. Assumed to be p } return arr; } + function replace(text, old, repl){ //replaces, in an array `text`, the instances of `old` with `repl` for (let i=0; i row.split('')); diff --git a/tests/space_fromfetch.js b/tests/space_fromfetch.js index 67b41cc..e6c7846 100644 --- a/tests/space_fromfetch.js +++ b/tests/space_fromfetch.js @@ -3,7 +3,8 @@ const Space = require('../space') newspace = new Space() -newspace.fromfetch({"4,2": {"content": " hhhhhhhh k hone ns ", "properties": {"writability": null, "cell_props": {}}}},[4,2,4,2],conform=false); +newspace.fromfetch({"4,2": {"content": " hhhhhhhh k hone ns ", "properties": {"writability": null, "cell_props": {}}}},[[4,2],[4,2]],conform=false); // Straight from a real tileUpdate +console.log(newspace.loc); console.log(newspace.data); //Should be an array of arrays of chars, representing the content of "content" above. -- cgit