aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2020-07-16 12:40:19 -0400
committerHolden Rohrer <hr@hrhr.dev>2020-07-16 12:40:19 -0400
commitdb24fbe16e0f73f9278f4ec090be756c9704dee1 (patch)
treec2a43383a763217efb5fa8bf763212464fc0db42
parent2e483bddc3c66aab0af9d4b80f5cacde42d4f041 (diff)
space.{adhoc,from*} now return this
This eases composition of space functions without having to create a bunch of closures or global variables
-rw-r--r--space.js4
1 files changed, 4 insertions, 0 deletions
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)