diff options
author | Holden Rohrer <holden.rohrer@gmail.com> | 2019-12-26 23:44:04 -0500 |
---|---|---|
committer | Holden Rohrer <holden.rohrer@gmail.com> | 2019-12-27 14:57:57 -0500 |
commit | ba62050f97564e49d8e4091a0b3360bbbd8650a2 (patch) | |
tree | 8fd74df03f98b787b268afb380cb7e0a9785cca8 | |
parent | c393afc348baefddf201e10c4d4d45ccde7f29ba (diff) |
added .copy to space
-rw-r--r-- | space.js | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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 |