Skip to content

Commit

Permalink
bump deps
Browse files Browse the repository at this point in the history
- fix: linting
- fix: partial node deprecated api
  • Loading branch information
commenthol committed Jan 1, 2019
1 parent 0585897 commit 89e9d49
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 46 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
coverage/
.nyc_output/
doc/
tmp/
*.log
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
19 changes: 13 additions & 6 deletions .zuul.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
ui: mocha-bdd
tunnel_host: http://focusaurus.com
# tunnel_host: http://focusaurus.com
browsers:
- name: chrome
version: latest
platform: Windows 10
version:
- 69
- latest
- name: firefox
platform: Windows 10
version:
- 45
- 60
- latest
- name: safari
version: latest
- name: microsoftedge
version: latest
version:
- 11
- latest
- name: MicrosoftEdge
version:
- 17
- latest
# - name: iphone
# version: latest
# Not Supported
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var obj = {
arr: [1, '2'],
regexp: /^test?$/,
date: new Date(),
buffer: new Buffer('data'),
buffer: Buffer.from('data'),
}
console.log(serialize(obj))
// > {str: "\u003Cscript\u003Evar a = 0 \u003E 1\u003C\u002Fscript\u003E", num: 3.1415, bool: true, nil: null, undef: undefined, obj: {foo: "bar"}, arr: [1, "2"], regexp: /^test?$/, date: new Date("2016-04-15T16:22:52.009Z"), buffer: new Buffer('ZGF0YQ==', 'base64')}
Expand Down
33 changes: 17 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@
"bugs": {
"url": "https://github.com/commenthol/serialize-to-js/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/commenthol/serialize-to-js.git"
},
"license": "MIT",
"author": "commenthol <[email protected]>",
"main": "lib",
"directories": {
"doc": "doc",
"test": "test"
},
"repository": {
"type": "git",
"url": "https://github.com/commenthol/serialize-to-js.git"
},
"scripts": {
"all": "npm run lint && npm test",
"clean": "rimraf doc coverage node_modules *.tgz",
"cover": "nyc -r text -r html npm test",
"clean": "rimraf doc coverage .nyc_output node_modules *.tgz",
"coverage": "nyc -r text -r html npm test",
"doc": "jsdox -o doc lib/*.js",
"lint": "eslint '**/*.js'",
"prepublishOnly": "npm run all",
Expand All @@ -42,18 +42,19 @@
}
},
"dependencies": {
"js-beautify": "^1.7.5",
"safer-eval": "^1.2.3"
"js-beautify": "^1.8.9",
"safer-eval": "^1.3.0"
},
"devDependencies": {
"eslint": "^4.18.2",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-standard": "^3.0.1",
"istanbul": "^0.4.5",
"mocha": "^5.0.1",
"eslint": "^5.11.1",
"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-standard": "^4.0.0",
"jsdox": "^0.4.10",
"mocha": "^5.2.0",
"nyc": "^13.1.0",
"rimraf": "^2.6.2"
},
"engines": {
Expand Down
14 changes: 9 additions & 5 deletions test/deserialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ var serialize = M.serialize
var deserialize = M.deserialize
var fixtures = require('./fixtures')

if (typeof assert.deepStrictEqual === 'undefined') {
assert.deepStrictEqual = assert.deepEqual // eslint-disable-line
}

function log (arg) { // eslint-disable-line no-unused-vars
console.log(JSON.stringify(arg))
}
Expand All @@ -27,7 +31,7 @@ describe('#deserialize', function () {
assert.strictEqual(res.toString(), exp.toString())
break
default:
assert.deepEqual(res, exp)
assert.deepEqual(res, exp) // eslint-disable-line node/no-deprecated-api
}
})
})
Expand Down Expand Up @@ -56,12 +60,12 @@ describe('#deserialize', function () {
it('should not throw on using `new Function`', function () {
var str = "new Function('return 25 + 9')()"
var res = deserialize(str, true)
assert.equal(res, 34)
assert.strictEqual(res, 34)
})
it('should not throw on using `eval`', function () {
var str = "eval('25 + 9')"
var res = deserialize(str, true)
assert.equal(res, 34)
assert.strictEqual(res, 34)
})
})

Expand All @@ -73,13 +77,13 @@ describe('#deserialize', function () {
bool: true,
nil: null,
undef: undefined,
obj: {foo: 'bar'},
obj: { foo: 'bar' },
arr: [1, '2'],
regexp: /^test?$/,
date: new Date()
}
var res = deserialize(serialize(obj), {})
assert.deepEqual(res, obj)
assert.deepEqual(res, obj) // eslint-disable-line node/no-deprecated-api
})
})
})
4 changes: 2 additions & 2 deletions test/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ module.exports = {
'/test(?:it)?/gi'
],
'object': [
{a: 1, b: 2},
{ a: 1, b: 2 },
'{a: 1, b: 2}'
],
'empty object': [
{},
'{}'
],
'object with backslash': [
{backslash: '\\'},
{ backslash: '\\' },
'{backslash: "\\\\"}'
],
'object of primitives': [
Expand Down
24 changes: 16 additions & 8 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ var M = require('..')
var serialize = M.serialize
var fixtures = require('./fixtures')

if (typeof assert.deepStrictEqual === 'undefined') {
assert.deepStrictEqual = assert.deepEqual // eslint-disable-line
}

function log (arg) { // eslint-disable-line no-unused-vars
console.log(JSON.stringify(arg))
}
Expand All @@ -20,7 +24,11 @@ describe('#serialize', function () {
var inp = tc[0]
var exp = tc[1]
var res = serialize(inp)
assert.strictEqual(res, exp)
if (typeof exp === 'object') {
assert.deepStrictEqual(res, exp)
} else {
assert.strictEqual(res, exp)
}
})
})
})
Expand All @@ -39,7 +47,7 @@ describe('#serialize', function () {
var res = serialize(o)
var exp = '{a: {"3": "3", one: true, "thr-ee": undefined, "4 four": "four\\n\\u003Ctest\\u003E\\u003C\\u002Ftest\\u003E", "five\\"(5)": 5}, b: {"3": "3", one: true, "thr-ee": undefined, "4 four": "four\\n\\u003Ctest\\u003E\\u003C\\u002Ftest\\u003E", "five\\"(5)": 5}}'
// console.log(JSON.stringify(res))
assert.equal(res, exp)
assert.strictEqual(res, exp)
})
it('converting an object of objects using references', function () {
var r = {
Expand Down Expand Up @@ -74,8 +82,8 @@ describe('#serialize', function () {
['.c["spa ce"]', '.a'],
['["spa ce"]', '.a']
]
assert.equal(res, exp)
assert.deepEqual(opts.references, refs)
assert.strictEqual(res, exp)
assert.deepStrictEqual(opts.references, refs)
})
it('converting a circular object throws', function () {
var o = {
Expand All @@ -95,9 +103,9 @@ describe('#serialize', function () {
}
}
o.a.b = o.a
var res = serialize(o, {ignoreCircular: true})
var res = serialize(o, { ignoreCircular: true })
var exp = '{a: {b: {/*[Circular]*/}}}'
assert.deepEqual(res, exp)
assert.deepStrictEqual(res, exp)
})
it('converting an object of objects with opts.unsafe', function () {
var o1 = {
Expand All @@ -111,8 +119,8 @@ describe('#serialize', function () {
a: o1,
b: o1
}
var res = serialize(o, {unsafe: true})
var res = serialize(o, { unsafe: true })
var exp = '{a: {"3": "3", one: true, "thr-ee": undefined, "4 four": "four\\n<test></test>", "five\\"(5)": 5}, b: {"3": "3", one: true, "thr-ee": undefined, "4 four": "four\\n<test></test>", "five\\"(5)": 5}}'
assert.equal(res, exp)
assert.strictEqual(res, exp)
})
})
20 changes: 12 additions & 8 deletions test/serializeToModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
var assert = require('assert')
var serializeToModule = require('..').serializeToModule

if (typeof assert.deepStrictEqual === 'undefined') {
assert.deepStrictEqual = assert.deepEqual // eslint-disable-line
}

function log (arg) { // eslint-disable-line no-unused-vars
console.log(JSON.stringify(arg))
}
Expand All @@ -31,8 +35,8 @@ describe('#serializeToModule', function () {
var res = serializeToModule(o)
var exp = 'module.exports = {\n a: {\n one: true,\n two: "a string\\nwith multiple\\r\\nlines.",\n "thr-ee": undefined\n },\n b: {\n one: true,\n two: "a string\\nwith multiple\\r\\nlines.",\n "thr-ee": undefined\n },\n c: {\n d: {\n one: true,\n two: "a string\\nwith multiple\\r\\nlines.",\n "thr-ee": undefined\n }\n }\n};'
// log(res)
assert.equal(res, exp)
assert.deepEqual(o, getObj(res))
assert.strictEqual(res, exp)
assert.deepStrictEqual(o, getObj(res))
})
it('object of objects using references', function () {
var r = {
Expand All @@ -57,8 +61,8 @@ describe('#serializeToModule', function () {
})
var exp = 'var m = module.exports = {"0": {one: true, two: "a string\\nwith multiple\\r\\nlines.", "thr-ee": undefined}, c: {}};\nm.a = m["0"];\nm.b = m["0"];\nm.c["0"] = m["0"];\nm.c.d = m["0"];\nm.c["spa ce"] = m["0"];\nm["spa ce"] = m["0"];\n'
// log(res)
assert.equal(res, exp)
assert.deepEqual(o, getObj(res))
assert.strictEqual(res, exp)
assert.deepStrictEqual(o, getObj(res))
})
it('object of objects - beautify', function () {
var r = {
Expand All @@ -77,8 +81,8 @@ describe('#serializeToModule', function () {
})
var exp = 'var m = module.exports = {\n a: {\n one: true,\n "thr-ee": /^test$/\n },\n c: {}\n};\nm.b = m.a;\nm.c.d = m.a;'
// log(res);
assert.equal(res, exp)
assert.deepEqual(o, getObj(res))
assert.strictEqual(res, exp)
assert.deepStrictEqual(o, getObj(res))
})
it('obj - with comments header', function () {
var o = {
Expand All @@ -91,7 +95,7 @@ describe('#serializeToModule', function () {
})
var exp = '/* eslint-disable */\nmodule.exports = {\n a: {\n b: "one"\n }\n};'
// log(res)
assert.equal(res, exp)
assert.deepEqual(o, getObj(res))
assert.strictEqual(res, exp)
assert.deepStrictEqual(o, getObj(res))
})
})

0 comments on commit 89e9d49

Please sign in to comment.