aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <holden.rohrer@gmail.com>2019-12-26 23:44:04 -0500
committerHolden Rohrer <holden.rohrer@gmail.com>2019-12-27 14:57:57 -0500
commitba62050f97564e49d8e4091a0b3360bbbd8650a2 (patch)
tree8fd74df03f98b787b268afb380cb7e0a9785cca8
parentc393afc348baefddf201e10c4d4d45ccde7f29ba (diff)
added .copy to space
-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