├── .eslintrc.js
├── .gitignore
├── 001-reversestring
├── README.md
├── index.js
└── test.js
├── 002-palindrome
├── README.md
├── index.js
└── test.js
├── 003-reverseint
├── README.md
├── index.js
└── test.js
├── 004-maxchar
├── README.md
├── index.js
└── test.js
├── 005-fizzbuzz
├── README.md
├── index.js
└── test.js
├── 006-chunk
├── README.md
├── index.js
└── test.js
├── 007-anagrams
├── README.md
├── index.js
└── test.js
├── 008-capitalize
├── README.md
├── index.js
└── test.js
├── 009-steps
├── README.md
├── index.js
└── test.js
├── 010-pyramid
├── README.md
├── index.js
└── test.js
├── 011-vowels
├── README.md
├── index.js
└── test.js
├── 012-matrix
├── README.md
├── index.js
└── test.js
├── 014-fib
├── README.md
├── index.js
└── test.js
├── 015-queue
├── README.md
├── index.js
└── test.js
├── 016-weave
├── README.md
├── index.js
├── queue.js
└── test.js
├── 017-stack
├── README.md
├── index.js
└── test.js
├── 018-queue-from-stack
├── README.md
├── index.js
├── stack.js
└── test.js
├── 019-linkedlist
├── Readme.md
├── directions.html
├── index.js
└── test.js
├── 020-midpoint-linkedlist
├── README.md
├── index.js
├── linkedlist.js
└── test.js
├── 021-circular-linkedlist
├── README.md
├── index.js
├── linkedlist.js
└── test.js
├── 022-fromlast-linkedlist
├── README.md
├── index.js
├── linkedlist.js
└── test.js
├── 023-tree
├── README.md
├── index.js
└── test.js
├── 024-levelwidth-treenode
├── README.md
├── index.js
├── node.js
└── test.js
├── 025-binary-search-trees
├── README.md
├── index.js
└── test.js
├── 026-validate-bst
├── README.md
├── index.js
├── node.js
└── test.js
├── 027-events-library
├── README.md
├── index.js
├── jquery-example.html
└── test.js
├── 028-sorting
├── README.md
├── index.js
└── test.js
├── LICENSE
├── README.md
├── jest.config.js
├── package.json
└── yarn.lock
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | es6: true,
4 | browser: true,
5 | },
6 | extends: 'airbnb-base',
7 | rules: {
8 | // Personal Preferences below ... proffessionally may change
9 | 'arrow-body-style': 0,
10 | 'arrow-parens': 0,
11 | 'func-names': 0,
12 | 'no-underscore-dangle': 0,
13 | 'symbol-description': 0,
14 | 'brace-style': 0,
15 | 'template-curly-spacing': 0,
16 | 'no-unused-vars': 0,
17 | 'no-undef': 0,
18 | 'no-trailing-spaces': 0,
19 | 'no-unused-expressions': 0,
20 | 'no-param-reassign': 0,
21 | 'no-restricted-syntax': 0,
22 | 'no-empty': 0,
23 | 'no-empty-function': 0,
24 | 'no-useless-return': 0,
25 | 'prefer-const': 0,
26 | 'max-len': 0,
27 | // Never use these last 3 in a real application... I mean never!
28 | 'no-alert': 0,
29 | 'no-console': 0,
30 | 'no-debugger': 0,
31 | },
32 | };
33 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ### OSX ###
2 | *.DS_Store
3 | .AppleDouble
4 | .LSOverride
5 |
6 | # Icon must end with two
7 | Icon
8 | # Thumbnails
9 | ._*
10 | # Files that might appear in the root of a volume
11 | .DocumentRevisions-V100
12 | .fseventsd
13 | .Spotlight-V100
14 | .TemporaryItems
15 | .Trashes
16 | .VolumeIcon.icns
17 | .com.apple.timemachine.donotpresent
18 | # Directories potentially created on remote AFP share
19 | .AppleDB
20 | .AppleDesktop
21 | Network Trash Folder
22 | Temporary Items
23 | .apdisk
24 |
25 | ### Node ###
26 | # Logs
27 | logs
28 | *.log
29 | npm-debug.log*
30 |
31 | # Runtime data
32 | pids
33 | *.pid
34 | *.seed
35 | *.pid.lock
36 |
37 | # Directory for instrumented libs generated by jscoverage/JSCover
38 | lib-cov
39 |
40 | # Coverage directory used by tools like istanbul
41 | coverage
42 |
43 | # nyc test coverage
44 | .nyc_output
45 |
46 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
47 | .grunt
48 |
49 | # node-waf configuration
50 | .lock-wscript
51 |
52 | # Compiled binary addons (http://nodejs.org/api/addons.html)
53 | build/Release
54 |
55 | # Dependency directories
56 | node_modules
57 | jspm_packages
58 |
59 | # Optional npm cache directory
60 | .npm
61 |
62 | # Optional eslint cache
63 | .eslintcache
64 |
65 | # Optional REPL history
66 | .node_repl_history
67 |
68 | # Output of 'npm pack'
69 | *.tgz
70 |
71 | # Yarn Integrity file
72 | .yarn-integrity
73 |
74 | # Nuxt build
75 | .nuxt
76 |
77 | # Nuxt generate
78 | dist
79 |
80 | # Ignore Unsolved Exercises
81 | 000-unsolved-exercises
82 |
--------------------------------------------------------------------------------
/001-reversestring/README.md:
--------------------------------------------------------------------------------
1 | # String Reversal
2 |
3 | ## Directions
4 |
5 | Given a string, return a new string with the reversed order of characters
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | reverse('apple') === 'leppa';
11 | reverse('hello') === 'olleh';
12 | reverse('Greetings!') === '!sgniteerG';
13 | ```
14 |
--------------------------------------------------------------------------------
/001-reversestring/index.js:
--------------------------------------------------------------------------------
1 | // Solution 1
2 | const reverse1 = (str) => str.split('').reverse().join('');
3 |
4 | // Solution 1a
5 | // ES6 Shorthand for solution 1
6 | const reverse1a = (str) => [...str].reverse().join('');
7 |
8 | // Solution 2
9 | const reverse2 = (str) => {
10 | let reversed = '';
11 | for (const currentCharacter of str) reversed = `${currentCharacter}${reversed}`;
12 | return reversed;
13 | };
14 |
15 | // Solution 3
16 | const reverse3 = (str) => str.split('').reduce((reversed, currentCharacter) => `${currentCharacter}${reversed}`, '');
17 |
18 | const reverse = reverse2;
19 | module.exports = reverse;
20 |
--------------------------------------------------------------------------------
/001-reversestring/test.js:
--------------------------------------------------------------------------------
1 | const reverse = require('./index');
2 |
3 | test('Reverse function exists', () => {
4 | expect(reverse)
5 | .toBeDefined();
6 | });
7 |
8 | test('Reverse reverses a string', () => {
9 | expect(reverse('abcd'))
10 | .toEqual('dcba');
11 | });
12 |
13 | test('Reverse reverses a string including spaces', () => {
14 | expect(reverse(' abcd'))
15 | .toEqual('dcba ');
16 | });
17 |
--------------------------------------------------------------------------------
/002-palindrome/README.md:
--------------------------------------------------------------------------------
1 | # Palindromes
2 |
3 | ## Directions
4 |
5 | Given a string, return true if the string is a palindrome or false if it is not. Palindromes are strings that form the same word if it is reversed. **Do** include spaces and punctuation in determining if the string is a palindrome.
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | palindrome("abba") === true;
11 | palindrome("abcdefg") === false;
12 | ```
13 |
--------------------------------------------------------------------------------
/002-palindrome/index.js:
--------------------------------------------------------------------------------
1 | // Solution 1
2 | const palindrome1 = (str) => str === str.split('').reverse().join('');
3 |
4 | // Solution 2
5 | const palindrome2 = (str) => {
6 | return str.split('').every((char, index) => char === str[str.length - index - 1]);
7 | };
8 |
9 | const palindrome = palindrome2;
10 | module.exports = palindrome;
11 |
--------------------------------------------------------------------------------
/002-palindrome/test.js:
--------------------------------------------------------------------------------
1 | const palindrome = require('./index');
2 |
3 | test('palindrome function is defined', () => {
4 | expect(typeof palindrome)
5 | .toEqual('function');
6 | });
7 |
8 | test('"aba" is a palindrome', () => {
9 | expect(palindrome('aba'))
10 | .toBeTruthy();
11 | });
12 |
13 | test('" aba" is not a palindrome', () => {
14 | expect(palindrome(' aba'))
15 | .toBeFalsy();
16 | });
17 |
18 | test('"aba " is not a palindrome', () => {
19 | expect(palindrome('aba '))
20 | .toBeFalsy();
21 | });
22 |
23 | test('"greetings" is not a palindrome', () => {
24 | expect(palindrome('greetings'))
25 | .toBeFalsy();
26 | });
27 |
28 | test('"1000000001" a palindrome', () => {
29 | expect(palindrome('1000000001'))
30 | .toBeTruthy();
31 | });
32 |
33 | test('"Fish hsif" is not a palindrome', () => {
34 | expect(palindrome('Fish hsif'))
35 | .toBeFalsy();
36 | });
37 |
38 | test('"pennep" a palindrome', () => {
39 | expect(palindrome('pennep'))
40 | .toBeTruthy();
41 | });
42 |
--------------------------------------------------------------------------------
/003-reverseint/README.md:
--------------------------------------------------------------------------------
1 | # Integer Reversal
2 |
3 | ## Directions
4 |
5 | Given an integer, return an integer that is the reverse ordering of numbers.
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | reverseInt(15) === 51;
11 | reverseInt(981) === 189;
12 | reverseInt(500) === 5;
13 | reverseInt(-15) === -51;
14 | reverseInt(-90) === -9;
15 | ```
16 |
--------------------------------------------------------------------------------
/003-reverseint/index.js:
--------------------------------------------------------------------------------
1 | // Solution
2 | const reverseInt = (num) => {
3 | return Math.sign(num) * parseInt(num.toString().split('').reverse().join(''), 10);
4 | };
5 |
6 | module.exports = reverseInt;
7 |
--------------------------------------------------------------------------------
/003-reverseint/test.js:
--------------------------------------------------------------------------------
1 | const reverseInt = require('./index');
2 |
3 | test('ReverseInt function exists', () => {
4 | expect(reverseInt)
5 | .toBeDefined();
6 | });
7 |
8 | test('ReverseInt handles 0 as an input', () => {
9 | expect(reverseInt(0))
10 | .toEqual(0);
11 | });
12 |
13 | test('ReverseInt flips a positive number', () => {
14 | expect(reverseInt(5))
15 | .toEqual(5);
16 | expect(reverseInt(15))
17 | .toEqual(51);
18 | expect(reverseInt(90))
19 | .toEqual(9);
20 | expect(reverseInt(2359))
21 | .toEqual(9532);
22 | });
23 |
24 | test('ReverseInt flips a negative number', () => {
25 | expect(reverseInt(-5))
26 | .toEqual(-5);
27 | expect(reverseInt(-15))
28 | .toEqual(-51);
29 | expect(reverseInt(-90))
30 | .toEqual(-9);
31 | expect(reverseInt(-2359))
32 | .toEqual(-9532);
33 | });
34 |
--------------------------------------------------------------------------------
/004-maxchar/README.md:
--------------------------------------------------------------------------------
1 | # Maximum Characters
2 |
3 | ## Directions
4 |
5 | Given a string, return the character that is most commonly used in the string.
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | maxChar("abcccccccd") === "c";
11 | maxChar("apple 1231111") === "1";
12 | ```
13 |
--------------------------------------------------------------------------------
/004-maxchar/index.js:
--------------------------------------------------------------------------------
1 | // Solution
2 | const maxChar = (str) => {
3 | const charMap = {};
4 | for (const char of str) charMap[char] = charMap[char] + 1 || 1;
5 | let solution;
6 | let maxValue = 0;
7 | for (const char in charMap) {
8 | if (charMap[char] > maxValue) {
9 | maxValue = charMap[char];
10 | solution = char;
11 | }
12 | }
13 | return solution;
14 | };
15 |
16 | module.exports = maxChar;
17 |
--------------------------------------------------------------------------------
/004-maxchar/test.js:
--------------------------------------------------------------------------------
1 | const maxChar = require('./index');
2 |
3 | test('maxChar function exists', () => {
4 | expect(typeof maxChar)
5 | .toEqual('function');
6 | });
7 |
8 | test('Finds the most frequently used char', () => {
9 | expect(maxChar('a'))
10 | .toEqual('a');
11 | expect(maxChar('abcdefghijklmnaaaaa'))
12 | .toEqual('a');
13 | });
14 |
15 | test('Works with numbers in the string', () => {
16 | expect(maxChar('ab1c1d1e1f1g1'))
17 | .toEqual('1');
18 | });
19 |
--------------------------------------------------------------------------------
/005-fizzbuzz/README.md:
--------------------------------------------------------------------------------
1 | # The Classic FizzBuzz!
2 |
3 | ## Directions
4 |
5 | Write a program that console logs the numbers from 1 to n. But for multiples of three print “fizz” instead of the number and for the multiples of five print “buzz”. For numbers which are multiples of both three and five print “fizzbuzz”.
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | > fizzBuzz(15);
11 | 1
12 | 2
13 | fizz
14 | 4
15 | buzz
16 | fizz
17 | 7
18 | 8
19 | fizz
20 | buzz
21 | 11
22 | fizz
23 | 13
24 | 14
25 | fizzbuzz
26 | ```
27 |
--------------------------------------------------------------------------------
/005-fizzbuzz/index.js:
--------------------------------------------------------------------------------
1 | // Solution 1
2 | const fizzBuzz1 = (n) => {
3 | for (let i = 1; i <= n; i += 1) {
4 | if (i % (3 * 5) === 0) console.log('fizzbuzz');
5 | else if (i % 3 === 0) console.log('fizz');
6 | else if (i % 5 === 0) console.log('buzz');
7 | else console.log(i);
8 | }
9 | };
10 |
11 | // Solution 2
12 | // => https://codepen.io/IamManchanda/pen/KZXQYr
13 | const range = (count) => Array.from({ length: count }, (v, i) => i + 1); // Helper Function
14 |
15 | // or, you can Hack the prototype of `Number` Object with iterators and generators
16 |
17 | /*
18 | * Number.prototype[Symbol.iterator] = function* () {
19 | * for (let i = 1; i <= this; i += 1) yield i;
20 | * };
21 | *
22 | * const range = (count) => [...count];
23 | */
24 |
25 | const fizzBuzz2 = (n) => {
26 | for (i of range(n)) {
27 | if (i % (3 * 5) === 0) console.log('fizzbuzz');
28 | else if (i % 3 === 0) console.log('fizz');
29 | else if (i % 5 === 0) console.log('buzz');
30 | else console.log(i);
31 | }
32 | };
33 |
34 | const fizzBuzz = fizzBuzz2;
35 | module.exports = fizzBuzz;
36 |
--------------------------------------------------------------------------------
/005-fizzbuzz/test.js:
--------------------------------------------------------------------------------
1 | const fizzBuzz = require('./index');
2 |
3 | test('fizzBuzz function is defined', () => {
4 | expect(fizzBuzz)
5 | .toBeDefined();
6 | });
7 |
8 | test('Calling fizzbuzz with 15 prints out the correct values', () => {
9 | fizzBuzz(15);
10 |
11 | expect(console.log.mock.calls[0][0]).toEqual(1);
12 | expect(console.log.mock.calls[1][0]).toEqual(2);
13 | expect(console.log.mock.calls[2][0]).toEqual('fizz');
14 | expect(console.log.mock.calls[3][0]).toEqual(4);
15 | expect(console.log.mock.calls[4][0]).toEqual('buzz');
16 | expect(console.log.mock.calls[5][0]).toEqual('fizz');
17 | expect(console.log.mock.calls[6][0]).toEqual(7);
18 | expect(console.log.mock.calls[7][0]).toEqual(8);
19 | expect(console.log.mock.calls[8][0]).toEqual('fizz');
20 | expect(console.log.mock.calls[9][0]).toEqual('buzz');
21 | expect(console.log.mock.calls[10][0]).toEqual(11);
22 | expect(console.log.mock.calls[11][0]).toEqual('fizz');
23 | expect(console.log.mock.calls[12][0]).toEqual(13);
24 | expect(console.log.mock.calls[13][0]).toEqual(14);
25 | expect(console.log.mock.calls[14][0]).toEqual('fizzbuzz');
26 | });
27 |
28 | beforeEach(() => {
29 | jest.spyOn(console, 'log');
30 | });
31 |
32 | afterEach(() => {
33 | console.log.mockRestore();
34 | });
35 |
--------------------------------------------------------------------------------
/006-chunk/README.md:
--------------------------------------------------------------------------------
1 | # Array Chunking
2 |
3 | ## Directions
4 |
5 | Given an array and chunk size, divide the array into many subarrays where each subarray is of length size
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | chunk([1, 2, 3, 4], 2) === [[ 1, 2], [3, 4]];
11 | chunk([1, 2, 3, 4, 5], 2) === [[ 1, 2], [3, 4], [5]];
12 | chunk([1, 2, 3, 4, 5, 6, 7, 8], 3) === [[ 1, 2, 3], [4, 5, 6], [7, 8]];
13 | chunk([1, 2, 3, 4, 5], 4) === [[ 1, 2, 3, 4], [5]];
14 | chunk([1, 2, 3, 4, 5], 10) === [[ 1, 2, 3, 4, 5]];
15 | ```
16 |
--------------------------------------------------------------------------------
/006-chunk/index.js:
--------------------------------------------------------------------------------
1 | // Solution 1
2 | const chunk1 = (array, size) => {
3 | const chunked = [];
4 | for (const element of array) {
5 | const lastElement = chunked[chunked.length - 1];
6 | if (!lastElement || lastElement.length === size) chunked.push([element]);
7 | else lastElement.push(element);
8 | }
9 | return chunked;
10 | };
11 |
12 | // Solution 2
13 | const chunk2 = (array, size) => {
14 | const chunked = [];
15 | let index = 0;
16 | while (index < array.length) {
17 | chunked.push(array.slice(index, index + size));
18 | index += size;
19 | }
20 | return chunked;
21 | };
22 |
23 | const chunk = chunk2;
24 | module.exports = chunk;
25 |
--------------------------------------------------------------------------------
/006-chunk/test.js:
--------------------------------------------------------------------------------
1 | const chunk = require('./index');
2 |
3 | test('function chunk exists', () => {
4 | expect(typeof chunk).toEqual('function');
5 | });
6 |
7 | test('chunk divides an array of 10 elements with chunk size 2', () => {
8 | const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
9 | const chunked = chunk(arr, 2);
10 |
11 | expect(chunked).toEqual([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]);
12 | });
13 |
14 | test('chunk divides an array of 3 elements with chunk size 1', () => {
15 | const arr = [1, 2, 3];
16 | const chunked = chunk(arr, 1);
17 |
18 | expect(chunked).toEqual([[1], [2], [3]]);
19 | });
20 |
21 | test('chunk divides an array of 5 elements with chunk size 3', () => {
22 | const arr = [1, 2, 3, 4, 5];
23 | const chunked = chunk(arr, 3);
24 |
25 | expect(chunked).toEqual([[1, 2, 3], [4, 5]]);
26 | });
27 |
28 | test('chunk divides an array of 13 elements with chunk size 5', () => {
29 | const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
30 | const chunked = chunk(arr, 5);
31 |
32 | expect(chunked).toEqual([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13]]);
33 | });
34 |
--------------------------------------------------------------------------------
/007-anagrams/README.md:
--------------------------------------------------------------------------------
1 | # Anagrams
2 |
3 | ## Directions
4 |
5 | Check to see if two provided strings are anagrams of eachother. One string is an anagram of another if it uses the same characters in the same quantity. Only consider characters, not spaces or punctuation. Consider capital letters to be the same as lower case
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | anagrams('rail safety', 'fairy tales') === True;
11 | anagrams('RAIL! SAFETY!', 'fairy tales') === True;
12 | anagrams('Hi there', 'Bye there') === False;
13 | ```
14 |
--------------------------------------------------------------------------------
/007-anagrams/index.js:
--------------------------------------------------------------------------------
1 | // Helper Function for both solutions
2 | const cleanString = (str) => str.replace(/[^\w]/g, '').toLowerCase();
3 |
4 | // Solution 1
5 | const sortString = (str) => cleanString(str).split('').sort().join(''); // Helper Function
6 | const anagrams1 = (stringA, stringB) => sortString(stringA) === sortString(stringB);
7 |
8 | // Solution 2
9 | const buildCharMap = (str) => { // Helper Function
10 | const charMap = {};
11 | for (const char of cleanString(str)) charMap[char] = charMap[char] + 1 || 1;
12 | return charMap;
13 | };
14 | const anagrams2 = (stringA, stringB) => {
15 | const aCharMap = buildCharMap(stringA);
16 | const bCharMap = buildCharMap(stringB);
17 | if (Object.keys(aCharMap).length !== Object.keys(bCharMap).length) return false;
18 | for (const char in aCharMap) if (aCharMap[char] !== bCharMap[char]) return false;
19 | return true;
20 | };
21 |
22 | const anagrams = anagrams2;
23 | module.exports = anagrams;
24 |
--------------------------------------------------------------------------------
/007-anagrams/test.js:
--------------------------------------------------------------------------------
1 | const anagrams = require('./index.js');
2 |
3 | test('anagrams function exists', () => {
4 | expect(typeof anagrams).toEqual('function');
5 | });
6 |
7 | test('"hello" is an anagram of "llohe"', () => {
8 | expect(anagrams('hello', 'llohe')).toBeTruthy();
9 | });
10 |
11 | test('"Whoa! Hi!" is an anagram of "Hi! Whoa!"', () => {
12 | expect(anagrams('Whoa! Hi!', 'Hi! Whoa!')).toBeTruthy();
13 | });
14 |
15 | test('"One One" is not an anagram of "Two two two"', () => {
16 | expect(anagrams('One One', 'Two two two')).toBeFalsy();
17 | });
18 |
19 | test('"One one" is not an anagram of "One one c"', () => {
20 | expect(anagrams('One one', 'One one c')).toBeFalsy();
21 | });
22 |
23 | test('"A tree, a life, a bench" is not an anagram of "A tree, a fence, a yard"', () => {
24 | expect(
25 | anagrams('A tree, a life, a bench', 'A tree, a fence, a yard'),
26 | ).toBeFalsy();
27 | });
28 |
--------------------------------------------------------------------------------
/008-capitalize/README.md:
--------------------------------------------------------------------------------
1 | # Sentence Capitialization
2 |
3 | ## Directions
4 |
5 | Write a function that accepts a string. The function should capitalize the first letter of each word in the string then return the capitalized string.
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | capitalize('a short sentence') === 'A Short Sentence';
11 | capitalize('a lazy fox') === 'A Lazy Fox';
12 | capitalize('look, it is working!') === 'Look, It Is Working!';
13 | ```
14 |
--------------------------------------------------------------------------------
/008-capitalize/index.js:
--------------------------------------------------------------------------------
1 | // Solution 1
2 | const capitalize1 = (str) => {
3 | const wordsArray = [];
4 | for (const word of str.split(' ')) wordsArray.push(`${ word[0].toUpperCase() }${ word.slice(1) }`);
5 | return wordsArray.join(' ');
6 | };
7 |
8 | // Solution 2
9 | const range = (count) => Array.from({ length: count }, (v, i) => i + 1); // Helper Function
10 | const capitalize2 = (str) => {
11 | let result = str[0].toUpperCase();
12 | for (i of range(str.length - 1)) str[i - 1] === ' ' ? result += str[i].toUpperCase() : result += str[i];
13 | return result;
14 | };
15 |
16 | const capitalize = capitalize2;
17 | module.exports = capitalize;
18 |
--------------------------------------------------------------------------------
/008-capitalize/test.js:
--------------------------------------------------------------------------------
1 | const capitalize = require('./index');
2 |
3 | test('Capitalize is a function', () => {
4 | expect(typeof capitalize).toEqual('function');
5 | });
6 |
7 | test('capitalizes the first letter of every word in a sentence', () => {
8 | expect(capitalize('hi there, how is it going?')).toEqual(
9 | 'Hi There, How Is It Going?',
10 | );
11 | });
12 |
13 | test('capitalizes the first letter', () => {
14 | expect(capitalize('i love breakfast at bill miller bbq')).toEqual(
15 | 'I Love Breakfast At Bill Miller Bbq',
16 | );
17 | });
18 |
--------------------------------------------------------------------------------
/009-steps/README.md:
--------------------------------------------------------------------------------
1 | # Printing Steps
2 |
3 | ## Directions
4 |
5 | Write a function that accepts a positive number N. The function should console log a step shape with N levels using the # character. Make sure the step has spaces on the right hand side!
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | > steps(2)
11 | '# '
12 | '##'
13 |
14 | > steps(3)
15 | '# '
16 | '## '
17 | '###'
18 |
19 | > steps(4)
20 | '# '
21 | '## '
22 | '### '
23 | '####'
24 | ```
25 |
--------------------------------------------------------------------------------
/009-steps/index.js:
--------------------------------------------------------------------------------
1 | // Solution 1
2 | const steps1 = (n) => {
3 | for (let row = 0; row < n; row += 1) {
4 | let stair = '';
5 | for (let column = 0; column < n; column += 1) column <= row ? stair += '#' : stair += ' ';
6 | console.log(stair);
7 | }
8 | };
9 |
10 | // Solution 2
11 | const steps2 = (n, row = 0, stair = '') => {
12 | if (n === row) return;
13 | if (n === stair.length) {
14 | console.log(stair);
15 | return steps2(n, row + 1);
16 | }
17 | const addToStair = stair.length <= row ? '#' : ' ';
18 | steps2(n, row, stair + addToStair);
19 | };
20 |
21 | const steps = steps2;
22 | module.exports = steps;
23 |
--------------------------------------------------------------------------------
/009-steps/test.js:
--------------------------------------------------------------------------------
1 | const steps = require('./index');
2 |
3 | beforeEach(() => {
4 | jest.spyOn(console, 'log');
5 | });
6 |
7 | afterEach(() => {
8 | console.log.mockRestore();
9 | });
10 |
11 | test('steps is a function', () => {
12 | expect(typeof steps).toEqual('function');
13 | });
14 |
15 | test('steps called with n = 1', () => {
16 | steps(1);
17 | expect(console.log.mock.calls[0][0]).toEqual('#');
18 | expect(console.log.mock.calls.length).toEqual(1);
19 | });
20 |
21 | test('steps called with n = 2', () => {
22 | steps(2);
23 | expect(console.log.mock.calls[0][0]).toEqual('# ');
24 | expect(console.log.mock.calls[1][0]).toEqual('##');
25 | expect(console.log.mock.calls.length).toEqual(2);
26 | });
27 |
28 | test('steps called with n = 3', () => {
29 | steps(3);
30 | expect(console.log.mock.calls[0][0]).toEqual('# ');
31 | expect(console.log.mock.calls[1][0]).toEqual('## ');
32 | expect(console.log.mock.calls[2][0]).toEqual('###');
33 | expect(console.log.mock.calls.length).toEqual(3);
34 | });
35 |
--------------------------------------------------------------------------------
/010-pyramid/README.md:
--------------------------------------------------------------------------------
1 | # Two Sided Steps - Pyramids
2 |
3 | ## Directions
4 |
5 | Write a function that accepts a positive number N. The function should console log a pyramid shape with N levels using the # character. Make sure the pyramid has spaces on both the left **and** right hand sides
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | > pyramid(1)
11 | '#'
12 | > pyramid(2)
13 | ' # '
14 | '###'
15 | > pyramid(3)
16 | ' # '
17 | ' ### '
18 | '#####'
19 | ```
20 |
--------------------------------------------------------------------------------
/010-pyramid/index.js:
--------------------------------------------------------------------------------
1 | // Solution 1
2 | const pyramid1 = (n) => {
3 | const midpoint = Math.floor(((2 * n) - 1) / 2);
4 | for (let row = 0; row < n; row += 1) {
5 | let level = '';
6 | for (let column = 0; column < (2 * n) - 1; column += 1) {
7 | midpoint - row <= column && midpoint + row >= column ? level += '#' : level += ' ';
8 | }
9 | console.log(level);
10 | }
11 | };
12 |
13 | // Solution 2
14 | const pyramid2 = (n, row = 0, level = '') => {
15 | if (n === row) { return; }
16 | if (level.length === (2 * n) - 1) {
17 | console.log(level);
18 | return pyramid2(n, row + 1);
19 | }
20 | const midpoint = Math.floor(((2 * n) - 1) / 2);
21 | const addToLevel = midpoint - row <= level.length && midpoint + row >= level.length ? '#' : ' ';
22 | pyramid2(n, row, level + addToLevel);
23 | };
24 |
25 | const pyramid = pyramid2;
26 | module.exports = pyramid;
27 |
--------------------------------------------------------------------------------
/010-pyramid/test.js:
--------------------------------------------------------------------------------
1 | const pyramid = require('./index');
2 |
3 | beforeEach(() => {
4 | jest.spyOn(console, 'log');
5 | });
6 |
7 | afterEach(() => {
8 | console.log.mockRestore();
9 | });
10 |
11 | test('pyramid is a function', () => {
12 | expect(typeof pyramid).toEqual('function');
13 | });
14 |
15 | test('prints a pryamid for n = 2', () => {
16 | pyramid(2);
17 | expect(console.log.mock.calls[0][0]).toEqual(' # ');
18 | expect(console.log.mock.calls[1][0]).toEqual('###');
19 | expect(console.log.mock.calls.length).toEqual(2);
20 | });
21 |
22 | test('prints a pryamid for n = 3', () => {
23 | pyramid(3);
24 | expect(console.log.mock.calls[0][0]).toEqual(' # ');
25 | expect(console.log.mock.calls[1][0]).toEqual(' ### ');
26 | expect(console.log.mock.calls[2][0]).toEqual('#####');
27 | expect(console.log.mock.calls.length).toEqual(3);
28 | });
29 |
30 | test('prints a pryamid for n = 4', () => {
31 | pyramid(4);
32 | expect(console.log.mock.calls[0][0]).toEqual(' # ');
33 | expect(console.log.mock.calls[1][0]).toEqual(' ### ');
34 | expect(console.log.mock.calls[2][0]).toEqual(' ##### ');
35 | expect(console.log.mock.calls[3][0]).toEqual('#######');
36 | expect(console.log.mock.calls.length).toEqual(4);
37 | });
38 |
--------------------------------------------------------------------------------
/011-vowels/README.md:
--------------------------------------------------------------------------------
1 | # Find the Vowels
2 |
3 | ## Directions
4 |
5 | Write a function that returns the number of vowels used in a string. Vowels are the characters 'a', 'e' 'i', 'o', and 'u'.
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | vowels('Hi There!') === 3
11 | vowels('Why do you ask?') === 4
12 | vowels('Why?') === 0
13 | ```
14 |
--------------------------------------------------------------------------------
/011-vowels/index.js:
--------------------------------------------------------------------------------
1 | // Solution 1
2 | const vowels1 = (str) => {
3 | let count = 0;
4 | const checker = ['a', 'i', 'e', 'o', 'u'];
5 | for (const char of str.toLowerCase()) checker.includes(char) ? count += 1 : count += 0;
6 | return count;
7 | };
8 |
9 | // Solution 2
10 | const vowels2 = (str) => {
11 | const matches = str.match(/[aeiou]/gi);
12 | return matches ? matches.length : 0;
13 | };
14 |
15 | const vowels = vowels2;
16 | module.exports = vowels;
17 |
--------------------------------------------------------------------------------
/011-vowels/test.js:
--------------------------------------------------------------------------------
1 | const vowels = require('./index');
2 |
3 | test('Vowels is a function', () => {
4 | expect(typeof vowels).toEqual('function');
5 | });
6 |
7 | test('returns the number of vowels used', () => {
8 | expect(vowels('aeiou')).toEqual(5);
9 | });
10 |
11 | test('returns the number of vowels used when they are capitalized', () => {
12 | expect(vowels('AEIOU')).toEqual(5);
13 | });
14 |
15 | test('returns the number of vowels used', () => {
16 | expect(vowels('abcdefghijklmnopqrstuvwxyz')).toEqual(5);
17 | });
18 |
19 | test('returns the number of vowels used', () => {
20 | expect(vowels('bcdfghjkl')).toEqual(0);
21 | });
22 |
--------------------------------------------------------------------------------
/012-matrix/README.md:
--------------------------------------------------------------------------------
1 | # Enter the Matrix Spiral
2 |
3 | ## Directions
4 |
5 | Write a function that accepts an integer N and returns a NxN spiral matrix.
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | > matrix(2)
11 | [
12 | [1, 2],
13 | [4, 3]
14 | ]
15 | > matrix(3)
16 | [
17 | [1, 2, 3],
18 | [8, 9, 4],
19 | [7, 6, 5]
20 | ]
21 | > matrix(4)
22 | [
23 | [1, 2, 3, 4],
24 | [12, 13, 14, 5],
25 | [11, 16, 15, 6],
26 | [10, 9, 8, 7]
27 | ]
28 | ```
29 |
--------------------------------------------------------------------------------
/012-matrix/index.js:
--------------------------------------------------------------------------------
1 | const matrix = (n) => {
2 | const results = [];
3 | for (let i = 0; i < n; i += 1) results.push([]);
4 | let counter = 1;
5 | let startColumn = 0;
6 | let endColumn = n - 1;
7 | let startRow = 0;
8 | let endRow = n - 1;
9 | while (startColumn <= endColumn && startRow <= endRow) {
10 | // Top Row
11 | for (let tr = startColumn; tr <= endColumn; tr += 1) {
12 | results[startRow][tr] = counter;
13 | counter += 1;
14 | }
15 | startRow += 1;
16 | // Right column
17 | for (let rc = startRow; rc <= endRow; rc += 1) {
18 | results[rc][endColumn] = counter;
19 | counter += 1;
20 | }
21 | endColumn -= 1;
22 | // Bottom row
23 | for (let br = endColumn; br >= startColumn; br -= 1) {
24 | results[endRow][br] = counter;
25 | counter += 1;
26 | }
27 | endRow -= 1;
28 | // Left Column
29 | for (let lc = endRow; lc >= startRow; lc -= 1) {
30 | results[lc][startColumn] = counter;
31 | counter += 1;
32 | }
33 | startColumn += 1;
34 | }
35 | return results;
36 | };
37 |
38 | module.exports = matrix;
39 |
--------------------------------------------------------------------------------
/012-matrix/test.js:
--------------------------------------------------------------------------------
1 | const matrix = require('./index');
2 |
3 | test('matrix is a function', () => {
4 | expect(typeof matrix).toEqual('function');
5 | });
6 |
7 | test('matrix produces a 2x2 array', () => {
8 | const m = matrix(2);
9 | expect(m.length).toEqual(2);
10 | expect(m[0]).toEqual([1, 2]);
11 | expect(m[1]).toEqual([4, 3]);
12 | });
13 |
14 | test('matrix produces a 3x3 array', () => {
15 | const m = matrix(3);
16 | expect(m.length).toEqual(3);
17 | expect(m[0]).toEqual([1, 2, 3]);
18 | expect(m[1]).toEqual([8, 9, 4]);
19 | expect(m[2]).toEqual([7, 6, 5]);
20 | });
21 |
22 | test('matrix produces a 4x4 array', () => {
23 | const m = matrix(4);
24 | expect(m.length).toEqual(4);
25 | expect(m[0]).toEqual([1, 2, 3, 4]);
26 | expect(m[1]).toEqual([12, 13, 14, 5]);
27 | expect(m[2]).toEqual([11, 16, 15, 6]);
28 | expect(m[3]).toEqual([10, 9, 8, 7]);
29 | });
30 |
--------------------------------------------------------------------------------
/014-fib/README.md:
--------------------------------------------------------------------------------
1 | # Runtime Complexity in Practice - Fibonacci series
2 |
3 | ## Directions
4 |
5 | Print out the n-th entry in the fibonacci series. The fibonacci series is an ordering of numbers where each number is the sum of the preceeding two. For example, the sequence `[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]` forms the first ten entries of the fibonacci series.
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | fib(4) === 3
11 | ```
12 |
--------------------------------------------------------------------------------
/014-fib/index.js:
--------------------------------------------------------------------------------
1 | // Solution 1 - Iterative & Linear => O(n)
2 | const fib1 = (n) => {
3 | const result = [0, 1];
4 | for (let i = 2; i <= n; i += 1) {
5 | const a = result[result.length - 1];
6 | const b = result[result.length - 2];
7 | result.push(a + b);
8 | }
9 | return result[result.length - 1];
10 | };
11 |
12 | // Solution 2 - Recursive & Exponential => O(2 ** n)
13 | const fib2 = (n) => {
14 | if (n < 2) return n;
15 | return fib2(n - 1) + fib2(n - 2);
16 | };
17 |
18 | // Solution 3 - Memoization/Recursive & Linear => O(n)
19 | const memoize = (fn) => { // Utility Memoize Function
20 | const cache = {};
21 | return (...args) => {
22 | if (cache[args]) { return cache[args]; }
23 | cache[args] = fn.apply(this, args);
24 | return cache[args];
25 | };
26 | };
27 |
28 | let fib3 = (n) => {
29 | if (n < 2) return n;
30 | return fib3(n - 1) + fib3(n - 2);
31 | };
32 | fib3 = memoize(fib3);
33 |
34 | const fib = fib3;
35 | module.exports = fib;
36 |
--------------------------------------------------------------------------------
/014-fib/test.js:
--------------------------------------------------------------------------------
1 | const fib = require('./index');
2 |
3 | test('Fib function is defined', () => {
4 | expect(typeof fib).toEqual('function');
5 | });
6 |
7 | test('calculates correct fib value for 1', () => {
8 | expect(fib(1)).toEqual(1);
9 | });
10 |
11 | test('calculates correct fib value for 2', () => {
12 | expect(fib(2)).toEqual(1);
13 | });
14 |
15 | test('calculates correct fib value for 3', () => {
16 | expect(fib(3)).toEqual(2);
17 | });
18 |
19 | test('calculates correct fib value for 4', () => {
20 | expect(fib(4)).toEqual(3);
21 | });
22 |
23 | test('calculates correct fib value for 15', () => {
24 | expect(fib(39)).toEqual(63245986);
25 | });
26 |
--------------------------------------------------------------------------------
/015-queue/README.md:
--------------------------------------------------------------------------------
1 | # The Queue
2 |
3 | ## Directions
4 |
5 | Create a queue data structure. The queue should be a class with methods 'add' and 'remove'. Adding to the queue should store an element until it is removed
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | const q = new Queue();
11 | q.add(1);
12 | q.remove(); // returns 1;
13 | ```
14 |
--------------------------------------------------------------------------------
/015-queue/index.js:
--------------------------------------------------------------------------------
1 | // Solution
2 | class Queue {
3 | constructor() {
4 | this.data = [];
5 | }
6 |
7 | add(record) {
8 | this.data.unshift(record);
9 | }
10 |
11 | remove() {
12 | return this.data.pop();
13 | }
14 | }
15 |
16 | module.exports = Queue;
17 |
--------------------------------------------------------------------------------
/015-queue/test.js:
--------------------------------------------------------------------------------
1 | const Queue = require('./index');
2 |
3 | test('Queue is a class', () => {
4 | expect(typeof Queue.prototype.constructor).toEqual('function');
5 | });
6 |
7 | test('can add elements to a queue', () => {
8 | const q = new Queue();
9 | expect(() => {
10 | q.add(1);
11 | }).not.toThrow();
12 | });
13 |
14 | test('can remove elements from a queue', () => {
15 | const q = new Queue();
16 | expect(() => {
17 | q.add(1);
18 | q.remove();
19 | }).not.toThrow();
20 | });
21 |
22 | test('Order of elements is maintained', () => {
23 | const q = new Queue();
24 | q.add(1);
25 | q.add(2);
26 | q.add(3);
27 | expect(q.remove()).toEqual(1);
28 | expect(q.remove()).toEqual(2);
29 | expect(q.remove()).toEqual(3);
30 | expect(q.remove()).toEqual(undefined);
31 | });
32 |
--------------------------------------------------------------------------------
/016-weave/README.md:
--------------------------------------------------------------------------------
1 | # Underwater Queue Weaving
2 |
3 | ## Directions
4 |
5 | 1) Complete the task in weave/queue.js
6 | 2) Implement the 'weave' function. Weave receives two queues as arguments and combines the contents of each into a new, third queue. The third queue should contain the **alterating** content of the two queues. The function should handle queues of different lengths without inserting 'undefined' into the new one. **Do not** access the array inside of any queue, only use the 'add', 'remove', and 'peek' functions.
7 |
8 | ## Examples
9 |
10 | ```javascript
11 | const queueOne = new Queue();
12 | queueOne.add(1);
13 | queueOne.add(2);
14 | const queueTwo = new Queue();
15 | queueTwo.add('Hi');
16 | queueTwo.add('There');
17 | const q = weave(queueOne, queueTwo);
18 | q.remove() // 1
19 | q.remove() // 'Hi'
20 | q.remove() // 2
21 | q.remove() // 'There'
22 | ```
23 |
--------------------------------------------------------------------------------
/016-weave/index.js:
--------------------------------------------------------------------------------
1 | // Solution
2 | const Queue = require('./queue');
3 |
4 | const weave = (sourceOne, sourceTwo) => {
5 | const q = new Queue();
6 | while (sourceOne.peek() || sourceTwo.peek()) {
7 | if (sourceOne.peek()) q.add(sourceOne.remove());
8 | if (sourceTwo.peek()) q.add(sourceTwo.remove());
9 | }
10 | return q;
11 | };
12 |
13 | module.exports = weave;
14 |
--------------------------------------------------------------------------------
/016-weave/queue.js:
--------------------------------------------------------------------------------
1 | // Queue Class
2 | class Queue {
3 | constructor() {
4 | this.data = [];
5 | }
6 |
7 | add(record) {
8 | this.data.unshift(record);
9 | }
10 |
11 | remove() {
12 | return this.data.pop();
13 | }
14 |
15 | peek() {
16 | return this.data[this.data.length - 1];
17 | }
18 | }
19 |
20 | module.exports = Queue;
21 |
--------------------------------------------------------------------------------
/016-weave/test.js:
--------------------------------------------------------------------------------
1 | const weave = require('./index');
2 | const Queue = require('./queue');
3 |
4 | test('queues have a peek function', () => {
5 | const q = new Queue();
6 | expect(typeof q.peek).toEqual('function');
7 | });
8 |
9 | test('peek returns, but does not remove, the first value', () => {
10 | const q = new Queue();
11 | q.add(1);
12 | q.add(2);
13 | expect(q.peek()).toEqual(1);
14 | expect(q.peek()).toEqual(1);
15 | expect(q.remove()).toEqual(1);
16 | expect(q.remove()).toEqual(2);
17 | });
18 |
19 | test('weave is a function', () => {
20 | expect(typeof weave).toEqual('function');
21 | });
22 |
23 | test('weave can combine two queues', () => {
24 | const one = new Queue();
25 | one.add(1);
26 | one.add(2);
27 | one.add(3);
28 | one.add(4);
29 | const two = new Queue();
30 | two.add('one');
31 | two.add('two');
32 | two.add('three');
33 | two.add('four');
34 |
35 | const result = weave(one, two);
36 | expect(result.remove()).toEqual(1);
37 | expect(result.remove()).toEqual('one');
38 | expect(result.remove()).toEqual(2);
39 | expect(result.remove()).toEqual('two');
40 | expect(result.remove()).toEqual(3);
41 | expect(result.remove()).toEqual('three');
42 | expect(result.remove()).toEqual(4);
43 | expect(result.remove()).toEqual('four');
44 | expect(result.remove()).toBeUndefined();
45 | });
46 |
--------------------------------------------------------------------------------
/017-stack/README.md:
--------------------------------------------------------------------------------
1 | # Stack 'Em Up With Stacks
2 |
3 | ## Directions
4 |
5 | Create a stack data structure. The stack should be a class with methods 'push', 'pop', and 'peek'. Adding an element to the stack should store it until it is removed.
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | const s = new Stack();
11 | s.push(1);
12 | s.push(2);
13 | s.pop(); // returns 2
14 | s.pop(); // returns 1
15 | ```
16 |
--------------------------------------------------------------------------------
/017-stack/index.js:
--------------------------------------------------------------------------------
1 | // Solution
2 | class Stack {
3 | constructor() {
4 | this.data = [];
5 | }
6 |
7 | push(record) {
8 | this.data.push(record);
9 | }
10 |
11 | pop() {
12 | return this.data.pop();
13 | }
14 |
15 | peek() {
16 | return this.data[this.data.length - 1];
17 | }
18 | }
19 |
20 | module.exports = Stack;
21 |
--------------------------------------------------------------------------------
/017-stack/test.js:
--------------------------------------------------------------------------------
1 | const Stack = require('./index');
2 |
3 | test('Stack is a class', () => {
4 | expect(typeof Stack.prototype.constructor).toEqual('function');
5 | });
6 |
7 | test('stack can add and remove items', () => {
8 | const s = new Stack();
9 | s.push(1);
10 | expect(s.pop()).toEqual(1);
11 | s.push(2);
12 | expect(s.pop()).toEqual(2);
13 | });
14 |
15 | test('stack can follows first in, last out', () => {
16 | const s = new Stack();
17 | s.push(1);
18 | s.push(2);
19 | s.push(3);
20 | expect(s.pop()).toEqual(3);
21 | expect(s.pop()).toEqual(2);
22 | expect(s.pop()).toEqual(1);
23 | });
24 |
25 | test('peek returns the first element but doesnt pop it', () => {
26 | const s = new Stack();
27 | s.push(1);
28 | s.push(2);
29 | s.push(3);
30 | expect(s.peek()).toEqual(3);
31 | expect(s.pop()).toEqual(3);
32 | expect(s.peek()).toEqual(2);
33 | expect(s.pop()).toEqual(2);
34 | expect(s.peek()).toEqual(1);
35 | expect(s.pop()).toEqual(1);
36 | });
37 |
--------------------------------------------------------------------------------
/018-queue-from-stack/README.md:
--------------------------------------------------------------------------------
1 | # Two Become One - Queue From Stack
2 |
3 | ## Directions
4 |
5 | Implement a Queue datastructure using two stacks. *Do not* create an array inside of the 'Queue' class. Queue should implement the methods 'add', 'remove', and 'peek'. For a reminder on what each method does, look back at the Queue exercise.
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | const q = new Queue();
11 | q.add(1);
12 | q.add(2);
13 | q.peek(); // returns 1
14 | q.remove(); // returns 1
15 | q.remove(); // returns 2
16 | ```
17 |
--------------------------------------------------------------------------------
/018-queue-from-stack/index.js:
--------------------------------------------------------------------------------
1 | // Solution
2 | const Stack = require('./stack');
3 |
4 | class Queue {
5 | constructor() {
6 | this.first = new Stack();
7 | this.second = new Stack();
8 | }
9 |
10 | pushToFirstFromSecond() {
11 | while (this.second.peek()) this.first.push(this.second.pop());
12 | }
13 |
14 | pushToSecondFromFirst() {
15 | while (this.first.peek()) this.second.push(this.first.pop());
16 | }
17 |
18 | add(record) {
19 | this.first.push(record);
20 | }
21 |
22 | remove() {
23 | this.pushToSecondFromFirst();
24 | const record = this.second.pop();
25 | this.pushToFirstFromSecond();
26 | return record;
27 | }
28 |
29 | peek() {
30 | this.pushToSecondFromFirst();
31 | const record = this.second.peek();
32 | this.pushToFirstFromSecond();
33 | return record;
34 | }
35 | }
36 |
37 | module.exports = Queue;
38 |
--------------------------------------------------------------------------------
/018-queue-from-stack/stack.js:
--------------------------------------------------------------------------------
1 | class Stack {
2 | constructor() {
3 | this.data = [];
4 | }
5 |
6 | push(record) {
7 | this.data.push(record);
8 | }
9 |
10 | pop() {
11 | return this.data.pop();
12 | }
13 |
14 | peek() {
15 | return this.data[this.data.length - 1];
16 | }
17 | }
18 |
19 | module.exports = Stack;
20 |
--------------------------------------------------------------------------------
/018-queue-from-stack/test.js:
--------------------------------------------------------------------------------
1 | const Queue = require('./index');
2 |
3 | test('Queue is a class', () => {
4 | expect(typeof Queue.prototype.constructor).toEqual('function');
5 | });
6 |
7 | test('can add elements to a queue', () => {
8 | const q = new Queue();
9 | expect(() => {
10 | q.add(1);
11 | }).not.toThrow();
12 | });
13 |
14 | test('can remove elements from a queue', () => {
15 | const q = new Queue();
16 | expect(() => {
17 | q.add(1);
18 | q.remove();
19 | }).not.toThrow();
20 | });
21 |
22 | test('Order of elements is maintained', () => {
23 | const q = new Queue();
24 | q.add(1);
25 | q.add(2);
26 | q.add(3);
27 | expect(q.remove()).toEqual(1);
28 | expect(q.remove()).toEqual(2);
29 | expect(q.remove()).toEqual(3);
30 | expect(q.remove()).toEqual(undefined);
31 | });
32 |
33 | test('peek returns, but does not remove, the first value', () => {
34 | const q = new Queue();
35 | q.add(1);
36 | q.add(2);
37 | expect(q.peek()).toEqual(1);
38 | expect(q.peek()).toEqual(1);
39 | expect(q.remove()).toEqual(1);
40 | expect(q.remove()).toEqual(2);
41 | });
42 |
--------------------------------------------------------------------------------
/019-linkedlist/Readme.md:
--------------------------------------------------------------------------------
1 | # Linked List
2 |
3 | ## Directions
4 |
5 | Implement classes Node and Linked Lists. See [**directions**](./directions.html) document (View the HTML page from a browser.)
6 |
--------------------------------------------------------------------------------
/019-linkedlist/directions.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
18 |
19 |
20 |
21 |
Node Class API
22 |
23 |
24 |
25 |
Function
26 |
Arguments
27 |
Returns
28 |
Directions
29 |
Example
30 |
31 |
32 |
33 |
34 |
constructor
35 |
(data, node)
36 |
Node
37 |
38 | Creates a class instance to represent a node. The node should
39 | have two properties, 'data' and 'next'. Accept both
40 | of these as arguments to the 'Node' constructor, then
41 | assign them to the instance as properties 'data' and 'next'.
42 | If 'next' is not provided to the constructor, then default its
43 | value to be 'null'.
44 |
45 |
46 |
47 | const n = new Node('There');
48 | n.data // 'Hi'
49 | n.next // null
50 | const n2 = new Node('Hi', n);
51 | n.next // returns n
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
LinkedList Class API
60 |
61 |
62 |
63 |
Function
64 |
Arguments
65 |
Returns
66 |
Directions
67 |
Example
68 |
69 |
70 |
71 |
72 |
constructor
73 |
-
74 |
(LinkedList)
75 |
76 | Create a class to represent a linked list. When created,
77 | a linked list should have *no* head node associated with it.
78 | The LinkedList instance will have one property, 'head', which
79 | is a reference to the first node of the linked list. By default
80 | 'head' should be 'null'.
81 |
82 |
83 |
84 | const list = new LinkedList();
85 | list.head // null
86 |
87 |
88 |
89 |
90 |
size
91 |
-
92 |
(integer)
93 |
94 | Returns the number of nodes in the linked list.
95 |
140 | Returns the node at the provided index
141 |
142 |
143 |
144 | const list = new LinkedList();
145 | list.insertFirst('a');
146 | list.insertFirst('b');
147 | list.insertFirst('c');
148 | list.getAt(1); // returns node with data 'b'
149 |
150 |
151 |
152 |
153 |
getFirst
154 |
-
155 |
(Node)
156 |
157 | Returns the first node of the linked list.
158 |
159 |
160 |
161 | const list = new LinkedList();
162 | list.insertFirst('a');
163 | list.insertFirst('b');
164 | list.getFirst(); // returns Node instance with data 'a'
165 |
166 |
167 |
168 |
169 |
170 | getLast
171 |
172 |
173 | -
174 |
175 |
176 | (Node)
177 |
178 |
179 | Returns the last node of the linked list
180 |
181 |
182 |
183 | const list = new LinkedList();
184 | list.insertFirst('a');
185 | list.insertFirst('b');
186 | list.getLast(); // returns node with data 'a'
187 |
188 |
189 |
190 |
191 |
192 | removeAt
193 |
194 |
195 | (integer)
196 |
197 |
198 | -
199 |
200 |
201 | Removes node at the provided index
202 |
203 |
204 |
205 | const list = new LinkedList();
206 | list.insertFirst('a');
207 | list.insertFirst('b');
208 | list.insertFirst('c');
209 | list.removeAt(1);
210 | list.getAt(1); // returns node with data 'a'
211 |
212 |
213 |
214 |
215 |
216 | removeFirst
217 |
218 |
219 | -
220 |
221 |
222 | -
223 |
224 |
225 | Removes only the first node of the linked list. The list's head should
226 | now be the second element.
227 |
228 |
229 |
230 | const list = new LinkedList();
231 | list.insertFirst('a');
232 | list.insertFirst('b');
233 | list.removeFirst();
234 | list.getFirst(); // returns node with data 'a'
235 |
236 |
237 |
238 |
239 |
240 | removeLast
241 |
242 |
243 | -
244 |
245 |
246 | -
247 |
248 |
249 | Removes the last node of the chain
250 |
251 |
252 |
253 | const list = new LinkedList();
254 | list.insertFirst('a');
255 | list.insertFirst('b');
256 | list.removeLast();
257 | list.size(); // returns 1
258 | list.getLast(); // returns node with data of 'b'
259 |
260 |
261 |
262 |
263 |
264 | insertAt
265 |
266 |
267 | (data, integer)
268 |
269 |
270 | -
271 |
272 |
273 | Create an insert a new node at provided index.
274 | If index is out of bounds, add the node to the end
275 | of the list.
276 |
277 |
278 |
279 | const list = new LinkedList();
280 | list.insertFirst('a');
281 | list.insertFirst('b');
282 | list.insertFirst('c');
283 | list.insertAt('Hi', 1)
284 | list.getAt(1); // returns node with data 'Hi'
285 |
286 |
287 |
288 |
289 |
insertFirst
290 |
(data)
291 |
-
292 |
293 | Creates a new Node from argument 'data' and assigns the resulting
294 | node to the 'head' property. Make sure to handle the case in which
295 | the linked list already has a node assigned to the 'head' property.
296 |
297 |
298 |
299 | const list = new LinkedList();
300 | list.insertFirst('Hi There'); // List has one node
301 |
302 |
303 |
304 |
305 |
306 | insertLast
307 |
308 |
309 | (data)
310 |
311 |
312 | -
313 |
314 |
315 | Inserts a new node with provided data at the end of the chain
316 |
317 |
318 |
319 | const list = new LinkedList();
320 | list.insertFirst('a');
321 | list.insertFirst('b');
322 | list.insertLast('c');
323 | list.getLast(); // returns node with data 'C'
324 |
325 |
326 |
327 |
328 |
329 | forEach
330 |
331 |
332 | (function)
333 |
334 |
335 | -
336 |
337 |
338 | Calls the provided function with every node of the chain
339 |
367 | Linked list should be compatible as the subject of a 'for...of' loop
368 |
369 |
370 |
371 | const list = new LinkedList();
372 |
373 | list.insertLast(1);
374 | list.insertLast(2);
375 | list.insertLast(3);
376 | list.insertLast(4);
377 |
378 | for (let node of list) {
379 | node.data += 10;
380 | }
381 |
382 | node.getAt(1); // returns node with data 11
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
--------------------------------------------------------------------------------
/019-linkedlist/index.js:
--------------------------------------------------------------------------------
1 | // Solution
2 | class Node {
3 | constructor(data, next = null) {
4 | this.data = data;
5 | this.next = next;
6 | }
7 | }
8 |
9 | class LinkedList {
10 | constructor() {
11 | this.head = null;
12 | }
13 |
14 | size() {
15 | let counter = 0;
16 | let node = this.head;
17 | while (node) {
18 | counter += 1;
19 | node = node.next;
20 | }
21 | return counter;
22 | }
23 |
24 | clear() {
25 | this.head = null;
26 | }
27 |
28 | getAt(index) {
29 | let counter = 0;
30 | let node = this.head;
31 | while (node) {
32 | if (counter === index) return node;
33 | counter += 1;
34 | node = node.next;
35 | }
36 | return null;
37 | }
38 |
39 | getFirst() {
40 | return this.getAt(0);
41 | }
42 |
43 | getLast() {
44 | return this.getAt(this.size() - 1);
45 | }
46 |
47 | removeAt(index) {
48 | if (!this.head) return;
49 | if (index === 0) {
50 | this.head = this.head.next;
51 | return;
52 | }
53 | const previous = this.getAt(index - 1);
54 | if (!previous || !previous.next) return;
55 | previous.next = previous.next.next;
56 | }
57 |
58 | removeFirst() {
59 | return this.removeAt(0);
60 | }
61 |
62 | removeLast() {
63 | return this.removeAt(this.size() - 1);
64 | }
65 |
66 | insertAt(data, index) {
67 | if (!this.head) {
68 | this.head = new Node(data);
69 | return;
70 | }
71 | if (index === 0) {
72 | this.head = new Node(data, this.head);
73 | return;
74 | }
75 | const previous = this.getAt(index - 1) || this.getLast();
76 | const node = new Node(data, previous.next);
77 | previous.next = node;
78 | }
79 |
80 | insertFirst(data) {
81 | return this.insertAt(data, 0);
82 | }
83 |
84 | insertLast(data) {
85 | // `this.size()` instead of `this.size() - 1` because we are adding a node after the current last item (hence last item `index + 1`)
86 | return this.insertAt(data, this.size());
87 | }
88 |
89 | forEach(fn) {
90 | let node = this.head;
91 | let counter = 0;
92 | while (node) {
93 | fn(node, counter);
94 | node = node.next;
95 | counter += 1;
96 | }
97 | }
98 |
99 | * [Symbol.iterator]() {
100 | let node = this.head;
101 | while (node) {
102 | yield node;
103 | node = node.next;
104 | }
105 | }
106 | }
107 |
108 | module.exports = { Node, LinkedList };
109 |
--------------------------------------------------------------------------------
/019-linkedlist/test.js:
--------------------------------------------------------------------------------
1 | const { Node, LinkedList } = require('./index');
2 |
3 | describe('Node', () => {
4 | describe('constructor', () => {
5 | test('is a class (has prototype constructor which is equal to a function)', () => {
6 | expect(typeof Node.prototype.constructor).toEqual('function');
7 | });
8 |
9 | test('has properties "data" and "next" when both defined in a function', () => {
10 | const node = new Node('a', 'b');
11 | expect(node.data).toEqual('a');
12 | expect(node.next).toEqual('b');
13 | });
14 |
15 | test('has property "data" whereas "next" returns "null" if not defined', () => {
16 | const node = new Node('a');
17 | expect(node.data).toEqual('a');
18 | expect(node.next).toEqual(null);
19 | });
20 | });
21 | });
22 |
23 | describe('LinkedList', () => {
24 | describe('constructor', () => {
25 | test('is a class (has prototype constructor which is equal to a function)', () => {
26 | expect(typeof LinkedList.prototype.constructor).toEqual('function');
27 | });
28 |
29 | test('has property "head" which returns "null" without any definition in a function', () => {
30 | const list = new LinkedList();
31 | expect(list.head).toEqual(null);
32 | });
33 | });
34 |
35 | describe('size', () => {
36 | test('returns the number of items in the linked list', () => {
37 | const list = new LinkedList();
38 | expect(list.size()).toEqual(0);
39 | list.insertFirst(1);
40 | list.insertFirst(1);
41 | list.insertFirst(1);
42 | list.insertFirst(1);
43 | expect(list.size()).toEqual(4);
44 | });
45 | });
46 |
47 | describe('clear', () => {
48 | test('empties out the list', () => {
49 | const list = new LinkedList();
50 | expect(list.size()).toEqual(0);
51 | list.insertFirst(1);
52 | list.insertFirst(1);
53 | list.insertFirst(1);
54 | list.insertFirst(1);
55 | expect(list.size()).toEqual(4);
56 | list.clear();
57 | expect(list.size()).toEqual(0);
58 | });
59 | });
60 |
61 | describe('getAt', () => {
62 | test('returns the node at given index', () => {
63 | const list = new LinkedList();
64 | expect(list.getAt(10)).toEqual(null);
65 | list.insertLast(1);
66 | list.insertLast(2);
67 | list.insertLast(3);
68 | list.insertLast(4);
69 | expect(list.getAt(0).data).toEqual(1);
70 | expect(list.getAt(1).data).toEqual(2);
71 | expect(list.getAt(2).data).toEqual(3);
72 | expect(list.getAt(3).data).toEqual(4);
73 | });
74 | });
75 |
76 | describe('getFirst', () => {
77 | test('returns the first element', () => {
78 | const list = new LinkedList();
79 | list.insertFirst(1);
80 | expect(list.getFirst().data).toEqual(1);
81 | list.insertFirst(2);
82 | expect(list.getFirst().data).toEqual(2);
83 | });
84 | });
85 |
86 | describe('getLast', () => {
87 | test('returns the last element', () => {
88 | const list = new LinkedList();
89 | list.insertFirst(2);
90 | expect(list.getLast()).toEqual({ data: 2, next: null });
91 | list.insertFirst(1);
92 | expect(list.getLast()).toEqual({ data: 2, next: null });
93 | });
94 | });
95 |
96 | describe('removeAt', () => {
97 | test('doesnt crash on an empty list', () => {
98 | const list = new LinkedList();
99 | expect(() => {
100 | list.removeAt(0);
101 | list.removeAt(1);
102 | list.removeAt(2);
103 | }).not.toThrow();
104 | });
105 |
106 | test('doesnt crash on an index out of bounds', () => {
107 | const list = new LinkedList();
108 | expect(() => {
109 | // eslint-disable-next-line no-shadow
110 | const list = new LinkedList();
111 | list.insertFirst('a');
112 | list.removeAt(1);
113 | }).not.toThrow();
114 | });
115 |
116 | test('deletes the first node', () => {
117 | const list = new LinkedList();
118 | list.insertLast(1);
119 | list.insertLast(2);
120 | list.insertLast(3);
121 | list.insertLast(4);
122 | expect(list.getAt(0).data).toEqual(1);
123 | list.removeAt(0);
124 | expect(list.getAt(0).data).toEqual(2);
125 | });
126 |
127 | test('deletes the node at the given index', () => {
128 | const list = new LinkedList();
129 | list.insertLast(1);
130 | list.insertLast(2);
131 | list.insertLast(3);
132 | list.insertLast(4);
133 | expect(list.getAt(1).data).toEqual(2);
134 | list.removeAt(1);
135 | expect(list.getAt(1).data).toEqual(3);
136 | });
137 |
138 | test('works on the last node', () => {
139 | const list = new LinkedList();
140 | list.insertLast(1);
141 | list.insertLast(2);
142 | list.insertLast(3);
143 | list.insertLast(4);
144 | expect(list.getAt(3).data).toEqual(4);
145 | list.removeAt(3);
146 | expect(list.getAt(3)).toEqual(null);
147 | });
148 | });
149 |
150 | describe('removeFirst', () => {
151 | test('removes the first node when the list has a size of one', () => {
152 | const list = new LinkedList();
153 | list.insertFirst('a');
154 | list.removeFirst();
155 | expect(list.size()).toEqual(0);
156 | expect(list.getFirst()).toEqual(null);
157 | });
158 |
159 | test('removes the first node when the list has a size of three', () => {
160 | const list = new LinkedList();
161 | list.insertFirst('c');
162 | list.insertFirst('b');
163 | list.insertFirst('a');
164 | list.removeFirst();
165 | expect(list.size()).toEqual(2);
166 | expect(list.getFirst().data).toEqual('b');
167 | list.removeFirst();
168 | expect(list.size()).toEqual(1);
169 | expect(list.getFirst().data).toEqual('c');
170 | });
171 | });
172 |
173 | describe('removeLast', () => {
174 | test('removes the last node when list is empty', () => {
175 | const list = new LinkedList();
176 | expect(() => {
177 | list.removeLast();
178 | }).not.toThrow();
179 | });
180 |
181 | test('removes the last node when list is length 1', () => {
182 | const list = new LinkedList();
183 | list.insertFirst('a');
184 | list.removeLast();
185 | expect(list.head).toEqual(null);
186 | });
187 |
188 | test('removes the last node when list is length 2', () => {
189 | const list = new LinkedList();
190 | list.insertFirst('b');
191 | list.insertFirst('a');
192 | list.removeLast();
193 | expect(list.size()).toEqual(1);
194 | expect(list.head.data).toEqual('a');
195 | });
196 |
197 | test('removes the last node when list is length 3', () => {
198 | const list = new LinkedList();
199 | list.insertFirst('c');
200 | list.insertFirst('b');
201 | list.insertFirst('a');
202 | list.removeLast();
203 | expect(list.size()).toEqual(2);
204 | expect(list.getLast().data).toEqual('b');
205 | });
206 | });
207 |
208 | describe('insertAt', () => {
209 | test('inserts a new node with data at the 0 index when the list is empty', () => {
210 | const list = new LinkedList();
211 | list.insertAt('hi', 0);
212 | expect(list.getFirst().data).toEqual('hi');
213 | });
214 |
215 | test('inserts a new node with data at the 0 index when the list has elements', () => {
216 | const list = new LinkedList();
217 | list.insertLast('a');
218 | list.insertLast('b');
219 | list.insertLast('c');
220 | list.insertAt('hi', 0);
221 | expect(list.getAt(0).data).toEqual('hi');
222 | expect(list.getAt(1).data).toEqual('a');
223 | expect(list.getAt(2).data).toEqual('b');
224 | expect(list.getAt(3).data).toEqual('c');
225 | });
226 |
227 | test('inserts a new node with data at a middle index', () => {
228 | const list = new LinkedList();
229 | list.insertLast('a');
230 | list.insertLast('b');
231 | list.insertLast('c');
232 | list.insertLast('d');
233 | list.insertAt('hi', 2);
234 | expect(list.getAt(0).data).toEqual('a');
235 | expect(list.getAt(1).data).toEqual('b');
236 | expect(list.getAt(2).data).toEqual('hi');
237 | expect(list.getAt(3).data).toEqual('c');
238 | expect(list.getAt(4).data).toEqual('d');
239 | });
240 |
241 | test('inserts a new node with data at a last index', () => {
242 | const list = new LinkedList();
243 | list.insertLast('a');
244 | list.insertLast('b');
245 | list.insertAt('hi', 2);
246 | expect(list.getAt(0).data).toEqual('a');
247 | expect(list.getAt(1).data).toEqual('b');
248 | expect(list.getAt(2).data).toEqual('hi');
249 | });
250 |
251 | test('insert a new node when index is out of bounds', () => {
252 | const list = new LinkedList();
253 | list.insertLast('a');
254 | list.insertLast('b');
255 | list.insertAt('hi', 30);
256 |
257 | expect(list.getAt(0).data).toEqual('a');
258 | expect(list.getAt(1).data).toEqual('b');
259 | expect(list.getAt(2).data).toEqual('hi');
260 | });
261 | });
262 |
263 | describe('insertFirst', () => {
264 | test('appends a node to the start of the list', () => {
265 | const list = new LinkedList();
266 | list.insertFirst(1);
267 | expect(list.head.data).toEqual(1);
268 | list.insertFirst(2);
269 | expect(list.head.data).toEqual(2);
270 | list.insertFirst(3);
271 | expect(list.head.data).toEqual(3);
272 | });
273 | });
274 |
275 | describe('insertLast', () => {
276 | test('adds to the end of the list', () => {
277 | const list = new LinkedList();
278 | list.insertFirst('a');
279 | list.insertLast('b');
280 | expect(list.size()).toEqual(2);
281 | expect(list.getLast().data).toEqual('b');
282 | });
283 | });
284 |
285 | describe('forEach', () => {
286 | test('applies a transform to each node', () => {
287 | const list = new LinkedList();
288 |
289 | list.insertLast(1);
290 | list.insertLast(2);
291 | list.insertLast(3);
292 | list.insertLast(4);
293 |
294 | list.forEach(node => {
295 | node.data += 10;
296 | });
297 |
298 | expect(list.getAt(0).data).toEqual(11);
299 | expect(list.getAt(1).data).toEqual(12);
300 | expect(list.getAt(2).data).toEqual(13);
301 | expect(list.getAt(3).data).toEqual(14);
302 | });
303 | });
304 |
305 | describe('for...of loops', () => {
306 | test('works with the linked list', () => {
307 | const list = new LinkedList();
308 |
309 | list.insertLast(1);
310 | list.insertLast(2);
311 | list.insertLast(3);
312 | list.insertLast(4);
313 |
314 | for (let node of list) {
315 | node.data += 10;
316 | }
317 |
318 | expect(list.getAt(0).data).toEqual(11);
319 | expect(list.getAt(1).data).toEqual(12);
320 | expect(list.getAt(2).data).toEqual(13);
321 | expect(list.getAt(3).data).toEqual(14);
322 | });
323 |
324 | test('for...of works on an empty list', () => {
325 | const list = new LinkedList();
326 | expect(() => {
327 | for (let node of list) {
328 | }
329 | }).not.toThrow();
330 | });
331 | });
332 | });
333 |
--------------------------------------------------------------------------------
/020-midpoint-linkedlist/README.md:
--------------------------------------------------------------------------------
1 | # Midpoint of a Linked List
2 |
3 | ## Directions
4 |
5 | Return the 'middle' node of a linked list. If the list has an even number of elements, return the node at the end of the first half of the list. *Do not* use a counter variable, *do not* retrieve the size of the list, and only iterate through the list one time.
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | const list = new LinkedList();
11 | list.insertLast('a')
12 | list.insertLast('b')
13 | list.insertLast('c')
14 | midpoint(list); // returns { data: 'b' }
15 | // Midpoint returns the middle node of an odd numbered list
16 | ```
17 |
18 | or
19 |
20 | ```javascript
21 | const list = new LinkedList();
22 | list.insertLast('a');
23 | list.insertLast('b');
24 | list.insertLast('c');
25 | list.insertLast('d');
26 | midpoint(list); // returns { data: 'b' }
27 | // Midpoint returns the node at the end of the first half of an even numbered list
28 | ```
29 |
30 |
--------------------------------------------------------------------------------
/020-midpoint-linkedlist/index.js:
--------------------------------------------------------------------------------
1 | // Solution
2 | const midpoint = (list) => {
3 | let slowIncrement = list.getFirst();
4 | let fastIncrement = list.getFirst();
5 | while (fastIncrement.next && fastIncrement.next.next) {
6 | slowIncrement = slowIncrement.next;
7 | fastIncrement = fastIncrement.next.next;
8 | }
9 | return slowIncrement;
10 | };
11 |
12 | module.exports = midpoint;
13 |
--------------------------------------------------------------------------------
/020-midpoint-linkedlist/linkedlist.js:
--------------------------------------------------------------------------------
1 | // Solution
2 | class Node {
3 | constructor(data, next = null) {
4 | this.data = data;
5 | this.next = next;
6 | }
7 | }
8 |
9 | class LinkedList {
10 | constructor() {
11 | this.head = null;
12 | }
13 |
14 | size() {
15 | let counter = 0;
16 | let node = this.head;
17 | while (node) {
18 | counter += 1;
19 | node = node.next;
20 | }
21 | return counter;
22 | }
23 |
24 | clear() {
25 | this.head = null;
26 | }
27 |
28 | getAt(index) {
29 | let counter = 0;
30 | let node = this.head;
31 | while (node) {
32 | if (counter === index) return node;
33 | counter += 1;
34 | node = node.next;
35 | }
36 | return null;
37 | }
38 |
39 | getFirst() {
40 | return this.getAt(0);
41 | }
42 |
43 | getLast() {
44 | return this.getAt(this.size() - 1);
45 | }
46 |
47 | removeAt(index) {
48 | if (!this.head) return;
49 | if (index === 0) {
50 | this.head = this.head.next;
51 | return;
52 | }
53 | const previous = this.getAt(index - 1);
54 | if (!previous || !previous.next) return;
55 | previous.next = previous.next.next;
56 | }
57 |
58 | removeFirst() {
59 | return this.removeAt(0);
60 | }
61 |
62 | removeLast() {
63 | return this.removeAt(this.size() - 1);
64 | }
65 |
66 | insertAt(data, index) {
67 | if (!this.head) {
68 | this.head = new Node(data);
69 | return;
70 | }
71 | if (index === 0) {
72 | this.head = new Node(data, this.head);
73 | return;
74 | }
75 | const previous = this.getAt(index - 1) || this.getLast();
76 | const node = new Node(data, previous.next);
77 | previous.next = node;
78 | }
79 |
80 | insertFirst(data) {
81 | return this.insertAt(data, 0);
82 | }
83 |
84 | insertLast(data) {
85 | // `this.size()` instead of `this.size() - 1` because we are adding a node after the current last item (hence last item `index + 1`)
86 | return this.insertAt(data, this.size());
87 | }
88 |
89 | forEach(fn) {
90 | let node = this.head;
91 | let counter = 0;
92 | while (node) {
93 | fn(node, counter);
94 | node = node.next;
95 | counter += 1;
96 | }
97 | }
98 |
99 | * [Symbol.iterator]() {
100 | let node = this.head;
101 | while (node) {
102 | yield node;
103 | node = node.next;
104 | }
105 | }
106 | }
107 |
108 | module.exports = { Node, LinkedList };
109 |
--------------------------------------------------------------------------------
/020-midpoint-linkedlist/test.js:
--------------------------------------------------------------------------------
1 | const midpoint = require('./index');
2 | const { LinkedList } = require('./linkedlist');
3 |
4 | test('Midpoint is a function', () => {
5 | expect(typeof midpoint).toEqual('function');
6 | });
7 |
8 | describe('Midpoint returns the middle node of an odd numbered list', () => {
9 | test('when the list has 3 elements', () => {
10 | const l = new LinkedList();
11 | l.insertLast('a');
12 | l.insertLast('b');
13 | l.insertLast('c');
14 | expect(midpoint(l).data).toEqual('b');
15 | });
16 |
17 | test('when the list has 5 elements', () => {
18 | const l = new LinkedList();
19 | l.insertLast('a');
20 | l.insertLast('b');
21 | l.insertLast('c');
22 | l.insertLast('d');
23 | l.insertLast('e');
24 | expect(midpoint(l).data).toEqual('c');
25 | });
26 | });
27 |
28 | describe('Midpoint returns the node at the end of the first half of an even numbered list', () => {
29 | test('when the list has 2 elements', () => {
30 | const list = new LinkedList();
31 | list.insertLast('a');
32 | list.insertLast('b');
33 | expect(midpoint(list).data).toEqual('a');
34 | });
35 |
36 | test('when the list has 4 elements', () => {
37 | const list = new LinkedList();
38 | list.insertLast('a');
39 | list.insertLast('b');
40 | list.insertLast('c');
41 | list.insertLast('d');
42 | expect(midpoint(list).data).toEqual('b');
43 | });
44 | });
45 |
--------------------------------------------------------------------------------
/021-circular-linkedlist/README.md:
--------------------------------------------------------------------------------
1 | # Circular Linked List
2 |
3 | ## Directions
4 |
5 | Given a linked list, return true if the list is circular, false if it is not.
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | const list = new LinkedList();
11 | const a = new Node('a');
12 | const b = new Node('b');
13 | const c = new Node('c');
14 | list.head = a;
15 | a.next = b;
16 | b.next = c;
17 | c.next = b;
18 | circular(list) // true
19 | ```
20 |
--------------------------------------------------------------------------------
/021-circular-linkedlist/index.js:
--------------------------------------------------------------------------------
1 | // Solution
2 | const circular = (list) => {
3 | let slowIncrement = list.getFirst();
4 | let fastIncrement = list.getFirst();
5 | while (fastIncrement.next && fastIncrement.next.next) {
6 | slowIncrement = slowIncrement.next;
7 | fastIncrement = fastIncrement.next.next;
8 | if (slowIncrement === fastIncrement) return true;
9 | }
10 | return false;
11 | };
12 |
13 | module.exports = circular;
14 |
--------------------------------------------------------------------------------
/021-circular-linkedlist/linkedlist.js:
--------------------------------------------------------------------------------
1 | // Solution
2 | class Node {
3 | constructor(data, next = null) {
4 | this.data = data;
5 | this.next = next;
6 | }
7 | }
8 |
9 | class LinkedList {
10 | constructor() {
11 | this.head = null;
12 | }
13 |
14 | size() {
15 | let counter = 0;
16 | let node = this.head;
17 | while (node) {
18 | counter += 1;
19 | node = node.next;
20 | }
21 | return counter;
22 | }
23 |
24 | clear() {
25 | this.head = null;
26 | }
27 |
28 | getAt(index) {
29 | let counter = 0;
30 | let node = this.head;
31 | while (node) {
32 | if (counter === index) return node;
33 | counter += 1;
34 | node = node.next;
35 | }
36 | return null;
37 | }
38 |
39 | getFirst() {
40 | return this.getAt(0);
41 | }
42 |
43 | getLast() {
44 | return this.getAt(this.size() - 1);
45 | }
46 |
47 | removeAt(index) {
48 | if (!this.head) return;
49 | if (index === 0) {
50 | this.head = this.head.next;
51 | return;
52 | }
53 | const previous = this.getAt(index - 1);
54 | if (!previous || !previous.next) return;
55 | previous.next = previous.next.next;
56 | }
57 |
58 | removeFirst() {
59 | return this.removeAt(0);
60 | }
61 |
62 | removeLast() {
63 | return this.removeAt(this.size() - 1);
64 | }
65 |
66 | insertAt(data, index) {
67 | if (!this.head) {
68 | this.head = new Node(data);
69 | return;
70 | }
71 | if (index === 0) {
72 | this.head = new Node(data, this.head);
73 | return;
74 | }
75 | const previous = this.getAt(index - 1) || this.getLast();
76 | const node = new Node(data, previous.next);
77 | previous.next = node;
78 | }
79 |
80 | insertFirst(data) {
81 | return this.insertAt(data, 0);
82 | }
83 |
84 | insertLast(data) {
85 | // `this.size()` instead of `this.size() - 1` because we are adding a node after the current last item (hence last item `index + 1`)
86 | return this.insertAt(data, this.size());
87 | }
88 |
89 | forEach(fn) {
90 | let node = this.head;
91 | let counter = 0;
92 | while (node) {
93 | fn(node, counter);
94 | node = node.next;
95 | counter += 1;
96 | }
97 | }
98 |
99 | * [Symbol.iterator]() {
100 | let node = this.head;
101 | while (node) {
102 | yield node;
103 | node = node.next;
104 | }
105 | }
106 | }
107 |
108 | module.exports = { Node, LinkedList };
109 |
--------------------------------------------------------------------------------
/021-circular-linkedlist/test.js:
--------------------------------------------------------------------------------
1 | const circular = require('./index');
2 | const { Node, LinkedList } = require('./linkedlist');
3 |
4 | test('circular', () => {
5 | expect(typeof circular).toEqual('function');
6 | });
7 |
8 | test('circular detects circular linked lists', () => {
9 | const list = new LinkedList();
10 | const a = new Node('a');
11 | const b = new Node('b');
12 | const c = new Node('c');
13 |
14 | list.head = a;
15 | a.next = b;
16 | b.next = c;
17 | c.next = b;
18 |
19 | expect(circular(list)).toEqual(true);
20 | });
21 |
22 | test('circular detects circular linked lists linked at the head', () => {
23 | const list = new LinkedList();
24 | const a = new Node('a');
25 | const b = new Node('b');
26 | const c = new Node('c');
27 |
28 | list.head = a;
29 | a.next = b;
30 | b.next = c;
31 | c.next = a;
32 |
33 | expect(circular(list)).toEqual(true);
34 | });
35 |
36 | test('circular detects non-circular linked lists', () => {
37 | const list = new LinkedList();
38 | const a = new Node('a');
39 | const b = new Node('b');
40 | const c = new Node('c');
41 |
42 | list.head = a;
43 | a.next = b;
44 | b.next = c;
45 | c.next = null;
46 |
47 | expect(circular(list)).toEqual(false);
48 | });
49 |
--------------------------------------------------------------------------------
/022-fromlast-linkedlist/README.md:
--------------------------------------------------------------------------------
1 | # Step Back From the Tail
2 |
3 | ## Directions
4 |
5 | Given a linked list, return the element n spaces from the last node in the list. Do not call the 'size' method of the linked list. Assume that n will always be less than the length of the list.
6 |
7 | ## Examples
8 |
9 | ```javascript
10 | const list = new List();
11 | list.insertLast('a');
12 | list.insertLast('b');
13 | list.insertLast('c');
14 | list.insertLast('d');
15 | fromLast(list, 2).data === // 'b'
16 | ```
17 |
--------------------------------------------------------------------------------
/022-fromlast-linkedlist/index.js:
--------------------------------------------------------------------------------
1 | // Solution
2 | const fromLast = (list, n) => {
3 | let slowIncrement = list.getFirst();
4 | let fastIncrement = list.getFirst();
5 | while (n > 0) {
6 | fastIncrement = fastIncrement.next;
7 | n -= 1;
8 | }
9 | while (fastIncrement.next) {
10 | slowIncrement = slowIncrement.next;
11 | fastIncrement = fastIncrement.next;
12 | }
13 | return slowIncrement;
14 | };
15 |
16 | module.exports = fromLast;
17 |
--------------------------------------------------------------------------------
/022-fromlast-linkedlist/linkedlist.js:
--------------------------------------------------------------------------------
1 | // Solution
2 | class Node {
3 | constructor(data, next = null) {
4 | this.data = data;
5 | this.next = next;
6 | }
7 | }
8 |
9 | class LinkedList {
10 | constructor() {
11 | this.head = null;
12 | }
13 |
14 | size() {
15 | let counter = 0;
16 | let node = this.head;
17 | while (node) {
18 | counter += 1;
19 | node = node.next;
20 | }
21 | return counter;
22 | }
23 |
24 | clear() {
25 | this.head = null;
26 | }
27 |
28 | getAt(index) {
29 | let counter = 0;
30 | let node = this.head;
31 | while (node) {
32 | if (counter === index) return node;
33 | counter += 1;
34 | node = node.next;
35 | }
36 | return null;
37 | }
38 |
39 | getFirst() {
40 | return this.getAt(0);
41 | }
42 |
43 | getLast() {
44 | return this.getAt(this.size() - 1);
45 | }
46 |
47 | removeAt(index) {
48 | if (!this.head) return;
49 | if (index === 0) {
50 | this.head = this.head.next;
51 | return;
52 | }
53 | const previous = this.getAt(index - 1);
54 | if (!previous || !previous.next) return;
55 | previous.next = previous.next.next;
56 | }
57 |
58 | removeFirst() {
59 | return this.removeAt(0);
60 | }
61 |
62 | removeLast() {
63 | return this.removeAt(this.size() - 1);
64 | }
65 |
66 | insertAt(data, index) {
67 | if (!this.head) {
68 | this.head = new Node(data);
69 | return;
70 | }
71 | if (index === 0) {
72 | this.head = new Node(data, this.head);
73 | return;
74 | }
75 | const previous = this.getAt(index - 1) || this.getLast();
76 | const node = new Node(data, previous.next);
77 | previous.next = node;
78 | }
79 |
80 | insertFirst(data) {
81 | return this.insertAt(data, 0);
82 | }
83 |
84 | insertLast(data) {
85 | // `this.size()` instead of `this.size() - 1` because we are adding a node after the current last item (hence last item `index + 1`)
86 | return this.insertAt(data, this.size());
87 | }
88 |
89 | forEach(fn) {
90 | let node = this.head;
91 | let counter = 0;
92 | while (node) {
93 | fn(node, counter);
94 | node = node.next;
95 | counter += 1;
96 | }
97 | }
98 |
99 | * [Symbol.iterator]() {
100 | let node = this.head;
101 | while (node) {
102 | yield node;
103 | node = node.next;
104 | }
105 | }
106 | }
107 |
108 | module.exports = { Node, LinkedList };
109 |
--------------------------------------------------------------------------------
/022-fromlast-linkedlist/test.js:
--------------------------------------------------------------------------------
1 | const fromLast = require('./index');
2 | const { LinkedList } = require('./linkedlist');
3 |
4 | test('fromLast is a function', () => {
5 | expect(typeof fromLast).toEqual('function');
6 | });
7 |
8 | test('fromLast returns the node n elements from the end', () => {
9 | const list = new LinkedList();
10 |
11 | list.insertLast('a');
12 | list.insertLast('b');
13 | list.insertLast('c');
14 | list.insertLast('d');
15 | list.insertLast('e');
16 |
17 | expect(fromLast(list, 3).data).toEqual('b');
18 | });
19 |
--------------------------------------------------------------------------------
/023-tree/README.md:
--------------------------------------------------------------------------------
1 | # Building a Tree
2 |
3 | ## Directions
4 |
5 | 1) Create a node class. The constructor should accept an argument that gets assigned to the data property and initialize an empty array for storing children. The node class should have methods 'add' and 'remove'.
6 | 2) Create a tree class. The tree constructor should initialize a 'root' property to null.
7 | 3) Implement 'traverseBF' and 'traverseDF' on the tree class. Each method should accept a function that gets called with each element in the tree.
8 |
--------------------------------------------------------------------------------
/023-tree/index.js:
--------------------------------------------------------------------------------
1 | // Solution
2 | class Node {
3 | constructor(data) {
4 | this.data = data;
5 | this.children = [];
6 | }
7 |
8 | add(data) {
9 | this.children.push(new Node(data));
10 | }
11 |
12 | remove(data) {
13 | this.children = this.children.filter((node) => node.data !== data);
14 | }
15 | }
16 |
17 | class Tree {
18 | constructor() {
19 | this.root = null;
20 | }
21 |
22 | traverseBreadthFirst(fn) {
23 | const arr = [this.root];
24 | while (arr.length) {
25 | const node = arr.shift();
26 | arr.push(...node.children);
27 | fn(node);
28 | }
29 | }
30 |
31 | traverseDepthFirst(fn) {
32 | const arr = [this.root];
33 | while (arr.length) {
34 | const node = arr.shift();
35 | arr.unshift(...node.children);
36 | fn(node);
37 | }
38 | }
39 | }
40 |
41 | module.exports = { Tree, Node };
42 |
--------------------------------------------------------------------------------
/023-tree/test.js:
--------------------------------------------------------------------------------
1 | const { Node, Tree } = require('./index');
2 |
3 | describe('Node', () => {
4 | test('Node is a constructor', () => {
5 | expect(typeof Node.prototype.constructor).toEqual('function');
6 | });
7 |
8 | test('Node has a data and children properties', () => {
9 | const n = new Node('a');
10 | expect(n.data).toEqual('a');
11 | expect(n.children.length).toEqual(0);
12 | });
13 |
14 | test('Node can add children', () => {
15 | const n = new Node('a');
16 | n.add('b');
17 | expect(n.children.length).toEqual(1);
18 | expect(n.children[0].children).toEqual([]);
19 | });
20 |
21 | test('Node can remove children', () => {
22 | const n = new Node('a');
23 | n.add('b');
24 | expect(n.children.length).toEqual(1);
25 | n.remove('b');
26 | expect(n.children.length).toEqual(0);
27 | });
28 | });
29 |
30 | describe('Tree', () => {
31 | test('starts empty', () => {
32 | const t = new Tree();
33 | expect(t.root).toEqual(null);
34 | });
35 |
36 | test('Can traverse BreadthFirst', () => {
37 | const letters = [];
38 | const t = new Tree();
39 | t.root = new Node('a');
40 | t.root.add('b');
41 | t.root.add('c');
42 | t.root.children[0].add('d');
43 |
44 | t.traverseBreadthFirst((node) => {
45 | letters.push(node.data);
46 | });
47 |
48 | expect(letters).toEqual(['a', 'b', 'c', 'd']);
49 | });
50 |
51 | test('Can traverse DepthFirst', () => {
52 | const letters = [];
53 | const t = new Tree();
54 | t.root = new Node('a');
55 | t.root.add('b');
56 | t.root.add('c');
57 | t.root.children[0].add('d');
58 |
59 | t.traverseDepthFirst((node) => {
60 | letters.push(node.data);
61 | });
62 |
63 | expect(letters).toEqual(['a', 'b', 'd', 'c']);
64 | });
65 | });
66 |
--------------------------------------------------------------------------------
/024-levelwidth-treenode/README.md:
--------------------------------------------------------------------------------
1 | # Tree Width with Level Width
2 |
3 | ## Directions
4 |
5 | Given the root node of a tree, return an array where each element is the width of the tree at each level.
6 |
7 | ## Examples
8 |
9 | ```bash
10 | Given:
11 | 0
12 | / | \
13 | 1 2 3
14 | | |
15 | 4 5
16 |
17 | Answer: [1, 3, 2]
18 | ```
19 |
--------------------------------------------------------------------------------
/024-levelwidth-treenode/index.js:
--------------------------------------------------------------------------------
1 | // Solution
2 | const levelWidth = (root) => {
3 | const arr = [root, 'stopper']; // 'stopper' is the pointer
4 | const counters = [0];
5 | while (arr.length > 1) {
6 | const node = arr.shift();
7 | if (node === 'stopper') {
8 | counters.push(0);
9 | arr.push('stopper');
10 | } else {
11 | arr.push(...node.children);
12 | counters[counters.length - 1] += 1;
13 | }
14 | }
15 | return counters;
16 | };
17 |
18 | module.exports = levelWidth;
19 |
--------------------------------------------------------------------------------
/024-levelwidth-treenode/node.js:
--------------------------------------------------------------------------------
1 | class Node {
2 | constructor(data) {
3 | this.data = data;
4 | this.children = [];
5 | }
6 |
7 | add(data) {
8 | this.children.push(new Node(data));
9 | }
10 | }
11 |
12 | module.exports = Node;
13 |
--------------------------------------------------------------------------------
/024-levelwidth-treenode/test.js:
--------------------------------------------------------------------------------
1 | const Node = require('./node');
2 | const levelWidth = require('./index');
3 |
4 | test('levelWidth is a function', () => {
5 | expect(typeof levelWidth).toEqual('function');
6 | });
7 |
8 | test('levelWidth returns number of nodes at widest point', () => {
9 | const root = new Node(0);
10 | root.add(1);
11 | root.add(2);
12 | root.add(3);
13 | root.children[0].add(4);
14 | root.children[2].add(5);
15 |
16 | expect(levelWidth(root)).toEqual([1, 3, 2]);
17 | });
18 |
19 | test('levelWidth returns number of nodes at widest point', () => {
20 | const root = new Node(0);
21 | root.add(1);
22 | root.children[0].add(2);
23 | root.children[0].add(3);
24 | root.children[0].children[0].add(4);
25 |
26 | expect(levelWidth(root)).toEqual([1, 1, 2, 1]);
27 | });
28 |
--------------------------------------------------------------------------------
/025-binary-search-trees/README.md:
--------------------------------------------------------------------------------
1 | # Binary Search Trees
2 |
3 | ## Directions
4 |
5 | 1) Implement the Node class to create a binary search tree. The constructor should initialize values 'data', 'left', and 'right'.
6 | 2) Implement the 'insert' method for the Node class. Insert should accept an argument 'data', then create an insert a new node at the appropriate location in the tree.
7 | 3) Implement the 'contains' method for the Node class. Contains should accept a 'data' argument and return the Node in the tree with the same value.
8 |
--------------------------------------------------------------------------------
/025-binary-search-trees/index.js:
--------------------------------------------------------------------------------
1 | // Solution
2 | class Node {
3 | constructor(data) {
4 | this.data = data;
5 | this.left = null;
6 | this.right = null;
7 | }
8 |
9 | insert(data) {
10 | if (data < this.data && this.left) this.left.insert(data);
11 | else if (data > this.data && this.right) this.right.insert(data);
12 | else if (data < this.data) this.left = new Node(data);
13 | else if (data > this.data) this.right = new Node(data);
14 | }
15 |
16 | contains(data) {
17 | if (this.data === data) return this;
18 | if (this.data < data && this.right) return this.right.contains(data);
19 | if (this.data > data && this.left) return this.left.contains(data);
20 | return null;
21 | }
22 | }
23 |
24 | module.exports = Node;
25 |
--------------------------------------------------------------------------------
/025-binary-search-trees/test.js:
--------------------------------------------------------------------------------
1 | const Node = require('./index');
2 |
3 | test('Node is a constructor', () => {
4 | expect(typeof Node.prototype.constructor).toEqual('function');
5 | });
6 |
7 | test('Node can insert correctly', () => {
8 | const node = new Node(10);
9 | node.insert(5);
10 | node.insert(15);
11 | node.insert(17);
12 |
13 | expect(node.left.data).toEqual(5);
14 | expect(node.right.data).toEqual(15);
15 | expect(node.right.right.data).toEqual(17);
16 | });
17 |
18 | test('Contains returns node with the same data', () => {
19 | const node = new Node(10);
20 | node.insert(5);
21 | node.insert(15);
22 | node.insert(20);
23 | node.insert(0);
24 | node.insert(-5);
25 | node.insert(3);
26 |
27 | const three = node.left.left.right;
28 | expect(node.contains(3)).toEqual(three);
29 | });
30 |
31 | test('Contains returns null if value not found', () => {
32 | const node = new Node(10);
33 | node.insert(5);
34 | node.insert(15);
35 | node.insert(20);
36 | node.insert(0);
37 | node.insert(-5);
38 | node.insert(3);
39 |
40 | expect(node.contains(9999)).toEqual(null);
41 | });
42 |
--------------------------------------------------------------------------------
/026-validate-bst/README.md:
--------------------------------------------------------------------------------
1 | # Validating a Binary Search Tree
2 |
3 | ## Directions
4 |
5 | Given a node, validate the binary search tree, ensuring that every node's left hand child is less than the parent node's value, and that every node's right hand child is greater than the parent.
6 |
--------------------------------------------------------------------------------
/026-validate-bst/index.js:
--------------------------------------------------------------------------------
1 | // Solution
2 |
3 | const validate = (node, min = null, max = null) => {
4 | if (max !== null && node.data > max) return false;
5 | if (min !== null && node.data < min) return false;
6 | if (node.left && !validate(node.left, min, node.data)) return false;
7 | if (node.right && !validate(node.right, node.data, max)) return false;
8 | return true;
9 | };
10 |
11 | module.exports = validate;
12 |
--------------------------------------------------------------------------------
/026-validate-bst/node.js:
--------------------------------------------------------------------------------
1 | class Node {
2 | constructor(data) {
3 | this.data = data;
4 | this.left = null;
5 | this.right = null;
6 | }
7 |
8 | insert(data) {
9 | if (data < this.data && this.left) this.left.insert(data);
10 | else if (data > this.data && this.right) this.right.insert(data);
11 | else if (data < this.data) this.left = new Node(data);
12 | else if (data > this.data) this.right = new Node(data);
13 | }
14 |
15 | contains(data) {
16 | if (this.data === data) return this;
17 | if (this.data < data && this.right) return this.right.contains(data);
18 | if (this.data > data && this.left) return this.left.contains(data);
19 | return null;
20 | }
21 | }
22 |
23 | module.exports = Node;
24 |
--------------------------------------------------------------------------------
/026-validate-bst/test.js:
--------------------------------------------------------------------------------
1 | const Node = require('./node');
2 | const validate = require('./index');
3 |
4 | test('Validate recognizes a valid BST', () => {
5 | const n = new Node(10);
6 | n.insert(5);
7 | n.insert(15);
8 | n.insert(0);
9 | n.insert(20);
10 |
11 | expect(validate(n)).toEqual(true);
12 | });
13 |
14 | test('Validate recognizes an invalid BST', () => {
15 | const n = new Node(10);
16 | n.insert(5);
17 | n.insert(15);
18 | n.insert(0);
19 | n.insert(20);
20 | n.left.left.right = new Node(999);
21 |
22 | expect(validate(n)).toEqual(false);
23 | });
24 |
--------------------------------------------------------------------------------
/027-events-library/README.md:
--------------------------------------------------------------------------------
1 | # Create a Events Library!
2 |
3 | ## Directions
4 |
5 | Create an 'eventing' library out of the Events class. See `jquery-example.html` for demo. The Events class should have these methods below:
6 |
7 | **on**: Register an event handler
8 | **trigger**: Trigger all callbacks associated with a given eventName
9 | **off**: Remove all event handlers associated with the given eventName
10 |
--------------------------------------------------------------------------------
/027-events-library/index.js:
--------------------------------------------------------------------------------
1 | // Solution
2 | class Events {
3 | constructor() {
4 | this.events = {};
5 | }
6 |
7 | on(eventName, callback) {
8 | if (this.events[eventName]) this.events[eventName].push(callback);
9 | else this.events[eventName] = [callback];
10 | }
11 |
12 | trigger(eventName) {
13 | if (this.events[eventName]) for (let cb of this.events[eventName]) cb();
14 | }
15 |
16 | off(eventName) {
17 | delete this.events[eventName];
18 | }
19 | }
20 |
21 | module.exports = Events;
22 |
--------------------------------------------------------------------------------
/027-events-library/jquery-example.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 |
Click the button
11 |
12 |
16 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/027-events-library/test.js:
--------------------------------------------------------------------------------
1 | const Events = require('./index');
2 |
3 | test('Events can be registered then triggered', () => {
4 | const events = new Events();
5 |
6 | const cb1 = jest.fn();
7 |
8 | events.on('click', cb1);
9 | events.trigger('click');
10 |
11 | expect(cb1.mock.calls.length).toBe(1);
12 | });
13 |
14 | test('Multiple events can be registered then triggered', () => {
15 | const events = new Events();
16 |
17 | const cb1 = jest.fn();
18 | const cb2 = jest.fn();
19 |
20 | events.on('click', cb1);
21 | events.on('click', cb2);
22 | events.trigger('click');
23 |
24 | expect(cb1.mock.calls.length).toBe(1);
25 | expect(cb2.mock.calls.length).toBe(1);
26 | });
27 |
28 | test('Events can be triggered multiple times', () => {
29 | const events = new Events();
30 |
31 | const cb1 = jest.fn();
32 | const cb2 = jest.fn();
33 |
34 | events.on('click', cb1);
35 | events.trigger('click');
36 | events.on('click', cb2);
37 | events.trigger('click');
38 | events.trigger('click');
39 |
40 | expect(cb1.mock.calls.length).toBe(3);
41 | expect(cb2.mock.calls.length).toBe(2);
42 | });
43 |
44 | test('Events can have different names', () => {
45 | const events = new Events();
46 |
47 | const cb1 = jest.fn();
48 | const cb2 = jest.fn();
49 |
50 | events.on('click', cb1);
51 | events.trigger('click');
52 | events.on('hover', cb2);
53 | events.trigger('click');
54 | events.trigger('hover');
55 |
56 | expect(cb1.mock.calls.length).toBe(2);
57 | expect(cb2.mock.calls.length).toBe(1);
58 | });
59 |
60 | test('Events can be toggled off', () => {
61 | const events = new Events();
62 |
63 | const cb1 = jest.fn();
64 | const cb2 = jest.fn();
65 |
66 | events.on('hover', cb2);
67 |
68 | events.on('click', cb1);
69 | events.trigger('click');
70 | events.off('click');
71 | events.trigger('click');
72 |
73 | events.trigger('hover');
74 |
75 | expect(cb1.mock.calls.length).toBe(1);
76 | expect(cb2.mock.calls.length).toBe(1);
77 | });
78 |
--------------------------------------------------------------------------------
/028-sorting/README.md:
--------------------------------------------------------------------------------
1 | # Sorting
2 |
3 | ## Directions
4 |
5 | Implement bubbleSort, selectionSort, and mergeSort
6 |
--------------------------------------------------------------------------------
/028-sorting/index.js:
--------------------------------------------------------------------------------
1 | // Solutions
2 | const bubbleSort = (arr) => {
3 | for (let i = 0; i < arr.length; i += 1) {
4 | for (let j = 0; j < (arr.length - i - 1); j += 1) {
5 | if (arr[j] > arr[j + 1]) [arr[j], arr[j + 1]] = [arr[j + 1], arr[j]];
6 | }
7 | }
8 | return arr;
9 | };
10 |
11 | const selectionSort = (arr) => {
12 | for (let i = 0; i < arr.length; i += 1) {
13 | let indexOfMin = i;
14 | for (let j = i + 1; j < arr.length; j += 1) if (arr[j] < arr[indexOfMin]) indexOfMin = j;
15 | if (indexOfMin !== i) [arr[i], arr[indexOfMin]] = [arr[indexOfMin], arr[i]];
16 | }
17 | return arr;
18 | };
19 |
20 | const merge = (left, right) => {
21 | const results = [];
22 | while (left.length && right.length) (left[0] < right[0]) ? results.push(left.shift()) : results.push(right.shift());
23 | return [...results, ...left, ...right];
24 | };
25 |
26 | const mergeSort = (arr) => {
27 | if (arr.length === 1) return arr;
28 | const centerPoint = Math.floor(arr.length / 2);
29 | return merge(mergeSort(arr.slice(0, centerPoint)), mergeSort(arr.slice(centerPoint)));
30 | };
31 |
32 | module.exports = {
33 | bubbleSort,
34 | selectionSort,
35 | merge,
36 | mergeSort,
37 | };
38 |
--------------------------------------------------------------------------------
/028-sorting/test.js:
--------------------------------------------------------------------------------
1 | const {
2 | bubbleSort,
3 | selectionSort,
4 | merge,
5 | mergeSort,
6 | } = require('./index');
7 |
8 | function getArray() {
9 | return [100, -40, 500, -124, 0, 21, 7];
10 | }
11 |
12 | function getSortedArray() {
13 | return [-124, -40, 0, 7, 21, 100, 500];
14 | }
15 |
16 | describe('Bubble sort', () => {
17 | test('sorts an array', () => {
18 | expect(bubbleSort(getArray())).toEqual(getSortedArray());
19 | });
20 | });
21 |
22 | describe('Selection sort', () => {
23 | test('sorts an array', () => {
24 | expect(selectionSort(getArray())).toEqual(getSortedArray());
25 | });
26 | });
27 |
28 | describe('Merge sort', () => {
29 | test('merge function can join together two sorted arrays', () => {
30 | const left = [1, 10];
31 | const right = [2, 8, 12];
32 |
33 | expect(merge(left, right)).toEqual([1, 2, 8, 10, 12]);
34 | });
35 |
36 | test('sorts an array', () => {
37 | expect(mergeSort(getArray())).toEqual(getSortedArray());
38 | });
39 | });
40 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Algorithms & Data Structures in JavaScript.
2 |
3 | This repository has been made while learning [from this tutorial](https://www.udemy.com/coding-interview-bootcamp-algorithms-and-data-structure/) by [Stephen Grider](https://twitter.com/ste_grider).
4 |
5 | That being said, I am planning to update the project with some more questions soon. Check back soon!
6 |
7 | This repository started its origin as a fork from [this repository's starter boilerplate](https://github.com/StephenGrider/AlgoCasts/tree/master/exercises). That being said, the solution code is all written by me while learning from tutorial with my [preferred coding style](./.eslintrc.js).
8 |
9 | **License Concerns:** The starting forked code has a GNU License [see here](https://github.com/StephenGrider/AlgoCasts/blob/master/LICENSE) and same is the case with [this repository](https://github.com/IamManchanda/algorithms-javascript/blob/master/LICENSE). So there is no Plagiarism concerns anyways. Feel free to fork, only thing you shouldn't do is make your own course out of it as mentioned [here](https://github.com/StephenGrider/AlgoCasts/issues/33#issuecomment-421508234) by Stephen Grider.
10 |
11 | ## Where are Questions and their respective Answers? What about Tests?
12 |
13 | - **Question:** All folders have specific `README.md` where respective question has been asked.
14 | - **Answers:** All folders have specific `index.js` where respective answer has been solved.
15 | - **Tests:** All folders have specific `test.js` which contains respective test file. Use Jest for same as mentioned below.
16 |
17 | ## Test with Jest
18 |
19 | Step1: Install Jest
20 |
21 | ```bash
22 | npm install -g jest
23 | ```
24 |
25 | Step2: Run Jest into the targeted test such as
26 |
27 | ```bash
28 | jest 007-anagrams/test.js --watch
29 | ```
30 |
--------------------------------------------------------------------------------
/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | verbose: true,
3 | testURL: 'http://localhost/',
4 | };
5 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "algorithms-javascript",
3 | "version": "1.0.0",
4 | "description": "Algorithms & Data Structures in JavaScript!",
5 | "main": "index.js",
6 | "repository": "git@github.com:IamManchanda/algorithms-javascript.git",
7 | "author": "Harry Manchanda ",
8 | "license": "MIT",
9 | "dependencies": {
10 | "eslint": "^5.0.1",
11 | "eslint-config-airbnb-base": "^13.0.0",
12 | "eslint-plugin-import": "^2.13.0",
13 | "lodash": "^4.17.10"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/yarn.lock:
--------------------------------------------------------------------------------
1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2 | # yarn lockfile v1
3 |
4 |
5 | acorn-jsx@^4.1.1:
6 | version "4.1.1"
7 | resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-4.1.1.tgz#e8e41e48ea2fe0c896740610ab6a4ffd8add225e"
8 | dependencies:
9 | acorn "^5.0.3"
10 |
11 | acorn@^5.0.3, acorn@^5.6.0:
12 | version "5.7.1"
13 | resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.1.tgz#f095829297706a7c9776958c0afc8930a9b9d9d8"
14 |
15 | ajv-keywords@^3.0.0:
16 | version "3.2.0"
17 | resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.2.0.tgz#e86b819c602cf8821ad637413698f1dec021847a"
18 |
19 | ajv@^6.0.1, ajv@^6.5.0:
20 | version "6.5.2"
21 | resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.5.2.tgz#678495f9b82f7cca6be248dd92f59bff5e1f4360"
22 | dependencies:
23 | fast-deep-equal "^2.0.1"
24 | fast-json-stable-stringify "^2.0.0"
25 | json-schema-traverse "^0.4.1"
26 | uri-js "^4.2.1"
27 |
28 | ansi-escapes@^3.0.0:
29 | version "3.1.0"
30 | resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.1.0.tgz#f73207bb81207d75fd6c83f125af26eea378ca30"
31 |
32 | ansi-regex@^2.0.0:
33 | version "2.1.1"
34 | resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
35 |
36 | ansi-regex@^3.0.0:
37 | version "3.0.0"
38 | resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998"
39 |
40 | ansi-styles@^2.2.1:
41 | version "2.2.1"
42 | resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
43 |
44 | ansi-styles@^3.2.1:
45 | version "3.2.1"
46 | resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
47 | dependencies:
48 | color-convert "^1.9.0"
49 |
50 | argparse@^1.0.7:
51 | version "1.0.10"
52 | resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
53 | dependencies:
54 | sprintf-js "~1.0.2"
55 |
56 | array-union@^1.0.1:
57 | version "1.0.2"
58 | resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39"
59 | dependencies:
60 | array-uniq "^1.0.1"
61 |
62 | array-uniq@^1.0.1:
63 | version "1.0.3"
64 | resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6"
65 |
66 | arrify@^1.0.0:
67 | version "1.0.1"
68 | resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d"
69 |
70 | babel-code-frame@^6.26.0:
71 | version "6.26.0"
72 | resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"
73 | dependencies:
74 | chalk "^1.1.3"
75 | esutils "^2.0.2"
76 | js-tokens "^3.0.2"
77 |
78 | balanced-match@^1.0.0:
79 | version "1.0.0"
80 | resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
81 |
82 | brace-expansion@^1.1.7:
83 | version "1.1.11"
84 | resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
85 | dependencies:
86 | balanced-match "^1.0.0"
87 | concat-map "0.0.1"
88 |
89 | builtin-modules@^1.0.0:
90 | version "1.1.1"
91 | resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
92 |
93 | caller-path@^0.1.0:
94 | version "0.1.0"
95 | resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f"
96 | dependencies:
97 | callsites "^0.2.0"
98 |
99 | callsites@^0.2.0:
100 | version "0.2.0"
101 | resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca"
102 |
103 | chalk@^1.1.3:
104 | version "1.1.3"
105 | resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
106 | dependencies:
107 | ansi-styles "^2.2.1"
108 | escape-string-regexp "^1.0.2"
109 | has-ansi "^2.0.0"
110 | strip-ansi "^3.0.0"
111 | supports-color "^2.0.0"
112 |
113 | chalk@^2.0.0, chalk@^2.1.0:
114 | version "2.4.1"
115 | resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e"
116 | dependencies:
117 | ansi-styles "^3.2.1"
118 | escape-string-regexp "^1.0.5"
119 | supports-color "^5.3.0"
120 |
121 | chardet@^0.4.0:
122 | version "0.4.2"
123 | resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2"
124 |
125 | circular-json@^0.3.1:
126 | version "0.3.3"
127 | resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66"
128 |
129 | cli-cursor@^2.1.0:
130 | version "2.1.0"
131 | resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5"
132 | dependencies:
133 | restore-cursor "^2.0.0"
134 |
135 | cli-width@^2.0.0:
136 | version "2.2.0"
137 | resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
138 |
139 | color-convert@^1.9.0:
140 | version "1.9.2"
141 | resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.2.tgz#49881b8fba67df12a96bdf3f56c0aab9e7913147"
142 | dependencies:
143 | color-name "1.1.1"
144 |
145 | color-name@1.1.1:
146 | version "1.1.1"
147 | resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.1.tgz#4b1415304cf50028ea81643643bd82ea05803689"
148 |
149 | concat-map@0.0.1:
150 | version "0.0.1"
151 | resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
152 |
153 | contains-path@^0.1.0:
154 | version "0.1.0"
155 | resolved "https://registry.yarnpkg.com/contains-path/-/contains-path-0.1.0.tgz#fe8cf184ff6670b6baef01a9d4861a5cbec4120a"
156 |
157 | cross-spawn@^6.0.5:
158 | version "6.0.5"
159 | resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
160 | dependencies:
161 | nice-try "^1.0.4"
162 | path-key "^2.0.1"
163 | semver "^5.5.0"
164 | shebang-command "^1.2.0"
165 | which "^1.2.9"
166 |
167 | debug@^2.6.8, debug@^2.6.9:
168 | version "2.6.9"
169 | resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
170 | dependencies:
171 | ms "2.0.0"
172 |
173 | debug@^3.1.0:
174 | version "3.1.0"
175 | resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
176 | dependencies:
177 | ms "2.0.0"
178 |
179 | deep-is@~0.1.3:
180 | version "0.1.3"
181 | resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
182 |
183 | define-properties@^1.1.2:
184 | version "1.1.2"
185 | resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
186 | dependencies:
187 | foreach "^2.0.5"
188 | object-keys "^1.0.8"
189 |
190 | del@^2.0.2:
191 | version "2.2.2"
192 | resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8"
193 | dependencies:
194 | globby "^5.0.0"
195 | is-path-cwd "^1.0.0"
196 | is-path-in-cwd "^1.0.0"
197 | object-assign "^4.0.1"
198 | pify "^2.0.0"
199 | pinkie-promise "^2.0.0"
200 | rimraf "^2.2.8"
201 |
202 | doctrine@1.5.0:
203 | version "1.5.0"
204 | resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa"
205 | dependencies:
206 | esutils "^2.0.2"
207 | isarray "^1.0.0"
208 |
209 | doctrine@^2.1.0:
210 | version "2.1.0"
211 | resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d"
212 | dependencies:
213 | esutils "^2.0.2"
214 |
215 | error-ex@^1.2.0:
216 | version "1.3.2"
217 | resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf"
218 | dependencies:
219 | is-arrayish "^0.2.1"
220 |
221 | es-abstract@^1.10.0, es-abstract@^1.6.1:
222 | version "1.12.0"
223 | resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.12.0.tgz#9dbbdd27c6856f0001421ca18782d786bf8a6165"
224 | dependencies:
225 | es-to-primitive "^1.1.1"
226 | function-bind "^1.1.1"
227 | has "^1.0.1"
228 | is-callable "^1.1.3"
229 | is-regex "^1.0.4"
230 |
231 | es-to-primitive@^1.1.1:
232 | version "1.1.1"
233 | resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d"
234 | dependencies:
235 | is-callable "^1.1.1"
236 | is-date-object "^1.0.1"
237 | is-symbol "^1.0.1"
238 |
239 | escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
240 | version "1.0.5"
241 | resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
242 |
243 | eslint-config-airbnb-base@^13.0.0:
244 | version "13.0.0"
245 | resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-13.0.0.tgz#2ee6279c4891128e49d6445b24aa13c2d1a21450"
246 | dependencies:
247 | eslint-restricted-globals "^0.1.1"
248 | object.assign "^4.1.0"
249 | object.entries "^1.0.4"
250 |
251 | eslint-import-resolver-node@^0.3.1:
252 | version "0.3.2"
253 | resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz#58f15fb839b8d0576ca980413476aab2472db66a"
254 | dependencies:
255 | debug "^2.6.9"
256 | resolve "^1.5.0"
257 |
258 | eslint-module-utils@^2.2.0:
259 | version "2.2.0"
260 | resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.2.0.tgz#b270362cd88b1a48ad308976ce7fa54e98411746"
261 | dependencies:
262 | debug "^2.6.8"
263 | pkg-dir "^1.0.0"
264 |
265 | eslint-plugin-import@^2.13.0:
266 | version "2.13.0"
267 | resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.13.0.tgz#df24f241175e312d91662dc91ca84064caec14ed"
268 | dependencies:
269 | contains-path "^0.1.0"
270 | debug "^2.6.8"
271 | doctrine "1.5.0"
272 | eslint-import-resolver-node "^0.3.1"
273 | eslint-module-utils "^2.2.0"
274 | has "^1.0.1"
275 | lodash "^4.17.4"
276 | minimatch "^3.0.3"
277 | read-pkg-up "^2.0.0"
278 | resolve "^1.6.0"
279 |
280 | eslint-restricted-globals@^0.1.1:
281 | version "0.1.1"
282 | resolved "https://registry.yarnpkg.com/eslint-restricted-globals/-/eslint-restricted-globals-0.1.1.tgz#35f0d5cbc64c2e3ed62e93b4b1a7af05ba7ed4d7"
283 |
284 | eslint-scope@^4.0.0:
285 | version "4.0.0"
286 | resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.0.tgz#50bf3071e9338bcdc43331794a0cb533f0136172"
287 | dependencies:
288 | esrecurse "^4.1.0"
289 | estraverse "^4.1.1"
290 |
291 | eslint-visitor-keys@^1.0.0:
292 | version "1.0.0"
293 | resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d"
294 |
295 | eslint@^5.0.1:
296 | version "5.0.1"
297 | resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.0.1.tgz#109b90ab7f7a736f54e0f341c8bb9d09777494c3"
298 | dependencies:
299 | ajv "^6.5.0"
300 | babel-code-frame "^6.26.0"
301 | chalk "^2.1.0"
302 | cross-spawn "^6.0.5"
303 | debug "^3.1.0"
304 | doctrine "^2.1.0"
305 | eslint-scope "^4.0.0"
306 | eslint-visitor-keys "^1.0.0"
307 | espree "^4.0.0"
308 | esquery "^1.0.1"
309 | esutils "^2.0.2"
310 | file-entry-cache "^2.0.0"
311 | functional-red-black-tree "^1.0.1"
312 | glob "^7.1.2"
313 | globals "^11.5.0"
314 | ignore "^3.3.3"
315 | imurmurhash "^0.1.4"
316 | inquirer "^5.2.0"
317 | is-resolvable "^1.1.0"
318 | js-yaml "^3.11.0"
319 | json-stable-stringify-without-jsonify "^1.0.1"
320 | levn "^0.3.0"
321 | lodash "^4.17.5"
322 | minimatch "^3.0.4"
323 | mkdirp "^0.5.1"
324 | natural-compare "^1.4.0"
325 | optionator "^0.8.2"
326 | path-is-inside "^1.0.2"
327 | pluralize "^7.0.0"
328 | progress "^2.0.0"
329 | regexpp "^1.1.0"
330 | require-uncached "^1.0.3"
331 | semver "^5.5.0"
332 | string.prototype.matchall "^2.0.0"
333 | strip-ansi "^4.0.0"
334 | strip-json-comments "^2.0.1"
335 | table "^4.0.3"
336 | text-table "^0.2.0"
337 |
338 | espree@^4.0.0:
339 | version "4.0.0"
340 | resolved "https://registry.yarnpkg.com/espree/-/espree-4.0.0.tgz#253998f20a0f82db5d866385799d912a83a36634"
341 | dependencies:
342 | acorn "^5.6.0"
343 | acorn-jsx "^4.1.1"
344 |
345 | esprima@^4.0.0:
346 | version "4.0.0"
347 | resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804"
348 |
349 | esquery@^1.0.1:
350 | version "1.0.1"
351 | resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.1.tgz#406c51658b1f5991a5f9b62b1dc25b00e3e5c708"
352 | dependencies:
353 | estraverse "^4.0.0"
354 |
355 | esrecurse@^4.1.0:
356 | version "4.2.1"
357 | resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.1.tgz#007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf"
358 | dependencies:
359 | estraverse "^4.1.0"
360 |
361 | estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1:
362 | version "4.2.0"
363 | resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13"
364 |
365 | esutils@^2.0.2:
366 | version "2.0.2"
367 | resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b"
368 |
369 | external-editor@^2.1.0:
370 | version "2.2.0"
371 | resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.2.0.tgz#045511cfd8d133f3846673d1047c154e214ad3d5"
372 | dependencies:
373 | chardet "^0.4.0"
374 | iconv-lite "^0.4.17"
375 | tmp "^0.0.33"
376 |
377 | fast-deep-equal@^2.0.1:
378 | version "2.0.1"
379 | resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49"
380 |
381 | fast-json-stable-stringify@^2.0.0:
382 | version "2.0.0"
383 | resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2"
384 |
385 | fast-levenshtein@~2.0.4:
386 | version "2.0.6"
387 | resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
388 |
389 | figures@^2.0.0:
390 | version "2.0.0"
391 | resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962"
392 | dependencies:
393 | escape-string-regexp "^1.0.5"
394 |
395 | file-entry-cache@^2.0.0:
396 | version "2.0.0"
397 | resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-2.0.0.tgz#c392990c3e684783d838b8c84a45d8a048458361"
398 | dependencies:
399 | flat-cache "^1.2.1"
400 | object-assign "^4.0.1"
401 |
402 | find-up@^1.0.0:
403 | version "1.1.2"
404 | resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f"
405 | dependencies:
406 | path-exists "^2.0.0"
407 | pinkie-promise "^2.0.0"
408 |
409 | find-up@^2.0.0:
410 | version "2.1.0"
411 | resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7"
412 | dependencies:
413 | locate-path "^2.0.0"
414 |
415 | flat-cache@^1.2.1:
416 | version "1.3.0"
417 | resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.3.0.tgz#d3030b32b38154f4e3b7e9c709f490f7ef97c481"
418 | dependencies:
419 | circular-json "^0.3.1"
420 | del "^2.0.2"
421 | graceful-fs "^4.1.2"
422 | write "^0.2.1"
423 |
424 | foreach@^2.0.5:
425 | version "2.0.5"
426 | resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
427 |
428 | fs.realpath@^1.0.0:
429 | version "1.0.0"
430 | resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
431 |
432 | function-bind@^1.1.0, function-bind@^1.1.1:
433 | version "1.1.1"
434 | resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
435 |
436 | functional-red-black-tree@^1.0.1:
437 | version "1.0.1"
438 | resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"
439 |
440 | glob@^7.0.3, glob@^7.0.5, glob@^7.1.2:
441 | version "7.1.2"
442 | resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
443 | dependencies:
444 | fs.realpath "^1.0.0"
445 | inflight "^1.0.4"
446 | inherits "2"
447 | minimatch "^3.0.4"
448 | once "^1.3.0"
449 | path-is-absolute "^1.0.0"
450 |
451 | globals@^11.5.0:
452 | version "11.7.0"
453 | resolved "https://registry.yarnpkg.com/globals/-/globals-11.7.0.tgz#a583faa43055b1aca771914bf68258e2fc125673"
454 |
455 | globby@^5.0.0:
456 | version "5.0.0"
457 | resolved "https://registry.yarnpkg.com/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d"
458 | dependencies:
459 | array-union "^1.0.1"
460 | arrify "^1.0.0"
461 | glob "^7.0.3"
462 | object-assign "^4.0.1"
463 | pify "^2.0.0"
464 | pinkie-promise "^2.0.0"
465 |
466 | graceful-fs@^4.1.2:
467 | version "4.1.11"
468 | resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
469 |
470 | has-ansi@^2.0.0:
471 | version "2.0.0"
472 | resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91"
473 | dependencies:
474 | ansi-regex "^2.0.0"
475 |
476 | has-flag@^3.0.0:
477 | version "3.0.0"
478 | resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
479 |
480 | has-symbols@^1.0.0:
481 | version "1.0.0"
482 | resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44"
483 |
484 | has@^1.0.1:
485 | version "1.0.3"
486 | resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796"
487 | dependencies:
488 | function-bind "^1.1.1"
489 |
490 | hosted-git-info@^2.1.4:
491 | version "2.6.1"
492 | resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.6.1.tgz#6e4cee78b01bb849dcf93527708c69fdbee410df"
493 |
494 | iconv-lite@^0.4.17:
495 | version "0.4.23"
496 | resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.23.tgz#297871f63be507adcfbfca715d0cd0eed84e9a63"
497 | dependencies:
498 | safer-buffer ">= 2.1.2 < 3"
499 |
500 | ignore@^3.3.3:
501 | version "3.3.10"
502 | resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043"
503 |
504 | imurmurhash@^0.1.4:
505 | version "0.1.4"
506 | resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
507 |
508 | inflight@^1.0.4:
509 | version "1.0.6"
510 | resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
511 | dependencies:
512 | once "^1.3.0"
513 | wrappy "1"
514 |
515 | inherits@2:
516 | version "2.0.3"
517 | resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
518 |
519 | inquirer@^5.2.0:
520 | version "5.2.0"
521 | resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-5.2.0.tgz#db350c2b73daca77ff1243962e9f22f099685726"
522 | dependencies:
523 | ansi-escapes "^3.0.0"
524 | chalk "^2.0.0"
525 | cli-cursor "^2.1.0"
526 | cli-width "^2.0.0"
527 | external-editor "^2.1.0"
528 | figures "^2.0.0"
529 | lodash "^4.3.0"
530 | mute-stream "0.0.7"
531 | run-async "^2.2.0"
532 | rxjs "^5.5.2"
533 | string-width "^2.1.0"
534 | strip-ansi "^4.0.0"
535 | through "^2.3.6"
536 |
537 | is-arrayish@^0.2.1:
538 | version "0.2.1"
539 | resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
540 |
541 | is-builtin-module@^1.0.0:
542 | version "1.0.0"
543 | resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe"
544 | dependencies:
545 | builtin-modules "^1.0.0"
546 |
547 | is-callable@^1.1.1, is-callable@^1.1.3:
548 | version "1.1.4"
549 | resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75"
550 |
551 | is-date-object@^1.0.1:
552 | version "1.0.1"
553 | resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
554 |
555 | is-fullwidth-code-point@^2.0.0:
556 | version "2.0.0"
557 | resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"
558 |
559 | is-path-cwd@^1.0.0:
560 | version "1.0.0"
561 | resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d"
562 |
563 | is-path-in-cwd@^1.0.0:
564 | version "1.0.1"
565 | resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz#5ac48b345ef675339bd6c7a48a912110b241cf52"
566 | dependencies:
567 | is-path-inside "^1.0.0"
568 |
569 | is-path-inside@^1.0.0:
570 | version "1.0.1"
571 | resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036"
572 | dependencies:
573 | path-is-inside "^1.0.1"
574 |
575 | is-promise@^2.1.0:
576 | version "2.1.0"
577 | resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa"
578 |
579 | is-regex@^1.0.4:
580 | version "1.0.4"
581 | resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
582 | dependencies:
583 | has "^1.0.1"
584 |
585 | is-resolvable@^1.1.0:
586 | version "1.1.0"
587 | resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.1.0.tgz#fb18f87ce1feb925169c9a407c19318a3206ed88"
588 |
589 | is-symbol@^1.0.1:
590 | version "1.0.1"
591 | resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
592 |
593 | isarray@^1.0.0:
594 | version "1.0.0"
595 | resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
596 |
597 | isexe@^2.0.0:
598 | version "2.0.0"
599 | resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
600 |
601 | js-tokens@^3.0.2:
602 | version "3.0.2"
603 | resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
604 |
605 | js-yaml@^3.11.0:
606 | version "3.12.0"
607 | resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1"
608 | dependencies:
609 | argparse "^1.0.7"
610 | esprima "^4.0.0"
611 |
612 | json-schema-traverse@^0.4.1:
613 | version "0.4.1"
614 | resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
615 |
616 | json-stable-stringify-without-jsonify@^1.0.1:
617 | version "1.0.1"
618 | resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
619 |
620 | levn@^0.3.0, levn@~0.3.0:
621 | version "0.3.0"
622 | resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee"
623 | dependencies:
624 | prelude-ls "~1.1.2"
625 | type-check "~0.3.2"
626 |
627 | load-json-file@^2.0.0:
628 | version "2.0.0"
629 | resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-2.0.0.tgz#7947e42149af80d696cbf797bcaabcfe1fe29ca8"
630 | dependencies:
631 | graceful-fs "^4.1.2"
632 | parse-json "^2.2.0"
633 | pify "^2.0.0"
634 | strip-bom "^3.0.0"
635 |
636 | locate-path@^2.0.0:
637 | version "2.0.0"
638 | resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e"
639 | dependencies:
640 | p-locate "^2.0.0"
641 | path-exists "^3.0.0"
642 |
643 | lodash@^4.17.10, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0:
644 | version "4.17.10"
645 | resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"
646 |
647 | mimic-fn@^1.0.0:
648 | version "1.2.0"
649 | resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"
650 |
651 | minimatch@^3.0.3, minimatch@^3.0.4:
652 | version "3.0.4"
653 | resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
654 | dependencies:
655 | brace-expansion "^1.1.7"
656 |
657 | minimist@0.0.8:
658 | version "0.0.8"
659 | resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
660 |
661 | mkdirp@^0.5.1:
662 | version "0.5.1"
663 | resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
664 | dependencies:
665 | minimist "0.0.8"
666 |
667 | ms@2.0.0:
668 | version "2.0.0"
669 | resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
670 |
671 | mute-stream@0.0.7:
672 | version "0.0.7"
673 | resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab"
674 |
675 | natural-compare@^1.4.0:
676 | version "1.4.0"
677 | resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
678 |
679 | nice-try@^1.0.4:
680 | version "1.0.4"
681 | resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.4.tgz#d93962f6c52f2c1558c0fbda6d512819f1efe1c4"
682 |
683 | normalize-package-data@^2.3.2:
684 | version "2.4.0"
685 | resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.4.0.tgz#12f95a307d58352075a04907b84ac8be98ac012f"
686 | dependencies:
687 | hosted-git-info "^2.1.4"
688 | is-builtin-module "^1.0.0"
689 | semver "2 || 3 || 4 || 5"
690 | validate-npm-package-license "^3.0.1"
691 |
692 | object-assign@^4.0.1:
693 | version "4.1.1"
694 | resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
695 |
696 | object-keys@^1.0.11, object-keys@^1.0.8:
697 | version "1.0.12"
698 | resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.12.tgz#09c53855377575310cca62f55bb334abff7b3ed2"
699 |
700 | object.assign@^4.1.0:
701 | version "4.1.0"
702 | resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da"
703 | dependencies:
704 | define-properties "^1.1.2"
705 | function-bind "^1.1.1"
706 | has-symbols "^1.0.0"
707 | object-keys "^1.0.11"
708 |
709 | object.entries@^1.0.4:
710 | version "1.0.4"
711 | resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.0.4.tgz#1bf9a4dd2288f5b33f3a993d257661f05d161a5f"
712 | dependencies:
713 | define-properties "^1.1.2"
714 | es-abstract "^1.6.1"
715 | function-bind "^1.1.0"
716 | has "^1.0.1"
717 |
718 | once@^1.3.0:
719 | version "1.4.0"
720 | resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
721 | dependencies:
722 | wrappy "1"
723 |
724 | onetime@^2.0.0:
725 | version "2.0.1"
726 | resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4"
727 | dependencies:
728 | mimic-fn "^1.0.0"
729 |
730 | optionator@^0.8.2:
731 | version "0.8.2"
732 | resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64"
733 | dependencies:
734 | deep-is "~0.1.3"
735 | fast-levenshtein "~2.0.4"
736 | levn "~0.3.0"
737 | prelude-ls "~1.1.2"
738 | type-check "~0.3.2"
739 | wordwrap "~1.0.0"
740 |
741 | os-tmpdir@~1.0.2:
742 | version "1.0.2"
743 | resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
744 |
745 | p-limit@^1.1.0:
746 | version "1.3.0"
747 | resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8"
748 | dependencies:
749 | p-try "^1.0.0"
750 |
751 | p-locate@^2.0.0:
752 | version "2.0.0"
753 | resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43"
754 | dependencies:
755 | p-limit "^1.1.0"
756 |
757 | p-try@^1.0.0:
758 | version "1.0.0"
759 | resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3"
760 |
761 | parse-json@^2.2.0:
762 | version "2.2.0"
763 | resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9"
764 | dependencies:
765 | error-ex "^1.2.0"
766 |
767 | path-exists@^2.0.0:
768 | version "2.1.0"
769 | resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b"
770 | dependencies:
771 | pinkie-promise "^2.0.0"
772 |
773 | path-exists@^3.0.0:
774 | version "3.0.0"
775 | resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
776 |
777 | path-is-absolute@^1.0.0:
778 | version "1.0.1"
779 | resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
780 |
781 | path-is-inside@^1.0.1, path-is-inside@^1.0.2:
782 | version "1.0.2"
783 | resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53"
784 |
785 | path-key@^2.0.1:
786 | version "2.0.1"
787 | resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
788 |
789 | path-parse@^1.0.5:
790 | version "1.0.5"
791 | resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1"
792 |
793 | path-type@^2.0.0:
794 | version "2.0.0"
795 | resolved "https://registry.yarnpkg.com/path-type/-/path-type-2.0.0.tgz#f012ccb8415b7096fc2daa1054c3d72389594c73"
796 | dependencies:
797 | pify "^2.0.0"
798 |
799 | pify@^2.0.0:
800 | version "2.3.0"
801 | resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
802 |
803 | pinkie-promise@^2.0.0:
804 | version "2.0.1"
805 | resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa"
806 | dependencies:
807 | pinkie "^2.0.0"
808 |
809 | pinkie@^2.0.0:
810 | version "2.0.4"
811 | resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870"
812 |
813 | pkg-dir@^1.0.0:
814 | version "1.0.0"
815 | resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-1.0.0.tgz#7a4b508a8d5bb2d629d447056ff4e9c9314cf3d4"
816 | dependencies:
817 | find-up "^1.0.0"
818 |
819 | pluralize@^7.0.0:
820 | version "7.0.0"
821 | resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777"
822 |
823 | prelude-ls@~1.1.2:
824 | version "1.1.2"
825 | resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
826 |
827 | progress@^2.0.0:
828 | version "2.0.0"
829 | resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f"
830 |
831 | punycode@^2.1.0:
832 | version "2.1.1"
833 | resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
834 |
835 | read-pkg-up@^2.0.0:
836 | version "2.0.0"
837 | resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-2.0.0.tgz#6b72a8048984e0c41e79510fd5e9fa99b3b549be"
838 | dependencies:
839 | find-up "^2.0.0"
840 | read-pkg "^2.0.0"
841 |
842 | read-pkg@^2.0.0:
843 | version "2.0.0"
844 | resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-2.0.0.tgz#8ef1c0623c6a6db0dc6713c4bfac46332b2368f8"
845 | dependencies:
846 | load-json-file "^2.0.0"
847 | normalize-package-data "^2.3.2"
848 | path-type "^2.0.0"
849 |
850 | regexp.prototype.flags@^1.2.0:
851 | version "1.2.0"
852 | resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.2.0.tgz#6b30724e306a27833eeb171b66ac8890ba37e41c"
853 | dependencies:
854 | define-properties "^1.1.2"
855 |
856 | regexpp@^1.1.0:
857 | version "1.1.0"
858 | resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-1.1.0.tgz#0e3516dd0b7904f413d2d4193dce4618c3a689ab"
859 |
860 | require-uncached@^1.0.3:
861 | version "1.0.3"
862 | resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3"
863 | dependencies:
864 | caller-path "^0.1.0"
865 | resolve-from "^1.0.0"
866 |
867 | resolve-from@^1.0.0:
868 | version "1.0.1"
869 | resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226"
870 |
871 | resolve@^1.5.0, resolve@^1.6.0:
872 | version "1.8.1"
873 | resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26"
874 | dependencies:
875 | path-parse "^1.0.5"
876 |
877 | restore-cursor@^2.0.0:
878 | version "2.0.0"
879 | resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf"
880 | dependencies:
881 | onetime "^2.0.0"
882 | signal-exit "^3.0.2"
883 |
884 | rimraf@^2.2.8:
885 | version "2.6.2"
886 | resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"
887 | dependencies:
888 | glob "^7.0.5"
889 |
890 | run-async@^2.2.0:
891 | version "2.3.0"
892 | resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0"
893 | dependencies:
894 | is-promise "^2.1.0"
895 |
896 | rxjs@^5.5.2:
897 | version "5.5.11"
898 | resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.5.11.tgz#f733027ca43e3bec6b994473be4ab98ad43ced87"
899 | dependencies:
900 | symbol-observable "1.0.1"
901 |
902 | "safer-buffer@>= 2.1.2 < 3":
903 | version "2.1.2"
904 | resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
905 |
906 | "semver@2 || 3 || 4 || 5", semver@^5.5.0:
907 | version "5.5.0"
908 | resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"
909 |
910 | shebang-command@^1.2.0:
911 | version "1.2.0"
912 | resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
913 | dependencies:
914 | shebang-regex "^1.0.0"
915 |
916 | shebang-regex@^1.0.0:
917 | version "1.0.0"
918 | resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
919 |
920 | signal-exit@^3.0.2:
921 | version "3.0.2"
922 | resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
923 |
924 | slice-ansi@1.0.0:
925 | version "1.0.0"
926 | resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-1.0.0.tgz#044f1a49d8842ff307aad6b505ed178bd950134d"
927 | dependencies:
928 | is-fullwidth-code-point "^2.0.0"
929 |
930 | spdx-correct@^3.0.0:
931 | version "3.0.0"
932 | resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.0.0.tgz#05a5b4d7153a195bc92c3c425b69f3b2a9524c82"
933 | dependencies:
934 | spdx-expression-parse "^3.0.0"
935 | spdx-license-ids "^3.0.0"
936 |
937 | spdx-exceptions@^2.1.0:
938 | version "2.1.0"
939 | resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz#2c7ae61056c714a5b9b9b2b2af7d311ef5c78fe9"
940 |
941 | spdx-expression-parse@^3.0.0:
942 | version "3.0.0"
943 | resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz#99e119b7a5da00e05491c9fa338b7904823b41d0"
944 | dependencies:
945 | spdx-exceptions "^2.1.0"
946 | spdx-license-ids "^3.0.0"
947 |
948 | spdx-license-ids@^3.0.0:
949 | version "3.0.0"
950 | resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz#7a7cd28470cc6d3a1cfe6d66886f6bc430d3ac87"
951 |
952 | sprintf-js@~1.0.2:
953 | version "1.0.3"
954 | resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
955 |
956 | string-width@^2.1.0, string-width@^2.1.1:
957 | version "2.1.1"
958 | resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
959 | dependencies:
960 | is-fullwidth-code-point "^2.0.0"
961 | strip-ansi "^4.0.0"
962 |
963 | string.prototype.matchall@^2.0.0:
964 | version "2.0.0"
965 | resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-2.0.0.tgz#2af8fe3d2d6dc53ca2a59bd376b089c3c152b3c8"
966 | dependencies:
967 | define-properties "^1.1.2"
968 | es-abstract "^1.10.0"
969 | function-bind "^1.1.1"
970 | has-symbols "^1.0.0"
971 | regexp.prototype.flags "^1.2.0"
972 |
973 | strip-ansi@^3.0.0:
974 | version "3.0.1"
975 | resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf"
976 | dependencies:
977 | ansi-regex "^2.0.0"
978 |
979 | strip-ansi@^4.0.0:
980 | version "4.0.0"
981 | resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f"
982 | dependencies:
983 | ansi-regex "^3.0.0"
984 |
985 | strip-bom@^3.0.0:
986 | version "3.0.0"
987 | resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"
988 |
989 | strip-json-comments@^2.0.1:
990 | version "2.0.1"
991 | resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
992 |
993 | supports-color@^2.0.0:
994 | version "2.0.0"
995 | resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
996 |
997 | supports-color@^5.3.0:
998 | version "5.4.0"
999 | resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.4.0.tgz#1c6b337402c2137605efe19f10fec390f6faab54"
1000 | dependencies:
1001 | has-flag "^3.0.0"
1002 |
1003 | symbol-observable@1.0.1:
1004 | version "1.0.1"
1005 | resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.1.tgz#8340fc4702c3122df5d22288f88283f513d3fdd4"
1006 |
1007 | table@^4.0.3:
1008 | version "4.0.3"
1009 | resolved "https://registry.yarnpkg.com/table/-/table-4.0.3.tgz#00b5e2b602f1794b9acaf9ca908a76386a7813bc"
1010 | dependencies:
1011 | ajv "^6.0.1"
1012 | ajv-keywords "^3.0.0"
1013 | chalk "^2.1.0"
1014 | lodash "^4.17.4"
1015 | slice-ansi "1.0.0"
1016 | string-width "^2.1.1"
1017 |
1018 | text-table@^0.2.0:
1019 | version "0.2.0"
1020 | resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
1021 |
1022 | through@^2.3.6:
1023 | version "2.3.8"
1024 | resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
1025 |
1026 | tmp@^0.0.33:
1027 | version "0.0.33"
1028 | resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
1029 | dependencies:
1030 | os-tmpdir "~1.0.2"
1031 |
1032 | type-check@~0.3.2:
1033 | version "0.3.2"
1034 | resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72"
1035 | dependencies:
1036 | prelude-ls "~1.1.2"
1037 |
1038 | uri-js@^4.2.1:
1039 | version "4.2.2"
1040 | resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0"
1041 | dependencies:
1042 | punycode "^2.1.0"
1043 |
1044 | validate-npm-package-license@^3.0.1:
1045 | version "3.0.3"
1046 | resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz#81643bcbef1bdfecd4623793dc4648948ba98338"
1047 | dependencies:
1048 | spdx-correct "^3.0.0"
1049 | spdx-expression-parse "^3.0.0"
1050 |
1051 | which@^1.2.9:
1052 | version "1.3.1"
1053 | resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"
1054 | dependencies:
1055 | isexe "^2.0.0"
1056 |
1057 | wordwrap@~1.0.0:
1058 | version "1.0.0"
1059 | resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
1060 |
1061 | wrappy@1:
1062 | version "1.0.2"
1063 | resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
1064 |
1065 | write@^0.2.1:
1066 | version "0.2.1"
1067 | resolved "https://registry.yarnpkg.com/write/-/write-0.2.1.tgz#5fc03828e264cea3fe91455476f7a3c566cb0757"
1068 | dependencies:
1069 | mkdirp "^0.5.1"
1070 |
--------------------------------------------------------------------------------