From 48f340ec12e919d70f2d9567c4a46e3c1080b1bc Mon Sep 17 00:00:00 2001 From: JinHyuk Kim Date: Thu, 8 Nov 2018 06:53:25 +0900 Subject: [PATCH 1/5] [refactor] Fix a small typo and code styling (#88) --- Readme.md | 2 +- index.js | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index 2463bc7..ac22117 100644 --- a/Readme.md +++ b/Readme.md @@ -54,7 +54,7 @@ var packet = { encoder.encode(packet, function(encodedPackets) { var decoder = new parser.Decoder(); decoder.on('decoded', function(decodedPacket) { - // decodedPacket.type == parser.BINARY_EVENTEVENT + // decodedPacket.type == parser.BINARY_EVENT // Buffer.isBuffer(decodedPacket.data.i) == true // Buffer.isBuffer(decodedPacket.data.j) == true // decodedPacket.id == 15 diff --git a/index.js b/index.js index daa242c..102615a 100644 --- a/index.js +++ b/index.js @@ -229,7 +229,7 @@ function Decoder() { Emitter(Decoder.prototype); /** - * Decodes an ecoded packet string into packet JSON. + * Decodes an encoded packet string into packet JSON. * * @param {String} obj - encoded packet * @return {Object} packet @@ -250,8 +250,7 @@ Decoder.prototype.add = function(obj) { } else { // non-binary full packet this.emit('decoded', packet); } - } - else if (isBuf(obj) || obj.base64) { // raw binary data + } else if (isBuf(obj) || obj.base64) { // raw binary data if (!this.reconstructor) { throw new Error('got binary data when not reconstructing a packet'); } else { @@ -261,8 +260,7 @@ Decoder.prototype.add = function(obj) { this.emit('decoded', packet); } } - } - else { + } else { throw new Error('Unknown type: ' + obj); } }; From b57e06304e50ee9eed258d39cd4841c6269bca75 Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Wed, 7 Nov 2018 23:15:29 +0100 Subject: [PATCH 2/5] [test] Update travis configuration --- .travis.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ddf8173..d01efa3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,8 @@ language: node_js sudo: false node_js: - - '4' - - '6' - '8' - - node -notifications: - irc: 'irc.freenode.org##socket.io' + - '10' git: depth: 1 matrix: From d95e38f6b66341612cc82bdb7f9157d698166c73 Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Wed, 7 Nov 2018 23:16:54 +0100 Subject: [PATCH 3/5] [chore] Update the Makefile --- Makefile | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 2942f60..5bbd22a 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,14 @@ -REPORTER = dot +help: ## print this message + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' -test: +test: ## run tests either in the browser or in Node.js, based on the `BROWSERS` variable @if [ "x$(BROWSERS)" = "x" ]; then make test-node; else make test-zuul; fi -test-node: - @./node_modules/.bin/mocha \ - --reporter $(REPORTER) \ - --bail \ - test/index.js +test-node: ## run tests in Node.js + @./node_modules/.bin/mocha --reporter dot --bail test/index.js -test-zuul: - @./node_modules/zuul/bin/zuul \ - test/index.js +test-zuul: ## run tests in the browser + @./node_modules/zuul/bin/zuul test/index.js -.PHONY: test +.PHONY: help test test-node test-zuul From b47efb270d959e7456d8d44b4f3c386a884542b8 Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Wed, 7 Nov 2018 23:14:07 +0100 Subject: [PATCH 4/5] [fix] Remove any reference to the `global` variable Related: https://github.com/socketio/socket.io-client/issues/1166 --- binary.js | 4 ++-- is-buffer.js | 18 +++++++----------- test/blob.js | 8 ++++---- test/index.js | 7 +++++-- test/support/env.js | 2 +- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/binary.js b/binary.js index 1a530c7..3e2347d 100644 --- a/binary.js +++ b/binary.js @@ -7,8 +7,8 @@ var isArray = require('isarray'); var isBuf = require('./is-buffer'); var toString = Object.prototype.toString; -var withNativeBlob = typeof global.Blob === 'function' || toString.call(global.Blob) === '[object BlobConstructor]'; -var withNativeFile = typeof global.File === 'function' || toString.call(global.File) === '[object FileConstructor]'; +var withNativeBlob = typeof Blob === 'function' || (typeof Blob !== 'undefined' && toString.call(Blob) === '[object BlobConstructor]'); +var withNativeFile = typeof File === 'function' || (typeof File !== 'undefined' && toString.call(File) === '[object FileConstructor]'); /** * Replaces every Buffer | ArrayBuffer in packet with a numbered placeholder. diff --git a/is-buffer.js b/is-buffer.js index 9f451a4..c833865 100644 --- a/is-buffer.js +++ b/is-buffer.js @@ -1,16 +1,12 @@ module.exports = isBuf; -var withNativeBuffer = typeof global.Buffer === 'function' && typeof global.Buffer.isBuffer === 'function'; -var withNativeArrayBuffer = typeof global.ArrayBuffer === 'function'; +var withNativeBuffer = typeof Buffer === 'function' && typeof Buffer.isBuffer === 'function'; +var withNativeArrayBuffer = typeof ArrayBuffer === 'function'; -var isView = (function () { - if (withNativeArrayBuffer && typeof global.ArrayBuffer.isView === 'function') { - return global.ArrayBuffer.isView; - } else { - return function (obj) { return obj.buffer instanceof global.ArrayBuffer; }; - } -})(); +var isView = function (obj) { + return typeof ArrayBuffer.isView === 'function' ? ArrayBuffer.isView(obj) : (obj.buffer instanceof ArrayBuffer); +}; /** * Returns true if obj is a buffer or an arraybuffer. @@ -19,6 +15,6 @@ var isView = (function () { */ function isBuf(obj) { - return (withNativeBuffer && global.Buffer.isBuffer(obj)) || - (withNativeArrayBuffer && (obj instanceof global.ArrayBuffer || isView(obj))); + return (withNativeBuffer && Buffer.isBuffer(obj)) || + (withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj))); } diff --git a/test/blob.js b/test/blob.js index 31d4b24..4e101fe 100644 --- a/test/blob.js +++ b/test/blob.js @@ -1,10 +1,10 @@ var parser = require('../index.js'); -var expect = require('expect.js'); var helpers = require('./helpers.js'); -var encode = parser.encode; -var decode = parser.decode; -var BlobBuilder = global.BlobBuilder || global.WebKitBlobBuilder || global.MSBlobBuilder || global.MozBlobBuilder; +var BlobBuilder = typeof BlobBuilder !== 'undefined' ? BlobBuilder : + typeof WebKitBlobBuilder !== 'undefined' ? WebKitBlobBuilder : + typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder : + typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder : false; describe('parser', function() { it('encodes a Blob', function() { diff --git a/test/index.js b/test/index.js index ba6ce75..9d4a1cb 100644 --- a/test/index.js +++ b/test/index.js @@ -12,7 +12,10 @@ var blobSupported = (function() { * Create a blob builder even when vendor prefixes exist */ -var BlobBuilder = global.BlobBuilder || global.WebKitBlobBuilder || global.MSBlobBuilder || global.MozBlobBuilder; +var BlobBuilder = typeof BlobBuilder !== 'undefined' ? BlobBuilder : + typeof WebKitBlobBuilder !== 'undefined' ? WebKitBlobBuilder : + typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder : + typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder : false; var blobBuilderSupported = !!BlobBuilder && !!BlobBuilder.prototype.append && !!BlobBuilder.prototype.getBlob; require('./parser.js'); @@ -21,7 +24,7 @@ if (!env.browser) { require('./buffer.js'); } -if (global.ArrayBuffer) { +if (typeof ArrayBuffer !== 'undefined') { require('./arraybuffer.js'); } diff --git a/test/support/env.js b/test/support/env.js index c1d494e..0b4873d 100644 --- a/test/support/env.js +++ b/test/support/env.js @@ -2,4 +2,4 @@ // we only do this in our tests because we need to test engine.io-client // support in browsers and in node.js // some tests do not yet work in both -module.exports.browser = !!global.window; +module.exports.browser = typeof window !== 'undefined'; From 0de72b9cc25c0950f09811e1e2a951b80e67e3fb Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Wed, 7 Nov 2018 23:58:21 +0100 Subject: [PATCH 5/5] [chore] Release 3.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ba5067a..f95861d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "socket.io-parser", - "version": "3.2.0", + "version": "3.3.0", "description": "socket.io protocol parser", "repository": { "type": "git", pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy