From 257f90f0dcd3714fe9c099aa9b5e877d3e4f843f Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Sat, 31 Mar 2018 01:09:32 +0200 Subject: [PATCH] fix(Morse): Correctly spell omit BREAKING CHANGE: Change option property omitUnknownCharacter to it's correct spelling --- docs/ciphers/morse.md | 22 +++++++++++----------- src/morse.js | 6 +++--- test/morse.test.js | 12 ++++++------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/docs/ciphers/morse.md b/docs/ciphers/morse.md index 402e00a..45df19a 100644 --- a/docs/ciphers/morse.md +++ b/docs/ciphers/morse.md @@ -17,7 +17,7 @@ The options are the same for both methods, `encode` and `decode` const options = { separator: ' ', // Custom delimiter or glue failOnUnknownCharacter: true, // Should an error be thrown when a character is not included in the alphabet - ommitUnknownCharacter: false // Should unknown character be ommitted or preserverd? (Only if failOnUnknownCharacter is false) + omitUnknownCharacter: false // Should unknown character be omitted or preserverd? (Only if failOnUnknownCharacter is false) } ``` @@ -59,20 +59,20 @@ import { encode } from 'cipher-collection/morse' const preserveOptions = { separator: '', failOnUnknownCharacter: false, - ommitUnknownCharacter: false + omitUnknownCharacter: false } // Preserve chraracters that can't get encoded console.log(encode('€€€', preserveOptions)) // €€€ -const ommitOptions = { +const omitOptions = { separator: '', failOnUnknownCharacter: false, - ommitUnknownCharacter: true + omitUnknownCharacter: true } -// Ommit chraracters that can't get encoded -console.log(encode('€€€S', ommitOptions)) // ... +// omit chraracters that can't get encoded +console.log(encode('€€€S', omitOptions)) // ... ``` @@ -105,17 +105,17 @@ import { decode } from 'cipher-collection/morse' const preserveOptions = { failOnUnknownCharacter: false, - ommitUnknownCharacter: false + omitUnknownCharacter: false } // Preserve chraracters that can't get decoded console.log(decode('.-.-.-.-.-', preserveOptions)) // .-.-.-.-.- -const ommitOptions = { +const omitOptions = { failOnUnknownCharacter: false, - ommitUnknownCharacter: true + omitUnknownCharacter: true } -// Ommit chraracters that can't get decoded -console.log(decode('.-.-.-.-.- ...', ommitOptions)) // S +// omit chraracters that can't get decoded +console.log(decode('.-.-.-.-.- ...', omitOptions)) // S ``` diff --git a/src/morse.js b/src/morse.js index a12ca13..be2363f 100644 --- a/src/morse.js +++ b/src/morse.js @@ -9,7 +9,7 @@ export const decode = (input, options = {}) => { if (options.failOnUnknownCharacter) { throw Error('Undecodable character') } - return options.ommitUnknownCharacter ? '' : c + return options.omitUnknownCharacter ? '' : c }).join('') } @@ -25,7 +25,7 @@ export const encode = (input, options = {}) => { if (options.failOnUnknownCharacter) { throw Error('Unencodable character') } - return options.ommitUnknownCharacter ? '' : c + return options.omitUnknownCharacter ? '' : c }).join(options.separator) } @@ -86,7 +86,7 @@ const ALPHABET = { const DEFAULT_OPTIONS = { separator: ' ', failOnUnknownCharacter: true, - ommitUnknownCharacter: false + omitUnknownCharacter: false } export default { decode, diff --git a/test/morse.test.js b/test/morse.test.js index 5e34c17..a9ee4f1 100644 --- a/test/morse.test.js +++ b/test/morse.test.js @@ -7,12 +7,12 @@ const encodedAlphabet = '.- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. const invalidCharacter = { input: '€S', preserve: '€...', - ommit: '...' + omit: '...' } const invalidMorseCharacter = { input: '.-.-.-.-.-.- ...', preserve: '.-.-.-.-.-.-S', - ommit: 'S' + omit: 'S' } describe('decoding', () => { @@ -33,8 +33,8 @@ describe('decoding', () => { })).toBe(invalidMorseCharacter.preserve) expect(morse.decode(invalidMorseCharacter.input, { failOnUnknownCharacter: false, - ommitUnknownCharacter: true - })).toBe(invalidMorseCharacter.ommit) + omitUnknownCharacter: true + })).toBe(invalidMorseCharacter.omit) }) }) describe('encoding', () => { @@ -50,7 +50,7 @@ describe('encoding', () => { expect(morse.encode(invalidCharacter.input, { separator: '', failOnUnknownCharacter: false, - ommitUnknownCharacter: true - })).toBe(invalidCharacter.ommit) + omitUnknownCharacter: true + })).toBe(invalidCharacter.omit) }) })