From ba62050f97564e49d8e4091a0b3360bbbd8650a2 Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Thu, 26 Dec 2019 23:44:04 -0500 Subject: added .copy to space --- space.js | 7 +++++++ 1 file changed, 7 insertions(+) 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 -- cgit