substack/json-stable-stringify — pull request #4 by rprieto (2013-12-22 03:40:09+00:00)
Title: Handle cyclic dependencies (instead of stack overflow)

If the object being stringified has a cycle:

- `{cycles: false}` (default) will throw an exception, just like `JSON.stringify`

```
TypeError: Converting circular structure to JSON
```

- `{cycles: true}` will print it as `__cycle__`. For example:

```js
'{"a":1,"two":{"a":2,"one":"__cycle__"}}')
```