Skip to content

Commit

Permalink
Merge pull request #8 from commenthol/remove-deserialize
Browse files Browse the repository at this point in the history
break: remove deserialize method
  • Loading branch information
commenthol authored May 15, 2019
2 parents a73605a + c14ae72 commit 50310db
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 171 deletions.
32 changes: 0 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,38 +92,6 @@ console.log(opts.references);
**Returns**: `String`, serialized representation of `source`


### deserialize

`deserialize(str, [context])`

deserialize a serialized object to javascript

> _NOTE_: Deserialization uses `new Function()` for code evaluation which may be "harmful".
> **SO NOW YOU ARE WARNED!**
Uses [safer-eval][] for deserialization.

#### Example - deserializing regex, date, ...

```js
var str = '{obj: {foo: "bar"}, arr: [1, "2"], regexp: /^test?$/, date: new Date("2016-04-15T16:22:52.009Z")}'
var res = deserialize(str)
console.log(res)
//> { obj: { foo: 'bar' },
//> arr: [ 1, '2' ],
//> regexp: /^test?$/,
//> date: Sat Apr 16 2016 01:22:52 GMT+0900 (JST) }
```

**Parameters**

**str**: `String`, string containing serialized data

**context**: (optional) pass context e.g. if requiring Buffer use `{Buffer: Buffer}`.

**Returns**: `Any`, deserialized data


### serializeToModule

`serializeToModule(source, opts, opts.ignoreCircular, opts.reference, opts.comment, opts.beautify) `
Expand Down
37 changes: 0 additions & 37 deletions lib/deserialize.js

This file was deleted.

3 changes: 1 addition & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
serialize: require('./serialize'),
serializeToModule: require('./serializeToModule'),
deserialize: require('./deserialize')
serializeToModule: require('./serializeToModule')
}
20 changes: 9 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serialize-to-js",
"version": "1.2.2",
"version": "2.0.0-0",
"description": "serialize objects to javascript",
"keywords": [
"javascript",
Expand Down Expand Up @@ -42,20 +42,18 @@
}
},
"dependencies": {
"js-beautify": "^1.8.9",
"safer-eval": "^1.3.0"
"js-beautify": "^1.10.0"
},
"devDependencies": {
"eslint": "^5.11.1",
"eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-node": "^9.0.1",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-standard": "^4.0.0",
"jsdox": "^0.4.10",
"mocha": "^5.2.0",
"nyc": "^13.1.0",
"rimraf": "^2.6.2"
"mocha": "^6.1.4",
"nyc": "^14.1.1",
"rimraf": "^2.6.3"
},
"engines": {
"node": ">=4.0.0"
Expand Down
89 changes: 0 additions & 89 deletions test/deserialize.js

This file was deleted.

0 comments on commit 50310db

Please sign in to comment.