From d9584abe2c7c913ce95a1aea29e5744dd85e1af4 Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Wed, 22 Sep 2021 21:20:58 -0700 Subject: [PATCH] Remove JSON3 --- lib/facade.js | 5 ++--- lib/iframe-bootstrap.js | 5 ++--- lib/info-ajax.js | 3 +-- lib/info-iframe-receiver.js | 3 +-- lib/info-iframe.js | 3 +-- lib/main.js | 3 +-- lib/transport/iframe.js | 9 ++++----- lib/utils/escape.js | 4 +--- lib/utils/iframe.js | 3 +-- package-lock.json | 11 ----------- package.json | 1 - tests/lib/utils.js | 6 ++---- 12 files changed, 16 insertions(+), 40 deletions(-) diff --git a/lib/facade.js b/lib/facade.js index 320891e0..f2718dde 100644 --- a/lib/facade.js +++ b/lib/facade.js @@ -1,7 +1,6 @@ 'use strict'; -var JSON3 = require('json3') - , iframeUtils = require('./utils/iframe') +var iframeUtils = require('./utils/iframe') ; function FacadeJS(transport) { @@ -11,7 +10,7 @@ function FacadeJS(transport) { } FacadeJS.prototype._transportClose = function(code, reason) { - iframeUtils.postMessage('c', JSON3.stringify([code, reason])); + iframeUtils.postMessage('c', JSON.stringify([code, reason])); }; FacadeJS.prototype._transportMessage = function(frame) { iframeUtils.postMessage('t', frame); diff --git a/lib/iframe-bootstrap.js b/lib/iframe-bootstrap.js index b6a89db9..0587b046 100644 --- a/lib/iframe-bootstrap.js +++ b/lib/iframe-bootstrap.js @@ -2,7 +2,6 @@ var urlUtils = require('./utils/url') , eventUtils = require('./utils/event') - , JSON3 = require('json3') , FacadeJS = require('./facade') , InfoIframeReceiver = require('./info-iframe-receiver') , iframeUtils = require('./utils/iframe') @@ -45,7 +44,7 @@ module.exports = function(SockJS, availableTransports) { var iframeMessage; try { - iframeMessage = JSON3.parse(e.data); + iframeMessage = JSON.parse(e.data); } catch (ignored) { debug('bad json', e.data); return; @@ -58,7 +57,7 @@ module.exports = function(SockJS, availableTransports) { case 's': var p; try { - p = JSON3.parse(iframeMessage.data); + p = JSON.parse(iframeMessage.data); } catch (ignored) { debug('bad json', iframeMessage.data); break; diff --git a/lib/info-ajax.js b/lib/info-ajax.js index dda9ac96..85a5c344 100644 --- a/lib/info-ajax.js +++ b/lib/info-ajax.js @@ -2,7 +2,6 @@ var EventEmitter = require('events').EventEmitter , inherits = require('inherits') - , JSON3 = require('json3') , objectUtils = require('./utils/object') ; @@ -24,7 +23,7 @@ function InfoAjax(url, AjaxObject) { rtt = (+new Date()) - t0; if (text) { try { - info = JSON3.parse(text); + info = JSON.parse(text); } catch (e) { debug('bad json', text); } diff --git a/lib/info-iframe-receiver.js b/lib/info-iframe-receiver.js index cf529cf0..70cbc9b4 100644 --- a/lib/info-iframe-receiver.js +++ b/lib/info-iframe-receiver.js @@ -2,7 +2,6 @@ var inherits = require('inherits') , EventEmitter = require('events').EventEmitter - , JSON3 = require('json3') , XHRLocalObject = require('./transport/sender/xhr-local') , InfoAjax = require('./info-ajax') ; @@ -14,7 +13,7 @@ function InfoReceiverIframe(transUrl) { this.ir = new InfoAjax(transUrl, XHRLocalObject); this.ir.once('finish', function(info, rtt) { self.ir = null; - self.emit('message', JSON3.stringify([info, rtt])); + self.emit('message', JSON.stringify([info, rtt])); }); } diff --git a/lib/info-iframe.js b/lib/info-iframe.js index 302dcffe..81c4acb9 100644 --- a/lib/info-iframe.js +++ b/lib/info-iframe.js @@ -2,7 +2,6 @@ var EventEmitter = require('events').EventEmitter , inherits = require('inherits') - , JSON3 = require('json3') , utils = require('./utils/event') , IframeTransport = require('./transport/iframe') , InfoReceiverIframe = require('./info-iframe-receiver') @@ -24,7 +23,7 @@ function InfoIframe(baseUrl, url) { if (msg) { var d; try { - d = JSON3.parse(msg); + d = JSON.parse(msg); } catch (e) { debug('bad json', msg); self.emit('finish'); diff --git a/lib/main.js b/lib/main.js index eb669bee..90dc0428 100644 --- a/lib/main.js +++ b/lib/main.js @@ -4,7 +4,6 @@ require('./shims'); var URL = require('url-parse') , inherits = require('inherits') - , JSON3 = require('json3') , random = require('./utils/random') , escape = require('./utils/escape') , urlUtils = require('./utils/url') @@ -263,7 +262,7 @@ SockJS.prototype._transportMessage = function(msg) { if (content) { try { - payload = JSON3.parse(content); + payload = JSON.parse(content); } catch (e) { debug('bad json', content); } diff --git a/lib/transport/iframe.js b/lib/transport/iframe.js index a6747945..d567339f 100644 --- a/lib/transport/iframe.js +++ b/lib/transport/iframe.js @@ -9,7 +9,6 @@ // http://stevesouders.com/misc/test-postmessage.php var inherits = require('inherits') - , JSON3 = require('json3') , EventEmitter = require('events').EventEmitter , version = require('../version') , urlUtils = require('../utils/url') @@ -78,7 +77,7 @@ IframeTransport.prototype._message = function(e) { var iframeMessage; try { - iframeMessage = JSON3.parse(e.data); + iframeMessage = JSON.parse(e.data); } catch (ignored) { debug('bad json', e.data); return; @@ -93,7 +92,7 @@ IframeTransport.prototype._message = function(e) { case 's': this.iframeObj.loaded(); // window global dependency - this.postMessage('s', JSON3.stringify([ + this.postMessage('s', JSON.stringify([ version , this.transport , this.transUrl @@ -106,7 +105,7 @@ IframeTransport.prototype._message = function(e) { case 'c': var cdata; try { - cdata = JSON3.parse(iframeMessage.data); + cdata = JSON.parse(iframeMessage.data); } catch (ignored) { debug('bad json', iframeMessage.data); return; @@ -119,7 +118,7 @@ IframeTransport.prototype._message = function(e) { IframeTransport.prototype.postMessage = function(type, data) { debug('postMessage', type, data); - this.iframeObj.post(JSON3.stringify({ + this.iframeObj.post(JSON.stringify({ windowId: this.windowId , type: type , data: data || '' diff --git a/lib/utils/escape.js b/lib/utils/escape.js index 2113d7de..dd23f04c 100644 --- a/lib/utils/escape.js +++ b/lib/utils/escape.js @@ -1,7 +1,5 @@ 'use strict'; -var JSON3 = require('json3'); - // Some extra characters that Chrome gets wrong, and substitutes with // something else on the wire. // eslint-disable-next-line no-control-regex, no-misleading-character-class @@ -31,7 +29,7 @@ var unrollLookup = function(escapable) { // http://en.wikipedia.org/wiki/Mapping_of_Unicode_characters#Surrogates module.exports = { quote: function(string) { - var quoted = JSON3.stringify(string); + var quoted = JSON.stringify(string); // In most cases this should be very fast and good enough. extraEscapable.lastIndex = 0; diff --git a/lib/utils/iframe.js b/lib/utils/iframe.js index 1466e08c..732838fc 100644 --- a/lib/utils/iframe.js +++ b/lib/utils/iframe.js @@ -1,7 +1,6 @@ 'use strict'; var eventUtils = require('./event') - , JSON3 = require('json3') , browser = require('./browser') ; @@ -22,7 +21,7 @@ module.exports = { , postMessage: function(type, data) { if (global.parent !== global) { - global.parent.postMessage(JSON3.stringify({ + global.parent.postMessage(JSON.stringify({ windowId: module.exports.currentWindowId , type: type , data: data || '' diff --git a/package-lock.json b/package-lock.json index 7b8eb14f..2af3261f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,6 @@ "eventsource": "^1.1.0", "faye-websocket": "^0.11.4", "inherits": "^2.0.4", - "json3": "^3.3.3", "url-parse": "^1.5.3" }, "devDependencies": { @@ -5472,11 +5471,6 @@ "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", "dev": true }, - "node_modules/json3": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.3.tgz", - "integrity": "sha512-c7/8mbUsKigAbLkD5B010BK4D9LZm7A1pNItkEwiUZRpIN66exu/e7YQWysGun+TRKaJp8MhemM+VkfWv42aCA==" - }, "node_modules/jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -14992,11 +14986,6 @@ "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", "dev": true }, - "json3": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.3.tgz", - "integrity": "sha512-c7/8mbUsKigAbLkD5B010BK4D9LZm7A1pNItkEwiUZRpIN66exu/e7YQWysGun+TRKaJp8MhemM+VkfWv42aCA==" - }, "jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", diff --git a/package.json b/package.json index 6f1746b1..9a9467d7 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ "eventsource": "^1.1.0", "faye-websocket": "^0.11.4", "inherits": "^2.0.4", - "json3": "^3.3.3", "url-parse": "^1.5.3" }, "devDependencies": { diff --git a/tests/lib/utils.js b/tests/lib/utils.js index e5f0b636..552c6e45 100644 --- a/tests/lib/utils.js +++ b/tests/lib/utils.js @@ -1,8 +1,6 @@ 'use strict'; -var expect = require('expect.js') - , JSON3 = require('json3') - ; +var expect = require('expect.js'); describe('utils', function () { describe('random', function () { @@ -95,7 +93,7 @@ describe('utils', function () { c.push(String.fromCharCode(i)); } var allChars = c.join(''); - expect(JSON3.parse(escape.quote(allChars))).to.equal(allChars); + expect(JSON.parse(escape.quote(allChars))).to.equal(allChars); }); }); });