# dyna-stringify

> The dyna-stringify

Latest version **1.0.3** (published 2020-02-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install dyna-stringify
pnpm add dyna-stringify
yarn add dyna-stringify
bun add dyna-stringify
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2020-02-13 |
| First published | 2020-02-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 37.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | dennisat |

## Links

- npm: https://www.npmjs.com/package/dyna-stringify
- Repository: http://github.com/aneldev/dyna-stringify
- npm.io page: https://npm.io/package/dyna-stringify

## Recent versions

- 1.0.3 (latest) — 2020-02-13

## README

# About

Stringify object with circular references.


# Usage
```
// Minimal usage
dynaStringify(value);
dynaStringify(value, {spaces: 2});
dynaStringify(value, {spaces: 2, circularText: '!REF'});

// Extensive with callback for the reference text
dynaStringify(
  value, 
  {
    spaces: 2, 
    circularText: value => { 
      if (value.customerId) return `!RefCustId:${value.customerId}`; 
      return '!Ref',
    }
   }
);
```

# Syntax
_In Typescript_
```
 dynaStringify = (
  value: any,
  options?: {
    spaces?: number;
    circularText?: string | ((value: any) => string);
  },
): string;
```

# Example
```
const value = {
      name: 'John',
      age: 32,
      cars: ['VW', 'Plymouth'],
    };
value.cars.push(value);
```
The
`dynaStringify(value, {spaces: 2})`

returns
```
{
  "name": "John",
  "age": 32,
  "cars": [
    "VW",
    "Plymouth",
    "[CircularRef]"
  ]
}
```

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