Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwu9145 committed Apr 5, 2021
1 parent 0deb3df commit 1ee9e85
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

![Coverage badge gree][coverage-badge-green]

If this project helps you, please support it with a star :heart: (Thank you!).

[coverage-badge-green]: https://img.shields.io/badge/Coverage-100%25-brightgreen.svg
[coverage-badge-yellow]: https://img.shields.io/badge/Coverage-100%25-yellow.svg
[coverage-badge-red]: https://img.shields.io/badge/Coverage-100%25-red.svg
Expand All @@ -20,7 +22,29 @@ This is pure javascript function that aims to create a real hard copy from origi
| [Hard Copy nested object](#cannot-make-hard-copy-on-nested-objects) | :heavy_check_mark: | :x: | :heavy_check_mark: |
| [Copy functions](#loosing-functions) | :x: | :heavy_check_mark: | :heavy_check_mark: |
| [Keep prototype chain](#loosing-prototype-chain) | :x: | :x: | :heavy_check_mark: |
| Circular Reference | Throw Error | Keep Circular Ref | [Graceful Handle](#gracefully-handle-circular-reference) |

### Gracefully handle Circular Reference
```javascript
const originalObject = {
a: 'test',
f: 1
};
originalObject.a = originalObject;
originalObject.b = {};
originalObject.b.c = originalObject;
```
`deepCopy(originalObject)` will result in:

```javascript
{
a: '[Circular]',
f: 1,
b: {
c: '[Circular]',
},
};
```
## Limitions of common ways
### Cannot make hard copy on nested objects

Expand Down

0 comments on commit 1ee9e85

Please sign in to comment.