faye/faye — pull request #336 by miickel (2014-09-28 21:19:27+00:00)
Title: simplify copyObject()

Today I ran into a problem with faye, getting the wonderful `Uncaught RangeError: Maximum call stack size exceeded` :boom:. Until I reluctantly looked at the source-code, I was unable to understand what caused the error.

Anyway, what caused the problem was that the published message included objects with circular references. This made your existing, recursive, `copyObject` function go on forever.

In this humble PR, `copyObject` is simplified, while adding "support" for circular references... it might [speed things up](http://stackoverflow.com/a/5344074/93222) a little, as well.