Skip to content

Commit

Permalink
Remove JSON3
Browse files Browse the repository at this point in the history
  • Loading branch information
brycekahle committed Sep 23, 2021
1 parent eef94ea commit d9584ab
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 40 deletions.
5 changes: 2 additions & 3 deletions lib/facade.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

var JSON3 = require('json3')
, iframeUtils = require('./utils/iframe')
var iframeUtils = require('./utils/iframe')
;

function FacadeJS(transport) {
Expand All @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions lib/iframe-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions lib/info-ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

var EventEmitter = require('events').EventEmitter
, inherits = require('inherits')
, JSON3 = require('json3')
, objectUtils = require('./utils/object')
;

Expand All @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/info-iframe-receiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
;
Expand All @@ -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]));
});
}

Expand Down
3 changes: 1 addition & 2 deletions lib/info-iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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');
Expand Down
3 changes: 1 addition & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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);
}
Expand Down
9 changes: 4 additions & 5 deletions lib/transport/iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -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 || ''
Expand Down
4 changes: 1 addition & 3 deletions lib/utils/escape.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions lib/utils/iframe.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

var eventUtils = require('./event')
, JSON3 = require('json3')
, browser = require('./browser')
;

Expand All @@ -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 || ''
Expand Down
11 changes: 0 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 2 additions & 4 deletions tests/lib/utils.js
Original file line number Diff line number Diff line change
@@ -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 () {
Expand Down Expand Up @@ -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);
});
});
});
Expand Down

0 comments on commit d9584ab

Please sign in to comment.