From f06bcf2e8554ddf43d4633a1fd2b0b410d340fe2 Mon Sep 17 00:00:00 2001 From: Yoseph Anderson Date: Fri, 4 Nov 2016 10:45:31 -0600 Subject: [PATCH] javascript linter --- huffman_coding/javascript/compression.js | 18 +++++++++--------- huffman_coding/javascript/test.js | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/huffman_coding/javascript/compression.js b/huffman_coding/javascript/compression.js index f0fb6e1..e28fc81 100644 --- a/huffman_coding/javascript/compression.js +++ b/huffman_coding/javascript/compression.js @@ -8,11 +8,11 @@ function Leaf(character, count) { Leaf.prototype.encoderObject = function(parentBits) { return {[this.character]: parentBits} -} +}; Leaf.prototype.unsetParents = function() { return this; -} +}; ///////////////////////////// //// (>’.’)> NODE <(‘.'<) /// @@ -30,13 +30,13 @@ Node.prototype.encoderObject = function(parentBits = "") { var leftEncoderObject = this.left.encoderObject(parentBits + "0"); var rightEncoderObject = this.right.encoderObject(parentBits + "1"); return _.extend(leftEncoderObject, rightEncoderObject); -} +}; Node.prototype.unsetParents = function() { delete this.left.unsetParents().parent; delete this.right.unsetParents().parent; return this; -} +}; /////////////////////////////////// //// (⌐■_■) ENCODER (⌐■_■) //// @@ -55,13 +55,13 @@ function Encoder(message) { var nodeQueue = _.map(characterCounts, function(count, character) { return new Leaf(character, count); - }) + }); encoder.leaves = nodeQueue.slice(0); while(nodeQueue.length > 1) { nodeQueue = _.sortBy(nodeQueue, 'count'); - newNode = new Node(nodeQueue.shift(), nodeQueue.shift()) + newNode = new Node(nodeQueue.shift(), nodeQueue.shift()); newNode.left.parent = newNode.right.parent = newNode; nodeQueue.push(newNode); } @@ -73,13 +73,13 @@ function Encoder(message) { Encoder.prototype.characterToCode = function(character) { return this.root.encoderObject()[character]; -} +}; Encoder.prototype.decode = function(compressedBitstring) { // TODO: All the awesome -} +}; /////////////////////////////////// //// ><((((‘> DECODER <`))))>< //// @@ -92,4 +92,4 @@ function Decoder(compressedBitstring, rootNode) { Decoder.prototype.message = function(){ // TODO: It // YOU CAN DO IT!! -} +}; diff --git a/huffman_coding/javascript/test.js b/huffman_coding/javascript/test.js index 9d416e1..49166e2 100644 --- a/huffman_coding/javascript/test.js +++ b/huffman_coding/javascript/test.js @@ -29,7 +29,7 @@ describe('compression', function() { it('has a count equal to the sum of the counts of its leaves', function() { var node = new Node(new Leaf("!", 1), new Leaf("@", 2)); assert.equal(node.count, 3); - }) + }); it('returns itself as an object', function() { var leftLeaf = new Leaf("J", 1); @@ -42,7 +42,7 @@ describe('compression', function() { context('rootNode', function() { it('has a count equal to the message length', function() { - assert.equal(encoder.root.count, message.length) + assert.equal(encoder.root.count, message.length); }); it('has children that know about their parents', function() { @@ -64,7 +64,7 @@ describe('compression', function() { var numCharacters = _.uniq(message.split("")).length; assert.equal(numCharacters, encoder.leaves.length); encoder.leaves.forEach(function(leaf) { - assert.instanceOf(leaf, Leaf) + assert.instanceOf(leaf, Leaf); }); }); @@ -81,7 +81,7 @@ describe('compression', function() { }); it('can tell me the compressed bitstring', function() { - var compressed = "100001000111110000110001110111001011010010010010111010011110011100001100011101111110001101001111101011011011000100011110000111010111010111" + var compressed = "100001000111110000110001110111001011010010010010111010011110011100001100011101111110001101001111101011011011000100011110000111010111010111"; assert.equal(encoder.compressedBitstring, compressed); });