aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--space.js12
-rw-r--r--tests/space_subsection.js2
2 files changed, 7 insertions, 7 deletions
diff --git a/space.js b/space.js
index ae0ee50..50ae16c 100644
--- a/space.js
+++ b/space.js
@@ -111,14 +111,14 @@ function Space(){ // CLASS
} if (match) break;}
return loc;
}
- this.subsection = function(range){ // range is a standard quadruplet
+
+ this.subsection = function(range){ // range is a coordinate pair
+ // Similarly excludes this.loc
newspace = new Space();
- for (let line=0; line<=range[2]-range[0]; line++){
+ for (let line=range[0][0]; line<=range[1][0]; line++){
newspace.data.push([]);
- for (let chr=0; chr<=range[3]-range[1]; chr++){
- newspace.data[line].push(
- this.data[line+range[0]][chr+range[1]] || ''
- );
+ for (let chr=range[0][1]; chr<=range[1][1]; chr++){
+ newspace.data[line-range[0][0]].push(this.data[line][chr] || '');
}
}
return newspace;
diff --git a/tests/space_subsection.js b/tests/space_subsection.js
index b30b7e1..216b404 100644
--- a/tests/space_subsection.js
+++ b/tests/space_subsection.js
@@ -7,4 +7,4 @@ line\n\
\n\
long long long line\
');
-console.log(newspace.subsection([1,1,2,10]));
+console.log(newspace.subsection([[1,1],[2,10]]));