aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--space.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/space.js b/space.js
index 4a227cf..3fc14f4 100644
--- a/space.js
+++ b/space.js
@@ -143,6 +143,13 @@ function Space(){
}
return newspace;
}
+
+ this.copy = function(){ // deeply copies `array` and `loc` to a new space
+ let newspace = new Space();
+ newspace.data = this.data.map(row => row.slice()); // Deep copy
+ newspace.loc = this.loc.slice();
+ return newspace;
+ }
}
module.exports = Space