Skip to content

Commit

Permalink
Add Dry.toObject documentation + readme badges
Browse files Browse the repository at this point in the history
  • Loading branch information
skerit committed Jan 15, 2018
1 parent eef933f commit 9ab2808
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# JSON-dry

[![NPM version](http://img.shields.io/npm/v/json-dry.svg)](https://npmjs.org/package/json-dry)
[![Build Status](https://travis-ci.org/skerit/json-dry.svg?branch=master)](https://travis-ci.org/skerit/json-dry)
[![Coverage Status](https://coveralls.io/repos/github/skerit/json-dry/badge.svg?branch=master)](https://coveralls.io/github/skerit/json-dry?branch=master)

JSON-dry allows you to stringify objects containing circular references,
dates, regexes, ...

Expand Down Expand Up @@ -131,6 +135,14 @@ undried.fullname();
// returns "Jelle De Loecker"
```

### toObject

While `Dry.stringify` will return you with a json-valid string, `Dry.toObject` will give you a valid simplified object.

In fact: `Dry.stringify` is just a function that performs `JON.stringify` on `Dry.toObject`'s output.

**Why would you want to use this?** Things like `Workers` and `IndexedDB` communicate data using the [structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm). So instead of performing expensive stringify operations you can just use these objects.

## Cloning objects & instances

JSON-Dry offers a specialized `clone` method. While in theory you could clone an object by drying end reviving it, like so:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"devDependencies": {
"istanbul" : "^0.4.5",
"mocha" : "1.20.x",
"protoblast" : "~0.4.1"
"protoblast" : "skerit/protoblast#3218106"
},
"engines": {
"node": ">=6.4"
Expand Down

0 comments on commit 9ab2808

Please sign in to comment.