From db24fbe16e0f73f9278f4ec090be756c9704dee1 Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Thu, 16 Jul 2020 12:40:19 -0400 Subject: space.{adhoc,from*} now return this This eases composition of space functions without having to create a bunch of closures or global variables --- space.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/space.js b/space.js index 6d09c1b..1828dda 100644 --- a/space.js +++ b/space.js @@ -49,6 +49,7 @@ function Space(){ } } } + return this; } this.towrite = function(){ // Does no splitting or anything like that. Just returns a list of triplets for the write function @@ -70,6 +71,7 @@ function Space(){ this.fromfile = function(filename){ //Reads an external file into internal data this.adhoc(fs.readFileSync(filename,'utf8')); + return this; } this.adhoc = function(text){ @@ -82,6 +84,7 @@ function Space(){ } return row; }); + return this; } this.comb = function(other, func){ // other must have a valid .loc. If this.loc null, treated as offset @@ -112,6 +115,7 @@ function Space(){ this.data[row][chr] = func(this.data[row][chr], otherrow[chr-offset[1]] || ''); } } + return this; } this.search = function(other){ //Returns first instance of `other` subspace (prioritized vertically then horizontally) -- cgit