From 024ad14bf2892de2476fb511b59c308d954d9746 Mon Sep 17 00:00:00 2001 From: Jacob Carlsson Date: Fri, 23 Jan 2015 18:54:17 +0100 Subject: [PATCH 01/12] Add stream support --- morse.js | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- streamtest.js | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 streamtest.js diff --git a/morse.js b/morse.js index 71a044a..cc6c43a 100644 --- a/morse.js +++ b/morse.js @@ -2,11 +2,59 @@ module.exports = { encode: encode, decode: decode, map: map, - tree: tree + tree: tree, + createEncodeStream: createEncodeStream, + createDecodeStream: createDecodeStream }; var map = require('./map'); var tree = require('./tree'); +var util = require('util'); +var Transform = require('stream').Transform; + +// Encode stream +function MorseEncodeStream(options) { + Transform.call(this, options); +} + +util.inherits(MorseEncodeStream, Transform); + +MorseEncodeStream.prototype._transform = function(chunk, encoding, callback) { + var str = chunk.toString().toUpperCase(); + str = encode(str); + this.push(str) + callback(); +}; + +MorseEncodeStream.prototype._flush = function(callback) { + callback(); +}; + +// Decode stream stream +function MorseDecodeStream(options) { + Transform.call(this, options); +} + +util.inherits(MorseDecodeStream, Transform); + +MorseDecodeStream.prototype._transform = function(chunk, encoding, callback) { + var str = chunk.toString().toUpperCase(); + str = decode(str); + this.push(str) + callback(); +}; + +MorseDecodeStream.prototype._flush = function(callback) { + callback(); +}; + +function createEncodeStream() { + return new MorseEncodeStream(); +} + +function createDecodeStream() { + return new MorseDecodeStream(); +} function encode (obj) { return maybeRecurse(obj, encodeMorseString); diff --git a/streamtest.js b/streamtest.js new file mode 100644 index 0000000..a644b3d --- /dev/null +++ b/streamtest.js @@ -0,0 +1,39 @@ +var morse = require('./'); +var fs = require('fs'); +var Q = require('q'); + + +Q.fcall(function() { + var defered = Q.defer(); + + console.log('Readfile'); + console.time('readfile'); + + fs.readFile(__dirname + '/test/largetext.txt', 'utf8', function(err, text) { + if(err) return console.error(err); + + var encoded = morse.encode(text); + console.timeEnd('readfile'); + + var decoded = morse.decode(encoded); + + defered.resolve(); + }); + + return defered.promise; +}) +.then(function() { + var defered = Q.defer(); + console.log('Stream'); + + // Using streams + console.time('stream'); + var readStream = fs.createReadStream(__dirname + '/test/largetext.txt'); + + readStream.pipe(morse.createEncodeStream()).pipe(morse.createDecodeStream()).on('finish', function() { + console.timeEnd('stream'); + defered.resolve(); + }); + + return defered.promise; +}); From 4398ae894f3f2e2555f605898118088582eaab2f Mon Sep 17 00:00:00 2001 From: Jacob Carlsson Date: Fri, 23 Jan 2015 18:56:07 +0100 Subject: [PATCH 02/12] Add through2 for streams instead of manual stream creation --- morse.js | 46 ++++++++-------------------------------------- package.json | 8 ++++++-- 2 files changed, 14 insertions(+), 40 deletions(-) diff --git a/morse.js b/morse.js index cc6c43a..3100a7d 100644 --- a/morse.js +++ b/morse.js @@ -11,49 +11,19 @@ var map = require('./map'); var tree = require('./tree'); var util = require('util'); var Transform = require('stream').Transform; +var through2 = require('through2'); -// Encode stream -function MorseEncodeStream(options) { - Transform.call(this, options); -} - -util.inherits(MorseEncodeStream, Transform); - -MorseEncodeStream.prototype._transform = function(chunk, encoding, callback) { - var str = chunk.toString().toUpperCase(); - str = encode(str); - this.push(str) - callback(); -}; - -MorseEncodeStream.prototype._flush = function(callback) { - callback(); -}; - -// Decode stream stream -function MorseDecodeStream(options) { - Transform.call(this, options); -} - -util.inherits(MorseDecodeStream, Transform); - -MorseDecodeStream.prototype._transform = function(chunk, encoding, callback) { - var str = chunk.toString().toUpperCase(); - str = decode(str); - this.push(str) - callback(); -}; - -MorseDecodeStream.prototype._flush = function(callback) { - callback(); -}; - +// Stream support function createEncodeStream() { - return new MorseEncodeStream(); + return through2({}, function(chunk, enc, callback) { + callback(null, encode(chunk.toString())); + }); } function createDecodeStream() { - return new MorseDecodeStream(); + return through2({}, function(chunk, enc, callback) { + callback(null, decode(chunk.toString())); + }); } function encode (obj) { diff --git a/package.json b/package.json index 16be66a..c1b10de 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,13 @@ }, "main": "morse.js", "dependencies": { - "optimist": "*" + "optimist": "*", + "through2": "^0.6.3" + }, + "devDependencies": { + "mocha": "^2.1.0", + "q": "^1.1.2" }, - "devDependencies": {}, "optionalDependencies": {}, "engines": { "node": "*" From 1f37f0ab27d943e1143bb333cb3eaa84af020979 Mon Sep 17 00:00:00 2001 From: Jacob Carlsson Date: Tue, 27 Jan 2015 11:09:31 +0100 Subject: [PATCH 03/12] Add tests for streams --- package.json | 3 ++ test/array.js | 30 ++++++++-------- test/lorem-ipsum-encoded.txt | 1 + test/lorem-ipsum.txt | 1 + test/streamSpec.js | 67 ++++++++++++++++++++++++++++++++++++ 5 files changed, 86 insertions(+), 16 deletions(-) create mode 100644 test/lorem-ipsum-encoded.txt create mode 100644 test/lorem-ipsum.txt create mode 100644 test/streamSpec.js diff --git a/package.json b/package.json index c1b10de..d1f9d12 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,9 @@ "name": "morse", "description": "Morse code for mad scientists", "version": "0.1.0", + "scripts": { + "test": "mocha test/*Spec.js" + }, "repository": { "type": "git", "url": "git://github.com/ecto/morse.git" diff --git a/test/array.js b/test/array.js index 8415c62..67a3cad 100644 --- a/test/array.js +++ b/test/array.js @@ -1,20 +1,18 @@ var morse = require('../'); +var assert = require('assert'); -var arr = [ - 'hello', - 'world' -]; -console.log(arr); +describe('array', function() { + it('should encode and decode an array', function() { + var arr = [ + 'hello', + 'world' + ]; -var encoded = morse.encode(arr); -console.log(encoded); + var encoded = morse.encode(arr); + var decoded = morse.decode(encoded); -var decoded = morse.decode(encoded); -console.log(decoded); - -var expected = [ - 'HELLO', - 'WORLD' -]; - -console.log(expected[1] == decoded[1] ? 'pass' : 'fail'); + assert.deepEqual(decoded, arr.map(function(str) { + return str.toUpperCase(); + }), 'Arrays should be equal except for case'); + }); +}); diff --git a/test/lorem-ipsum-encoded.txt b/test/lorem-ipsum-encoded.txt new file mode 100644 index 0000000..c2e0597 --- /dev/null +++ b/test/lorem-ipsum-encoded.txt @@ -0,0 +1 @@ +.-.. --- .-. . -- ....... .. .--. ... ..- -- ....... -.. --- .-.. --- .-. ....... ... .. - ....... .- -- . - --..-- ....... -.-. --- -. ... . -.-. - . - ..- .-. ....... .- -.. .. .--. .. ... -.-. .. -. --. ....... . .-.. .. - .-.-.- ....... ..- - ....... ..- - ....... --- .-. -.-. .. ....... . .-.. .. - .-.-.- ....... ...- . ... - .. -... ..- .-.. ..- -- ....... - .-. .. ... - .. --.- ..- . ....... .- .-. -.-. ..- ....... . ..- ....... --- -.. .. --- ....... -... .. -... . -. -.. ..- -- ....... - .. -. -.-. .. -.. ..- -. - .-.-.- ....... .- . -. . .- -. ....... .-.. .- --- .-. . . - ....... .- - ....... --- -.. .. --- ....... -.-. --- -. -.. .. -- . -. - ..- -- ....... ..-. .- ..- -.-. .. -... ..- ... .-.-.- ....... .. -. - . --. . .-. ....... -.-. --- -. ... . --.- ..- .- - ....... -. .. ... .. ....... -.. .. .- -- .-.-.- ....... -. ..- .-.. .-.. .- -- ....... .. -. ....... --- .-. -.-. .. ....... ..- - ....... ..-. . .-.. .. ... ....... ... --- -.. .- .-.. . ... ....... .- .-.. .. --.- ..- . - .-.-.- ....... .--. .... .- ... . .-.. .-.. ..- ... ....... . - ....... -. ..- .-.. .-.. .- ....... . --. . - ....... .-.. .. --. ..- .-.. .- ....... ...- .. ...- . .-. .-. .- ....... ...- .- .-. .. ..- ... ....... . - ....... .- - ....... -. ..- -. -.-. .-.-.- ....... -. ..- .-.. .-.. .- ....... ..-. .- -.-. .. .-.. .. ... .. .-.-.- ....... -. ..- .-.. .-.. .- -- ....... .- ..- -.-. - --- .-. ....... -. . -.-. ....... --- .-. -.-. .. ....... -. --- -. ....... ..-. .-. .. -. --. .. .-.. .-.. .- .-.-.- ....... -.-. .-. .- ... ....... -. --- -. ....... .. -. - . .-. -.. ..- -- ....... ... .- .--. .. . -. .-.-.- ....... -.. ..- .. ... ....... ...- .. ...- . .-. .-. .- ....... ... .. - ....... .- -- . - ....... ...- . .-.. .. - ....... ... .. - ....... .- -- . - ....... . .-.. . .. ..-. . -. -.. .-.-.- ....... -. ..- .-.. .-.. .- -- ....... .- ..- -.-. - --- .-. ....... .- ....... ...- . .-.. .. - ....... .- -.-. ....... ..-. .- -.-. .. .-.. .. ... .. ... .-.-.- \ No newline at end of file diff --git a/test/lorem-ipsum.txt b/test/lorem-ipsum.txt new file mode 100644 index 0000000..ec98a8f --- /dev/null +++ b/test/lorem-ipsum.txt @@ -0,0 +1 @@ +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut orci elit. Vestibulum tristique arcu eu odio bibendum tincidunt. Aenean laoreet at odio condimentum faucibus. Integer consequat nisi diam. Nullam in orci ut felis sodales aliquet. Phasellus et nulla eget ligula viverra varius et at nunc. Nulla facilisi. Nullam auctor nec orci non fringilla. Cras non interdum sapien. Duis viverra sit amet velit sit amet eleifend. Nullam auctor a velit ac facilisis. diff --git a/test/streamSpec.js b/test/streamSpec.js new file mode 100644 index 0000000..db95628 --- /dev/null +++ b/test/streamSpec.js @@ -0,0 +1,67 @@ +var morse = require('../'); +var assert = require('assert'); +var fs = require('fs'); +var through2 = require('through2'); + +// Saves everything in .result +function StringStream() { + this.result = ''; +} + +StringStream.prototype.createStream = function() { + var _this = this; + + return through2({}, function(chunk, enc, callback) { + _this.result += chunk.toString(); + callback(null, chunk); + }, function(callback) { + callback(); + }); +} + +describe('stream', function() { + + it('should encode a stream', function(done) { + + fs.readFile(__dirname + '/lorem-ipsum.txt', 'utf8', function(err, text) { + if(err) return console.error(err); + + var encoded = morse.encode(text); + + var stringStream = new StringStream(); + + // Test it with streams + var readStream = fs.createReadStream(__dirname + '/lorem-ipsum.txt', {encoding: 'utf8'}); + readStream + .pipe(morse.createEncodeStream()) + .pipe(stringStream.createStream()) + .on('finish', function() { + + assert.equal(stringStream.result, encoded); + done(); + }); + }); + }); + + + it('should decode a stream', function(done) { + fs.readFile(__dirname + '/lorem-ipsum-encoded.txt', 'utf8', function(err, text) { + if(err) return console.error(err); + + var decoded = morse.decode(text); + + var stringStream = new StringStream(); + + // Test it with streams + var readStream = fs.createReadStream(__dirname + '/lorem-ipsum-encoded.txt', {encoding: 'utf8'}); + readStream + .pipe(morse.createDecodeStream()) + .pipe(stringStream.createStream()) + .on('finish', function() { + + assert.equal(stringStream.result, decoded); + done(); + }); + }); + }); +}); \ No newline at end of file From 47b8a8405b2ca7771a2db87118dbc407c70fd70f Mon Sep 17 00:00:00 2001 From: Jacob Carlsson Date: Tue, 27 Jan 2015 11:11:50 +0100 Subject: [PATCH 04/12] Removed unused testfile streamtest.js --- streamtest.js | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 streamtest.js diff --git a/streamtest.js b/streamtest.js deleted file mode 100644 index a644b3d..0000000 --- a/streamtest.js +++ /dev/null @@ -1,39 +0,0 @@ -var morse = require('./'); -var fs = require('fs'); -var Q = require('q'); - - -Q.fcall(function() { - var defered = Q.defer(); - - console.log('Readfile'); - console.time('readfile'); - - fs.readFile(__dirname + '/test/largetext.txt', 'utf8', function(err, text) { - if(err) return console.error(err); - - var encoded = morse.encode(text); - console.timeEnd('readfile'); - - var decoded = morse.decode(encoded); - - defered.resolve(); - }); - - return defered.promise; -}) -.then(function() { - var defered = Q.defer(); - console.log('Stream'); - - // Using streams - console.time('stream'); - var readStream = fs.createReadStream(__dirname + '/test/largetext.txt'); - - readStream.pipe(morse.createEncodeStream()).pipe(morse.createDecodeStream()).on('finish', function() { - console.timeEnd('stream'); - defered.resolve(); - }); - - return defered.promise; -}); From c9883ba10b9680b82c663efc7db55a8934c40e4b Mon Sep 17 00:00:00 2001 From: Jacob Carlsson Date: Tue, 27 Jan 2015 11:28:55 +0100 Subject: [PATCH 05/12] Add piping to binary It is now possible to pipe content to the morse binary and encode/decode the contents --- README.md | 14 ++++++++++++++ bin/morse.js | 13 ++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4fd4a6f..ba3238b 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,20 @@ $ morse -d "`cat hello.txt`" HELLO ```` +You can use pipes to pipe text into morse with the `-p` flag or `--pipe`. +```bash +$ echo "Hello morse" | morse -p +.... . .-.. .-.. --- ....... -- --- .-. ... . ? + +// Decode +$ echo ".... . .-.. .-.. --- ....... -- --- .-. ... . ?" | morse -p -d +HELLO MORSE + +// Pipe twice +$ echo "Hello morse" | morse -p | morse -p -d +HELLO MORSE +``` + ## example usage as a library ````javascript diff --git a/bin/morse.js b/bin/morse.js index 2f0581c..9c2b5ce 100755 --- a/bin/morse.js +++ b/bin/morse.js @@ -8,13 +8,24 @@ var argv = optimist .describe('d', 'Decode a string of Morse code') .alias('h', 'help') .describe('h', 'Show this text') + .alias('p', 'pipe') + .describe('p', 'Use stdin and pipe to stdout') .argv; -if (argv.h || !argv._.length) { +if (argv.h || (!argv._.length && !argv.p)) { optimist.showHelp(); process.exit(); } +// Check for pipe +if(argv.p) { + if(argv.d) { + process.stdin.pipe(morse.createDecodeStream()).pipe(process.stdout); + } else { + process.stdin.pipe(morse.createEncodeStream()).pipe(process.stdout); + } +} + var str = argv._.join(' '); if (argv.d) { console.log(morse.decode(str)); From 18301667cab54ae7295caa0ab3c148e51a7c1572 Mon Sep 17 00:00:00 2001 From: Jacob Carlsson Date: Tue, 27 Jan 2015 11:30:40 +0100 Subject: [PATCH 06/12] Update readme --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ba3238b..f3e6338 100644 --- a/README.md +++ b/README.md @@ -29,16 +29,20 @@ $ morse -d "`cat hello.txt`" HELLO ```` -You can use pipes to pipe text into morse with the `-p` flag or `--pipe`. +You can use pipes to pipe text into morse with the `-p` flag or `--pipe`. Encode: ```bash $ echo "Hello morse" | morse -p .... . .-.. .-.. --- ....... -- --- .-. ... . ? +``` -// Decode +Decode: +```bash $ echo ".... . .-.. .-.. --- ....... -- --- .-. ... . ?" | morse -p -d HELLO MORSE +``` -// Pipe twice +Pipe twice for fun +```bash $ echo "Hello morse" | morse -p | morse -p -d HELLO MORSE ``` From daa6584087ccd798920fe2a592067086c3a3c428 Mon Sep 17 00:00:00 2001 From: Jacob Carlsson Date: Tue, 27 Jan 2015 11:34:14 +0100 Subject: [PATCH 07/12] Update readme with streams --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index f3e6338..a455c88 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ $ morse -d "`cat hello.txt`" HELLO ```` +### using pipes You can use pipes to pipe text into morse with the `-p` flag or `--pipe`. Encode: ```bash $ echo "Hello morse" | morse -p @@ -67,6 +68,23 @@ morse.decode(encoded); // [ 'HELLO', 'WORLD' ] ```` +### example usage with streams + +```javascript +var morse = require('morse'); +var fs = require('fs'); + +// Encode +fs.createReadStream(__dirname + '/file.txt') + .pipe(morse.createEncodeStream()) + .pipe(process.stdout); + +// Decode +fs.createReadStream(__dirname + '/file-encoded.txt') + .pipe(morse.createDecodeStream()) + .pipe(process.stdout); +``` + ## methods ### morse.encode(obj) From a6e6672a393cf55c3db2d2e047d50adba064eb31 Mon Sep 17 00:00:00 2001 From: Jacob Carlsson Date: Tue, 27 Jan 2015 11:35:20 +0100 Subject: [PATCH 08/12] Add pipe flag to help output in readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a455c88..0255060 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,8 @@ Usage: morse [options] string Options: -d, --decode Decode a string of Morse code [boolean] - -h, --help Show this text + -h, --help Show this text + -p, --pipe Use stdin and pipe to stdout $ morse hello > hello.txt $ morse -d "`cat hello.txt`" From eac07066412eeb8d56c2b53721345c92719986cd Mon Sep 17 00:00:00 2001 From: Jacob Carlsson Date: Wed, 28 Jan 2015 09:22:12 +0100 Subject: [PATCH 09/12] Changed tabs to spaces --- test/streamSpec.js | 82 +++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/test/streamSpec.js b/test/streamSpec.js index db95628..8b5d2ff 100644 --- a/test/streamSpec.js +++ b/test/streamSpec.js @@ -5,63 +5,63 @@ var through2 = require('through2'); // Saves everything in .result function StringStream() { - this.result = ''; + this.result = ''; } StringStream.prototype.createStream = function() { - var _this = this; - - return through2({}, function(chunk, enc, callback) { - _this.result += chunk.toString(); - callback(null, chunk); - }, function(callback) { - callback(); - }); + var _this = this; + + return through2({}, function(chunk, enc, callback) { + _this.result += chunk.toString(); + callback(null, chunk); + }, function(callback) { + callback(); + }); } describe('stream', function() { - it('should encode a stream', function(done) { + it('should encode a stream', function(done) { - fs.readFile(__dirname + '/lorem-ipsum.txt', 'utf8', function(err, text) { - if(err) return console.error(err); + fs.readFile(__dirname + '/lorem-ipsum.txt', 'utf8', function(err, text) { + if(err) return console.error(err); - var encoded = morse.encode(text); + var encoded = morse.encode(text); - var stringStream = new StringStream(); + var stringStream = new StringStream(); - // Test it with streams - var readStream = fs.createReadStream(__dirname + '/lorem-ipsum.txt', {encoding: 'utf8'}); - readStream - .pipe(morse.createEncodeStream()) - .pipe(stringStream.createStream()) - .on('finish', function() { + // Test it with streams + var readStream = fs.createReadStream(__dirname + '/lorem-ipsum.txt', {encoding: 'utf8'}); + readStream + .pipe(morse.createEncodeStream()) + .pipe(stringStream.createStream()) + .on('finish', function() { - assert.equal(stringStream.result, encoded); - done(); - }); - }); - }); + assert.equal(stringStream.result, encoded); + done(); + }); + }); + }); - it('should decode a stream', function(done) { - fs.readFile(__dirname + '/lorem-ipsum-encoded.txt', 'utf8', function(err, text) { - if(err) return console.error(err); + it('should decode a stream', function(done) { + fs.readFile(__dirname + '/lorem-ipsum-encoded.txt', 'utf8', function(err, text) { + if(err) return console.error(err); - var decoded = morse.decode(text); + var decoded = morse.decode(text); - var stringStream = new StringStream(); + var stringStream = new StringStream(); - // Test it with streams - var readStream = fs.createReadStream(__dirname + '/lorem-ipsum-encoded.txt', {encoding: 'utf8'}); - readStream - .pipe(morse.createDecodeStream()) - .pipe(stringStream.createStream()) - .on('finish', function() { + // Test it with streams + var readStream = fs.createReadStream(__dirname + '/lorem-ipsum-encoded.txt', {encoding: 'utf8'}); + readStream + .pipe(morse.createDecodeStream()) + .pipe(stringStream.createStream()) + .on('finish', function() { - assert.equal(stringStream.result, decoded); - done(); - }); - }); - }); + assert.equal(stringStream.result, decoded); + done(); + }); + }); + }); }); \ No newline at end of file From c75516ad2ada9d59bf32b302a62765294328daa3 Mon Sep 17 00:00:00 2001 From: Jacob Carlsson Date: Wed, 28 Jan 2015 09:24:53 +0100 Subject: [PATCH 10/12] Changed all tabs to spaces in readme --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0255060..03fda56 100644 --- a/README.md +++ b/README.md @@ -77,13 +77,13 @@ var fs = require('fs'); // Encode fs.createReadStream(__dirname + '/file.txt') - .pipe(morse.createEncodeStream()) - .pipe(process.stdout); + .pipe(morse.createEncodeStream()) + .pipe(process.stdout); // Decode fs.createReadStream(__dirname + '/file-encoded.txt') - .pipe(morse.createDecodeStream()) - .pipe(process.stdout); + .pipe(morse.createDecodeStream()) + .pipe(process.stdout); ``` ## methods From a946363f529c26e2dbf4fbef0aa722dcb411cb1f Mon Sep 17 00:00:00 2001 From: Jacob Carlsson Date: Sat, 31 Jan 2015 20:17:56 +0100 Subject: [PATCH 11/12] Changed to default array test --- test/array.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/test/array.js b/test/array.js index 67a3cad..8415c62 100644 --- a/test/array.js +++ b/test/array.js @@ -1,18 +1,20 @@ var morse = require('../'); -var assert = require('assert'); -describe('array', function() { - it('should encode and decode an array', function() { - var arr = [ - 'hello', - 'world' - ]; +var arr = [ + 'hello', + 'world' +]; +console.log(arr); - var encoded = morse.encode(arr); - var decoded = morse.decode(encoded); +var encoded = morse.encode(arr); +console.log(encoded); - assert.deepEqual(decoded, arr.map(function(str) { - return str.toUpperCase(); - }), 'Arrays should be equal except for case'); - }); -}); +var decoded = morse.decode(encoded); +console.log(decoded); + +var expected = [ + 'HELLO', + 'WORLD' +]; + +console.log(expected[1] == decoded[1] ? 'pass' : 'fail'); From 7dabe8ae37982aab16ed7cdc00c7ad7e8504c308 Mon Sep 17 00:00:00 2001 From: Jacob Carlsson Date: Mon, 22 Feb 2016 20:16:38 +0100 Subject: [PATCH 12/12] Update dependencies --- package.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d1f9d12..0e6af4a 100644 --- a/package.json +++ b/package.json @@ -16,11 +16,10 @@ "main": "morse.js", "dependencies": { "optimist": "*", - "through2": "^0.6.3" + "through2": "^2.0.1" }, "devDependencies": { - "mocha": "^2.1.0", - "q": "^1.1.2" + "mocha": "^2.4.5" }, "optionalDependencies": {}, "engines": {