# circular

> Tiny utility to safely stringify objects with circular references

Latest version **1.0.5** (published 2014-08-26) · 0 weekly downloads

## Install

```sh
npm install circular
pnpm add circular
yarn add circular
bun add circular
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2014-08-26 |
| First published | 2014-02-19 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | muji |
| Maintainers | muji |
| Keywords | json, stringify, circular, circular reference |

## Links

- npm: https://www.npmjs.com/package/circular
- Repository: https://github.com/freeformsystems/circular
- Issues: https://github.com/freeformsystems/circular/issues
- npm.io page: https://npm.io/package/circular

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.5 (latest) — 2014-08-26
- 1.0.4 — 2014-08-24
- 1.0.3 — 2014-03-01
- 1.0.2 — 2014-02-20
- 1.0.1 — 2014-02-19

## README

# Circular

Tiny utility to safely stringify objects with circular references.

## Usage

Replace all circular references with the string `[Circular]`;

```javascript
var circular = require('circular');
var obj = {}; var child = {parent: obj}; obj.child = child;
var str = JSON.stringify(obj, circular());
// => {"child":{"parent":"[Circular]"}}
```

If you prefer you can pass an alternative string to use:

```javascript
var str = JSON.stringify(obj, circular('#ref'));
```

Or a function that returns a string:

```javascript
function ref(value){return '' + value};
var str = JSON.stringify(obj, circular(ref));
```
As of version `1.0.4` you can also pass an additional boolean that will convert function references to strings, useful for converting javascript modules to `couchdb` design documents.

```javascript
var str = JSON.stringify(obj, circular(null, true));
```

## License

Everything is [MIT](http://en.wikipedia.org/wiki/MIT_License). Read the [license](/LICENSE) if you feel inclined.

---
_Source: https://npm.io/package/circular · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
