Skip to content

Commit

Permalink
Some description
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Sep 4, 2020
1 parent b1ef3c8 commit 3877839
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 3 deletions.
52 changes: 51 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,64 @@
[![Build Status](https://travis-ci.org/discoveryjs/json-ext.svg?branch=master)](https://travis-ci.org/discoveryjs/json-ext)
[![Coverage Status](https://coveralls.io/repos/github/discoveryjs/json-ext/badge.svg?branch=master)](https://coveralls.io/github/discoveryjs/json-ext?)

A set of utilities that extend the use of JSON
A set of utilities that extend the use of JSON.

Features:

- [x] Stringify stream: `stringifyStream()`
- [ ] **TBD** Parse stream
- [x] Value info: `info()`
- [ ] **TBD**Support for circular references
- [ ] **TBD** Binary representation

## Install

```bash
npm install json-ext
```

## API

### stringifyStream(value[, replacer[, space]])

Mostly works the same as `JSON.stringify()`, but returns instance of `ReadableStream` instead of string.

Extensions:
- Promises are rescursively resolve and the result value is stringify as any onther
- Streams in object mode are output as arrays
- Streams in non-object mode are output as is

### info(value[, replacer[, space[, options]]])

`value`, `replacer` and `space` arguments are the same as for `JSON.stringify()`.

Result is an object:

```js
{
minLength: Number, // mininmal bytes when values is stringified
circular: [...], // list of circular references
duplicate: [...], // list of objects that occur more than once
async: [...] // list of async values, i.e. promises and streams
}
```

Options:

#### async

Type: `Boolean`
Default: `false`

Collect async values (promises and streams) or not.

#### continueOnCircular

Type: `Boolean`
Default: `false`

Stop walking through a value or not whenever circular reference is found. Setting option to `true` allows to find all circular references.

## License

MIT
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
"description": "A set of utilities that extend the use of JSON",
"keywords": [
"json",
"utils"
"utils",
"stream",
"async",
"promise",
"stringify",
"info"
],
"author": "Roman Dvornov <rdvornov@gmail.com> (https://github.com/lahmatiy)",
"license": "MIT",
Expand All @@ -28,5 +33,7 @@
"engines": {
"node": ">=12.0.0"
},
"files": []
"files": [
"src"
]
}

0 comments on commit 3877839

Please sign in to comment.