From 44a677a9c0631daed0b0f4a4b68c095b624183b8 Mon Sep 17 00:00:00 2001 From: James Coglan Date: Tue, 11 Jun 2019 15:54:09 +0100 Subject: [PATCH] Formatting change: {...} should have spaces inside the braces --- README.md | 10 ++--- lib/parser.js | 2 +- lib/pipeline/README.md | 10 ++--- lib/pipeline/functor.js | 2 +- lib/pipeline/index.js | 4 +- lib/websocket_extensions.js | 2 +- spec/parser_spec.js | 38 ++++++++--------- spec/websocket_extensions_spec.js | 68 +++++++++++++++---------------- 8 files changed, 68 insertions(+), 68 deletions(-) diff --git a/README.md b/README.md index 3ce97fc..68694ea 100644 --- a/README.md +++ b/README.md @@ -234,8 +234,8 @@ then the `permessage-deflate` extension will receive the call: ```js ext.createServerSession([ - {server_no_context_takeover: true, server_max_window_bits: 8}, - {server_max_window_bits: 15} + { server_no_context_takeover: true, server_max_window_bits: 8 }, + { server_max_window_bits: 15 } ]); ``` @@ -251,8 +251,8 @@ implement the following methods, as well as the *Session* API listed below. ```js clientSession.generateOffer() // e.g. -> [ -// {server_no_context_takeover: true, server_max_window_bits: 8}, -// {server_max_window_bits: 15} +// { server_no_context_takeover: true, server_max_window_bits: 8 }, +// { server_max_window_bits: 15 } // ] ``` @@ -277,7 +277,7 @@ must implement the following methods, as well as the *Session* API listed below. ```js serverSession.generateResponse() -// e.g. -> {server_max_window_bits: 8} +// e.g. -> { server_max_window_bits: 8 } ``` This returns the set of parameters the server session wants to send in its diff --git a/lib/parser.js b/lib/parser.js index 40a9ae0..b9e5e3e 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -83,7 +83,7 @@ Offers.prototype.push = function(name, params) { this._byName[name] = []; this._byName[name].push(params); - this._inOrder.push({name: name, params: params}); + this._inOrder.push({ name: name, params: params }); }; Offers.prototype.eachOffer = function(callback, context) { diff --git a/lib/pipeline/README.md b/lib/pipeline/README.md index ec76a9c..322a9c5 100644 --- a/lib/pipeline/README.md +++ b/lib/pipeline/README.md @@ -124,11 +124,11 @@ var crypto = require('crypto'), large = crypto.randomBytes(1 << 14), small = new Buffer('hi'); -deflate.outgoing({data: large}, function() { +deflate.outgoing({ data: large }, function() { console.log(1, 'large'); }); -deflate.outgoing({data: small}, function() { +deflate.outgoing({ data: small }, function() { console.log(2, 'small'); }); @@ -205,7 +205,7 @@ order is preserved: ```js var stream = require('stream'), - session = new stream.Transform({objectMode: true}); + session = new stream.Transform({ objectMode: true }); session._transform = function(message, _, callback) { var self = this; @@ -276,11 +276,11 @@ above: ```js var functor = new Functor(deflate, 'outgoing'); -functor.call({data: large}, function() { +functor.call({ data: large }, function() { console.log(1, 'large'); }); -functor.call({data: small}, function() { +functor.call({ data: small }, function() { console.log(2, 'small'); }); diff --git a/lib/pipeline/functor.js b/lib/pipeline/functor.js index f6c5f3b..fadb49a 100644 --- a/lib/pipeline/functor.js +++ b/lib/pipeline/functor.js @@ -15,7 +15,7 @@ Functor.QUEUE_SIZE = 8; Functor.prototype.call = function(error, message, callback, context) { if (this._stopped) return; - var record = {error: error, message: message, callback: callback, context: context, done: false}, + var record = { error: error, message: message, callback: callback, context: context, done: false }, called = false, self = this; diff --git a/lib/pipeline/index.js b/lib/pipeline/index.js index 169303c..930bbc8 100644 --- a/lib/pipeline/index.js +++ b/lib/pipeline/index.js @@ -5,7 +5,7 @@ var Cell = require('./cell'), var Pipeline = function(sessions) { this._cells = sessions.map(function(session) { return new Cell(session) }); - this._stopped = {incoming: false, outgoing: false}; + this._stopped = { incoming: false, outgoing: false }; }; Pipeline.prototype.processIncomingMessage = function(message, callback, context) { @@ -19,7 +19,7 @@ Pipeline.prototype.processOutgoingMessage = function(message, callback, context) }; Pipeline.prototype.close = function(callback, context) { - this._stopped = {incoming: true, outgoing: true}; + this._stopped = { incoming: true, outgoing: true }; var closed = this._cells.map(function(a) { return a.close() }); if (callback) diff --git a/lib/websocket_extensions.js b/lib/websocket_extensions.js index 12a1622..48adad8 100644 --- a/lib/websocket_extensions.js +++ b/lib/websocket_extensions.js @@ -112,7 +112,7 @@ var instance = { }, validFrameRsv: function(frame) { - var allowed = {rsv1: false, rsv2: false, rsv3: false}, + var allowed = { rsv1: false, rsv2: false, rsv3: false }, ext; if (Extensions.MESSAGE_OPCODES.indexOf(frame.opcode) >= 0) { diff --git a/spec/parser_spec.js b/spec/parser_spec.js index aa8f9e9..4f85aff 100644 --- a/spec/parser_spec.js +++ b/spec/parser_spec.js @@ -20,56 +20,56 @@ test.describe("Parser", function() { with(this) { }}) it("parses one offer with no params", function() { with(this) { - assertEqual( [{name: "a", params: {}}], + assertEqual( [{ name: "a", params: {}}], parse('a') ) }}) it("parses two offers with no params", function() { with(this) { - assertEqual( [{name: "a", params: {}}, {name: "b", params: {}}], + assertEqual( [{ name: "a", params: {}}, { name: "b", params: {}}], parse('a, b') ) }}) it("parses a duplicate offer name", function() { with(this) { - assertEqual( [{name: "a", params: {}}, {name: "a", params: {}}], + assertEqual( [{ name: "a", params: {}}, { name: "a", params: {}}], parse('a, a') ) }}) it("parses a flag", function() { with(this) { - assertEqual( [{name: "a", params: {b: true}}], + assertEqual( [{ name: "a", params: { b: true }}], parse('a; b') ) }}) it("parses an unquoted param", function() { with(this) { - assertEqual( [{name: "a", params: {b: 1}}], + assertEqual( [{ name: "a", params: { b: 1 }}], parse('a; b=1') ) }}) it("parses a quoted param", function() { with(this) { - assertEqual( [{name: "a", params: {b: 'hi, "there'}}], + assertEqual( [{ name: "a", params: { b: 'hi, "there' }}], parse('a; b="hi, \\"there"') ) }}) it("parses multiple params", function() { with(this) { - assertEqual( [{name: "a", params: {b: true, c: 1, d: 'hi'}}], + assertEqual( [{ name: "a", params: { b: true, c: 1, d: 'hi' }}], parse('a; b; c=1; d="hi"') ) }}) it("parses duplicate params", function() { with(this) { - assertEqual( [{name: "a", params: {b: [true, 'hi'], c: 1}}], + assertEqual( [{ name: "a", params: { b: [true, 'hi'], c: 1 }}], parse('a; b; c=1; b="hi"') ) }}) it("parses multiple complex offers", function() { with(this) { - assertEqual( [{name: "a", params: {b: 1}}, - {name: "c", params: {}}, - {name: "b", params: {d: true}}, - {name: "c", params: {e: ['hi, there', true]}}, - {name: "a", params: {b: true}}], + assertEqual( [{ name: "a", params: { b: 1 }}, + { name: "c", params: {}}, + { name: "b", params: { d: true }}, + { name: "c", params: { e: ['hi, there', true] }}, + { name: "a", params: { b: true }}], parse('a; b=1, c, b; d, c; e="hi, there"; e, a; b') ) }}) it("parses an extension name that shadows an Object property", function() { with(this) { - assertEqual( [{name: "hasOwnProperty", params: {}}], + assertEqual( [{ name: "hasOwnProperty", params: {}}], parse('hasOwnProperty') ) }}) @@ -86,23 +86,23 @@ test.describe("Parser", function() { with(this) { }}) it("serializes a flag", function() { with(this) { - assertEqual( 'a; b', Parser.serializeParams('a', {b: true}) ) + assertEqual( 'a; b', Parser.serializeParams('a', { b: true }) ) }}) it("serializes an unquoted param", function() { with(this) { - assertEqual( 'a; b=42', Parser.serializeParams('a', {b: '42'}) ) + assertEqual( 'a; b=42', Parser.serializeParams('a', { b: '42' }) ) }}) it("serializes a quoted param", function() { with(this) { - assertEqual( 'a; b="hi, there"', Parser.serializeParams('a', {b: 'hi, there'}) ) + assertEqual( 'a; b="hi, there"', Parser.serializeParams('a', { b: 'hi, there' }) ) }}) it("serializes multiple params", function() { with(this) { - assertEqual( 'a; b; c=1; d=hi', Parser.serializeParams('a', {b: true, c: 1, d: 'hi'}) ) + assertEqual( 'a; b; c=1; d=hi', Parser.serializeParams('a', { b: true, c: 1, d: 'hi' }) ) }}) it("serializes duplicate params", function() { with(this) { - assertEqual( 'a; b; b=hi; c=1', Parser.serializeParams('a', {b: [true, 'hi'], c: 1}) ) + assertEqual( 'a; b; b=hi; c=1', Parser.serializeParams('a', { b: [true, 'hi'], c: 1 }) ) }}) }}) }}) diff --git a/spec/websocket_extensions_spec.js b/spec/websocket_extensions_spec.js index 9988f47..8c6d873 100644 --- a/spec/websocket_extensions_spec.js +++ b/spec/websocket_extensions_spec.js @@ -6,7 +6,7 @@ test.describe("Extensions", function() { with(this) { before(function() { with(this) { this.extensions = new Extensions() - this.ext = {name: "deflate", type: "permessage", rsv1: true, rsv2: false, rsv3: false} + this.ext = { name: "deflate", type: "permessage", rsv1: true, rsv2: false, rsv3: false } this.session = {} }}) @@ -38,20 +38,20 @@ test.describe("Extensions", function() { with(this) { describe("client sessions", function() { with(this) { before(function() { with(this) { - this.offer = {mode: "compress"} + this.offer = { mode: "compress" } stub(ext, "createClientSession").returns(session) stub(session, "generateOffer").returns(offer) extensions.add(ext) - this.conflict = {name: "tar", type: "permessage", rsv1: true, rsv2: false, rsv3: false} + this.conflict = { name: "tar", type: "permessage", rsv1: true, rsv2: false, rsv3: false } this.conflictSession = {} stub(conflict, "createClientSession").returns(conflictSession) - stub(conflictSession, "generateOffer").returns({gzip: true}) + stub(conflictSession, "generateOffer").returns({ gzip: true }) - this.nonconflict = {name: "reverse", type: "permessage", rsv1: false, rsv2: true, rsv3: false} + this.nonconflict = { name: "reverse", type: "permessage", rsv1: false, rsv2: true, rsv3: false } this.nonconflictSession = {} stub(nonconflict, "createClientSession").returns(nonconflictSession) - stub(nonconflictSession, "generateOffer").returns({utf8: true}) + stub(nonconflictSession, "generateOffer").returns({ utf8: true }) stub(session, "activate").returns(true) stub(conflictSession, "activate").returns(true) @@ -133,18 +133,18 @@ test.describe("Extensions", function() { with(this) { }}) it("activates one session with a boolean param", function() { with(this) { - expect(session, "activate").given({gzip: true}).exactly(1).returning(true) + expect(session, "activate").given({ gzip: true }).exactly(1).returning(true) extensions.activate("deflate; gzip") }}) it("activates one session with a string param", function() { with(this) { - expect(session, "activate").given({mode: "compress"}).exactly(1).returning(true) + expect(session, "activate").given({ mode: "compress" }).exactly(1).returning(true) extensions.activate("deflate; mode=compress") }}) it("activates multiple sessions", function() { with(this) { - expect(session, "activate").given({a: true}).exactly(1).returning(true) - expect(nonconflictSession, "activate").given({b: true}).exactly(1).returning(true) + expect(session, "activate").given({ a: true }).exactly(1).returning(true) + expect(nonconflictSession, "activate").given({ b: true }).exactly(1).returning(true) extensions.activate("deflate; a, reverse; b") }}) @@ -180,7 +180,7 @@ test.describe("Extensions", function() { with(this) { it("processes messages in the reverse order given in the server's response", function() { with(this) { extensions.activate("deflate, reverse") - extensions.processIncomingMessage({frames: []}, function(error, message) { + extensions.processIncomingMessage({ frames: [] }, function(error, message) { assertNull( error ) assertEqual( ["reverse", "deflate"], message.frames ) }) @@ -188,9 +188,9 @@ test.describe("Extensions", function() { with(this) { it("yields an error if a session yields an error", function() { with(this) { extensions.activate("deflate") - stub(session, "processIncomingMessage").yields([{message: "ENOENT"}]) + stub(session, "processIncomingMessage").yields([{ message: "ENOENT" }]) - extensions.processIncomingMessage({frames: []}, function(error, message) { + extensions.processIncomingMessage({ frames: [] }, function(error, message) { assertEqual( "deflate: ENOENT", error.message ) assertNull( message ) }) @@ -198,11 +198,11 @@ test.describe("Extensions", function() { with(this) { it("does not call sessions after one has yielded an error", function() { with(this) { extensions.activate("deflate, reverse") - stub(nonconflictSession, "processIncomingMessage").yields([{message: "ENOENT"}]) + stub(nonconflictSession, "processIncomingMessage").yields([{ message: "ENOENT" }]) expect(session, "processIncomingMessage").exactly(0) - extensions.processIncomingMessage({frames: []}, function() {}) + extensions.processIncomingMessage({ frames: [] }, function() {}) }}) }}) @@ -336,11 +336,11 @@ test.describe("Extensions", function() { with(this) { extensions.activate("deflate, reverse") var out = [] - extensions.processOutgoingMessage({frames: []}, function(error, message) { out.push(message) }) - extensions.processOutgoingMessage({frames: [1]}, function(error, message) { out.push(message) }) + extensions.processOutgoingMessage({ frames: [] }, function(error, message) { out.push(message) }) + extensions.processOutgoingMessage({ frames: [1] }, function(error, message) { out.push(message) }) clock.tick(200) - assertEqual( [{frames: ["a", "c"]}, {frames: [1, "b", "d"]}], out ) + assertEqual( [{ frames: ["a", "c"] }, { frames: [1, "b", "d"] }], out ) }}) it("defers closing until the extension has finished processing", function() { with(this) { @@ -349,7 +349,7 @@ test.describe("Extensions", function() { with(this) { var closed = false, notified = false stub(session, "close", function() { closed = true }) - extensions.processOutgoingMessage({frames: []}, function() {}) + extensions.processOutgoingMessage({ frames: [] }, function() {}) extensions.close(function() { notified = true }) clock.tick(50) @@ -366,7 +366,7 @@ test.describe("Extensions", function() { with(this) { stub(session, "close", function() { closed[0] = true }) stub(nonconflictSession, "close", function() { closed[1] = true }) - extensions.processOutgoingMessage({frames: []}, function() {}); + extensions.processOutgoingMessage({ frames: [] }, function() {}); extensions.close(function() { notified = true }) clock.tick(50) @@ -384,7 +384,7 @@ test.describe("Extensions", function() { with(this) { extensions.activate("deflate") stub(session, "close", function() { closed = true }) - extensions.processOutgoingMessage({frames: []}, function() {}) + extensions.processOutgoingMessage({ frames: [] }, function() {}) extensions.close() clock.tick(100) @@ -397,7 +397,7 @@ test.describe("Extensions", function() { with(this) { it("processes messages in the order given in the server's response", function() { with(this) { extensions.activate("deflate, reverse") - extensions.processOutgoingMessage({frames: []}, function(error, message) { + extensions.processOutgoingMessage({ frames: [] }, function(error, message) { assertNull( error ) assertEqual( ["deflate", "reverse"], message.frames ) }) @@ -406,7 +406,7 @@ test.describe("Extensions", function() { with(this) { it("processes messages in the server's order, not the client's order", function() { with(this) { extensions.activate("reverse, deflate") - extensions.processOutgoingMessage({frames: []}, function(error, message) { + extensions.processOutgoingMessage({ frames: [] }, function(error, message) { assertNull( error ) assertEqual( ["reverse", "deflate"], message.frames ) }) @@ -414,9 +414,9 @@ test.describe("Extensions", function() { with(this) { it("yields an error if a session yields an error", function() { with(this) { extensions.activate("deflate") - stub(session, "processOutgoingMessage").yields([{message: "ENOENT"}]) + stub(session, "processOutgoingMessage").yields([{ message: "ENOENT" }]) - extensions.processOutgoingMessage({frames: []}, function(error, message) { + extensions.processOutgoingMessage({ frames: [] }, function(error, message) { assertEqual( "deflate: ENOENT", error.message ) assertNull( message ) }) @@ -424,30 +424,30 @@ test.describe("Extensions", function() { with(this) { it("does not call sessions after one has yielded an error", function() { with(this) { extensions.activate("deflate, reverse") - stub(session, "processOutgoingMessage").yields([{message: "ENOENT"}]) + stub(session, "processOutgoingMessage").yields([{ message: "ENOENT" }]) expect(nonconflictSession, "processOutgoingMessage").exactly(0) - extensions.processOutgoingMessage({frames: []}, function() {}) + extensions.processOutgoingMessage({ frames: [] }, function() {}) }}) }}) }}) describe("server sessions", function() { with(this) { before(function() { with(this) { - this.response = {mode: "compress"} + this.response = { mode: "compress" } stub(ext, "createServerSession").returns(session) stub(session, "generateResponse").returns(response) - this.conflict = {name: "tar", type: "permessage", rsv1: true, rsv2: false, rsv3: false} + this.conflict = { name: "tar", type: "permessage", rsv1: true, rsv2: false, rsv3: false } this.conflictSession = {} stub(conflict, "createServerSession").returns(conflictSession) - stub(conflictSession, "generateResponse").returns({gzip: true}) + stub(conflictSession, "generateResponse").returns({ gzip: true }) - this.nonconflict = {name: "reverse", type: "permessage", rsv1: false, rsv2: true, rsv3: false} + this.nonconflict = { name: "reverse", type: "permessage", rsv1: false, rsv2: true, rsv3: false } this.nonconflictSession = {} stub(nonconflict, "createServerSession").returns(nonconflictSession) - stub(nonconflictSession, "generateResponse").returns({utf8: true}) + stub(nonconflictSession, "generateResponse").returns({ utf8: true }) extensions.add(ext) extensions.add(conflict) @@ -456,12 +456,12 @@ test.describe("Extensions", function() { with(this) { describe("generateResponse", function() { with(this) { it("asks the extension for a server session with the offer", function() { with(this) { - expect(ext, "createServerSession").given([{flag: true}]).exactly(1).returning(session) + expect(ext, "createServerSession").given([{ flag: true }]).exactly(1).returning(session) extensions.generateResponse("deflate; flag") }}) it("asks the extension for a server session with multiple offers", function() { with(this) { - expect(ext, "createServerSession").given([{a: true}, {b: true}]).exactly(1).returning(session) + expect(ext, "createServerSession").given([{ a: true }, { b: true }]).exactly(1).returning(session) extensions.generateResponse("deflate; a, deflate; b") }})