diff --git a/docs/SNIPPET.txt b/docs/SNIPPET.txt index 569497affc..a4d1e1ddcd 100644 --- a/docs/SNIPPET.txt +++ b/docs/SNIPPET.txt @@ -1,7 +1,5 @@ -class HelloWorld { +export class HelloWorld { hello() { return 'Hello, World!'; } -} - -export default HelloWorld; +}; diff --git a/docs/TESTS.md b/docs/TESTS.md index e43ad32c1c..cd2a845173 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md @@ -28,10 +28,10 @@ $ npm run watch The skip method instructs the test suite to not run a test, this function could be used also under the aliases: `it.skip(name, fn) or xit(name, fn) or xtest(name, fn)` -- Why they are skipped ? +- Why they are skipped ? So as to enable users to concentrate on one test at a time and enable one by one as they evolve the solution. -- How to enable them ? +- How to enable them ? Change xtest to test. ```javascript @@ -43,11 +43,11 @@ test('title cased phrases', () => { ## Making Your First JavaScript 2015 Module Usually, tests on this track will load your implementation by importing it as a -JavaScript module: `import Bob from './bob.js';`. You just +JavaScript module: `import { Bob } from './bob.js';`. You just need to export your implementation from the referenced file, `bob.js`: ```javascript -export default class Bob { +export class Bob { hey(message) { // // Your solution to the exercise goes here diff --git a/exercises/allergies/allergies.spec.js b/exercises/allergies/allergies.spec.js index 7fb3161b07..9784f13faa 100644 --- a/exercises/allergies/allergies.spec.js +++ b/exercises/allergies/allergies.spec.js @@ -1,4 +1,4 @@ -import Allergies from './allergies'; +import { Allergies } from './allergies'; describe('Allergies', () => { test('no allergies at all', () => { diff --git a/exercises/allergies/example.js b/exercises/allergies/example.js index 7e9a3fb5a1..3844be905f 100644 --- a/exercises/allergies/example.js +++ b/exercises/allergies/example.js @@ -9,7 +9,7 @@ const possibleAllergies = [ 'cats', ]; -class Allergies { +export class Allergies { constructor(allergenIndex) { this.allergenIndex = allergenIndex; } @@ -23,5 +23,3 @@ class Allergies { return this.list().some(allergy => allergy === food); } } - -export default Allergies; diff --git a/exercises/anagram/anagram.spec.js b/exercises/anagram/anagram.spec.js index a03e0f5986..e9edb73ccb 100644 --- a/exercises/anagram/anagram.spec.js +++ b/exercises/anagram/anagram.spec.js @@ -1,4 +1,4 @@ -import Anagram from './anagram'; +import { Anagram } from './anagram'; describe('Anagram', () => { test('no matches', () => { diff --git a/exercises/anagram/example.js b/exercises/anagram/example.js index f34f549e36..7c0526f496 100644 --- a/exercises/anagram/example.js +++ b/exercises/anagram/example.js @@ -2,7 +2,7 @@ const normalize = str => str.toLowerCase().split('').sort().join(); const sameWord = (word, candidate) => word.toLowerCase() === candidate.toLowerCase(); const isAnagram = (word, candiate) => normalize(word) === normalize(candiate); -export default class Anagram { +export class Anagram { constructor(word) { this.word = word; } diff --git a/exercises/beer-song/beer-song.spec.js b/exercises/beer-song/beer-song.spec.js index 55b9e30c9b..850dd8dcf2 100644 --- a/exercises/beer-song/beer-song.spec.js +++ b/exercises/beer-song/beer-song.spec.js @@ -1,26 +1,26 @@ -import Beer from './beer-song'; +import { BeerSong } from './beer-song'; -describe('Beer', () => { +describe('BeerSong', () => { test('prints an arbitrary verse', () => { const expected = `8 bottles of beer on the wall, 8 bottles of beer. Take one down and pass it around, 7 bottles of beer on the wall. `; - expect(Beer.verse(8)).toEqual(expected); + expect(BeerSong.verse(8)).toEqual(expected); }); xtest('handles 1 bottle', () => { const expected = `1 bottle of beer on the wall, 1 bottle of beer. Take it down and pass it around, no more bottles of beer on the wall. `; - expect(Beer.verse(1)).toEqual(expected); + expect(BeerSong.verse(1)).toEqual(expected); }); xtest('handles 0 bottles', () => { const expected = `No more bottles of beer on the wall, no more bottles of beer. Go to the store and buy some more, 99 bottles of beer on the wall. `; - expect(Beer.verse(0)).toEqual(expected); + expect(BeerSong.verse(0)).toEqual(expected); }); xtest('sings several verses', () => { @@ -33,7 +33,7 @@ Take one down and pass it around, 6 bottles of beer on the wall. 6 bottles of beer on the wall, 6 bottles of beer. Take one down and pass it around, 5 bottles of beer on the wall. `; - expect(Beer.sing(8, 6)).toEqual(expected); + expect(BeerSong.sing(8, 6)).toEqual(expected); }); xtest('sings the rest of the verses', () => { @@ -49,11 +49,11 @@ Take it down and pass it around, no more bottles of beer on the wall. No more bottles of beer on the wall, no more bottles of beer. Go to the store and buy some more, 99 bottles of beer on the wall. `; - expect(Beer.sing(3)).toEqual(expected); + expect(BeerSong.sing(3)).toEqual(expected); }); xtest('sings all the verses', () => { - const song = Beer.sing(); + const song = BeerSong.sing(); expect(song).toEqual(`99 bottles of beer on the wall, 99 bottles of beer. Take one down and pass it around, 98 bottles of beer on the wall. diff --git a/exercises/beer-song/example.js b/exercises/beer-song/example.js index 165eded6b6..d0e4923aaf 100644 --- a/exercises/beer-song/example.js +++ b/exercises/beer-song/example.js @@ -27,7 +27,7 @@ function nextBottle(currentVerse) { return `${bottles(nextVerse(currentVerse)).toLowerCase()} of beer on the wall.\n`; } -class BeerSong { +export class BeerSong { static verse(number) { const line1 = `${bottles(number)} of beer on the wall, `; const line2 = `${bottles(number).toLowerCase()} of beer.\n`; @@ -46,5 +46,3 @@ class BeerSong { return verses.join('\n'); } } - -export default BeerSong; diff --git a/exercises/binary-search-tree/binary-search-tree.spec.js b/exercises/binary-search-tree/binary-search-tree.spec.js index 25d6425feb..8be168edbf 100644 --- a/exercises/binary-search-tree/binary-search-tree.spec.js +++ b/exercises/binary-search-tree/binary-search-tree.spec.js @@ -1,4 +1,4 @@ -import BinarySearchTree from './binary-search-tree'; +import { BinarySearchTree } from './binary-search-tree'; function recordAllData(bst) { const out = []; diff --git a/exercises/binary-search-tree/example.js b/exercises/binary-search-tree/example.js index b4c60574de..9b2b07ec10 100644 --- a/exercises/binary-search-tree/example.js +++ b/exercises/binary-search-tree/example.js @@ -1,4 +1,4 @@ -class BinarySearchTree { +export class BinarySearchTree { constructor(data) { this.data = data; this.left = undefined; @@ -45,5 +45,3 @@ class BinarySearchTree { } } } - -export default BinarySearchTree; diff --git a/exercises/binary-search/binary-search.spec.js b/exercises/binary-search/binary-search.spec.js index 0e85224ea0..e1c63bee59 100644 --- a/exercises/binary-search/binary-search.spec.js +++ b/exercises/binary-search/binary-search.spec.js @@ -1,4 +1,4 @@ -import BinarySearch from './binary-search'; +import { BinarySearch } from './binary-search'; describe('BinarySearch', () => { const sortedArray = [1, 2, 3, 4, 5, 6]; diff --git a/exercises/binary-search/example.js b/exercises/binary-search/example.js index f511f180c6..041018ed72 100644 --- a/exercises/binary-search/example.js +++ b/exercises/binary-search/example.js @@ -25,7 +25,7 @@ function recursiveSearch(array, value, start, end) { return mid; } -class BinarySearch { +export class BinarySearch { constructor(array) { if (isSortedArray(array)) { this.array = array; @@ -36,5 +36,3 @@ class BinarySearch { return recursiveSearch(this.array, value, 0, this.array.length); } } - -export default BinarySearch; diff --git a/exercises/binary/binary.spec.js b/exercises/binary/binary.spec.js index 1bccf2175b..d184b9ea6b 100644 --- a/exercises/binary/binary.spec.js +++ b/exercises/binary/binary.spec.js @@ -1,4 +1,4 @@ -import Binary from './binary'; +import { Binary } from './binary'; describe('binary', () => { test('0 is decimal 0', () => expect(new Binary('0').toDecimal()).toEqual(0)); diff --git a/exercises/binary/example.js b/exercises/binary/example.js index 25124d1429..018f476d53 100644 --- a/exercises/binary/example.js +++ b/exercises/binary/example.js @@ -1,6 +1,6 @@ // classy solution, eh? -class Binary { +export class Binary { constructor(binary) { this.binary = binary.match(/^[01]*$/) ? parseInt(binary, 2) : 0; } @@ -10,5 +10,3 @@ class Binary { return Number.isNaN(out) ? 0 : out; } } - -export default Binary; diff --git a/exercises/bowling/bowling.spec.js b/exercises/bowling/bowling.spec.js index 2d4a290800..28e300814f 100644 --- a/exercises/bowling/bowling.spec.js +++ b/exercises/bowling/bowling.spec.js @@ -1,4 +1,4 @@ -import Bowling from './bowling'; +import { Bowling } from './bowling'; describe('Bowling', () => { describe('Check game can be scored correctly.', () => { diff --git a/exercises/bowling/example.js b/exercises/bowling/example.js index b83e65ef2a..3cea48886e 100644 --- a/exercises/bowling/example.js +++ b/exercises/bowling/example.js @@ -1,4 +1,4 @@ -export default class Bowling { +export class Bowling { constructor() { this.maxPins = 10; this.maxFrames = 10; diff --git a/exercises/change/change.spec.js b/exercises/change/change.spec.js index 0966fff29a..02b15e55d5 100644 --- a/exercises/change/change.spec.js +++ b/exercises/change/change.spec.js @@ -1,4 +1,4 @@ -import Change from './change'; +import { Change } from './change'; describe('Change', () => { test('test change for 1 cent', () => { diff --git a/exercises/change/example.js b/exercises/change/example.js index 452f135d31..8454a9dbf7 100644 --- a/exercises/change/example.js +++ b/exercises/change/example.js @@ -34,7 +34,7 @@ class Candidate { } } -export default class Change { +export class Change { constructor() { this.candidates = []; } diff --git a/exercises/clock/clock.spec.js b/exercises/clock/clock.spec.js index a5760cbb46..8e05eb09cb 100644 --- a/exercises/clock/clock.spec.js +++ b/exercises/clock/clock.spec.js @@ -1,4 +1,4 @@ -import at from './clock'; +import { at } from './clock'; describe('Clock', () => { describe('Creating a new clock with an initial time', () => { diff --git a/exercises/clock/example.js b/exercises/clock/example.js index 68da0b01e0..2939d5d1cf 100644 --- a/exercises/clock/example.js +++ b/exercises/clock/example.js @@ -1,4 +1,4 @@ -export default function (hour, minute) { +export const at = (hour, minute) => { const MINUTESPERDAY = 1440; const HOURSPERDAY = 24; @@ -38,4 +38,4 @@ export default function (hour, minute) { && clock.minute === otherClock.clock.minute ), }; -} +}; diff --git a/exercises/complex-numbers/complex-numbers.spec.js b/exercises/complex-numbers/complex-numbers.spec.js index 54e96bcde9..eb0b88ff56 100644 --- a/exercises/complex-numbers/complex-numbers.spec.js +++ b/exercises/complex-numbers/complex-numbers.spec.js @@ -1,4 +1,4 @@ -import ComplexNumber from './complex-numbers.js'; +import { ComplexNumber } from './complex-numbers.js'; describe('Complex numbers', () => { test('Real part of a purely real number', () => { diff --git a/exercises/complex-numbers/example.js b/exercises/complex-numbers/example.js index c1cbb3c95b..a4624e5ef6 100644 --- a/exercises/complex-numbers/example.js +++ b/exercises/complex-numbers/example.js @@ -1,4 +1,4 @@ -export default class ComplexNumber { +export class ComplexNumber { constructor(real, imag) { this.real = real; this.imag = imag; diff --git a/exercises/connect/connect.spec.js b/exercises/connect/connect.spec.js index c8027767f9..cae0d27f7a 100644 --- a/exercises/connect/connect.spec.js +++ b/exercises/connect/connect.spec.js @@ -1,4 +1,4 @@ -import Board from './connect'; +import { Board } from './connect'; describe('Judging a game of connect', () => { test('an empty board has no winner', () => { diff --git a/exercises/connect/example.js b/exercises/connect/example.js index 57de09167f..1c2649d75b 100644 --- a/exercises/connect/example.js +++ b/exercises/connect/example.js @@ -2,7 +2,7 @@ * "Player O" plays from top to bottom, "Player X" plays from left to right. * @param board */ -export default class { +export class Board { constructor(board) { this.board = board.map(b => [...b]); } diff --git a/exercises/crypto-square/crypto-square.spec.js b/exercises/crypto-square/crypto-square.spec.js index 46ba2559d6..e852f171a1 100644 --- a/exercises/crypto-square/crypto-square.spec.js +++ b/exercises/crypto-square/crypto-square.spec.js @@ -1,4 +1,4 @@ -import Crypto from './crypto-square'; +import { Crypto } from './crypto-square'; describe('Crypto', () => { test('normalize strange characters', () => { diff --git a/exercises/crypto-square/example.js b/exercises/crypto-square/example.js index 4d22407697..2f625f3692 100644 --- a/exercises/crypto-square/example.js +++ b/exercises/crypto-square/example.js @@ -1,4 +1,4 @@ -export default class Square { +export class Crypto { constructor(input) { this.input = input; } diff --git a/exercises/custom-set/custom-set.spec.js b/exercises/custom-set/custom-set.spec.js index 1f32831ee1..ee527d99e6 100644 --- a/exercises/custom-set/custom-set.spec.js +++ b/exercises/custom-set/custom-set.spec.js @@ -1,4 +1,4 @@ -import CustomSet from './custom-set'; +import { CustomSet } from './custom-set'; describe('CustomSet', () => { describe('empty: returns true if the set contains no elements', () => { diff --git a/exercises/custom-set/example.js b/exercises/custom-set/example.js index 85b6918bc4..74a105af05 100644 --- a/exercises/custom-set/example.js +++ b/exercises/custom-set/example.js @@ -1,4 +1,4 @@ -export default class CustomSet { +export class CustomSet { constructor(data = []) { this.data = {}; data.forEach(el => this.add(el)); diff --git a/exercises/diamond/diamond.spec.js b/exercises/diamond/diamond.spec.js index 4aa1894c3b..ab2c9563c5 100644 --- a/exercises/diamond/diamond.spec.js +++ b/exercises/diamond/diamond.spec.js @@ -1,4 +1,4 @@ -import Diamond from './diamond.js'; +import { Diamond } from './diamond.js'; describe('Make diamond function', () => { const diamond = new Diamond(); diff --git a/exercises/diamond/example.js b/exercises/diamond/example.js index e5f497819d..bae646639f 100644 --- a/exercises/diamond/example.js +++ b/exercises/diamond/example.js @@ -1,4 +1,4 @@ -export default class Diamond { +export class Diamond { makeDiamond(input) { const inputIndex = input.charCodeAt() - 65; let output = ''; diff --git a/exercises/difference-of-squares/difference-of-squares.spec.js b/exercises/difference-of-squares/difference-of-squares.spec.js index accc954282..468f61e61d 100644 --- a/exercises/difference-of-squares/difference-of-squares.spec.js +++ b/exercises/difference-of-squares/difference-of-squares.spec.js @@ -1,4 +1,4 @@ -import Squares from './difference-of-squares'; +import { Squares } from './difference-of-squares'; describe('difference-of-squares', () => { const squares1 = new Squares(1); diff --git a/exercises/difference-of-squares/example.js b/exercises/difference-of-squares/example.js index 5244931d75..11200bb33b 100644 --- a/exercises/difference-of-squares/example.js +++ b/exercises/difference-of-squares/example.js @@ -1,4 +1,4 @@ -export default class Squares { +export class Squares { constructor(max) { this.max = max; } diff --git a/exercises/diffie-hellman/diffie-hellman.spec.js b/exercises/diffie-hellman/diffie-hellman.spec.js index ce67237db5..2296bfa96f 100644 --- a/exercises/diffie-hellman/diffie-hellman.spec.js +++ b/exercises/diffie-hellman/diffie-hellman.spec.js @@ -1,5 +1,5 @@ /* eslint-disable no-new */ -import DiffieHellman from './diffie-hellman'; +import { DiffieHellman } from './diffie-hellman'; describe('diffie-hellman', () => { const p = 23; diff --git a/exercises/diffie-hellman/example.js b/exercises/diffie-hellman/example.js index 940d3c9449..0989d669a7 100644 --- a/exercises/diffie-hellman/example.js +++ b/exercises/diffie-hellman/example.js @@ -5,7 +5,7 @@ const PRIMES = [ ]; /* eslint-enable max-len */ -export default class DiffieHellman { +export class DiffieHellman { constructor(p, g) { if (!DiffieHellman.validateInitialArguments(p, g)) { throw Error('Constructor arguments are out of range or non-prime!'); diff --git a/exercises/etl/etl.spec.js b/exercises/etl/etl.spec.js index c129654a01..bd75bc93a1 100644 --- a/exercises/etl/etl.spec.js +++ b/exercises/etl/etl.spec.js @@ -1,4 +1,4 @@ -import transform from './etl'; +import { transform } from './etl'; describe('Transform', () => { test('transforms one value', () => { diff --git a/exercises/etl/example.js b/exercises/etl/example.js index a660cac7e6..8c9fb4bd06 100644 --- a/exercises/etl/example.js +++ b/exercises/etl/example.js @@ -1,4 +1,4 @@ -function transform(input) { +export const transform = (input) => { const output = {}; Object.keys(input).forEach((key) => { @@ -11,6 +11,4 @@ function transform(input) { }); return output; -} - -export default transform; +}; diff --git a/exercises/flatten-array/example.js b/exercises/flatten-array/example.js index 635efe1105..462ac12371 100644 --- a/exercises/flatten-array/example.js +++ b/exercises/flatten-array/example.js @@ -1,4 +1,4 @@ -export default class Flattener { +export class Flattener { flatten(arr) { return arr .reduce((acc, el) => (Array.isArray(el) diff --git a/exercises/flatten-array/flatten-array.spec.js b/exercises/flatten-array/flatten-array.spec.js index 0daf1563a4..f8fdb23810 100644 --- a/exercises/flatten-array/flatten-array.spec.js +++ b/exercises/flatten-array/flatten-array.spec.js @@ -1,4 +1,4 @@ -import Flattener from './flatten-array.js'; +import { Flattener } from './flatten-array.js'; describe('FlattenArray', () => { const flattener = new Flattener(); diff --git a/exercises/food-chain/example.js b/exercises/food-chain/example.js index 5fdcca76e9..c5395276b8 100644 --- a/exercises/food-chain/example.js +++ b/exercises/food-chain/example.js @@ -1,4 +1,4 @@ -export default class Song { +export class Song { /** * @param {Number} number * verse number diff --git a/exercises/food-chain/food-chain.spec.js b/exercises/food-chain/food-chain.spec.js index 5c4149a102..348b494415 100644 --- a/exercises/food-chain/food-chain.spec.js +++ b/exercises/food-chain/food-chain.spec.js @@ -1,4 +1,4 @@ -import Song from './food-chain'; +import { Song } from './food-chain'; describe('Food Chain', () => { let song; diff --git a/exercises/forth/example.js b/exercises/forth/example.js index 8e84f6f22e..1792c0f5be 100644 --- a/exercises/forth/example.js +++ b/exercises/forth/example.js @@ -1,4 +1,4 @@ -class Forth { +export class Forth { constructor(){ this.stack = []; this.commands = Forth.basicCommands(); @@ -59,5 +59,3 @@ class Forth { }; } } - -export default Forth; diff --git a/exercises/forth/forth.spec.js b/exercises/forth/forth.spec.js index c5734cf974..c8896a80f9 100644 --- a/exercises/forth/forth.spec.js +++ b/exercises/forth/forth.spec.js @@ -1,4 +1,4 @@ -import Forth from './forth'; +import { Forth } from './forth'; describe('Forth', () => { let forth; diff --git a/exercises/grains/example.js b/exercises/grains/example.js index ad321f79b9..22ec1ec270 100644 --- a/exercises/grains/example.js +++ b/exercises/grains/example.js @@ -6,7 +6,7 @@ import BigInt from './big-integer'; * chess board, starting with one grain on the first * square, and doubling with each successive square. */ -export default class Grains { +export class Grains { /** * Gets the number of grains on the nth square * diff --git a/exercises/grains/grains.spec.js b/exercises/grains/grains.spec.js index 7e9b1ffc1b..19a96b5539 100644 --- a/exercises/grains/grains.spec.js +++ b/exercises/grains/grains.spec.js @@ -27,7 +27,7 @@ * See its tests in this folder for a quick primer on how to use it! ( : */ -import Grains from './grains'; +import { Grains } from './grains'; describe('Grains', () => { const grains = new Grains(); diff --git a/exercises/house/example.js b/exercises/house/example.js index 5edfb4f371..70aafa5339 100644 --- a/exercises/house/example.js +++ b/exercises/house/example.js @@ -28,7 +28,7 @@ const ACTIONS = [ 'belonged to', ]; -class House { +export class House { static verse(verseNumber) { const lines = []; const totalLines = verseNumber; @@ -58,5 +58,3 @@ class House { return lines; } } - -export default House; diff --git a/exercises/house/house.spec.js b/exercises/house/house.spec.js index 78dbffc376..cbded56d56 100644 --- a/exercises/house/house.spec.js +++ b/exercises/house/house.spec.js @@ -1,4 +1,4 @@ -import House from './house'; +import { House } from './house'; describe('House', () => { test('verse one - the house that jack built', () => { diff --git a/exercises/isbn-verifier/example.js b/exercises/isbn-verifier/example.js index 3d25bf400c..19e82238c9 100644 --- a/exercises/isbn-verifier/example.js +++ b/exercises/isbn-verifier/example.js @@ -1,4 +1,4 @@ -export default class ISBN { +export class ISBN { constructor(isbn) { this.isbn = isbn.replace(/-/g, ''); } diff --git a/exercises/isbn-verifier/isbn-verifier.spec.js b/exercises/isbn-verifier/isbn-verifier.spec.js index cfdd40018a..b6f4349498 100644 --- a/exercises/isbn-verifier/isbn-verifier.spec.js +++ b/exercises/isbn-verifier/isbn-verifier.spec.js @@ -1,4 +1,4 @@ -import ISBN from './isbn-verifier.js'; +import { ISBN } from './isbn-verifier.js'; describe('ISBN Verifier Test Suite', () => { test('valid isbn number', () => { diff --git a/exercises/kindergarten-garden/example.js b/exercises/kindergarten-garden/example.js index 56cfbc4960..53bba07067 100644 --- a/exercises/kindergarten-garden/example.js +++ b/exercises/kindergarten-garden/example.js @@ -34,7 +34,7 @@ function parse(diagram) { return diagram.split('\n').map(row => [...row].map(sign => plantCodes[sign])); } -class Garden { +export class Garden { constructor(diagram, students) { this.students = students || defaultChildren; this.students.sort(); @@ -44,5 +44,3 @@ class Garden { }); } } - -export default Garden; diff --git a/exercises/kindergarten-garden/kindergarten-garden.spec.js b/exercises/kindergarten-garden/kindergarten-garden.spec.js index 43416c644a..192a09275e 100644 --- a/exercises/kindergarten-garden/kindergarten-garden.spec.js +++ b/exercises/kindergarten-garden/kindergarten-garden.spec.js @@ -1,4 +1,4 @@ -import Garden from './kindergarten-garden'; +import { Garden } from './kindergarten-garden'; describe('Garden', () => { test('for Alice', () => { diff --git a/exercises/list-ops/example.js b/exercises/list-ops/example.js index 8d9525d592..a2b47f853c 100644 --- a/exercises/list-ops/example.js +++ b/exercises/list-ops/example.js @@ -1,4 +1,4 @@ -class List { +export class List { constructor(arr) { this.values = arr || []; } @@ -74,5 +74,3 @@ class List { return this; } } - -export default List; diff --git a/exercises/list-ops/list-ops.spec.js b/exercises/list-ops/list-ops.spec.js index 4c92cc6b36..3f5e01ffaf 100644 --- a/exercises/list-ops/list-ops.spec.js +++ b/exercises/list-ops/list-ops.spec.js @@ -1,5 +1,4 @@ -import List from './list-ops'; - +import { List } from './list-ops'; describe('append entries to a list and return the new list', () => { test('empty lists', () => { diff --git a/exercises/luhn/example.js b/exercises/luhn/example.js index a1d8ae9d93..205a8ce4bc 100644 --- a/exercises/luhn/example.js +++ b/exercises/luhn/example.js @@ -25,7 +25,7 @@ function isValid(num) { return sum > 0 && sum % 10 === 0; } -export default class Luhn { +export class Luhn { constructor(number) { this.valid = isValid(number); } diff --git a/exercises/luhn/luhn.spec.js b/exercises/luhn/luhn.spec.js index 3d66f44342..c995e96ae9 100644 --- a/exercises/luhn/luhn.spec.js +++ b/exercises/luhn/luhn.spec.js @@ -1,4 +1,4 @@ -import Luhn from './luhn'; +import { Luhn } from './luhn'; describe('Luhn', () => { test('single digit strings can not be valid', () => { diff --git a/exercises/nth-prime/example.js b/exercises/nth-prime/example.js index a6e021cd15..2a15fa4391 100644 --- a/exercises/nth-prime/example.js +++ b/exercises/nth-prime/example.js @@ -25,7 +25,7 @@ function generatePrimes(uptoNumber) { .map(p => p.number); } -class Prime { +export class Prime { nth(nthPrime) { if (nthPrime === 0) { throw new Error('Prime is not possible'); @@ -34,5 +34,3 @@ class Prime { return realPrimes[nthPrime - 1]; } } - -export default Prime; diff --git a/exercises/nth-prime/nth-prime.spec.js b/exercises/nth-prime/nth-prime.spec.js index 1565157605..f47d30f71c 100644 --- a/exercises/nth-prime/nth-prime.spec.js +++ b/exercises/nth-prime/nth-prime.spec.js @@ -1,4 +1,4 @@ -import Prime from './nth-prime'; +import { Prime } from './nth-prime'; describe('Prime', () => { const prime = new Prime(); diff --git a/exercises/nucleotide-count/example.js b/exercises/nucleotide-count/example.js index 5da99093f7..83fbd7849d 100644 --- a/exercises/nucleotide-count/example.js +++ b/exercises/nucleotide-count/example.js @@ -1,6 +1,6 @@ const count = (str, nuc) => [...str].filter(nucleotide => nucleotide === nuc).length; -class NucleotideCounts { +export class NucleotideCounts { static parse(strand) { if (strand.replace(/A|C|G|T/g, '').length) { throw new Error('Invalid nucleotide in strand'); @@ -9,5 +9,3 @@ class NucleotideCounts { } } } - -export default NucleotideCounts; diff --git a/exercises/nucleotide-count/nucleotide-count.spec.js b/exercises/nucleotide-count/nucleotide-count.spec.js index 2af419f70e..fc5877aa30 100644 --- a/exercises/nucleotide-count/nucleotide-count.spec.js +++ b/exercises/nucleotide-count/nucleotide-count.spec.js @@ -1,4 +1,4 @@ -import NucleotideCounts from './nucleotide-count'; +import { NucleotideCounts } from './nucleotide-count'; describe('count all nucleotides in a strand', () => { test('empty strand', () => { diff --git a/exercises/octal/example.js b/exercises/octal/example.js index ba128ff5c3..192a1eb966 100644 --- a/exercises/octal/example.js +++ b/exercises/octal/example.js @@ -1,7 +1,6 @@ - -export default function (octal) { +export const Octal = (octal) => { const newOctal = octal.match(/[^0-7]/) ? '0' : octal; return { toDecimal: () => newOctal.split('').reduce((prev, curr) => prev * 8 + parseInt(curr, 8), 0), }; -} +}; diff --git a/exercises/octal/octal.spec.js b/exercises/octal/octal.spec.js index a880e99eb5..0074612e84 100644 --- a/exercises/octal/octal.spec.js +++ b/exercises/octal/octal.spec.js @@ -1,4 +1,4 @@ -import Octal from './octal'; +import { Octal } from './octal'; describe('octal', () => { test('1 is decimal 1', () => { diff --git a/exercises/phone-number/example.js b/exercises/phone-number/example.js index bc73df3937..68efdf5033 100644 --- a/exercises/phone-number/example.js +++ b/exercises/phone-number/example.js @@ -1,4 +1,4 @@ -export default class PhoneNumber { +export class PhoneNumber { constructor(number) { this.rawNumber = number; } diff --git a/exercises/phone-number/phone-number.spec.js b/exercises/phone-number/phone-number.spec.js index c31139b775..fe98bcea68 100644 --- a/exercises/phone-number/phone-number.spec.js +++ b/exercises/phone-number/phone-number.spec.js @@ -1,4 +1,4 @@ -import PhoneNumber from './phone-number'; +import { PhoneNumber } from './phone-number'; describe('PhoneNumber()', () => { test('cleans the number', () => { diff --git a/exercises/pig-latin/example.js b/exercises/pig-latin/example.js index ce44dd03dc..b4d5d8fb18 100644 --- a/exercises/pig-latin/example.js +++ b/exercises/pig-latin/example.js @@ -10,7 +10,7 @@ function translateWord(word) { return `${newWord}ay`; } -const translator = { +export const translator = { translate(english) { return english .split(' ') @@ -18,5 +18,3 @@ const translator = { .join(' '); }, }; - -export default translator; diff --git a/exercises/pig-latin/pig-latin.spec.js b/exercises/pig-latin/pig-latin.spec.js index dda9222a26..adb1eb4b19 100644 --- a/exercises/pig-latin/pig-latin.spec.js +++ b/exercises/pig-latin/pig-latin.spec.js @@ -1,4 +1,4 @@ -import translator from './pig-latin'; +import { translator } from './pig-latin'; describe('Pig Latin', () => { describe('ay is added to words that start with vowels', () => { diff --git a/exercises/point-mutations/example.js b/exercises/point-mutations/example.js index ae66c899d1..09c587929d 100644 --- a/exercises/point-mutations/example.js +++ b/exercises/point-mutations/example.js @@ -1,4 +1,4 @@ -class DNA { +export class DNA { constructor(nucleotides) { this.nucleotides = nucleotides; } @@ -17,5 +17,3 @@ class DNA { return distance; } } - -export default DNA; diff --git a/exercises/point-mutations/point-mutations.spec.js b/exercises/point-mutations/point-mutations.spec.js index 551e3c49fa..fcc85decb3 100644 --- a/exercises/point-mutations/point-mutations.spec.js +++ b/exercises/point-mutations/point-mutations.spec.js @@ -1,4 +1,4 @@ -import DNA from './point-mutations'; +import { DNA } from './point-mutations'; describe('DNA', () => { test('no difference between empty strands', () => { diff --git a/exercises/protein-translation/example.js b/exercises/protein-translation/example.js index 23514df5a2..34cf0cccc3 100644 --- a/exercises/protein-translation/example.js +++ b/exercises/protein-translation/example.js @@ -20,7 +20,7 @@ const ACID_PROTEIN_MAP = { const getProtein = codon => ACID_PROTEIN_MAP[codon] || 'INVALID'; -export default function translate(rnaStrand) { +export const translate = (rnaStrand) => { const proteins = []; if (rnaStrand) { @@ -42,4 +42,4 @@ export default function translate(rnaStrand) { } return proteins; -} +}; diff --git a/exercises/protein-translation/protein-translation.spec.js b/exercises/protein-translation/protein-translation.spec.js index da60d177d8..3d450b5515 100644 --- a/exercises/protein-translation/protein-translation.spec.js +++ b/exercises/protein-translation/protein-translation.spec.js @@ -1,4 +1,4 @@ -import translate from './protein-translation'; +import { translate } from './protein-translation'; describe('ProteinTranslation', () => { test('Empty RNA has no proteins', () => { diff --git a/exercises/proverb/example.js b/exercises/proverb/example.js index bffc68b376..cae9cc54d5 100644 --- a/exercises/proverb/example.js +++ b/exercises/proverb/example.js @@ -5,7 +5,7 @@ const lastArgIsOptions = (args) => { const conclusion = (firstArg, qualifier = '') => `And all for the want of a ${qualifier}${firstArg}.`; -const proverb = (...args) => { +export const proverb = (...args) => { let options = {}; if (lastArgIsOptions(args)) { options = args.pop(); @@ -19,5 +19,3 @@ const proverb = (...args) => { return chainOfEvents.join('\n'); }; - -export default proverb; diff --git a/exercises/proverb/proverb.spec.js b/exercises/proverb/proverb.spec.js index 3599994cd3..bba277c543 100644 --- a/exercises/proverb/proverb.spec.js +++ b/exercises/proverb/proverb.spec.js @@ -1,4 +1,4 @@ -import proverb from './proverb'; +import { proverb } from './proverb'; describe('Proverb Test Suite', () => { test('a single consequence', () => { diff --git a/exercises/pythagorean-triplet/example.js b/exercises/pythagorean-triplet/example.js index 1f4973ed93..c44e8f0ccf 100644 --- a/exercises/pythagorean-triplet/example.js +++ b/exercises/pythagorean-triplet/example.js @@ -1,4 +1,4 @@ -export default class Triplet { +export class Triplet { constructor(a, b, c) { this.a = a; this.b = b; diff --git a/exercises/pythagorean-triplet/pythagorean-triplet.spec.js b/exercises/pythagorean-triplet/pythagorean-triplet.spec.js index 1dc0b365bd..6c247e3398 100644 --- a/exercises/pythagorean-triplet/pythagorean-triplet.spec.js +++ b/exercises/pythagorean-triplet/pythagorean-triplet.spec.js @@ -1,4 +1,4 @@ -import Triplet from './pythagorean-triplet'; +import { Triplet } from './pythagorean-triplet'; describe('Triplet', () => { test('calculates the sum', () => { diff --git a/exercises/rectangles/example.js b/exercises/rectangles/example.js index eae1e38df1..c7a2589e8e 100644 --- a/exercises/rectangles/example.js +++ b/exercises/rectangles/example.js @@ -1,4 +1,4 @@ -class Rectangles { +export class Rectangles { static count(diagram) { const rows = diagram.length; const cols = rows ? diagram[0].length : 0; @@ -33,5 +33,3 @@ class Rectangles { return rectangles; } } - -export default Rectangles; diff --git a/exercises/rectangles/rectangles.spec.js b/exercises/rectangles/rectangles.spec.js index 49ef91c880..0b21eaa9e3 100644 --- a/exercises/rectangles/rectangles.spec.js +++ b/exercises/rectangles/rectangles.spec.js @@ -1,4 +1,4 @@ -import Rectangles from './rectangles.js'; +import { Rectangles } from './rectangles.js'; describe('Rectangles', () => { test('no rows', () => { diff --git a/exercises/robot-simulator/example.js b/exercises/robot-simulator/example.js index 1022080d9d..6d31059ede 100644 --- a/exercises/robot-simulator/example.js +++ b/exercises/robot-simulator/example.js @@ -5,7 +5,7 @@ export class InvalidInputError extends Error { } } -class Robot { +export class Robot { constructor() { this.coordinates = [0, 0]; this.bearing = 'north'; @@ -87,6 +87,3 @@ class Robot { }); } } - - -export default Robot; diff --git a/exercises/robot-simulator/robot-simulator.spec.js b/exercises/robot-simulator/robot-simulator.spec.js index e23d3d0965..18418c5d8b 100644 --- a/exercises/robot-simulator/robot-simulator.spec.js +++ b/exercises/robot-simulator/robot-simulator.spec.js @@ -1,4 +1,4 @@ -import Robot, { InvalidInputError } from './robot-simulator'; +import { Robot, InvalidInputError } from './robot-simulator'; describe('Robot', () => { const robot = new Robot(); diff --git a/exercises/rotational-cipher/example.js b/exercises/rotational-cipher/example.js index bf56a6d707..50e8e8031b 100644 --- a/exercises/rotational-cipher/example.js +++ b/exercises/rotational-cipher/example.js @@ -1,4 +1,4 @@ -class RotationalCipher { +export class RotationalCipher { static rotate(text, shift) { return [...text].map((c) => { const isUpper = c.match(/[A-Z]/); @@ -12,5 +12,3 @@ class RotationalCipher { }).join(''); } } - -export default RotationalCipher; diff --git a/exercises/rotational-cipher/rotational-cipher.spec.js b/exercises/rotational-cipher/rotational-cipher.spec.js index c403a41259..9b19a505ac 100644 --- a/exercises/rotational-cipher/rotational-cipher.spec.js +++ b/exercises/rotational-cipher/rotational-cipher.spec.js @@ -1,4 +1,4 @@ -import RotationalCipher from './rotational-cipher'; +import { RotationalCipher } from './rotational-cipher'; describe('Rotational cipher', () => { test('rotate a by 0, same output as input', () => { diff --git a/exercises/saddle-points/example.js b/exercises/saddle-points/example.js index 9032d2c6e9..65d7c726b6 100644 --- a/exercises/saddle-points/example.js +++ b/exercises/saddle-points/example.js @@ -9,7 +9,7 @@ function findSaddlePoints(rows, rowMaxs, colMins) { }, []); } -export default class Matrix { +export class Matrix { constructor(data) { this.rows = []; this.columns = []; diff --git a/exercises/saddle-points/saddle-points.spec.js b/exercises/saddle-points/saddle-points.spec.js index adfa48bb93..56993fc188 100644 --- a/exercises/saddle-points/saddle-points.spec.js +++ b/exercises/saddle-points/saddle-points.spec.js @@ -1,4 +1,4 @@ -import Matrix from './saddle-points'; +import { Matrix } from './saddle-points'; describe('Matrix', () => { test('extracts a row', () => { diff --git a/exercises/say/example.js b/exercises/say/example.js index efc647ba2a..e5e68165d7 100644 --- a/exercises/say/example.js +++ b/exercises/say/example.js @@ -1,5 +1,4 @@ - -export default class Say { +export class Say { constructor() { this.smallNumbers = { 0: 'zero', diff --git a/exercises/say/say.spec.js b/exercises/say/say.spec.js index 5dabc53770..94abca7c1b 100644 --- a/exercises/say/say.spec.js +++ b/exercises/say/say.spec.js @@ -1,4 +1,4 @@ -import Say from './say'; +import { Say } from './say'; describe('say', () => { const say = new Say(); diff --git a/exercises/series/example.js b/exercises/series/example.js index 655a05b36c..c019699dc3 100644 --- a/exercises/series/example.js +++ b/exercises/series/example.js @@ -1,4 +1,4 @@ -export default class Series { +export class Series { constructor(numberString) { this.numberString = numberString; this.digits = this.getDigits(); diff --git a/exercises/series/series.spec.js b/exercises/series/series.spec.js index 9f1af0973b..75a4aff58f 100644 --- a/exercises/series/series.spec.js +++ b/exercises/series/series.spec.js @@ -1,4 +1,4 @@ -import Series from './series'; +import { Series } from './series'; describe('Series', () => { test('has digits (short)', () => { diff --git a/exercises/spiral-matrix/example.js b/exercises/spiral-matrix/example.js index 96287a0951..bfbbde6d1f 100644 --- a/exercises/spiral-matrix/example.js +++ b/exercises/spiral-matrix/example.js @@ -1,4 +1,4 @@ -class SpiralMatrix { +export class SpiralMatrix { static ofSize(size) { const spiral = Array(size).fill().map(() => Array(0)); @@ -19,6 +19,4 @@ class SpiralMatrix { return spiral; } -} - -export default SpiralMatrix; +}; diff --git a/exercises/spiral-matrix/spiral-matrix.spec.js b/exercises/spiral-matrix/spiral-matrix.spec.js index 0dcb3aac0b..dc69bb126b 100644 --- a/exercises/spiral-matrix/spiral-matrix.spec.js +++ b/exercises/spiral-matrix/spiral-matrix.spec.js @@ -1,4 +1,4 @@ -import SpiralMatrix from './spiral-matrix'; +import { SpiralMatrix } from './spiral-matrix'; describe('Spiral Matrix', () => { test('empty spiral', () => { diff --git a/exercises/sublist/example.js b/exercises/sublist/example.js index 7168a8587f..a5aee84163 100644 --- a/exercises/sublist/example.js +++ b/exercises/sublist/example.js @@ -1,4 +1,4 @@ -class List { +export class List { constructor(list = []) { this.list = list; } @@ -25,5 +25,3 @@ function lengthDiff(one, two){ function isSublist(one, two){ return one.join().match(two.join()); } - -export default List; diff --git a/exercises/sublist/sublist.spec.js b/exercises/sublist/sublist.spec.js index 414dd08370..55b91dc02e 100644 --- a/exercises/sublist/sublist.spec.js +++ b/exercises/sublist/sublist.spec.js @@ -1,5 +1,4 @@ -import List from './sublist'; - +import { List } from './sublist'; describe('sublist', () => { test('two empty lists are equal', () => { diff --git a/exercises/transpose/example.js b/exercises/transpose/example.js index 1c327990bb..54b32b76ba 100644 --- a/exercises/transpose/example.js +++ b/exercises/transpose/example.js @@ -3,7 +3,7 @@ function trimTrailingUndefined(array) { return array.slice(0, array.length - trailingUndefinedCount); } -export default function transpose(input) { +export function transpose(input) { const maxCol = Math.max(0, ...(input.map(row => row.length))); return [...Array(maxCol).keys()].map(col => trimTrailingUndefined( input.map((_v, row) => input[row][col]), diff --git a/exercises/transpose/transpose.spec.js b/exercises/transpose/transpose.spec.js index 05a345e631..7dcc6219e9 100644 --- a/exercises/transpose/transpose.spec.js +++ b/exercises/transpose/transpose.spec.js @@ -1,4 +1,4 @@ -import transpose from './transpose'; +import { transpose } from './transpose'; describe('Transpose', () => { test('empty string', () => { diff --git a/exercises/triangle/example.js b/exercises/triangle/example.js index 197064ed1c..6ed7e13b38 100644 --- a/exercises/triangle/example.js +++ b/exercises/triangle/example.js @@ -1,4 +1,4 @@ -class Triangle { +export class Triangle { constructor(...sides) { this.sides = sides; } @@ -45,5 +45,3 @@ class Triangle { return new Set(this.sides).size; } } - -export default Triangle; diff --git a/exercises/triangle/triangle.spec.js b/exercises/triangle/triangle.spec.js index 6cd1ee3b91..3c4b76d5fa 100644 --- a/exercises/triangle/triangle.spec.js +++ b/exercises/triangle/triangle.spec.js @@ -1,4 +1,4 @@ -import Triangle from './triangle'; +import { Triangle } from './triangle'; describe('Triangle', () => { test('equilateral triangles have equal sides', () => { diff --git a/exercises/trinary/example.js b/exercises/trinary/example.js index cc6d60c44e..818e829164 100644 --- a/exercises/trinary/example.js +++ b/exercises/trinary/example.js @@ -1,6 +1,6 @@ const BASE = 3; -export default class Trinary { +export class Trinary { constructor(decimal) { this.digits = [...decimal].reverse().map(Number); } diff --git a/exercises/trinary/trinary.spec.js b/exercises/trinary/trinary.spec.js index 502cdc1eb1..f7c564386d 100644 --- a/exercises/trinary/trinary.spec.js +++ b/exercises/trinary/trinary.spec.js @@ -1,4 +1,4 @@ -import Trinary from './trinary'; +import { Trinary } from './trinary'; describe('Trinary', () => { test('1 is decimal 1', () => { diff --git a/exercises/twelve-days/example.js b/exercises/twelve-days/example.js index 7b33811f61..52b35a1b95 100644 --- a/exercises/twelve-days/example.js +++ b/exercises/twelve-days/example.js @@ -1,4 +1,4 @@ -class TwelveDays { +export class TwelveDays { constructor() { this.verseList = [ 'On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree.', @@ -49,5 +49,3 @@ class TwelveDays { return song; } } - -export default TwelveDays; diff --git a/exercises/twelve-days/twelve-days.spec.js b/exercises/twelve-days/twelve-days.spec.js index 3d4c6984f4..f10b00f05e 100644 --- a/exercises/twelve-days/twelve-days.spec.js +++ b/exercises/twelve-days/twelve-days.spec.js @@ -1,4 +1,4 @@ -import TwelveDays from './twelve-days.js'; +import { TwelveDays } from './twelve-days.js'; describe('TwelveDays', () => { let twelveDaysObject; diff --git a/exercises/two-bucket/example.js b/exercises/two-bucket/example.js index 81709ccfcd..4fe7ccaa5d 100644 --- a/exercises/two-bucket/example.js +++ b/exercises/two-bucket/example.js @@ -1,4 +1,4 @@ -class TwoBucket { +export class TwoBucket { constructor(x, y, z, starter) { this.starter = starter; this.x = x; @@ -121,5 +121,3 @@ class TwoBucket { return moveCount + 1; } } - -export default TwoBucket; diff --git a/exercises/two-bucket/two-bucket.spec.js b/exercises/two-bucket/two-bucket.spec.js index 903b1a232d..6a6936f3cb 100644 --- a/exercises/two-bucket/two-bucket.spec.js +++ b/exercises/two-bucket/two-bucket.spec.js @@ -1,4 +1,4 @@ -import TwoBucket from './two-bucket'; +import { TwoBucket } from './two-bucket'; describe('TwoBucket', () => { describe('works for input of 3, 5, 1', () => { diff --git a/exercises/word-count/example.js b/exercises/word-count/example.js index 0d5fd39143..0eb59d3fe3 100644 --- a/exercises/word-count/example.js +++ b/exercises/word-count/example.js @@ -1,4 +1,4 @@ -class Words { +export class Words { count(input) { this.counts = {}; this.words = input.match(/\S+/g); @@ -11,5 +11,3 @@ class Words { return this.counts; } } - -export default Words; diff --git a/exercises/word-count/word-count.spec.js b/exercises/word-count/word-count.spec.js index 4790474bff..b35eb9e0d0 100644 --- a/exercises/word-count/word-count.spec.js +++ b/exercises/word-count/word-count.spec.js @@ -1,4 +1,4 @@ -import Words from './word-count'; +import { Words } from './word-count'; describe('words()', () => { const words = new Words(); diff --git a/exercises/zipper/example.js b/exercises/zipper/example.js index 21708c494c..374029d708 100644 --- a/exercises/zipper/example.js +++ b/exercises/zipper/example.js @@ -20,7 +20,7 @@ function rebuildTree(tree, trail) { return rebuildTree(fromTrail(tree, last), trail.slice(1)); } -class Zipper { +export class Zipper { constructor(tree, trail) { this.tree = tree; this.trail = trail; @@ -69,6 +69,3 @@ class Zipper { return new Zipper({ value: this.tree.value, left: this.tree.left, right }, this.trail); } } - - -export default Zipper; diff --git a/exercises/zipper/zipper.spec.js b/exercises/zipper/zipper.spec.js index 2c38a01fdd..9c9122a6dd 100644 --- a/exercises/zipper/zipper.spec.js +++ b/exercises/zipper/zipper.spec.js @@ -1,4 +1,4 @@ -import Zipper from './zipper'; +import { Zipper } from './zipper'; // Tests adapted from `problem-specifications/zipper/canonical-data.json` @ v1.0.0