Skip to content

Commit

Permalink
readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterloftis committed Jan 3, 2013
1 parent c0f5435 commit cd9c00d
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $ npm install cryo
Add the [latest minified build](https://github.com/hunterloftis/cryo/tree/master/build) to your project as a script: Add the [latest minified build](https://github.com/hunterloftis/cryo/tree/master/build) to your project as a script:


```html ```html
<script type='text/javascript' src='cryo-0.0.2.min.js'></script> <script type='text/javascript' src='cryo-0.0.3.min.js'></script>
``` ```


## Example ## Example
Expand All @@ -50,25 +50,24 @@ hydrated.hello(); // Hunter says hello!


### Undefined ### Undefined


`JSON.stringify()` doesn't store undefined values. `JSON.stringify()` loses undefined values.
This is frequently desired behavior, but Cryo's goal is to capture a verbatim snapshot of the target object. Cryo keeps them, since its goal is a verbatim snapshot of your object and all of its properties.
Undefined keys are still keys that exist in a container, so Cryo restores them to undefined values in `parse()`.


- [Undefined tests](https://github.com/hunterloftis/cryo/blob/master/test/null.test.js) - [Undefined tests](https://github.com/hunterloftis/cryo/blob/master/test/null.test.js)


### Date ### Date


`JSON.stringify()` converts Date objects to strings. `JSON.stringify()` loses Date objects, converting them to strings.
Cryo maintains Date objects so the parsed value is identical to the stringified value. Cryo maintains Date objects as Date objects and restores them in `Cryo.parse()`.


- [Date tests](https://github.com/hunterloftis/cryo/blob/master/test/date.test.js) - [Date tests](https://github.com/hunterloftis/cryo/blob/master/test/date.test.js)


### References ### References


JSON.stringify() replaces Object references with clones of data. `JSON.stringify()` makes multiple copies of single objects, losing object relationships.
When several references to the same object are stringified, those references will becomes separate clones of the object's data on JSON.parse(). When several references to the same object are JSON stringified, those references are turned into clones of each other.
Cryo maintains object references so the restored objects are identical to the stringified objects. Cryo maintains object references so the restored objects are identical to the stringified objects.
For example: This is easier to understand with an example:


```js ```js
var Cryo = require('../lib/cryo'); var Cryo = require('../lib/cryo');
Expand All @@ -90,6 +89,9 @@ console.log(withCryo.activeUser === withCryo.users[1]); // true


### Infinity ### Infinity


`JSON.stringify(Infinity)` returns `null`, even though `Infinity` is a numeric type in JavaScript.
Cryo successfully stringifies and parses `Infinity` as a `Number`.

- [Infinity tests](https://github.com/hunterloftis/cryo/blob/master/test/number.test.js) - [Infinity tests](https://github.com/hunterloftis/cryo/blob/master/test/number.test.js)


### Functions ### Functions
Expand Down

0 comments on commit cd9c00d

Please sign in to comment.