Skip to content

Commit

Permalink
Update READ.ME
Browse files Browse the repository at this point in the history
  • Loading branch information
jfet97 committed Jan 6, 2019
1 parent cc75d91 commit b9816de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import omniclone from 'omniclone';
2. let you to share the `[[Prototype]]` object between source and the resulting object (customizable behavior)
3. let you to clone objects with circular references (customizable behavior)
4. let you to copy getters and setters, non enumerables properties and also symbols (customizable behavior)
5. correct handling of String, Boolean, Number, Error, Promise, WeakMap and WeakSet objects
5. correct handling of String, Boolean, Number, Error, Promise, Map, WeakMap and WeakSet objects
6. safe similar sibilings references are not duplicated
7. correct cloning of Array objects (if the `invokeConstructors` flag is setted)
8. correct cloning of RegExp and Date objects
Expand Down Expand Up @@ -168,7 +168,7 @@ omniclone(source, {
});
```

## what about String, Boolean, Number, Error, Promise, WeakMap and WeakSet objects?
## what about String, Boolean, Number, Error, Promise, Map, WeakMap and WeakSet objects?

String, Boolean and Number objects passed to `omniclone` as sources will produce `null`.\
Error objects passed to `omniclone` as sources will produce `null` if the `discardErrorObjects` is set to `true` (as default).\
Expand All @@ -181,6 +181,8 @@ Error objects props will produce a `TypeError` if the `discardErrorObjects` is s
Promise, WeakMap and WeakSet objects will be returned if passed to `omniclone` as sources.\
Promise, WeakMap and WeakSet objects props will be shallow copied.

Map objects will be deeply cloned following same rules of normal objects.

## what about the 6th strength?

To understand it, let's compare the function `omniclone` with the well-know `JSON.parse(JSON.stringify(source))`:
Expand All @@ -201,4 +203,4 @@ When you will use `JSON.parse()`, an `{"foo":"bar"}` object will be created for
2. `super` is statically bound to a class heirarchy, remember it
3. `Error` objects cannot be properly copied because of js limitations
4. currently there is no isomorphic way to detect if an object is a `Proxy` nor is possible to access the handler object. Because of transparent virtualization, `omniclone` will copy each properties, the `constructor` and the `[[Prototype]]` directly from the proxed object.
5. currenlty there is a lack of support for Map and Set objects. I'm working on this.
5. currenlty there is a lack of support for Set objects. I'm working on this.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "omniclone",
"version": "0.4.0",
"version": "0.4.1",
"description": "deep cloning function for js objects",
"main": "dist/main.js",
"scripts": {
Expand Down Expand Up @@ -51,4 +51,4 @@
"^.+\\.js$": "babel-jest"
}
}
}
}

0 comments on commit b9816de

Please sign in to comment.