function to copy objects

This commit is contained in:
2020-03-10 10:46:12 +01:00
parent b72444f8c0
commit cbe4589476
3 changed files with 27 additions and 1 deletions

View File

@ -30,3 +30,11 @@ test ('try_parse_json should fail', (t) => {
t.is (json, null);
});
});
test ('copy object', (t) => {
const obj = {foo:'bar'};
const copy = util.copy_object(obj);
copy.foo = 'baz';
t.is(copy.foo, 'baz');
t.is(obj.foo, 'bar');
});