buxlabs/pure-utilities

make `deepclone` pure #90

emilos posted onGitHub

Context

In the README, we're stating that the methods are side effect free. Unfortunately it's not true in all of the cases yet.

function deepclone (object) {
  return JSON.parse(JSON.stringify(object))
}

deepclone fn would throw if you'd pass undefined or when the parsed object has circular references.

Acceptance criteria

  • ensure deepclone does not throw
  • add more tests

We probably need to add a default:

function deepclone (object = {}) {}

and wrap the fn body with try catch. The simplest thing to do is probably just return an empty object if there's an exception.


done! (at least so I think :smile: ) https://github.com/buxlabs/pure-utilities/pull/99

posted by inikonorov about 5 years ago

@inikonorov thanks!

posted by emilos about 5 years ago

Fund this Issue

$0.00
Funded

Pull requests