From 84321d0b752e5bda859bd7edb579d9a5f088928a Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Mon, 26 Nov 2012 20:07:29 +0200 Subject: [PATCH 001/613] Heapsort, mergesort and quicksort are added. --- src/sorting/heapsort.js | 42 ++++++++++++++++++++ src/sorting/merge-sort.js | 59 ----------------------------- src/sorting/mergesort.js | 80 +++++++++++++++++++++++++++++++++++++++ src/sorting/quicksort.js | 37 ++++++++++++++++++ 4 files changed, 159 insertions(+), 59 deletions(-) create mode 100644 src/sorting/heapsort.js delete mode 100644 src/sorting/merge-sort.js create mode 100644 src/sorting/mergesort.js create mode 100644 src/sorting/quicksort.js diff --git a/src/sorting/heapsort.js b/src/sorting/heapsort.js new file mode 100644 index 00000000..85950a8a --- /dev/null +++ b/src/sorting/heapsort.js @@ -0,0 +1,42 @@ +var heapSort = (function () { + function heapify(array, index, heapSize) { + var left = 2 * index + 1, + right = 2 * index + 2, + largest = index; + + if (left < heapSize && array[left] > array[index]) + largest = left; + + if (right < heapSize && array[right] > array[largest]) + largest = right; + + if (largest !== index) { + var temp = array[index]; + array[index] = array[largest]; + array[largest] = temp; + heapify(array, largest, heapSize); + } + } + + function buildMaxHeap(array) { + for (var i = Math.floor(array.length / 2); i >= 0; i -= 1) { + heapify(array, i, array.length); + } + return array; + } + + return function (array) { + var size = array.length, + temp; + buildMaxHeap(array); + for (var i = array.length - 1; i > 0; i -= 1) { + temp = array[0]; + array[0] = array[i]; + array[i] = temp; + size -= 1; + heapify(array, 0, size); + } + return array; + }; +}()); + diff --git a/src/sorting/merge-sort.js b/src/sorting/merge-sort.js deleted file mode 100644 index 54da8ce0..00000000 --- a/src/sorting/merge-sort.js +++ /dev/null @@ -1,59 +0,0 @@ -var array0 = [3,5,7,4,3,2,6,8,9,0]; -var array1 = [3,5,7,4,3,2,6,8,9,0]; - -function mergeSort(array) { - return merger(array, 0, array.length); -} - -function merger(array, start, end) { - if (Math.abs(end - start) <= 1) { - return []; - } - var middle = Math.ceil((start + end) / 2); - - merger(array, start, middle); - merger(array, middle, end); - - return merge(array, start, middle, end); -} - -function merge(array, start, middle, end) { - var left = [], - right = [], - leftSize = middle - start, - rightSize = end - middle, - maxSize = Math.max(leftSize, rightSize), - size = end - start, - i; - - for (i = 0; i < maxSize; i += 1) { - if (i < leftSize) { - left[i] = array[start + i]; - } - if (i < rightSize) { - right[i] = array[middle + i]; - } - } - i = 0; - while (i < size) { - if (left.length && right.length) { - if (left[0] >= right[0]) { - array[start + i] = right.shift(); - } else { - array[start + i] = left.shift(); - } - } else if (left.length) { - array[start + i] = left.shift(); - } else { - array[start + i] = right.shift(); - } - i += 1; - } - return array; -} - - -console.log(mergeSort(array0)); -console.log(array1.sort(function (a, b) { - return a - b; -})); diff --git a/src/sorting/mergesort.js b/src/sorting/mergesort.js new file mode 100644 index 00000000..bf64a970 --- /dev/null +++ b/src/sorting/mergesort.js @@ -0,0 +1,80 @@ + +var mergeSort = (function () { + /** + * Mergesort method which is recursively called for sorting the input array. + * + * @private + * @param {array} array The array which should be sorted + * @param {number} start Left side of the subarray + * @param {number} end Right side of the subarray + * @returns {array} Array with sorted subarray + */ + function mergesort(array, start, end) { + if (Math.abs(end - start) <= 1) { + return []; + } + var middle = Math.ceil((start + end) / 2); + + mergesort(array, start, middle); + mergesort(array, middle, end); + + return merge(array, start, middle, end); + } + + /** + * Devides and sort merges two subarrays of given array + * + * @private + * @param {array} array The array which subarrays should be sorted + * @param {number} start The start of the first subarray. This subarray is with end middle - 1. + * @param {number} middle The start of the second array + * @param {number} end end - 1 is the end of the second array + * @returns {array} The array with sorted subarray + */ + function merge(array, start, middle, end) { + var left = [], + right = [], + leftSize = middle - start, + rightSize = end - middle, + maxSize = Math.max(leftSize, rightSize), + size = end - start, + i; + + for (i = 0; i < maxSize; i += 1) { + if (i < leftSize) { + left[i] = array[start + i]; + } + if (i < rightSize) { + right[i] = array[middle + i]; + } + } + i = 0; + while (i < size) { + if (left.length && right.length) { + if (left[0] >= right[0]) { + array[start + i] = right.shift(); + } else { + array[start + i] = left.shift(); + } + } else if (left.length) { + array[start + i] = left.shift(); + } else { + array[start + i] = right.shift(); + } + i += 1; + } + return array; + } + + /** + * Initial call to the mergesort method + * + * @public + * @param {array} array The array which will be sorted + * @returns {array} Sorted array + */ + return function (array) { + return mergesort(array, 0, array.length); + } + +}()); diff --git a/src/sorting/quicksort.js b/src/sorting/quicksort.js new file mode 100644 index 00000000..b890ffdd --- /dev/null +++ b/src/sorting/quicksort.js @@ -0,0 +1,37 @@ +var quickSort = (function () { + + function partition(array, left, right) { + var cmp = array[right - 1], + minEnd = left, + maxEnd; + for (maxEnd = left; maxEnd < right - 1; maxEnd += 1) { + if (array[maxEnd] <= cmp) { + swap(array, maxEnd, minEnd); + minEnd += 1; + } + } + swap(array, minEnd, right - 1); + return minEnd; + } + + function swap(array, i, j) { + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + return array; + } + + function quickSort(array, left, right) { + if (left < right) { + var p = partition(array, left, right); + quickSort(array, left, p); + quickSort(array, p + 1, right); + } + return array; + } + + return function (array) { + return quickSort(array, 0, array.length); + }; +}()); + From 5261c30608b7904a6edb34af8160ad3c7b57d547 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Fri, 30 Nov 2012 22:45:56 +0200 Subject: [PATCH 002/613] Two more sorting algorithms are added (bucket and counting sorts) --- src/sorting/{bubble-sort.js => bubblesort.js} | 0 src/sorting/bucketsort.js | 108 ++++++++++++++++++ src/sorting/countingsort.js | 88 ++++++++++++++ .../{insertion-sort.js => insertionsort.js} | 0 ...ion-sort.js => recursive-insertionsort.js} | 0 .../{selection-sort.js => selectionsort.js} | 0 6 files changed, 196 insertions(+) rename src/sorting/{bubble-sort.js => bubblesort.js} (100%) create mode 100644 src/sorting/bucketsort.js create mode 100644 src/sorting/countingsort.js rename src/sorting/{insertion-sort.js => insertionsort.js} (100%) rename src/sorting/{recursive-insertion-sort.js => recursive-insertionsort.js} (100%) rename src/sorting/{selection-sort.js => selectionsort.js} (100%) diff --git a/src/sorting/bubble-sort.js b/src/sorting/bubblesort.js similarity index 100% rename from src/sorting/bubble-sort.js rename to src/sorting/bubblesort.js diff --git a/src/sorting/bucketsort.js b/src/sorting/bucketsort.js new file mode 100644 index 00000000..a9695577 --- /dev/null +++ b/src/sorting/bucketsort.js @@ -0,0 +1,108 @@ +var array = [0.21, 0.44, 0.221, 0.01, 0.88]; + +/** + * Bucketsort. This algorithm has complexity O(n) but it's not + * correct for every input. + * + * @public + */ +var bucketSort = (function () { + + /** + * Insertionsort. + * + * @private + * @param {array} array Input array + * @returns {array} array Sorted input array + */ + function insertionSort(array) { + var current, + j; + for (var i = 1; i < array.length; i += 1) { + current = array[i]; + j = i - 1; + while (j >= 0 && current < array[j]) { + array[j + 1] = array[j]; + j -= 1; + } + array[j + 1] = current; + } + return array; + } + + /** + * Creates buckets for given array + * + * @private + * @param {array} array Input array + * @returns {array} buckets Array whith array for each bucket. + * Each bucket contains an array with all elements from the input which are with suitable size. + */ + function createBuckets(array) { + var buckets = [], + currentBucket, + current, + sectorSize = 1 / array.length; + for (var i = 0; i < array.length; i += 1) { + current = array[i]; + currentBucket = Math.floor(current / sectorSize); + if (buckets[currentBucket] === undefined) { + buckets[currentBucket] = []; + } + buckets[currentBucket].push(current); + } + return buckets; + } + + /** + * Sorts the arrays from each bucket. + * + * @private + * @param {array} buckets Given buckets + * @returns {array} buckets Buckets with sorted arrays for each bucket + */ + function sortBuckets(buckets) { + for (var i = 0; i < buckets.length; i += 1) { + if (buckets[i] !== undefined) + insertionSort(buckets[i]); + } + return buckets; + } + + /** + * Unions all buckets' arrays + * + * @private + * @param {array} buckets Input buckets + * @returns {array} result Sorted array which contains all elements form each bucket + */ + function unionBuckets(buckets) { + var result = [], + currentBucket; + for (var i = 0; i < buckets.length; i += 1) { + currentBucket = buckets[i]; + if (currentBucket !== undefined) { + for (var j = 0; j < currentBucket.length; j += 1) { + result.push(currentBucket[j]); + } + } + } + return result; + } + + /** + * Sorts given array with bucketsort + * + * @public + * @param {array} array Input array which should be sorted + * @returns {array} Sorted array + */ + return function (array) { + var buckets = createBuckets(array); + sortBuckets(buckets); + return unionBuckets(buckets); + return insertionSort([4,5,2,3,65,8,9,0]); + } +}()); + +console.log(bucketSort(array)); diff --git a/src/sorting/countingsort.js b/src/sorting/countingsort.js new file mode 100644 index 00000000..691fb34b --- /dev/null +++ b/src/sorting/countingsort.js @@ -0,0 +1,88 @@ +var array = [44,2,34,6,7,34,4,4,2,3,6,8]; + +/** + * Counting sort algorithm. It's with complexity O(n) but it's + * correct for specific input. + * + * @public + */ +var countingSort = function () { + + /** + * Gets the count of the elements into the input array + * + * @private + * @param {array} array The input array + * @returns {array} count The count of each element from the input array + */ + function getCount(array) { + var count = [], + current; + for (var i = 0; i < array.length; i += 1) { + current = array[i]; + if (count[current] !== undefined) { + count[current] += 1; + } else { + count[current] = 1; + } + } + return count; + } + + /** + * Gets the count of the elements which are less than a given + * + * @private + * @param {array} array The input array + * @returns {array} less The count of the elements which are less than each element from the input + */ + function getLessCount(array) { + var less = [], + last; + less[0] = array[0] || 0; + for (var i = 1; i < array.length; i += 1) { + last = array[i - 1] || 0; + less[i] = last + less[i - 1]; + } + return less; + } + + /** + * Sorts the input array + * + * @private + * @param {array} array Input which should be sorted + * @param {array} less Count of the less elements for each element + * @returns {array} result The sorted input + */ + function sort(array, less) { + var result = [], + currentPositions = [], + current, + position; + for (var i = 0; i < array.length; i += 1) { + current = array[i]; + position = less[current]; + if (currentPositions[current] === undefined) { + currentPositions[current] = position; + } + result[currentPositions[current]] = current; + currentPositions[current] += 1; + } + return result; + } + + /** + * Sorts a given array + * + * @public + * @param {array} array Array which should be sorted + * @returns {array} array Sorted array + */ + return function (array) { + var less = getLessCount(getCount(array)); + return sort(array, less); + } +}(); + +console.log(countingSort(array)); diff --git a/src/sorting/insertion-sort.js b/src/sorting/insertionsort.js similarity index 100% rename from src/sorting/insertion-sort.js rename to src/sorting/insertionsort.js diff --git a/src/sorting/recursive-insertion-sort.js b/src/sorting/recursive-insertionsort.js similarity index 100% rename from src/sorting/recursive-insertion-sort.js rename to src/sorting/recursive-insertionsort.js diff --git a/src/sorting/selection-sort.js b/src/sorting/selectionsort.js similarity index 100% rename from src/sorting/selection-sort.js rename to src/sorting/selectionsort.js From e932c3271b7d828e9d5782a837daf95387a2d875 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Fri, 30 Nov 2012 23:18:43 +0200 Subject: [PATCH 003/613] JSDoc added to the algorithms --- src/sorting/bubblesort.js | 7 +++++ src/sorting/heapsort.js | 30 ++++++++++++++++++ src/sorting/insertion-binary-sort.js | 10 ++++++ src/sorting/insertionsort.js | 42 ++++++------------------- src/sorting/quicksort.js | 43 +++++++++++++++++++++++++- src/sorting/recursive-insertionsort.js | 7 +++++ 6 files changed, 105 insertions(+), 34 deletions(-) diff --git a/src/sorting/bubblesort.js b/src/sorting/bubblesort.js index 4f694842..21c25bce 100644 --- a/src/sorting/bubblesort.js +++ b/src/sorting/bubblesort.js @@ -1,5 +1,12 @@ var array = [3,5,2,4,7,9,6,4,5]; +/** + * The bubblesort algorithm. Complexity O(n^2). + * + * @public + * @param {array} array Input array + * @returns {array} array Sorted array + */ function bubbleSort(array) { var temp; for (var i = 0; i < array.length; i += 1) { diff --git a/src/sorting/heapsort.js b/src/sorting/heapsort.js index 85950a8a..d8306104 100644 --- a/src/sorting/heapsort.js +++ b/src/sorting/heapsort.js @@ -1,4 +1,19 @@ +var array = [3,4,6,2,3,6,8,9]; + +/** + * The heapsort algorithm. It's complexity is O(nlog n). + * + * @public + */ var heapSort = (function () { + + /** + * Finds the correct place of given element in given max heap. + * + * @private + * @param {array} array Array + * @param {number} index Index of the element which palce in the max heap should be find + */ function heapify(array, index, heapSize) { var left = 2 * index + 1, right = 2 * index + 2, @@ -18,6 +33,13 @@ var heapSort = (function () { } } + /** + * Builds max heap from a given array. + * + * @private + * @param {array} array Array which should be turned into max heap + * @returns {array} array Array turned into max heap + */ function buildMaxHeap(array) { for (var i = Math.floor(array.length / 2); i >= 0; i -= 1) { heapify(array, i, array.length); @@ -25,6 +47,13 @@ var heapSort = (function () { return array; } + /** + * Heapsort. Turns the input array into a max heap and after that sorts it. + * + * @public + * @param {array} array Input array + * @returns {array} array Sorted array + */ return function (array) { var size = array.length, temp; @@ -40,3 +69,4 @@ var heapSort = (function () { }; }()); +console.log(heapSort(array)); diff --git a/src/sorting/insertion-binary-sort.js b/src/sorting/insertion-binary-sort.js index 916b66f1..86e780fd 100644 --- a/src/sorting/insertion-binary-sort.js +++ b/src/sorting/insertion-binary-sort.js @@ -1,5 +1,15 @@ var array = [5,6,3,3,6,8,9,4,3]; +/** + * Modified version of insertionsort. It uses binary search for finding + * where the current element should be inserted. It's correct because + * the binary search looks just in the first part of the array + * which is actually sorted. It's complexity is O(n^2) + * + * @public + * @param {array} array Input array + * @param {array} array Sorted array + */ function insertionBinarySort(array) { var current, middle, diff --git a/src/sorting/insertionsort.js b/src/sorting/insertionsort.js index d09bb066..4e9546da 100644 --- a/src/sorting/insertionsort.js +++ b/src/sorting/insertionsort.js @@ -1,8 +1,12 @@ -var array0 = [2,3,5,1,2,4,7,9,0,3,3]; -var array1 = [2,3,5,1,2,4,7,9,0,3,3]; -var array2 = [2,3,5,1,2,4,7,9,0,3,3]; - +var array = [2,3,5,1,2,4,7,9,0,3,3]; +/** + * Insertionsort algorithm. It's complexity is O(n^2). + * + * @public + * @param {array} array Input array + * @returns {array} array Sorted array + */ function insertionSort(array) { var current, j; @@ -18,32 +22,4 @@ function insertionSort(array) { return array; } -/* Works in JS because of the functional scope */ -function insertionSort2(array) { - var key; - for (var i = 0; i < array.length; i += 1) { - key = array[i]; - for (var j = i - 1; j >= 0 && key < array[j]; j -= 1) { - array[j + 1] = array[j]; - } - array[j + 1] = key; - } - return array; -} - -/* Works in JS because of the functional scope */ -function insertionSortDesc(array) { - var key; - for (var i = 1; i < array.length; i += 1) { - key = array[i]; - for (var j = i - 1; i >= 0 && array[j] < key; j -= 1) { - array[j + 1] = array[j]; - } - array[j + 1] = key; - } - return array; -} - -console.log(insertionSort(array0)); -console.log(insertionSort2(array1)); -console.log(insertionSortDesc(array2)); +console.log(insertionSort(array)); diff --git a/src/sorting/quicksort.js b/src/sorting/quicksort.js index b890ffdd..ffb66797 100644 --- a/src/sorting/quicksort.js +++ b/src/sorting/quicksort.js @@ -1,5 +1,20 @@ +var array = [3,4,7,3,3,5,8,3,34,3,7,9]; + +/** + * The quicksort algorithm. It's complexity is O(nlog n). + * + * @public + */ var quickSort = (function () { + /** + * Partitions given subarray. + * + * @private + * @param {array} array Input array + * @param {number} left The start of the subarray + * @param {number} right The end of the subarray + */ function partition(array, left, right) { var cmp = array[right - 1], minEnd = left, @@ -14,13 +29,31 @@ var quickSort = (function () { return minEnd; } + /** + * Swap the places of two elements + * + * @private + * @param {array} array The array which contains the elements + * @param {number} i The index of the first element + * @param {number} j The index of the second element + * @returns {array} array The array with swaped elements + */ function swap(array, i, j) { var temp = array[i]; array[i] = array[j]; array[j] = temp; return array; } - + + /** + * Sorts given array. + * + * @private + * @param {array} array Array which should be sorted + * @param {number} left The start of the subarray which should be handled + * @param {number} right The end of the subarray which should be handled + * @returns {array} array Sorted array + */ function quickSort(array, left, right) { if (left < right) { var p = partition(array, left, right); @@ -30,8 +63,16 @@ var quickSort = (function () { return array; } + /** + * Calls the quicksort function with it's initial values. + * + * @public + * @param {array} array The input array which should be sorted + * @returns {array} array Sorted array + */ return function (array) { return quickSort(array, 0, array.length); }; }()); +console.log(quickSort(array)); diff --git a/src/sorting/recursive-insertionsort.js b/src/sorting/recursive-insertionsort.js index 95f851ae..4c58a342 100644 --- a/src/sorting/recursive-insertionsort.js +++ b/src/sorting/recursive-insertionsort.js @@ -1,5 +1,12 @@ var array = [4,6,2,2,4,56,7,7,51,23,5,7]; +/** + * Recursive version of insertionsort. Complexity O(n^2). + * + * @public + * @param {array} array Input array + * @param {number} [max] Index of the element which place we should find in the current function call + */ function recursiveInsertionSort(array, max) { if (max <= 0) return array; From 9d27a9fb15ec87ae74fda5ecc17c8e2adf67f6a4 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Fri, 30 Nov 2012 23:23:35 +0200 Subject: [PATCH 004/613] Few mistakes in the JSDoc are corrected --- src/sorting/heapsort.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sorting/heapsort.js b/src/sorting/heapsort.js index d8306104..6bbb7088 100644 --- a/src/sorting/heapsort.js +++ b/src/sorting/heapsort.js @@ -12,7 +12,7 @@ var heapSort = (function () { * * @private * @param {array} array Array - * @param {number} index Index of the element which palce in the max heap should be find + * @param {number} index Index of the element which palce in the max heap should be found. */ function heapify(array, index, heapSize) { var left = 2 * index + 1, @@ -34,7 +34,7 @@ var heapSort = (function () { } /** - * Builds max heap from a given array. + * Builds max heap from given array. * * @private * @param {array} array Array which should be turned into max heap @@ -48,7 +48,7 @@ var heapSort = (function () { } /** - * Heapsort. Turns the input array into a max heap and after that sorts it. + * Heapsort. Turns the input array into max heap and after that sorts it. * * @public * @param {array} array Input array From aee4840b1f39dc2be8e22612e693ccdce260a332 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Sun, 2 Dec 2012 12:15:39 +0200 Subject: [PATCH 005/613] Few more algorithms are documented. MaxHeap is added --- src/data-structures/heap.js | 99 +++++++++++++++++++ .../{binary-search.js => binarysearch.js} | 9 ++ src/searching/recursive-binary-search.js | 30 ------ src/searching/recursive-binarysearch.js | 60 +++++++++++ 4 files changed, 168 insertions(+), 30 deletions(-) create mode 100644 src/data-structures/heap.js rename src/searching/{binary-search.js => binarysearch.js} (75%) delete mode 100644 src/searching/recursive-binary-search.js create mode 100644 src/searching/recursive-binarysearch.js diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js new file mode 100644 index 00000000..76fee5bb --- /dev/null +++ b/src/data-structures/heap.js @@ -0,0 +1,99 @@ +/** + * Constructor function of maximum heap + * + * @public + */ +function MaxHeap() { + this._heap = []; +} + +/** + * Exchange indexes with start index given as argument + * to turn the heap into valid maxheap. On a single call + * this method maintains only a single "branch" of the heap + * + * @private + * @param {number} index The parent + */ +MaxHeap.prototype._heapify = function (index) { + var max = index, + left = 2 * index + 1, + right = 2 * index + 2, + temp; + + if (left < this._heap.length && this._heap[left] > this._heap[index]) + max = left; + + if (right < this._heap.length && this._heap[right] > this._heap[index]) + max = right; + + if (index !== max) { + temp = this._heap[index]; + this._heap[index] = this._heap[max]; + this._heap[max] = temp; + this._heapify(max); + } + +} + +/** + * Increases the key for give index + * + * @public + * @param {number} index Index which key should be increased + * @param {number} value New value of the key + * @returns {number} parent The new position of the element + */ +MaxHeap.prototype.increaseKey = function (index, value) { + var elem = this._heap[index], + parent = Math.floor(index / 2), + temp; + if (elem && elem <= value) { + while (parent >= 0 && elem > this._heap[parent]) { + temp = this._heap[parent]; + this._heap[parent] = elem; + this._heap[index] = temp; + index = parent; + parent = Math.floor(parent / 2); + } + } + return parent; +} + +/** + * Adds new element to the heap + * + * @public + * @param {number} value The new value which will be inserted + * @returns {number} The index of the inserted value + */ +MaxHeap.prototype.add = function (value) { + this._heap.push(value); + return this.increaseKey(this._heap.length - 1, value); +} + +/** + * Gets the current value which is on the top of the heap + * + * @public + * returns {numner} The current largest value which is on the top of the heap + */ +MaxHeap.prototype.max = function () { + return this._heap[0]; +} + +/** + * Remove and return the current maximum value which is on the top of the heap + * + * @public + * @returns {number} max Extracted value + */ +MaxHeap.prototype.extractMax = function () { + if (!this._heap.length) + throw new 'The heap is already empty!'; + + var max = this._heap.shift(); + this._heapify(0); + return max; +} + diff --git a/src/searching/binary-search.js b/src/searching/binarysearch.js similarity index 75% rename from src/searching/binary-search.js rename to src/searching/binarysearch.js index b5c9c640..219d3ad0 100644 --- a/src/searching/binary-search.js +++ b/src/searching/binarysearch.js @@ -1,5 +1,14 @@ var array = [5, 8, 53, 56, 123, 322, 400, 2356, 8000, 23333]; +/** + * Searchs for specific element in given array using the binary search algorithm. + * It's complexity is O(log n) + * + * @public + * @param {array} array Input array + * @param {number} key The key of the element which index we should find + * @returns {number} index The index of the element or -1 if not found + */ function binarySearch(array, key) { var middle = Math.round(array.length / 2), left = 0, diff --git a/src/searching/recursive-binary-search.js b/src/searching/recursive-binary-search.js deleted file mode 100644 index 36eb121b..00000000 --- a/src/searching/recursive-binary-search.js +++ /dev/null @@ -1,30 +0,0 @@ -var array = [5, 8, 53, 56, 123, 322, 400, 2356, 8000, 23333]; - -function binarySearch(array, key) { - return recursiveBinarySearch(array, key, 0, array.length); -} - -function recursiveBinarySearch(array, key, left, right) { - if (left > right) - return -1; - var middle = Math.floor((right + left) / 2); - if (array[middle] === key) - return middle; - else if (array[middle] > key) - return recursiveBinarySearch(array, key, left, middle - 1); - else - return recursiveBinarySearch(array, key, middle + 1, right); -} - -console.log(array); -console.log(5, binarySearch(array, 5)); -console.log(8, binarySearch(array, 8)); -console.log(53, binarySearch(array, 53)); -console.log(56, binarySearch(array, 56)); -console.log(123, binarySearch(array, 123)); -console.log(322, binarySearch(array, 322)); -console.log(400, binarySearch(array, 400)); -console.log(2356, binarySearch(array, 2356)); -console.log(8000, binarySearch(array, 8000)); -console.log(8001, binarySearch(array, 8001)); -console.log(23333, binarySearch(array, 23333)); diff --git a/src/searching/recursive-binarysearch.js b/src/searching/recursive-binarysearch.js new file mode 100644 index 00000000..306fb95e --- /dev/null +++ b/src/searching/recursive-binarysearch.js @@ -0,0 +1,60 @@ +var array = [5, 8, 53, 56, 123, 322, 400, 2356, 8000, 23333]; + + +/** + * Recursive version of binary search. It's complexity is O(log n). + * + * @public + */ +var binarySearch = (function () { + + /** + * Binary search. + * + * @pivate + * @param {array} array Given array where we should find the index of the element + * @param {number} key Key of the element which index should be found + * @param {number} left Left index + * @param {number} right Right index + * @returns {number} index The index of the element or -1 if not found + * + */ + function recursiveBinarySearch(array, key, left, right) { + if (left > right) + return -1; + var middle = Math.floor((right + left) / 2); + if (array[middle] === key) + return middle; + else if (array[middle] > key) + return recursiveBinarySearch(array, key, left, middle - 1); + else + return recursiveBinarySearch(array, key, middle + 1, right); + } + + /** + * Calls the binary search function with it's initial values. + * + * @param {array} array The input array + * @param {number} key The key of the element which index should be found + * @returns {number} index The index of the element or -1 if not found + */ + return function (array, key) { + return recursiveBinarySearch(array, key, 0, array.length); + } + +}()); + + + +console.log(array); +console.log(5, binarySearch(array, 5)); +console.log(8, binarySearch(array, 8)); +console.log(53, binarySearch(array, 53)); +console.log(56, binarySearch(array, 56)); +console.log(123, binarySearch(array, 123)); +console.log(322, binarySearch(array, 322)); +console.log(400, binarySearch(array, 400)); +console.log(2356, binarySearch(array, 2356)); +console.log(8000, binarySearch(array, 8000)); +console.log(8001, binarySearch(array, 8001)); +console.log(23333, binarySearch(array, 23333)); From 5ea244b8d304871e7cf306bc1ad52b5d9930dab8 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Wed, 12 Dec 2012 22:24:12 +0200 Subject: [PATCH 006/613] Binary search tree is added --- .../.binary-search-tree.js.swp | Bin 0 -> 24576 bytes src/data-structures/binary-search-tree.js | 275 ++++++++++++++++++ src/data-structures/heap.js | 11 +- src/searching/maximum-subarray.js | 20 ++ 4 files changed, 301 insertions(+), 5 deletions(-) create mode 100644 src/data-structures/.binary-search-tree.js.swp create mode 100644 src/data-structures/binary-search-tree.js create mode 100644 src/searching/maximum-subarray.js diff --git a/src/data-structures/.binary-search-tree.js.swp b/src/data-structures/.binary-search-tree.js.swp new file mode 100644 index 0000000000000000000000000000000000000000..a912127ca44ed19bd796267394990d3e5257915e GIT binary patch literal 24576 zcmeI4YmgjO8HU>cYD5$fOR+>xP|0lAoh2k1NZ1r1A;l^rF(wfbW0;-k-I*}cz17{b zo3L3y6r>O%lvM;3O(_TpmKI7$sVEmOgi9f4m8j(pkrG7Z5(T+Re7C1h<2>}(jul^qUjA;(NVeQ0y%g zqC!s?1@&T758SYKpyCyR%{`%82#V#NC~)2U#&GvJXCX2L4sZqP(O}PshdFajn0>q` z@!n%*sJ9-m`T!RttA3_Hra-1Zra-1Zra-1Zra-2^fu%q+e2{ZKRi0+6y~O^0P0Q~? z?B{;_duhx4gYD;w?eDEE_YZ3Me3Z=~&d1))eq{<|3Snmh@j&6nT; zSPyIAY*-Bnj)o)PE_D1kY=uw2I#>&9AP>jEd*HFxInLFv4c5RCm|}%JNq7Pthi}3+U>mH474R`ovw9Uj)G5P-piom|UcENp23t77 zQSpYx)tW-J?kay!MP*lce#up%Hg;uDa2XDz0%T~IwTs- zv_Z-i_emp|_FP7zj4S!61_Qrl8#D4%7!`s@TX&;1OydQWkwPR5DIc4S*9aB2nY5Nk zbEq=ndZzg&HeNrB_QHDOSZNJoo8Mp3#rCTepa|A}+a#FWY~!-WCfCt!+XL-0!^NcR zHD$|Rf^H<)Y9R^ z)NC*rn`86UHB$@C1k4QO_7C&*@vFnnRrY*^j*faj*~f4BGQj%Co0xE*0{rnxK0ND^~~o?>n5gY6Hk0iH7UY=0xBnOCcbS97DXUt&6(nDBz6qpg#vLUMAq z!jvqrR%s8jQWr6-uu$=a+HapB1r4RW(|32bDAFlSs_!DR5VD19&hYKBqd#?$Ub;Hl z2#Hb3^j)(4|0wJ3AISQf_5WM!9>Y%7@_zx@1NaU62)4sl;LETD*1}vk9R5N4zr%xY z3rKob!Wh&cyD|kb1u_LP1u_LP1u_LP1u_LP1u_LP1r9s~@_D_VIBvIVWTA_nDvzfw z=jHV>ezIHRliVc5$Rv(Gud#z6dn{v))7zWODar?K%^z`dQJ$@eQm$uqR~OMI540y? zdgho=lV#Q(VrEbBnn_8Vy{)Gxp!XkV&z@}s(I0zSK2pvFj;#OB#RRwGyOs6-#nv1j zWKDlPTnpELto=`i)8Hg{jy3(ga2ITaEiecrI2C3=4yMEJ@!9_lZh?#70vHGJ?{9)d zunb6x;?sfvr#m7fNsr%!hf<4KHI4FTk^~1H{)aHu6>YG>kwQ*23A)el^Tc z+gali&zX5hjfwI>HihHe-Q;E?dwU%n_VT!%S=f~D*ON#yV!}&rL#B3ioBMrwm(A=q zhiXi=3CGQTYGG5QRe^Goj~Jm#yOMX)V~qP3})OYoSi* zRE3H+VYt#SQ|totnZrfpsVShuo>DknvrKnT9ddU#>~d>eAUzMQBFA=!fB9>X0yT8Bc-?`->i(; z2%pG;B&?Ov+C@rAc7*l6E=g_}uS@L-C;SSrWtkN0hHs}7mXYbWS}C5Aj-gTq5SBJ9 zcapLiKUX8K-I}r_mEU0Y*kjMhR9k)FerokSZ1k4LOlq_jjo#_`X~?L15#wl>xY1K7 zbZpL~tK$D@^i)n%f09OT_0r+&uG`1gJlG9)ojY7D6y3$;O0|?TR$<&b_%5}g31^+e zOgTd33+n*dZ8F;6lE;?f)RgomCTDZokvs71@5QHa?L+l(*6DbXZd?E}@F83RpH zjc!L0N>@c4d#p*%o&%F9vxJh%cDjQFT*a+juIk*0np(GYp?2UxDb5HsMy>&$1wg@L z{KcYrbvCNx4!d3n&za(E-Dnvnr^`Hnv9{@cSGYM%KK8_5@}XFUaVUJI9Ii`+NeBWkC8DA!r z9Z;p!ZNO%mr(O6GFODNd+A)gcm=1)S+^?2&NxMwb$9C<+C9w|Us(u1W; zK_}dCTt;0vb!^)STwOC+c1% zw2tN@H`zj{T|s#WW&Qt7)}wMxUDp5ob|Lo=Yy4Z`3vd~H4n7MjVL2>;7g*ar3%A4N z@OiilE`f7kJ;+&qIp2Rj>-xLl5*UF&=!0Y68P@Z^ggfC5_$ho5E{BU?K70UPVO=k4 z{<~oZ$hrP2U@Ke*AA()1;a`Lw!?)ln7>3o5gBMx9KL`JTf5Gi=E8GNwFaX`~5_&uj z&%wXpd+;6jI&1)~SNozj`zBK$Qy^0yQy^2|09PP;6O7l#68nU9YPwHeLWhs^o2x5M=NeT8a=^ny?Q%rB3q8%$cinrv3 value) + insertKey = '_left'; + else + insertKey = '_right'; + if (!current[insertKey]) + current[insertKey] = new Node(value, null, null, current); + else + this.insert(value, current[insertKey]); +}; + +/** + * Prints the nodes of the tree in order. It starts the tree traversal from a given node. + * + * @private + * @param {Node} Node from which to start the traversal + * @param {Function} Callback which will be called for each traversed node + */ +BinaryTree.prototype._inorder = function (current, callback) { + if (!current) + return; + this._inorder(current._left, callback); + if (typeof callback === 'function') + callback(current); + this._inorder(current._right, callback); +}; + +/** + * Inorder traversal of the whole binary search tree + * + * @public + * @param {Function} Callback which will be called for each traversed node + */ +BinaryTree.prototype.inorder = function (callback) { + return this._inorder(this._root, callback); +}; + +/** + * Post-order traversal from given node + * + * @private + * @param {Node} Node from which to start the traversal + * @param {Function} Callback which will be called for each traversed node + */ +BinaryTree.prototype._postorder = function (current, callback) { + if (!current) + return; + if (typeof callback === 'function') + callback(current); + this._postorder(current._left, callback); + this._postorder(current._right, callback); +}; + +/** + * Post-order traversal of the whole tree + * + * @public + * @param {Function} Callback which will be called for each traversed node + */ +BinaryTree.prototype.postorder = function (callback) { + return this._postorder(this._root, callback); +}; + +/** + * Pre-order traversal of the tree from given node + * + * @private + * @param {Node} Node from which to start the traversal + * @param {Function} Callback which will be called for each traversed node + */ +BinaryTree.prototype._preorder = function (current, callback) { + if (!current) + return; + if (typeof callback === 'function') + callback(current); + this._preorder(current._left, callback); + this._preorder(current._right, callback); +}; + +/** + * Pre-order preorder traversal of the whole tree + * + * @public + * @param {Function} Callback which will be called for each traversed node + */ +BinaryTree.prototype.preorder = function (callback) { + return this._preorder(this._root, callback); +}; + +/** + * Finds a node by it's value. Average runtime complexity O(log n) + * + * @public + * @param {number|string} Value of the node which should be found + */ +BinaryTree.prototype.find = function (value) { + return this._find(value, this._root); +}; + +/** + * Finds a node by it's value in given sub-tree. Average runtime complexity: O(log n). + * + * @private + * @param {number|string} Value of the node which should be found + * @param {Node} Current node to be checked + */ +BinaryTree.prototype._find = function (value, current) { + if (!current) + return null; + + if (current.value === value) + return current; + + if (current.value > value) + return this._find(value, current._left); + + if (current.value < value) + return this._find(value, current._right); + +}; + +/** + * Replaces given child with new one, for given parent + * + * @private + * @param {Node} Parent node + * @param {Node} Child to be replaced + * @param {Node} Child replacement + */ +BinaryTree.prototype._replaceChild = function (parent, oldChild, newChild) { + if (!parent) { + this._root = newChild; + this._root._parent = null; + } else { + + if (parent._left === oldChild) + parent._left = newChild; + else + parent._right = newChild; + + if (newChild) { + newChild._parent = parent; + } + } +}; + +/** + * Removes node from the tree. Average runtime complexity: O(log n). + * + * @public + * @param {Node} Node to be removed + * @returns {boolean} True/false depending on whether the given node is removed + */ +BinaryTree.prototype.remove = function (node) { + if (!node) + return false; + + if (node._left && node._right) { + var min = this._findMin(node._right), + temp = node.value; + + node.value = min.value; + min.value = temp; + return this.remove(min); + } else { + if (node._left) + this._replaceChild(node._parent, node, node._left); + else if (node._right) + this._replaceChild(node._parent, node, node._right); + else + this._replaceChild(node._parent, node, null); + return true; + } +}; + +/** + * Finds the node with minimum value in given sub-tree + * + * @private + * @param {Node} Root of the sub-tree + * @param {[number|string]} Current minimum value of the sub-tree + * @returns {Node} The node with minimum value in the sub-tree + */ +BinaryTree.prototype._findMin = function (node, current) { + current = current || { value: Infinity }; + if (!node) + return current; + if (current.value > node.value) + current = node; + return this._findMin(node._left, current); +}; + +/** + * Finds the node with maximum value in given sub-tree + * + * @private + * @param {Node} Root of the sub-tree + * @param {[number|string]} Current maximum value of the sub-tree + * @returns {Node} The node with maximum value in the sub-tree + */ +BinaryTree.prototype._findMax = function (node, current) { + current = current || { value: -Infinity }; + if (!node) + return current; + if (current.value < node.value) + current = node; + return this._findMax(node._right, current); +}; + +/** + * Finds the node with minimum value in the whole tree + * + * @public + * @returns {Node} The minimum node of the tree + */ +BinaryTree.prototype.findMin = function () { + return this._findMin(this._root); +}; + +/** + * Finds the maximum node of the tree + * + * @public + * @returns {Node} The maximum node of the tree + * + */ +BinaryTree.prototype.findMax = function () { + return this._findMax(this._root); +}; diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index 76fee5bb..2010cf32 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -10,7 +10,7 @@ function MaxHeap() { /** * Exchange indexes with start index given as argument * to turn the heap into valid maxheap. On a single call - * this method maintains only a single "branch" of the heap + * this method maintains only a single "branch" of the heap. Complexity O(log n) * * @private * @param {number} index The parent @@ -37,7 +37,7 @@ MaxHeap.prototype._heapify = function (index) { } /** - * Increases the key for give index + * Increases the key for give index. Complexity O(log n). * * @public * @param {number} index Index which key should be increased @@ -61,7 +61,7 @@ MaxHeap.prototype.increaseKey = function (index, value) { } /** - * Adds new element to the heap + * Adds new element to the heap. Complexity O(log n). * * @public * @param {number} value The new value which will be inserted @@ -73,7 +73,7 @@ MaxHeap.prototype.add = function (value) { } /** - * Gets the current value which is on the top of the heap + * Gets the current value which is on the top of the heap. Complexity O(1). * * @public * returns {numner} The current largest value which is on the top of the heap @@ -83,7 +83,8 @@ MaxHeap.prototype.max = function () { } /** - * Remove and return the current maximum value which is on the top of the heap + * Remove and return the current maximum value which is on the top of the heap. + * Complexity O(log n). * * @public * @returns {number} max Extracted value diff --git a/src/searching/maximum-subarray.js b/src/searching/maximum-subarray.js new file mode 100644 index 00000000..c7603557 --- /dev/null +++ b/src/searching/maximum-subarray.js @@ -0,0 +1,20 @@ +/** + * Finds the maximum sum of subarray's element of given array using the Kadane's algorithm + * It's complexity is O(n). The algorithm can be found here: https://en.wikipedia.org/wiki/Maximum_subarray_problem#Kadane.27s_algorithm + * + * @public + * @param {array} array Input array + * @returns {number} max The maximum sum of the elements of subarray of the input + * + */ +function maxSubarray(array) { + var currentMax = 0, + max = 0; + + for (var i = 0; i < array.length; i += 1) { + currentMax = Math.max(0, currentMax + array[i]); + max = Math.max(max, currentMax); + } + + return max; +} From c5bfd8823ffde16d19945aa5578e43750e81c901 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Wed, 12 Dec 2012 22:26:05 +0200 Subject: [PATCH 007/613] Removed a swp file --- src/data-structures/.binary-search-tree.js.swp | Bin 24576 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/data-structures/.binary-search-tree.js.swp diff --git a/src/data-structures/.binary-search-tree.js.swp b/src/data-structures/.binary-search-tree.js.swp deleted file mode 100644 index a912127ca44ed19bd796267394990d3e5257915e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 24576 zcmeI4YmgjO8HU>cYD5$fOR+>xP|0lAoh2k1NZ1r1A;l^rF(wfbW0;-k-I*}cz17{b zo3L3y6r>O%lvM;3O(_TpmKI7$sVEmOgi9f4m8j(pkrG7Z5(T+Re7C1h<2>}(jul^qUjA;(NVeQ0y%g zqC!s?1@&T758SYKpyCyR%{`%82#V#NC~)2U#&GvJXCX2L4sZqP(O}PshdFajn0>q` z@!n%*sJ9-m`T!RttA3_Hra-1Zra-1Zra-1Zra-2^fu%q+e2{ZKRi0+6y~O^0P0Q~? z?B{;_duhx4gYD;w?eDEE_YZ3Me3Z=~&d1))eq{<|3Snmh@j&6nT; zSPyIAY*-Bnj)o)PE_D1kY=uw2I#>&9AP>jEd*HFxInLFv4c5RCm|}%JNq7Pthi}3+U>mH474R`ovw9Uj)G5P-piom|UcENp23t77 zQSpYx)tW-J?kay!MP*lce#up%Hg;uDa2XDz0%T~IwTs- zv_Z-i_emp|_FP7zj4S!61_Qrl8#D4%7!`s@TX&;1OydQWkwPR5DIc4S*9aB2nY5Nk zbEq=ndZzg&HeNrB_QHDOSZNJoo8Mp3#rCTepa|A}+a#FWY~!-WCfCt!+XL-0!^NcR zHD$|Rf^H<)Y9R^ z)NC*rn`86UHB$@C1k4QO_7C&*@vFnnRrY*^j*faj*~f4BGQj%Co0xE*0{rnxK0ND^~~o?>n5gY6Hk0iH7UY=0xBnOCcbS97DXUt&6(nDBz6qpg#vLUMAq z!jvqrR%s8jQWr6-uu$=a+HapB1r4RW(|32bDAFlSs_!DR5VD19&hYKBqd#?$Ub;Hl z2#Hb3^j)(4|0wJ3AISQf_5WM!9>Y%7@_zx@1NaU62)4sl;LETD*1}vk9R5N4zr%xY z3rKob!Wh&cyD|kb1u_LP1u_LP1u_LP1u_LP1u_LP1r9s~@_D_VIBvIVWTA_nDvzfw z=jHV>ezIHRliVc5$Rv(Gud#z6dn{v))7zWODar?K%^z`dQJ$@eQm$uqR~OMI540y? zdgho=lV#Q(VrEbBnn_8Vy{)Gxp!XkV&z@}s(I0zSK2pvFj;#OB#RRwGyOs6-#nv1j zWKDlPTnpELto=`i)8Hg{jy3(ga2ITaEiecrI2C3=4yMEJ@!9_lZh?#70vHGJ?{9)d zunb6x;?sfvr#m7fNsr%!hf<4KHI4FTk^~1H{)aHu6>YG>kwQ*23A)el^Tc z+gali&zX5hjfwI>HihHe-Q;E?dwU%n_VT!%S=f~D*ON#yV!}&rL#B3ioBMrwm(A=q zhiXi=3CGQTYGG5QRe^Goj~Jm#yOMX)V~qP3})OYoSi* zRE3H+VYt#SQ|totnZrfpsVShuo>DknvrKnT9ddU#>~d>eAUzMQBFA=!fB9>X0yT8Bc-?`->i(; z2%pG;B&?Ov+C@rAc7*l6E=g_}uS@L-C;SSrWtkN0hHs}7mXYbWS}C5Aj-gTq5SBJ9 zcapLiKUX8K-I}r_mEU0Y*kjMhR9k)FerokSZ1k4LOlq_jjo#_`X~?L15#wl>xY1K7 zbZpL~tK$D@^i)n%f09OT_0r+&uG`1gJlG9)ojY7D6y3$;O0|?TR$<&b_%5}g31^+e zOgTd33+n*dZ8F;6lE;?f)RgomCTDZokvs71@5QHa?L+l(*6DbXZd?E}@F83RpH zjc!L0N>@c4d#p*%o&%F9vxJh%cDjQFT*a+juIk*0np(GYp?2UxDb5HsMy>&$1wg@L z{KcYrbvCNx4!d3n&za(E-Dnvnr^`Hnv9{@cSGYM%KK8_5@}XFUaVUJI9Ii`+NeBWkC8DA!r z9Z;p!ZNO%mr(O6GFODNd+A)gcm=1)S+^?2&NxMwb$9C<+C9w|Us(u1W; zK_}dCTt;0vb!^)STwOC+c1% zw2tN@H`zj{T|s#WW&Qt7)}wMxUDp5ob|Lo=Yy4Z`3vd~H4n7MjVL2>;7g*ar3%A4N z@OiilE`f7kJ;+&qIp2Rj>-xLl5*UF&=!0Y68P@Z^ggfC5_$ho5E{BU?K70UPVO=k4 z{<~oZ$hrP2U@Ke*AA()1;a`Lw!?)ln7>3o5gBMx9KL`JTf5Gi=E8GNwFaX`~5_&uj z&%wXpd+;6jI&1)~SNozj`zBK$Qy^0yQy^2|09PP;6O7l#68nU9YPwHeLWhs^o2x5M=NeT8a=^ny?Q%rB3q8%$cinrv3 Date: Wed, 2 Jan 2013 21:46:05 +0200 Subject: [PATCH 008/613] Dijkstra is added. The heap is modified to be more usable. --- readme.md | 6 +- src/data-structures/heap.js | 63 +++++++++++--------- src/graphs/dijkstra.js | 112 ++++++++++++++++++++++++++++++++++++ 3 files changed, 153 insertions(+), 28 deletions(-) create mode 100644 src/graphs/dijkstra.js diff --git a/readme.md b/readme.md index 91cf4461..42fd5d05 100644 --- a/readme.md +++ b/readme.md @@ -1 +1,5 @@ -Different algorithms implemented in JavaScript +##About +This repository contains different famous Computer Science algorithms implemented in JavaScript + +##License +The code in this repository is distributed under the terms of the MIT license. diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index 2010cf32..7a1415bb 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -1,55 +1,63 @@ /** - * Constructor function of maximum heap + * Constructor function of minimum heap * * @public + * @param {function} Function used for comparition between the elements */ -function MaxHeap() { +function Heap(cmp) { this._heap = []; + if (typeof cmp === 'function') { + this._cmp = cmp; + } else { + this._cmp = function (a, b) { + return a - b; + }; + } } /** * Exchange indexes with start index given as argument - * to turn the heap into valid maxheap. On a single call + * to turn the tree into a valid heap. On a single call * this method maintains only a single "branch" of the heap. Complexity O(log n) * * @private * @param {number} index The parent */ -MaxHeap.prototype._heapify = function (index) { - var max = index, +Heap.prototype._heapify = function (index) { + var extr = index, left = 2 * index + 1, right = 2 * index + 2, temp; - if (left < this._heap.length && this._heap[left] > this._heap[index]) - max = left; + if (left < this._heap.length && this._cmp(this._heap[left], this._heap[index]) > 0) + extr = left; - if (right < this._heap.length && this._heap[right] > this._heap[index]) - max = right; + if (right < this._heap.length && this._cmp(this._heap[right], this._heap[index]) > 0) + extr = right; - if (index !== max) { + if (index !== extr) { temp = this._heap[index]; - this._heap[index] = this._heap[max]; - this._heap[max] = temp; - this._heapify(max); + this._heap[index] = this._heap[extr]; + this._heap[extr] = temp; + this._heapify(extr); } } /** - * Increases the key for give index. Complexity O(log n). + * Changes the key for give index. Complexity O(log n). * * @public - * @param {number} index Index which key should be increased + * @param {number} index Index which key should be changed * @param {number} value New value of the key * @returns {number} parent The new position of the element */ -MaxHeap.prototype.increaseKey = function (index, value) { +Heap.prototype.changeKey = function (index, value) { var elem = this._heap[index], parent = Math.floor(index / 2), temp; - if (elem && elem <= value) { - while (parent >= 0 && elem > this._heap[parent]) { + if (elem !== undefined) { + while (parent >= 0 && this._cmp(elem, this._heap[parent]) > 0) { temp = this._heap[parent]; this._heap[parent] = elem; this._heap[index] = temp; @@ -67,34 +75,35 @@ MaxHeap.prototype.increaseKey = function (index, value) { * @param {number} value The new value which will be inserted * @returns {number} The index of the inserted value */ -MaxHeap.prototype.add = function (value) { +Heap.prototype.add = function (value) { this._heap.push(value); - return this.increaseKey(this._heap.length - 1, value); + return this.changeKey(this._heap.length - 1, value); } /** * Gets the current value which is on the top of the heap. Complexity O(1). * * @public - * returns {numner} The current largest value which is on the top of the heap + * returns {numner} The current top value. */ -MaxHeap.prototype.max = function () { +Heap.prototype.top = function () { return this._heap[0]; } /** - * Remove and return the current maximum value which is on the top of the heap. + * Removes and returns the current extremum value which is on the top of the heap. * Complexity O(log n). * * @public - * @returns {number} max Extracted value + * @returns {number} The extremum value */ -MaxHeap.prototype.extractMax = function () { +Heap.prototype.extract = function () { if (!this._heap.length) throw new 'The heap is already empty!'; - var max = this._heap.shift(); + var extr = this._heap.shift(); this._heapify(0); - return max; + return extr; } +exports.Heap = Heap; diff --git a/src/graphs/dijkstra.js b/src/graphs/dijkstra.js new file mode 100644 index 00000000..3bbfdee5 --- /dev/null +++ b/src/graphs/dijkstra.js @@ -0,0 +1,112 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * + + A sample distance matrix + +var graph = [[NaN, 7, 9, NaN, NaN, 16], + [7, NaN, 10, 15, NaN, NaN], + [9, 10, NaN, 11, NaN, 2], + [NaN, 15, 11, NaN, 6, NaN], + [NaN, NaN, NaN, 6, NaN, 9], + [16, NaN, 2, NaN, 9, NaN]]; + +* * * * * * * * * * * * * * * * * * * * * * * */ + + +/** + * Dijstra's shortest path algorithm. + * For the implementation is not used the most suitable data structure (Fibonacci heap) + * but the binary heap gives also good results. The implementation bellow finds + * the minimum distance between two given nodes using a distance matrix. + */ +var dijstra = function () { + + var Heap = require('../data-structures/heap.js').Heap, + current, + visited, + distance, + unvisited; + + + /** + * Creates a new node instance + * + * @constructor + * @private + * @param {number} id The id of the node + * @param {number} distance The distance from the beginning + */ + function Node(id, distance) { + this.node = id; + this.distance = distance; + } + + /** + * Compares the distances between two nodes. + * + * @private + * @param {object} a A node + * @param {object} b A graph node + * @returns {number} The + */ + function compareNodesDistance(a, b) { + return b.distance - a.distance; + } + + /** + * Initialize all variables used for the algorithm + * + * @private + * @param {number} src A start node + */ + function init(src) { + var currentTemp; + current = {}; + visited = []; + distance = []; + unvisited = new Heap(compareNodesDistance); + for (var i = 0; i < graph.length; i += 1) { + currentTemp = new Node(); + if (src === i) { + currentTemp.distance = 0; + } else { + currentTemp.distance = Infinity; + } + currentTemp.node = i; + visited[i] = false; + distance[i] = currentTemp; + unvisited.add(currentTemp); + } + current.node = src; + current.distance = 0; + } + + /** + * Dijkstra's shortest path algorithm + * + * @public + * @param {number} src Source node + * @param {number} dest Destination node + * @param {array} graph A distance matrix of the graph + * @returns {number} The shortest distance between the nodes + */ + return function (src, dest, graph) { + var tempDistance = 0; + init(src); + while (current.node != dest && current.distance != Infinity) { + for (var i = 0; i < graph.length; i += 1) { + if (current.node !== i && //if it's not the current node + !visited[i] && //and if we haven't visited this node + !isNaN(graph[i][current.node])) { //and this node is sibling of the current... + + tempDistance = current.distance + graph[i][current.node]; + if (tempDistance < distance[i].distance) { + distance[i].distance = tempDistance; + } + } + } + visited[current.node] = true; + current = unvisited.extract(); + } + return distance[dest].distance; + }; +}(); From 733ba38eaa4014dfdc327a89a918321b64122706 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Wed, 2 Jan 2013 23:10:47 +0200 Subject: [PATCH 009/613] Usless line is removed from the bucket sort --- src/sorting/bucketsort.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sorting/bucketsort.js b/src/sorting/bucketsort.js index a9695577..35016ea9 100644 --- a/src/sorting/bucketsort.js +++ b/src/sorting/bucketsort.js @@ -101,7 +101,6 @@ var bucketSort = (function () { var buckets = createBuckets(array); sortBuckets(buckets); return unionBuckets(buckets); - return insertionSort([4,5,2,3,65,8,9,0]); } }()); From 1ec6cf11d2782695750dcb80328943af99bd2de4 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Fri, 4 Jan 2013 18:51:15 +0200 Subject: [PATCH 010/613] BFS and DFS are added --- src/graphs/bfs.js | 68 +++++++++++++++++++++++++++++++++++++++++++ src/graphs/dfs.js | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 src/graphs/bfs.js create mode 100644 src/graphs/dfs.js diff --git a/src/graphs/bfs.js b/src/graphs/bfs.js new file mode 100644 index 00000000..0ce987b8 --- /dev/null +++ b/src/graphs/bfs.js @@ -0,0 +1,68 @@ +/* * * * * * * * * * * * * * * * * * + + Sample graph + +var graph = [[1,0,1,0,0,0], + [0,1,0,1,0,0], + [1,0,1,0,1,0], + [0,1,0,1,1,0], + [0,0,1,1,1,1], + [0,0,0,0,1,1]]; +* * * * * * * * * * * * * * * * * */ + +/** + * Breadth-first search algorithm for matrix representation of graph. + * The algorithm finds whether there's a path between two given nodes. + */ +var breadthFirstSearch = function () { + + var visted = [], + queue = [], + target, + graph; + + /** + * Initializes the algorithm + * + * @private + * @param {array} inputGraph The input matrix of the graph + * @param {number} destination The destination + */ + function init(inputGraph, destination) { + graph = inputGraph; + target = destination; + visited = []; + queue = []; + for (var i = 0; i < graph.length; i += 1) + visited[i] = false; + } + + /** + * Finds whether there's a path between a given start node + * to given destination + * + * @public + * @param {array} graph A matrix representation of the graph + * @param {number} source The source node + * @param {number} destination The destination node + * @returns {boolean} true/false depending whether there's a path between the nodes + */ + return function (graph, source, destination) { + init(graph, destination); + var current; + queue.push(source); + while (queue.length > 0) { + current = queue.shift(); + visited[current] = true; + for (var i = 0; i < graph.length; i += 1) { + if (graph[current][i]) { + if (i === destination) + return true; + if (!visited[i]) + queue.push(i); + } + } + } + return false; + }; +}(); diff --git a/src/graphs/dfs.js b/src/graphs/dfs.js new file mode 100644 index 00000000..b758384b --- /dev/null +++ b/src/graphs/dfs.js @@ -0,0 +1,73 @@ +/* * * * * * * * * * * * * * * * * * + + Sample graph + +var graph = [[1,0,1,0,0,0], + [0,1,0,1,0,0], + [1,0,1,0,1,0], + [0,1,0,1,1,0], + [0,0,1,1,1,1], + [0,0,0,0,1,1]]; +* * * * * * * * * * * * * * * * * */ + +/** + * Depth-first search algorithm for matrix representation of graph. + * The algorithm finds whether there's a path between two given nodes. + */ +var depthFirstSearch = function () { + + var visted = [], + target, + graph; + + /** + * Returns whether the destination could be reached + * from given node + * + * @private + * @param {number} current Current node + * @returns {boolean} True/false depending whether + * the destination can be reached from the current node + */ + function dfs(current) { + if (current === target) return true; + visited[current] = true; + for (var i = 0; i < graph.length; i += 1) { + if (graph[current][i] === 1 && + !visited[i]) { + return depthFirstSearch(i); + } + } + return false; + } + + /** + * Initializes the algorithm + * + * @private + * @param {array} inputGraph The input matrix of the graph + * @param {number} destination The destination + */ + function init(inputGraph, destination) { + graph = inputGraph; + target = destination; + visited = []; + for (var i = 0; i < graph.length; i += 1) + visited[i] = false; + } + + /** + * Finds whether there's a path between a given start node + * to given destination + * + * @public + * @param {array} graph A matrix representation of the graph + * @param {number} source The source node + * @param {number} destination The destination node + * @returns {boolean} true/false depending whether there's a path between the nodes + */ + return function (graph, source, destination) { + init(graph, destination); + return dfs(source); + }; +}(); From add539706ebd1d1bbe733388445c068fc63c5736 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Tue, 12 Feb 2013 17:20:13 +0200 Subject: [PATCH 011/613] Floyd-Warshall algorithm is added --- src/graphs/floyd.js | 74 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/graphs/floyd.js diff --git a/src/graphs/floyd.js b/src/graphs/floyd.js new file mode 100644 index 00000000..88180c6b --- /dev/null +++ b/src/graphs/floyd.js @@ -0,0 +1,74 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * + + A sample distance matrix + +var graph = [[NaN, 7, 9, NaN, NaN, 16], + [7, NaN, 10, 15, NaN, NaN], + [9, 10, NaN, 11, NaN, 2], + [NaN, 15, 11, NaN, 6, NaN], + [NaN, NaN, NaN, 6, NaN, 9], + [16, NaN, 2, NaN, 9, NaN]]; + +* * * * * * * * * * * * * * * * * * * * * * * */ + +/** + * Finds the shortest distance between all vertices of the graph + * using the Floyd-Warshall algorithm. + * + * Complexity O(n^3) + */ +var floydWarshall = (function () { + + /** + * Matrix used for the algorithm. + */ + var dist; + + /** + * Initialize the distance matrix + * + * @private + * @param {array} graph Distance matrix of the array + * @return {array} Distance matrix used for the algorithm + */ + function init(graph) { + var dist = []; + var size = graph.length; + for (var i = 0; i < size; i += 1) { + dist[i] = []; + for (var j = 0; j < size; j += 1) { + if (i === j) { + dist[i][j] = 0; + } else if (isNaN(graph[i][j])) { + dist[i][j] = Infinity; + } else { + dist[i][j] = graph[i][j]; + } + } + } + return dist; + } + + /** + * Finds the shortest path between each two vertices + * Complexity O(n^3) + * + * @public + * @param {array} graph The graph which should be processed + * @return {array} The array which contains the shortest distance between each two vertices + */ + return function (graph) { + dist = init(graph); + var size = graph.length; + for (var k = 0; k < size; k += 1) { + for (var i = 0; i < size; i += 1) { + for (var j = 0; j < size; j += 1) { + if (dist[i][j] > dist[i][k] + dist[k][j]) { + dist[i][j] = dist[i][k] + dist[k][j]; + } + } + } + } + return dist; + } +}()); From bfffaaf511b671e000398008f78039e743a49a05 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Tue, 12 Feb 2013 22:24:28 +0200 Subject: [PATCH 012/613] Shellsort added --- src/sorting/shellsort.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/sorting/shellsort.js diff --git a/src/sorting/shellsort.js b/src/sorting/shellsort.js new file mode 100644 index 00000000..b340f6f9 --- /dev/null +++ b/src/sorting/shellsort.js @@ -0,0 +1,34 @@ +/** + * Shellsort + * + * Shellsort uses the gaps 701, 301, 132, 57, 23, 10, 4, 1 and uses insertion sort + * to sort the sub-arrays which match for the different gaps. + */ +var shellsort = (function () { + + var gaps = [701, 301, 132, 57, 23, 10, 4, 1]; + + /** + * Shellsort which uses the gaps in the lexical scope of the IIFE. + * + * @public + * @param {array} array Array which should be sorted + * @return {array} Sorted array + */ + return function (array) { + var gap, current; + + for (var k = 0; k < gaps.length; k += 1) { + gap = gaps[k]; + for (var i = gap; i < array.length; i += gap) { + current = array[i]; + for (var j = i; j >= gap && array[j - gap] > current; j -= gap) { + array[j] = array[j - gap]; + } + array[j] = current; + } + } + return array; + }; + +}()); From 92775cb6c6bc1c76e5c9b0e639abf4153afa8219 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Wed, 13 Feb 2013 20:15:58 +0200 Subject: [PATCH 013/613] Prim's algorithm for minimum spanning tree is added --- src/graphs/prim.js | 172 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 src/graphs/prim.js diff --git a/src/graphs/prim.js b/src/graphs/prim.js new file mode 100644 index 00000000..b5a4ee24 --- /dev/null +++ b/src/graphs/prim.js @@ -0,0 +1,172 @@ +var Heap = require('../data-structures/heap').Heap; + +/** + * Graph vertex + * + * @constructor + * @public + * @param {number} id The id of the vertex + */ +function Vertex(id) { + this.id = id; +} + +/** + * Graph edge + * + * @constructor + * @public + * @param {Vertex} e Vertex which this edge connects + * @param {Vertex} v Vertex which this edge connects + * @param {number} distance Weight of the node + */ +function Edge(e, v, distance) { + this.e = e; + this.v = v; + this.distance = distance; +} + +/** + * Graph + * + * @constructor + * @public + */ +function Graph(edges) { + console.log(edges); + this.edges = edges || []; +} + +/** + * Prim's algorithm for minimum spanning tree + * + * @public + * @return {Graph} Graph which is the minimum spanning tree + */ +Graph.prototype.prim = (function () { + + var queue; + + /** + * Initialize the algorithm. + * + * @private + */ + function init() { + queue = new Heap(compareEdges); + this.edges.forEach(function (e) { + queue.add(e); + }); + } + + /** + * Used for comparitions in the heap + * + * @private + * @param {Vertex} a First operand of the comparition + * @param {Vertex} b Second operand of the comparition + * @return {number} Number which which is equal, greater or less then zero and + * indicates whether the first vertex is "greater" than the second. + */ + function compareEdges(a, b) { + return b.distance - a.distance; + } + + /** + * Prim's algorithm implementation + * + * @public + * @return {Graph} Minimum spanning tree. + */ + return function () { + init.call(this); + var inTheTree = {}, + current = queue.extract(), + spannigTree = []; + spannigTree.push(current); + inTheTree[current.e.id] = true; + inTheTree[current.v.id] = true; + while (queue.isEmpty()) { + current = queue.extract(); + if (!inTheTree[current.v.id] || + !inTheTree[current.e.id]) { + spannigTree.push(current); + inTheTree[current.e.id] = true; + inTheTree[current.v.id] = true; + } + } + return new Graph(spannigTree); + }; + +}()); + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * Sample graph * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +var graph; + +(function () { + var edges = []; + + edges.push(new Edge( + new Vertex(0), + new Vertex(1), + 7 + )); + + edges.push(new Edge( + new Vertex(0), + new Vertex(2), + 9 + )); + + edges.push(new Edge( + new Vertex(0), + new Vertex(5), + 16 + )); + + edges.push(new Edge( + new Vertex(1), + new Vertex(2), + 10 + )); + + edges.push(new Edge( + new Vertex(1), + new Vertex(3), + 15 + )); + + edges.push(new Edge( + new Vertex(2), + new Vertex(3), + 11 + )); + + edges.push(new Edge( + new Vertex(2), + new Vertex(5), + 2 + )); + + edges.push(new Edge( + new Vertex(3), + new Vertex(4), + 6 + )); + + edges.push(new Edge( + new Vertex(4), + new Vertex(5), + 9 + )); + + graph = new Graph(edges); + +}()); + +console.log(graph.prim()); + +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ From 4cfd49342ce4cdb2e36eaeba8ce95519eb18a192 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Tue, 19 Feb 2013 16:07:40 +0200 Subject: [PATCH 014/613] Bucketsort validated by JSHint --- src/sorting/bucketsort.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sorting/bucketsort.js b/src/sorting/bucketsort.js index 35016ea9..b7c06a59 100644 --- a/src/sorting/bucketsort.js +++ b/src/sorting/bucketsort.js @@ -45,6 +45,7 @@ var bucketSort = (function () { sectorSize = 1 / array.length; for (var i = 0; i < array.length; i += 1) { current = array[i]; + console.log(current / sectorSize); currentBucket = Math.floor(current / sectorSize); if (buckets[currentBucket] === undefined) { buckets[currentBucket] = []; @@ -101,7 +102,7 @@ var bucketSort = (function () { var buckets = createBuckets(array); sortBuckets(buckets); return unionBuckets(buckets); - } + }; }()); console.log(bucketSort(array)); From 0521702040aa8a877dc5ebd3e51c48f295572816 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Tue, 19 Feb 2013 22:31:45 +0200 Subject: [PATCH 015/613] JSHint validation for the sorting algorithms --- src/sorting/countingsort.js | 2 +- src/sorting/mergesort.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sorting/countingsort.js b/src/sorting/countingsort.js index 691fb34b..d98a8c4c 100644 --- a/src/sorting/countingsort.js +++ b/src/sorting/countingsort.js @@ -82,7 +82,7 @@ var countingSort = function () { return function (array) { var less = getLessCount(getCount(array)); return sort(array, less); - } + }; }(); console.log(countingSort(array)); diff --git a/src/sorting/mergesort.js b/src/sorting/mergesort.js index bf64a970..5b9b3a67 100644 --- a/src/sorting/mergesort.js +++ b/src/sorting/mergesort.js @@ -75,6 +75,6 @@ var mergeSort = (function () { */ return function (array) { return mergesort(array, 0, array.length); - } + }; }()); From 32a6206261c8aedb2d9ef3e55ff2b03ae38449d3 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Tue, 19 Feb 2013 23:10:55 +0200 Subject: [PATCH 016/613] Selection sort is fixed --- src/sorting/selectionsort.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/sorting/selectionsort.js b/src/sorting/selectionsort.js index 25386443..92c862bb 100644 --- a/src/sorting/selectionsort.js +++ b/src/sorting/selectionsort.js @@ -1,22 +1,25 @@ -var array = [2,3,1,1,2,4,6,7,8,2,3,5,6,8]; - +/** + * Selection sort. It's complexity is O(n^2) + * + * @public + * @param {array} array Array to be sorted + * @return {array} The sorted array + */ function selectionSort(array) { - var min, - idx, - temp; + var min, idx, temp; for (var i = 0; i < array.length; i += 1) { - min = Infinity; - for (var j = i + 1; j < array.length; j += 1) { - if (min > array[j]) { - min = array[j]; - idx = j; - } - } - temp = array[idx]; - array[idx] = array[i]; - array[i] = temp; + idx = i; + min = array[i]; + for (var j = i + 1; j < array.length; j += 1) { + if (min > array[j]) { + min = array[j]; + idx = j; + } + } + temp = array[i]; + array[i] = min; + array[idx] = temp; } return array; } -console.log(selectionSort(array)); From d0d208d07ead87fdf4951f9b1ce6fa9d4d5137ec Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Wed, 20 Feb 2013 12:59:42 +0200 Subject: [PATCH 017/613] Refactoring of the directory tree + quicksort with middle element for pivot --- src/sorting/bubblesort/bubblesort.js | 24 ++++ src/sorting/heapsort/heapsort.js | 72 ++++++++++++ .../insertionsort/insertion-binary-sort.js | 37 ++++++ src/sorting/insertionsort/insertionsort.js | 25 ++++ .../insertionsort/recursive-insertionsort.js | 22 ++++ src/sorting/linearsort/bucketsort.js | 108 ++++++++++++++++++ src/sorting/linearsort/countingsort.js | 88 ++++++++++++++ src/sorting/mergesort/mergesort.js | 80 +++++++++++++ src/sorting/quicksort/quicksort-middle.js | 72 ++++++++++++ src/sorting/quicksort/quicksort.js | 78 +++++++++++++ src/sorting/selectionsort/selectionsort.js | 25 ++++ src/sorting/shellsort/shellsort.js | 34 ++++++ 12 files changed, 665 insertions(+) create mode 100644 src/sorting/bubblesort/bubblesort.js create mode 100644 src/sorting/heapsort/heapsort.js create mode 100644 src/sorting/insertionsort/insertion-binary-sort.js create mode 100644 src/sorting/insertionsort/insertionsort.js create mode 100644 src/sorting/insertionsort/recursive-insertionsort.js create mode 100644 src/sorting/linearsort/bucketsort.js create mode 100644 src/sorting/linearsort/countingsort.js create mode 100644 src/sorting/mergesort/mergesort.js create mode 100644 src/sorting/quicksort/quicksort-middle.js create mode 100644 src/sorting/quicksort/quicksort.js create mode 100644 src/sorting/selectionsort/selectionsort.js create mode 100644 src/sorting/shellsort/shellsort.js diff --git a/src/sorting/bubblesort/bubblesort.js b/src/sorting/bubblesort/bubblesort.js new file mode 100644 index 00000000..21c25bce --- /dev/null +++ b/src/sorting/bubblesort/bubblesort.js @@ -0,0 +1,24 @@ +var array = [3,5,2,4,7,9,6,4,5]; + +/** + * The bubblesort algorithm. Complexity O(n^2). + * + * @public + * @param {array} array Input array + * @returns {array} array Sorted array + */ +function bubbleSort(array) { + var temp; + for (var i = 0; i < array.length; i += 1) { + for (var j = i; j > 0; j -= 1) { + if (array[j] < array[j - 1]) { + temp = array[j]; + array[j] = array[j - 1]; + array[j - 1] = temp; + } + } + } + return array; +} + +console.log(bubbleSort(array)); diff --git a/src/sorting/heapsort/heapsort.js b/src/sorting/heapsort/heapsort.js new file mode 100644 index 00000000..6bbb7088 --- /dev/null +++ b/src/sorting/heapsort/heapsort.js @@ -0,0 +1,72 @@ +var array = [3,4,6,2,3,6,8,9]; + +/** + * The heapsort algorithm. It's complexity is O(nlog n). + * + * @public + */ +var heapSort = (function () { + + /** + * Finds the correct place of given element in given max heap. + * + * @private + * @param {array} array Array + * @param {number} index Index of the element which palce in the max heap should be found. + */ + function heapify(array, index, heapSize) { + var left = 2 * index + 1, + right = 2 * index + 2, + largest = index; + + if (left < heapSize && array[left] > array[index]) + largest = left; + + if (right < heapSize && array[right] > array[largest]) + largest = right; + + if (largest !== index) { + var temp = array[index]; + array[index] = array[largest]; + array[largest] = temp; + heapify(array, largest, heapSize); + } + } + + /** + * Builds max heap from given array. + * + * @private + * @param {array} array Array which should be turned into max heap + * @returns {array} array Array turned into max heap + */ + function buildMaxHeap(array) { + for (var i = Math.floor(array.length / 2); i >= 0; i -= 1) { + heapify(array, i, array.length); + } + return array; + } + + /** + * Heapsort. Turns the input array into max heap and after that sorts it. + * + * @public + * @param {array} array Input array + * @returns {array} array Sorted array + */ + return function (array) { + var size = array.length, + temp; + buildMaxHeap(array); + for (var i = array.length - 1; i > 0; i -= 1) { + temp = array[0]; + array[0] = array[i]; + array[i] = temp; + size -= 1; + heapify(array, 0, size); + } + return array; + }; +}()); + +console.log(heapSort(array)); diff --git a/src/sorting/insertionsort/insertion-binary-sort.js b/src/sorting/insertionsort/insertion-binary-sort.js new file mode 100644 index 00000000..86e780fd --- /dev/null +++ b/src/sorting/insertionsort/insertion-binary-sort.js @@ -0,0 +1,37 @@ +var array = [5,6,3,3,6,8,9,4,3]; + +/** + * Modified version of insertionsort. It uses binary search for finding + * where the current element should be inserted. It's correct because + * the binary search looks just in the first part of the array + * which is actually sorted. It's complexity is O(n^2) + * + * @public + * @param {array} array Input array + * @param {array} array Sorted array + */ +function insertionBinarySort(array) { + var current, + middle, + left, + right; + for (var i = 1; i < array.length; i += 1) { + current = array[i]; + left = 0; + right = i; + middle = Math.floor((left + right) / 2); + while (left < right) { + if (array[middle] <= current) + left = middle + 1; + else + right = middle - 1; + middle = Math.floor((left + right) / 2); + } + for (var j = i; j > middle; j -= 1) + array[j] = array[j - 1]; + array[j] = current; + } + return array; +} + +console.log(insertionBinarySort(array)); diff --git a/src/sorting/insertionsort/insertionsort.js b/src/sorting/insertionsort/insertionsort.js new file mode 100644 index 00000000..4e9546da --- /dev/null +++ b/src/sorting/insertionsort/insertionsort.js @@ -0,0 +1,25 @@ +var array = [2,3,5,1,2,4,7,9,0,3,3]; + +/** + * Insertionsort algorithm. It's complexity is O(n^2). + * + * @public + * @param {array} array Input array + * @returns {array} array Sorted array + */ +function insertionSort(array) { + var current, + j; + for (var i = 1; i < array.length; i += 1) { + current = array[i]; + j = i - 1; + while (j >= 0 && array[j] > current) { + array[j + 1] = array[j]; + j -= 1; + } + array[j + 1] = current; + } + return array; +} + +console.log(insertionSort(array)); diff --git a/src/sorting/insertionsort/recursive-insertionsort.js b/src/sorting/insertionsort/recursive-insertionsort.js new file mode 100644 index 00000000..4c58a342 --- /dev/null +++ b/src/sorting/insertionsort/recursive-insertionsort.js @@ -0,0 +1,22 @@ +var array = [4,6,2,2,4,56,7,7,51,23,5,7]; + +/** + * Recursive version of insertionsort. Complexity O(n^2). + * + * @public + * @param {array} array Input array + * @param {number} [max] Index of the element which place we should find in the current function call + */ +function recursiveInsertionSort(array, max) { + if (max <= 0) + return array; + if (max === undefined) + max = array.length - 1; + recursiveInsertionSort(array, max - 1); + for (var i = max - 1, current = array[max]; i >= 0 && current < array[i]; i -= 1) + array[i + 1] = array[i]; + array[i + 1] = current; + return array; +} + +console.log(recursiveInsertionSort(array)); diff --git a/src/sorting/linearsort/bucketsort.js b/src/sorting/linearsort/bucketsort.js new file mode 100644 index 00000000..b7c06a59 --- /dev/null +++ b/src/sorting/linearsort/bucketsort.js @@ -0,0 +1,108 @@ +var array = [0.21, 0.44, 0.221, 0.01, 0.88]; + +/** + * Bucketsort. This algorithm has complexity O(n) but it's not + * correct for every input. + * + * @public + */ +var bucketSort = (function () { + + /** + * Insertionsort. + * + * @private + * @param {array} array Input array + * @returns {array} array Sorted input array + */ + function insertionSort(array) { + var current, + j; + for (var i = 1; i < array.length; i += 1) { + current = array[i]; + j = i - 1; + while (j >= 0 && current < array[j]) { + array[j + 1] = array[j]; + j -= 1; + } + array[j + 1] = current; + } + return array; + } + + /** + * Creates buckets for given array + * + * @private + * @param {array} array Input array + * @returns {array} buckets Array whith array for each bucket. + * Each bucket contains an array with all elements from the input which are with suitable size. + */ + function createBuckets(array) { + var buckets = [], + currentBucket, + current, + sectorSize = 1 / array.length; + for (var i = 0; i < array.length; i += 1) { + current = array[i]; + console.log(current / sectorSize); + currentBucket = Math.floor(current / sectorSize); + if (buckets[currentBucket] === undefined) { + buckets[currentBucket] = []; + } + buckets[currentBucket].push(current); + } + return buckets; + } + + /** + * Sorts the arrays from each bucket. + * + * @private + * @param {array} buckets Given buckets + * @returns {array} buckets Buckets with sorted arrays for each bucket + */ + function sortBuckets(buckets) { + for (var i = 0; i < buckets.length; i += 1) { + if (buckets[i] !== undefined) + insertionSort(buckets[i]); + } + return buckets; + } + + /** + * Unions all buckets' arrays + * + * @private + * @param {array} buckets Input buckets + * @returns {array} result Sorted array which contains all elements form each bucket + */ + function unionBuckets(buckets) { + var result = [], + currentBucket; + for (var i = 0; i < buckets.length; i += 1) { + currentBucket = buckets[i]; + if (currentBucket !== undefined) { + for (var j = 0; j < currentBucket.length; j += 1) { + result.push(currentBucket[j]); + } + } + } + return result; + } + + /** + * Sorts given array with bucketsort + * + * @public + * @param {array} array Input array which should be sorted + * @returns {array} Sorted array + */ + return function (array) { + var buckets = createBuckets(array); + sortBuckets(buckets); + return unionBuckets(buckets); + }; +}()); + +console.log(bucketSort(array)); diff --git a/src/sorting/linearsort/countingsort.js b/src/sorting/linearsort/countingsort.js new file mode 100644 index 00000000..d98a8c4c --- /dev/null +++ b/src/sorting/linearsort/countingsort.js @@ -0,0 +1,88 @@ +var array = [44,2,34,6,7,34,4,4,2,3,6,8]; + +/** + * Counting sort algorithm. It's with complexity O(n) but it's + * correct for specific input. + * + * @public + */ +var countingSort = function () { + + /** + * Gets the count of the elements into the input array + * + * @private + * @param {array} array The input array + * @returns {array} count The count of each element from the input array + */ + function getCount(array) { + var count = [], + current; + for (var i = 0; i < array.length; i += 1) { + current = array[i]; + if (count[current] !== undefined) { + count[current] += 1; + } else { + count[current] = 1; + } + } + return count; + } + + /** + * Gets the count of the elements which are less than a given + * + * @private + * @param {array} array The input array + * @returns {array} less The count of the elements which are less than each element from the input + */ + function getLessCount(array) { + var less = [], + last; + less[0] = array[0] || 0; + for (var i = 1; i < array.length; i += 1) { + last = array[i - 1] || 0; + less[i] = last + less[i - 1]; + } + return less; + } + + /** + * Sorts the input array + * + * @private + * @param {array} array Input which should be sorted + * @param {array} less Count of the less elements for each element + * @returns {array} result The sorted input + */ + function sort(array, less) { + var result = [], + currentPositions = [], + current, + position; + for (var i = 0; i < array.length; i += 1) { + current = array[i]; + position = less[current]; + if (currentPositions[current] === undefined) { + currentPositions[current] = position; + } + result[currentPositions[current]] = current; + currentPositions[current] += 1; + } + return result; + } + + /** + * Sorts a given array + * + * @public + * @param {array} array Array which should be sorted + * @returns {array} array Sorted array + */ + return function (array) { + var less = getLessCount(getCount(array)); + return sort(array, less); + }; +}(); + +console.log(countingSort(array)); diff --git a/src/sorting/mergesort/mergesort.js b/src/sorting/mergesort/mergesort.js new file mode 100644 index 00000000..5b9b3a67 --- /dev/null +++ b/src/sorting/mergesort/mergesort.js @@ -0,0 +1,80 @@ + +var mergeSort = (function () { + /** + * Mergesort method which is recursively called for sorting the input array. + * + * @private + * @param {array} array The array which should be sorted + * @param {number} start Left side of the subarray + * @param {number} end Right side of the subarray + * @returns {array} Array with sorted subarray + */ + function mergesort(array, start, end) { + if (Math.abs(end - start) <= 1) { + return []; + } + var middle = Math.ceil((start + end) / 2); + + mergesort(array, start, middle); + mergesort(array, middle, end); + + return merge(array, start, middle, end); + } + + /** + * Devides and sort merges two subarrays of given array + * + * @private + * @param {array} array The array which subarrays should be sorted + * @param {number} start The start of the first subarray. This subarray is with end middle - 1. + * @param {number} middle The start of the second array + * @param {number} end end - 1 is the end of the second array + * @returns {array} The array with sorted subarray + */ + function merge(array, start, middle, end) { + var left = [], + right = [], + leftSize = middle - start, + rightSize = end - middle, + maxSize = Math.max(leftSize, rightSize), + size = end - start, + i; + + for (i = 0; i < maxSize; i += 1) { + if (i < leftSize) { + left[i] = array[start + i]; + } + if (i < rightSize) { + right[i] = array[middle + i]; + } + } + i = 0; + while (i < size) { + if (left.length && right.length) { + if (left[0] >= right[0]) { + array[start + i] = right.shift(); + } else { + array[start + i] = left.shift(); + } + } else if (left.length) { + array[start + i] = left.shift(); + } else { + array[start + i] = right.shift(); + } + i += 1; + } + return array; + } + + /** + * Initial call to the mergesort method + * + * @public + * @param {array} array The array which will be sorted + * @returns {array} Sorted array + */ + return function (array) { + return mergesort(array, 0, array.length); + }; + +}()); diff --git a/src/sorting/quicksort/quicksort-middle.js b/src/sorting/quicksort/quicksort-middle.js new file mode 100644 index 00000000..f5f63077 --- /dev/null +++ b/src/sorting/quicksort/quicksort-middle.js @@ -0,0 +1,72 @@ +/** + * Quicksort algorithm. It's with complexity O(n log(n)). + * In this version of quicksort I use the middle element of the + * array for pivot. + */ + + +/** + * Quicksort algorithm + * + * @public + * @param {array} array Array which should be sorted. + * @return {array} Sorted array. + */ +var quicksort = (function () { + + /** + * Partitions the array in two parts by the middle elements. + * All elemnts which are less than the chosen one goes left from it + * all which are greater goes right from it. + * + * @param {array} array Array which should be partitioned + * @param {number} left Left part of the array + * @param {number} right Right part of the array + * @return {number} + */ + function partition(array, left, right) { + var pivot = array[Math.floor((left + right) / 2)], + temp; + while (left <= right) { + while (array[left] < pivot) + left += 1; + while (array[right] > pivot) + right -= 1; + if (left <= right) { + temp = array[left]; + array[left] = array[right]; + array[right] = temp; + left += 1; + right -= 1; + } + } + return left; + } + + /** + * Recursively calls itself with different values for + * left/right part of the array which should be processed + * + * @private + * @param {array} array Array which should be processed + * @param {number} left Left part of the array which should be processed + * @param {number} right Right part of the array which should be processed + */ + function quicksort(array, left, right) { + var mid = partition(array, left, right); + if (left < mid - 1) + quicksort(array, left, mid - 1); + if (right > mid) + quicksort(array, mid, right); + } + + /** + * Quicksort's initial point + * @public + */ + return function (array) { + quicksort(array, 0, array.length - 1); + return array; + }; + +}()); diff --git a/src/sorting/quicksort/quicksort.js b/src/sorting/quicksort/quicksort.js new file mode 100644 index 00000000..ffb66797 --- /dev/null +++ b/src/sorting/quicksort/quicksort.js @@ -0,0 +1,78 @@ +var array = [3,4,7,3,3,5,8,3,34,3,7,9]; + +/** + * The quicksort algorithm. It's complexity is O(nlog n). + * + * @public + */ +var quickSort = (function () { + + /** + * Partitions given subarray. + * + * @private + * @param {array} array Input array + * @param {number} left The start of the subarray + * @param {number} right The end of the subarray + */ + function partition(array, left, right) { + var cmp = array[right - 1], + minEnd = left, + maxEnd; + for (maxEnd = left; maxEnd < right - 1; maxEnd += 1) { + if (array[maxEnd] <= cmp) { + swap(array, maxEnd, minEnd); + minEnd += 1; + } + } + swap(array, minEnd, right - 1); + return minEnd; + } + + /** + * Swap the places of two elements + * + * @private + * @param {array} array The array which contains the elements + * @param {number} i The index of the first element + * @param {number} j The index of the second element + * @returns {array} array The array with swaped elements + */ + function swap(array, i, j) { + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + return array; + } + + /** + * Sorts given array. + * + * @private + * @param {array} array Array which should be sorted + * @param {number} left The start of the subarray which should be handled + * @param {number} right The end of the subarray which should be handled + * @returns {array} array Sorted array + */ + function quickSort(array, left, right) { + if (left < right) { + var p = partition(array, left, right); + quickSort(array, left, p); + quickSort(array, p + 1, right); + } + return array; + } + + /** + * Calls the quicksort function with it's initial values. + * + * @public + * @param {array} array The input array which should be sorted + * @returns {array} array Sorted array + */ + return function (array) { + return quickSort(array, 0, array.length); + }; +}()); + +console.log(quickSort(array)); diff --git a/src/sorting/selectionsort/selectionsort.js b/src/sorting/selectionsort/selectionsort.js new file mode 100644 index 00000000..92c862bb --- /dev/null +++ b/src/sorting/selectionsort/selectionsort.js @@ -0,0 +1,25 @@ +/** + * Selection sort. It's complexity is O(n^2) + * + * @public + * @param {array} array Array to be sorted + * @return {array} The sorted array + */ +function selectionSort(array) { + var min, idx, temp; + for (var i = 0; i < array.length; i += 1) { + idx = i; + min = array[i]; + for (var j = i + 1; j < array.length; j += 1) { + if (min > array[j]) { + min = array[j]; + idx = j; + } + } + temp = array[i]; + array[i] = min; + array[idx] = temp; + } + return array; +} + diff --git a/src/sorting/shellsort/shellsort.js b/src/sorting/shellsort/shellsort.js new file mode 100644 index 00000000..b340f6f9 --- /dev/null +++ b/src/sorting/shellsort/shellsort.js @@ -0,0 +1,34 @@ +/** + * Shellsort + * + * Shellsort uses the gaps 701, 301, 132, 57, 23, 10, 4, 1 and uses insertion sort + * to sort the sub-arrays which match for the different gaps. + */ +var shellsort = (function () { + + var gaps = [701, 301, 132, 57, 23, 10, 4, 1]; + + /** + * Shellsort which uses the gaps in the lexical scope of the IIFE. + * + * @public + * @param {array} array Array which should be sorted + * @return {array} Sorted array + */ + return function (array) { + var gap, current; + + for (var k = 0; k < gaps.length; k += 1) { + gap = gaps[k]; + for (var i = gap; i < array.length; i += gap) { + current = array[i]; + for (var j = i; j >= gap && array[j - gap] > current; j -= gap) { + array[j] = array[j - gap]; + } + array[j] = current; + } + } + return array; + }; + +}()); From 78654c17e4d0ad54b8dae140141d8b6e352550a8 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Wed, 20 Feb 2013 13:00:09 +0200 Subject: [PATCH 018/613] Old files removed --- src/sorting/bubblesort.js | 24 ------ src/sorting/bucketsort.js | 108 ------------------------- src/sorting/countingsort.js | 88 -------------------- src/sorting/heapsort.js | 72 ----------------- src/sorting/insertion-binary-sort.js | 37 --------- src/sorting/insertionsort.js | 25 ------ src/sorting/mergesort.js | 80 ------------------ src/sorting/quicksort.js | 78 ------------------ src/sorting/recursive-insertionsort.js | 22 ----- src/sorting/selectionsort.js | 25 ------ src/sorting/shellsort.js | 34 -------- 11 files changed, 593 deletions(-) delete mode 100644 src/sorting/bubblesort.js delete mode 100644 src/sorting/bucketsort.js delete mode 100644 src/sorting/countingsort.js delete mode 100644 src/sorting/heapsort.js delete mode 100644 src/sorting/insertion-binary-sort.js delete mode 100644 src/sorting/insertionsort.js delete mode 100644 src/sorting/mergesort.js delete mode 100644 src/sorting/quicksort.js delete mode 100644 src/sorting/recursive-insertionsort.js delete mode 100644 src/sorting/selectionsort.js delete mode 100644 src/sorting/shellsort.js diff --git a/src/sorting/bubblesort.js b/src/sorting/bubblesort.js deleted file mode 100644 index 21c25bce..00000000 --- a/src/sorting/bubblesort.js +++ /dev/null @@ -1,24 +0,0 @@ -var array = [3,5,2,4,7,9,6,4,5]; - -/** - * The bubblesort algorithm. Complexity O(n^2). - * - * @public - * @param {array} array Input array - * @returns {array} array Sorted array - */ -function bubbleSort(array) { - var temp; - for (var i = 0; i < array.length; i += 1) { - for (var j = i; j > 0; j -= 1) { - if (array[j] < array[j - 1]) { - temp = array[j]; - array[j] = array[j - 1]; - array[j - 1] = temp; - } - } - } - return array; -} - -console.log(bubbleSort(array)); diff --git a/src/sorting/bucketsort.js b/src/sorting/bucketsort.js deleted file mode 100644 index b7c06a59..00000000 --- a/src/sorting/bucketsort.js +++ /dev/null @@ -1,108 +0,0 @@ -var array = [0.21, 0.44, 0.221, 0.01, 0.88]; - -/** - * Bucketsort. This algorithm has complexity O(n) but it's not - * correct for every input. - * - * @public - */ -var bucketSort = (function () { - - /** - * Insertionsort. - * - * @private - * @param {array} array Input array - * @returns {array} array Sorted input array - */ - function insertionSort(array) { - var current, - j; - for (var i = 1; i < array.length; i += 1) { - current = array[i]; - j = i - 1; - while (j >= 0 && current < array[j]) { - array[j + 1] = array[j]; - j -= 1; - } - array[j + 1] = current; - } - return array; - } - - /** - * Creates buckets for given array - * - * @private - * @param {array} array Input array - * @returns {array} buckets Array whith array for each bucket. - * Each bucket contains an array with all elements from the input which are with suitable size. - */ - function createBuckets(array) { - var buckets = [], - currentBucket, - current, - sectorSize = 1 / array.length; - for (var i = 0; i < array.length; i += 1) { - current = array[i]; - console.log(current / sectorSize); - currentBucket = Math.floor(current / sectorSize); - if (buckets[currentBucket] === undefined) { - buckets[currentBucket] = []; - } - buckets[currentBucket].push(current); - } - return buckets; - } - - /** - * Sorts the arrays from each bucket. - * - * @private - * @param {array} buckets Given buckets - * @returns {array} buckets Buckets with sorted arrays for each bucket - */ - function sortBuckets(buckets) { - for (var i = 0; i < buckets.length; i += 1) { - if (buckets[i] !== undefined) - insertionSort(buckets[i]); - } - return buckets; - } - - /** - * Unions all buckets' arrays - * - * @private - * @param {array} buckets Input buckets - * @returns {array} result Sorted array which contains all elements form each bucket - */ - function unionBuckets(buckets) { - var result = [], - currentBucket; - for (var i = 0; i < buckets.length; i += 1) { - currentBucket = buckets[i]; - if (currentBucket !== undefined) { - for (var j = 0; j < currentBucket.length; j += 1) { - result.push(currentBucket[j]); - } - } - } - return result; - } - - /** - * Sorts given array with bucketsort - * - * @public - * @param {array} array Input array which should be sorted - * @returns {array} Sorted array - */ - return function (array) { - var buckets = createBuckets(array); - sortBuckets(buckets); - return unionBuckets(buckets); - }; -}()); - -console.log(bucketSort(array)); diff --git a/src/sorting/countingsort.js b/src/sorting/countingsort.js deleted file mode 100644 index d98a8c4c..00000000 --- a/src/sorting/countingsort.js +++ /dev/null @@ -1,88 +0,0 @@ -var array = [44,2,34,6,7,34,4,4,2,3,6,8]; - -/** - * Counting sort algorithm. It's with complexity O(n) but it's - * correct for specific input. - * - * @public - */ -var countingSort = function () { - - /** - * Gets the count of the elements into the input array - * - * @private - * @param {array} array The input array - * @returns {array} count The count of each element from the input array - */ - function getCount(array) { - var count = [], - current; - for (var i = 0; i < array.length; i += 1) { - current = array[i]; - if (count[current] !== undefined) { - count[current] += 1; - } else { - count[current] = 1; - } - } - return count; - } - - /** - * Gets the count of the elements which are less than a given - * - * @private - * @param {array} array The input array - * @returns {array} less The count of the elements which are less than each element from the input - */ - function getLessCount(array) { - var less = [], - last; - less[0] = array[0] || 0; - for (var i = 1; i < array.length; i += 1) { - last = array[i - 1] || 0; - less[i] = last + less[i - 1]; - } - return less; - } - - /** - * Sorts the input array - * - * @private - * @param {array} array Input which should be sorted - * @param {array} less Count of the less elements for each element - * @returns {array} result The sorted input - */ - function sort(array, less) { - var result = [], - currentPositions = [], - current, - position; - for (var i = 0; i < array.length; i += 1) { - current = array[i]; - position = less[current]; - if (currentPositions[current] === undefined) { - currentPositions[current] = position; - } - result[currentPositions[current]] = current; - currentPositions[current] += 1; - } - return result; - } - - /** - * Sorts a given array - * - * @public - * @param {array} array Array which should be sorted - * @returns {array} array Sorted array - */ - return function (array) { - var less = getLessCount(getCount(array)); - return sort(array, less); - }; -}(); - -console.log(countingSort(array)); diff --git a/src/sorting/heapsort.js b/src/sorting/heapsort.js deleted file mode 100644 index 6bbb7088..00000000 --- a/src/sorting/heapsort.js +++ /dev/null @@ -1,72 +0,0 @@ -var array = [3,4,6,2,3,6,8,9]; - -/** - * The heapsort algorithm. It's complexity is O(nlog n). - * - * @public - */ -var heapSort = (function () { - - /** - * Finds the correct place of given element in given max heap. - * - * @private - * @param {array} array Array - * @param {number} index Index of the element which palce in the max heap should be found. - */ - function heapify(array, index, heapSize) { - var left = 2 * index + 1, - right = 2 * index + 2, - largest = index; - - if (left < heapSize && array[left] > array[index]) - largest = left; - - if (right < heapSize && array[right] > array[largest]) - largest = right; - - if (largest !== index) { - var temp = array[index]; - array[index] = array[largest]; - array[largest] = temp; - heapify(array, largest, heapSize); - } - } - - /** - * Builds max heap from given array. - * - * @private - * @param {array} array Array which should be turned into max heap - * @returns {array} array Array turned into max heap - */ - function buildMaxHeap(array) { - for (var i = Math.floor(array.length / 2); i >= 0; i -= 1) { - heapify(array, i, array.length); - } - return array; - } - - /** - * Heapsort. Turns the input array into max heap and after that sorts it. - * - * @public - * @param {array} array Input array - * @returns {array} array Sorted array - */ - return function (array) { - var size = array.length, - temp; - buildMaxHeap(array); - for (var i = array.length - 1; i > 0; i -= 1) { - temp = array[0]; - array[0] = array[i]; - array[i] = temp; - size -= 1; - heapify(array, 0, size); - } - return array; - }; -}()); - -console.log(heapSort(array)); diff --git a/src/sorting/insertion-binary-sort.js b/src/sorting/insertion-binary-sort.js deleted file mode 100644 index 86e780fd..00000000 --- a/src/sorting/insertion-binary-sort.js +++ /dev/null @@ -1,37 +0,0 @@ -var array = [5,6,3,3,6,8,9,4,3]; - -/** - * Modified version of insertionsort. It uses binary search for finding - * where the current element should be inserted. It's correct because - * the binary search looks just in the first part of the array - * which is actually sorted. It's complexity is O(n^2) - * - * @public - * @param {array} array Input array - * @param {array} array Sorted array - */ -function insertionBinarySort(array) { - var current, - middle, - left, - right; - for (var i = 1; i < array.length; i += 1) { - current = array[i]; - left = 0; - right = i; - middle = Math.floor((left + right) / 2); - while (left < right) { - if (array[middle] <= current) - left = middle + 1; - else - right = middle - 1; - middle = Math.floor((left + right) / 2); - } - for (var j = i; j > middle; j -= 1) - array[j] = array[j - 1]; - array[j] = current; - } - return array; -} - -console.log(insertionBinarySort(array)); diff --git a/src/sorting/insertionsort.js b/src/sorting/insertionsort.js deleted file mode 100644 index 4e9546da..00000000 --- a/src/sorting/insertionsort.js +++ /dev/null @@ -1,25 +0,0 @@ -var array = [2,3,5,1,2,4,7,9,0,3,3]; - -/** - * Insertionsort algorithm. It's complexity is O(n^2). - * - * @public - * @param {array} array Input array - * @returns {array} array Sorted array - */ -function insertionSort(array) { - var current, - j; - for (var i = 1; i < array.length; i += 1) { - current = array[i]; - j = i - 1; - while (j >= 0 && array[j] > current) { - array[j + 1] = array[j]; - j -= 1; - } - array[j + 1] = current; - } - return array; -} - -console.log(insertionSort(array)); diff --git a/src/sorting/mergesort.js b/src/sorting/mergesort.js deleted file mode 100644 index 5b9b3a67..00000000 --- a/src/sorting/mergesort.js +++ /dev/null @@ -1,80 +0,0 @@ - -var mergeSort = (function () { - /** - * Mergesort method which is recursively called for sorting the input array. - * - * @private - * @param {array} array The array which should be sorted - * @param {number} start Left side of the subarray - * @param {number} end Right side of the subarray - * @returns {array} Array with sorted subarray - */ - function mergesort(array, start, end) { - if (Math.abs(end - start) <= 1) { - return []; - } - var middle = Math.ceil((start + end) / 2); - - mergesort(array, start, middle); - mergesort(array, middle, end); - - return merge(array, start, middle, end); - } - - /** - * Devides and sort merges two subarrays of given array - * - * @private - * @param {array} array The array which subarrays should be sorted - * @param {number} start The start of the first subarray. This subarray is with end middle - 1. - * @param {number} middle The start of the second array - * @param {number} end end - 1 is the end of the second array - * @returns {array} The array with sorted subarray - */ - function merge(array, start, middle, end) { - var left = [], - right = [], - leftSize = middle - start, - rightSize = end - middle, - maxSize = Math.max(leftSize, rightSize), - size = end - start, - i; - - for (i = 0; i < maxSize; i += 1) { - if (i < leftSize) { - left[i] = array[start + i]; - } - if (i < rightSize) { - right[i] = array[middle + i]; - } - } - i = 0; - while (i < size) { - if (left.length && right.length) { - if (left[0] >= right[0]) { - array[start + i] = right.shift(); - } else { - array[start + i] = left.shift(); - } - } else if (left.length) { - array[start + i] = left.shift(); - } else { - array[start + i] = right.shift(); - } - i += 1; - } - return array; - } - - /** - * Initial call to the mergesort method - * - * @public - * @param {array} array The array which will be sorted - * @returns {array} Sorted array - */ - return function (array) { - return mergesort(array, 0, array.length); - }; - -}()); diff --git a/src/sorting/quicksort.js b/src/sorting/quicksort.js deleted file mode 100644 index ffb66797..00000000 --- a/src/sorting/quicksort.js +++ /dev/null @@ -1,78 +0,0 @@ -var array = [3,4,7,3,3,5,8,3,34,3,7,9]; - -/** - * The quicksort algorithm. It's complexity is O(nlog n). - * - * @public - */ -var quickSort = (function () { - - /** - * Partitions given subarray. - * - * @private - * @param {array} array Input array - * @param {number} left The start of the subarray - * @param {number} right The end of the subarray - */ - function partition(array, left, right) { - var cmp = array[right - 1], - minEnd = left, - maxEnd; - for (maxEnd = left; maxEnd < right - 1; maxEnd += 1) { - if (array[maxEnd] <= cmp) { - swap(array, maxEnd, minEnd); - minEnd += 1; - } - } - swap(array, minEnd, right - 1); - return minEnd; - } - - /** - * Swap the places of two elements - * - * @private - * @param {array} array The array which contains the elements - * @param {number} i The index of the first element - * @param {number} j The index of the second element - * @returns {array} array The array with swaped elements - */ - function swap(array, i, j) { - var temp = array[i]; - array[i] = array[j]; - array[j] = temp; - return array; - } - - /** - * Sorts given array. - * - * @private - * @param {array} array Array which should be sorted - * @param {number} left The start of the subarray which should be handled - * @param {number} right The end of the subarray which should be handled - * @returns {array} array Sorted array - */ - function quickSort(array, left, right) { - if (left < right) { - var p = partition(array, left, right); - quickSort(array, left, p); - quickSort(array, p + 1, right); - } - return array; - } - - /** - * Calls the quicksort function with it's initial values. - * - * @public - * @param {array} array The input array which should be sorted - * @returns {array} array Sorted array - */ - return function (array) { - return quickSort(array, 0, array.length); - }; -}()); - -console.log(quickSort(array)); diff --git a/src/sorting/recursive-insertionsort.js b/src/sorting/recursive-insertionsort.js deleted file mode 100644 index 4c58a342..00000000 --- a/src/sorting/recursive-insertionsort.js +++ /dev/null @@ -1,22 +0,0 @@ -var array = [4,6,2,2,4,56,7,7,51,23,5,7]; - -/** - * Recursive version of insertionsort. Complexity O(n^2). - * - * @public - * @param {array} array Input array - * @param {number} [max] Index of the element which place we should find in the current function call - */ -function recursiveInsertionSort(array, max) { - if (max <= 0) - return array; - if (max === undefined) - max = array.length - 1; - recursiveInsertionSort(array, max - 1); - for (var i = max - 1, current = array[max]; i >= 0 && current < array[i]; i -= 1) - array[i + 1] = array[i]; - array[i + 1] = current; - return array; -} - -console.log(recursiveInsertionSort(array)); diff --git a/src/sorting/selectionsort.js b/src/sorting/selectionsort.js deleted file mode 100644 index 92c862bb..00000000 --- a/src/sorting/selectionsort.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Selection sort. It's complexity is O(n^2) - * - * @public - * @param {array} array Array to be sorted - * @return {array} The sorted array - */ -function selectionSort(array) { - var min, idx, temp; - for (var i = 0; i < array.length; i += 1) { - idx = i; - min = array[i]; - for (var j = i + 1; j < array.length; j += 1) { - if (min > array[j]) { - min = array[j]; - idx = j; - } - } - temp = array[i]; - array[i] = min; - array[idx] = temp; - } - return array; -} - diff --git a/src/sorting/shellsort.js b/src/sorting/shellsort.js deleted file mode 100644 index b340f6f9..00000000 --- a/src/sorting/shellsort.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Shellsort - * - * Shellsort uses the gaps 701, 301, 132, 57, 23, 10, 4, 1 and uses insertion sort - * to sort the sub-arrays which match for the different gaps. - */ -var shellsort = (function () { - - var gaps = [701, 301, 132, 57, 23, 10, 4, 1]; - - /** - * Shellsort which uses the gaps in the lexical scope of the IIFE. - * - * @public - * @param {array} array Array which should be sorted - * @return {array} Sorted array - */ - return function (array) { - var gap, current; - - for (var k = 0; k < gaps.length; k += 1) { - gap = gaps[k]; - for (var i = gap; i < array.length; i += gap) { - current = array[i]; - for (var j = i; j >= gap && array[j - gap] > current; j -= gap) { - array[j] = array[j - gap]; - } - array[j] = current; - } - } - return array; - }; - -}()); From 468dbe25f035d360fbab8162f954733925cc1757 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Wed, 20 Feb 2013 13:09:28 +0200 Subject: [PATCH 019/613] A little minor fix in Prim's algorithm --- src/graphs/prim.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/graphs/prim.js b/src/graphs/prim.js index b5a4ee24..14e8032b 100644 --- a/src/graphs/prim.js +++ b/src/graphs/prim.js @@ -85,7 +85,6 @@ Graph.prototype.prim = (function () { spannigTree = []; spannigTree.push(current); inTheTree[current.e.id] = true; - inTheTree[current.v.id] = true; while (queue.isEmpty()) { current = queue.extract(); if (!inTheTree[current.v.id] || From 89879a6ede8c0cf7e5529a0439bf1aa0343e1687 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Thu, 21 Feb 2013 12:01:41 +0200 Subject: [PATCH 020/613] Refactoring of the graph algorithms --- src/graphs/searching/bfs.js | 68 +++++++++++ src/graphs/searching/dfs.js | 73 ++++++++++++ src/graphs/shortest-path/dijkstra.js | 112 ++++++++++++++++++ src/graphs/shortest-path/floyd.js | 74 ++++++++++++ src/graphs/spanning-trees/prim.js | 171 +++++++++++++++++++++++++++ 5 files changed, 498 insertions(+) create mode 100644 src/graphs/searching/bfs.js create mode 100644 src/graphs/searching/dfs.js create mode 100644 src/graphs/shortest-path/dijkstra.js create mode 100644 src/graphs/shortest-path/floyd.js create mode 100644 src/graphs/spanning-trees/prim.js diff --git a/src/graphs/searching/bfs.js b/src/graphs/searching/bfs.js new file mode 100644 index 00000000..0ce987b8 --- /dev/null +++ b/src/graphs/searching/bfs.js @@ -0,0 +1,68 @@ +/* * * * * * * * * * * * * * * * * * + + Sample graph + +var graph = [[1,0,1,0,0,0], + [0,1,0,1,0,0], + [1,0,1,0,1,0], + [0,1,0,1,1,0], + [0,0,1,1,1,1], + [0,0,0,0,1,1]]; +* * * * * * * * * * * * * * * * * */ + +/** + * Breadth-first search algorithm for matrix representation of graph. + * The algorithm finds whether there's a path between two given nodes. + */ +var breadthFirstSearch = function () { + + var visted = [], + queue = [], + target, + graph; + + /** + * Initializes the algorithm + * + * @private + * @param {array} inputGraph The input matrix of the graph + * @param {number} destination The destination + */ + function init(inputGraph, destination) { + graph = inputGraph; + target = destination; + visited = []; + queue = []; + for (var i = 0; i < graph.length; i += 1) + visited[i] = false; + } + + /** + * Finds whether there's a path between a given start node + * to given destination + * + * @public + * @param {array} graph A matrix representation of the graph + * @param {number} source The source node + * @param {number} destination The destination node + * @returns {boolean} true/false depending whether there's a path between the nodes + */ + return function (graph, source, destination) { + init(graph, destination); + var current; + queue.push(source); + while (queue.length > 0) { + current = queue.shift(); + visited[current] = true; + for (var i = 0; i < graph.length; i += 1) { + if (graph[current][i]) { + if (i === destination) + return true; + if (!visited[i]) + queue.push(i); + } + } + } + return false; + }; +}(); diff --git a/src/graphs/searching/dfs.js b/src/graphs/searching/dfs.js new file mode 100644 index 00000000..b758384b --- /dev/null +++ b/src/graphs/searching/dfs.js @@ -0,0 +1,73 @@ +/* * * * * * * * * * * * * * * * * * + + Sample graph + +var graph = [[1,0,1,0,0,0], + [0,1,0,1,0,0], + [1,0,1,0,1,0], + [0,1,0,1,1,0], + [0,0,1,1,1,1], + [0,0,0,0,1,1]]; +* * * * * * * * * * * * * * * * * */ + +/** + * Depth-first search algorithm for matrix representation of graph. + * The algorithm finds whether there's a path between two given nodes. + */ +var depthFirstSearch = function () { + + var visted = [], + target, + graph; + + /** + * Returns whether the destination could be reached + * from given node + * + * @private + * @param {number} current Current node + * @returns {boolean} True/false depending whether + * the destination can be reached from the current node + */ + function dfs(current) { + if (current === target) return true; + visited[current] = true; + for (var i = 0; i < graph.length; i += 1) { + if (graph[current][i] === 1 && + !visited[i]) { + return depthFirstSearch(i); + } + } + return false; + } + + /** + * Initializes the algorithm + * + * @private + * @param {array} inputGraph The input matrix of the graph + * @param {number} destination The destination + */ + function init(inputGraph, destination) { + graph = inputGraph; + target = destination; + visited = []; + for (var i = 0; i < graph.length; i += 1) + visited[i] = false; + } + + /** + * Finds whether there's a path between a given start node + * to given destination + * + * @public + * @param {array} graph A matrix representation of the graph + * @param {number} source The source node + * @param {number} destination The destination node + * @returns {boolean} true/false depending whether there's a path between the nodes + */ + return function (graph, source, destination) { + init(graph, destination); + return dfs(source); + }; +}(); diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js new file mode 100644 index 00000000..3bbfdee5 --- /dev/null +++ b/src/graphs/shortest-path/dijkstra.js @@ -0,0 +1,112 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * + + A sample distance matrix + +var graph = [[NaN, 7, 9, NaN, NaN, 16], + [7, NaN, 10, 15, NaN, NaN], + [9, 10, NaN, 11, NaN, 2], + [NaN, 15, 11, NaN, 6, NaN], + [NaN, NaN, NaN, 6, NaN, 9], + [16, NaN, 2, NaN, 9, NaN]]; + +* * * * * * * * * * * * * * * * * * * * * * * */ + + +/** + * Dijstra's shortest path algorithm. + * For the implementation is not used the most suitable data structure (Fibonacci heap) + * but the binary heap gives also good results. The implementation bellow finds + * the minimum distance between two given nodes using a distance matrix. + */ +var dijstra = function () { + + var Heap = require('../data-structures/heap.js').Heap, + current, + visited, + distance, + unvisited; + + + /** + * Creates a new node instance + * + * @constructor + * @private + * @param {number} id The id of the node + * @param {number} distance The distance from the beginning + */ + function Node(id, distance) { + this.node = id; + this.distance = distance; + } + + /** + * Compares the distances between two nodes. + * + * @private + * @param {object} a A node + * @param {object} b A graph node + * @returns {number} The + */ + function compareNodesDistance(a, b) { + return b.distance - a.distance; + } + + /** + * Initialize all variables used for the algorithm + * + * @private + * @param {number} src A start node + */ + function init(src) { + var currentTemp; + current = {}; + visited = []; + distance = []; + unvisited = new Heap(compareNodesDistance); + for (var i = 0; i < graph.length; i += 1) { + currentTemp = new Node(); + if (src === i) { + currentTemp.distance = 0; + } else { + currentTemp.distance = Infinity; + } + currentTemp.node = i; + visited[i] = false; + distance[i] = currentTemp; + unvisited.add(currentTemp); + } + current.node = src; + current.distance = 0; + } + + /** + * Dijkstra's shortest path algorithm + * + * @public + * @param {number} src Source node + * @param {number} dest Destination node + * @param {array} graph A distance matrix of the graph + * @returns {number} The shortest distance between the nodes + */ + return function (src, dest, graph) { + var tempDistance = 0; + init(src); + while (current.node != dest && current.distance != Infinity) { + for (var i = 0; i < graph.length; i += 1) { + if (current.node !== i && //if it's not the current node + !visited[i] && //and if we haven't visited this node + !isNaN(graph[i][current.node])) { //and this node is sibling of the current... + + tempDistance = current.distance + graph[i][current.node]; + if (tempDistance < distance[i].distance) { + distance[i].distance = tempDistance; + } + } + } + visited[current.node] = true; + current = unvisited.extract(); + } + return distance[dest].distance; + }; +}(); diff --git a/src/graphs/shortest-path/floyd.js b/src/graphs/shortest-path/floyd.js new file mode 100644 index 00000000..88180c6b --- /dev/null +++ b/src/graphs/shortest-path/floyd.js @@ -0,0 +1,74 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * + + A sample distance matrix + +var graph = [[NaN, 7, 9, NaN, NaN, 16], + [7, NaN, 10, 15, NaN, NaN], + [9, 10, NaN, 11, NaN, 2], + [NaN, 15, 11, NaN, 6, NaN], + [NaN, NaN, NaN, 6, NaN, 9], + [16, NaN, 2, NaN, 9, NaN]]; + +* * * * * * * * * * * * * * * * * * * * * * * */ + +/** + * Finds the shortest distance between all vertices of the graph + * using the Floyd-Warshall algorithm. + * + * Complexity O(n^3) + */ +var floydWarshall = (function () { + + /** + * Matrix used for the algorithm. + */ + var dist; + + /** + * Initialize the distance matrix + * + * @private + * @param {array} graph Distance matrix of the array + * @return {array} Distance matrix used for the algorithm + */ + function init(graph) { + var dist = []; + var size = graph.length; + for (var i = 0; i < size; i += 1) { + dist[i] = []; + for (var j = 0; j < size; j += 1) { + if (i === j) { + dist[i][j] = 0; + } else if (isNaN(graph[i][j])) { + dist[i][j] = Infinity; + } else { + dist[i][j] = graph[i][j]; + } + } + } + return dist; + } + + /** + * Finds the shortest path between each two vertices + * Complexity O(n^3) + * + * @public + * @param {array} graph The graph which should be processed + * @return {array} The array which contains the shortest distance between each two vertices + */ + return function (graph) { + dist = init(graph); + var size = graph.length; + for (var k = 0; k < size; k += 1) { + for (var i = 0; i < size; i += 1) { + for (var j = 0; j < size; j += 1) { + if (dist[i][j] > dist[i][k] + dist[k][j]) { + dist[i][j] = dist[i][k] + dist[k][j]; + } + } + } + } + return dist; + } +}()); diff --git a/src/graphs/spanning-trees/prim.js b/src/graphs/spanning-trees/prim.js new file mode 100644 index 00000000..14e8032b --- /dev/null +++ b/src/graphs/spanning-trees/prim.js @@ -0,0 +1,171 @@ +var Heap = require('../data-structures/heap').Heap; + +/** + * Graph vertex + * + * @constructor + * @public + * @param {number} id The id of the vertex + */ +function Vertex(id) { + this.id = id; +} + +/** + * Graph edge + * + * @constructor + * @public + * @param {Vertex} e Vertex which this edge connects + * @param {Vertex} v Vertex which this edge connects + * @param {number} distance Weight of the node + */ +function Edge(e, v, distance) { + this.e = e; + this.v = v; + this.distance = distance; +} + +/** + * Graph + * + * @constructor + * @public + */ +function Graph(edges) { + console.log(edges); + this.edges = edges || []; +} + +/** + * Prim's algorithm for minimum spanning tree + * + * @public + * @return {Graph} Graph which is the minimum spanning tree + */ +Graph.prototype.prim = (function () { + + var queue; + + /** + * Initialize the algorithm. + * + * @private + */ + function init() { + queue = new Heap(compareEdges); + this.edges.forEach(function (e) { + queue.add(e); + }); + } + + /** + * Used for comparitions in the heap + * + * @private + * @param {Vertex} a First operand of the comparition + * @param {Vertex} b Second operand of the comparition + * @return {number} Number which which is equal, greater or less then zero and + * indicates whether the first vertex is "greater" than the second. + */ + function compareEdges(a, b) { + return b.distance - a.distance; + } + + /** + * Prim's algorithm implementation + * + * @public + * @return {Graph} Minimum spanning tree. + */ + return function () { + init.call(this); + var inTheTree = {}, + current = queue.extract(), + spannigTree = []; + spannigTree.push(current); + inTheTree[current.e.id] = true; + while (queue.isEmpty()) { + current = queue.extract(); + if (!inTheTree[current.v.id] || + !inTheTree[current.e.id]) { + spannigTree.push(current); + inTheTree[current.e.id] = true; + inTheTree[current.v.id] = true; + } + } + return new Graph(spannigTree); + }; + +}()); + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * Sample graph * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +var graph; + +(function () { + var edges = []; + + edges.push(new Edge( + new Vertex(0), + new Vertex(1), + 7 + )); + + edges.push(new Edge( + new Vertex(0), + new Vertex(2), + 9 + )); + + edges.push(new Edge( + new Vertex(0), + new Vertex(5), + 16 + )); + + edges.push(new Edge( + new Vertex(1), + new Vertex(2), + 10 + )); + + edges.push(new Edge( + new Vertex(1), + new Vertex(3), + 15 + )); + + edges.push(new Edge( + new Vertex(2), + new Vertex(3), + 11 + )); + + edges.push(new Edge( + new Vertex(2), + new Vertex(5), + 2 + )); + + edges.push(new Edge( + new Vertex(3), + new Vertex(4), + 6 + )); + + edges.push(new Edge( + new Vertex(4), + new Vertex(5), + 9 + )); + + graph = new Graph(edges); + +}()); + +console.log(graph.prim()); + +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ From 719e1502b64d3941eb1a584b25c8bc308e760159 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Thu, 21 Feb 2013 12:05:09 +0200 Subject: [PATCH 021/613] Refactoring of the graph algorithms --- src/data-structures/heap.js | 17 +-- src/graphs/bfs.js | 68 ----------- src/graphs/dfs.js | 73 ------------ src/graphs/dijkstra.js | 112 ------------------ src/graphs/floyd.js | 74 ------------ src/graphs/prim.js | 171 --------------------------- src/graphs/shortest-path/dijkstra.js | 2 +- src/graphs/spanning-trees/prim.js | 2 +- 8 files changed, 12 insertions(+), 507 deletions(-) delete mode 100644 src/graphs/bfs.js delete mode 100644 src/graphs/dfs.js delete mode 100644 src/graphs/dijkstra.js delete mode 100644 src/graphs/floyd.js delete mode 100644 src/graphs/prim.js diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index 7a1415bb..ea401c25 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -13,7 +13,7 @@ function Heap(cmp) { return a - b; }; } -} +}; /** * Exchange indexes with start index given as argument @@ -41,8 +41,7 @@ Heap.prototype._heapify = function (index) { this._heap[extr] = temp; this._heapify(extr); } - -} +}; /** * Changes the key for give index. Complexity O(log n). @@ -66,7 +65,7 @@ Heap.prototype.changeKey = function (index, value) { } } return parent; -} +}; /** * Adds new element to the heap. Complexity O(log n). @@ -78,7 +77,7 @@ Heap.prototype.changeKey = function (index, value) { Heap.prototype.add = function (value) { this._heap.push(value); return this.changeKey(this._heap.length - 1, value); -} +}; /** * Gets the current value which is on the top of the heap. Complexity O(1). @@ -88,7 +87,7 @@ Heap.prototype.add = function (value) { */ Heap.prototype.top = function () { return this._heap[0]; -} +}; /** * Removes and returns the current extremum value which is on the top of the heap. @@ -104,6 +103,10 @@ Heap.prototype.extract = function () { var extr = this._heap.shift(); this._heapify(0); return extr; -} +}; + +Heap.prototype.isEmpty = function () { + return !this._heapify.length; +}; exports.Heap = Heap; diff --git a/src/graphs/bfs.js b/src/graphs/bfs.js deleted file mode 100644 index 0ce987b8..00000000 --- a/src/graphs/bfs.js +++ /dev/null @@ -1,68 +0,0 @@ -/* * * * * * * * * * * * * * * * * * - - Sample graph - -var graph = [[1,0,1,0,0,0], - [0,1,0,1,0,0], - [1,0,1,0,1,0], - [0,1,0,1,1,0], - [0,0,1,1,1,1], - [0,0,0,0,1,1]]; -* * * * * * * * * * * * * * * * * */ - -/** - * Breadth-first search algorithm for matrix representation of graph. - * The algorithm finds whether there's a path between two given nodes. - */ -var breadthFirstSearch = function () { - - var visted = [], - queue = [], - target, - graph; - - /** - * Initializes the algorithm - * - * @private - * @param {array} inputGraph The input matrix of the graph - * @param {number} destination The destination - */ - function init(inputGraph, destination) { - graph = inputGraph; - target = destination; - visited = []; - queue = []; - for (var i = 0; i < graph.length; i += 1) - visited[i] = false; - } - - /** - * Finds whether there's a path between a given start node - * to given destination - * - * @public - * @param {array} graph A matrix representation of the graph - * @param {number} source The source node - * @param {number} destination The destination node - * @returns {boolean} true/false depending whether there's a path between the nodes - */ - return function (graph, source, destination) { - init(graph, destination); - var current; - queue.push(source); - while (queue.length > 0) { - current = queue.shift(); - visited[current] = true; - for (var i = 0; i < graph.length; i += 1) { - if (graph[current][i]) { - if (i === destination) - return true; - if (!visited[i]) - queue.push(i); - } - } - } - return false; - }; -}(); diff --git a/src/graphs/dfs.js b/src/graphs/dfs.js deleted file mode 100644 index b758384b..00000000 --- a/src/graphs/dfs.js +++ /dev/null @@ -1,73 +0,0 @@ -/* * * * * * * * * * * * * * * * * * - - Sample graph - -var graph = [[1,0,1,0,0,0], - [0,1,0,1,0,0], - [1,0,1,0,1,0], - [0,1,0,1,1,0], - [0,0,1,1,1,1], - [0,0,0,0,1,1]]; -* * * * * * * * * * * * * * * * * */ - -/** - * Depth-first search algorithm for matrix representation of graph. - * The algorithm finds whether there's a path between two given nodes. - */ -var depthFirstSearch = function () { - - var visted = [], - target, - graph; - - /** - * Returns whether the destination could be reached - * from given node - * - * @private - * @param {number} current Current node - * @returns {boolean} True/false depending whether - * the destination can be reached from the current node - */ - function dfs(current) { - if (current === target) return true; - visited[current] = true; - for (var i = 0; i < graph.length; i += 1) { - if (graph[current][i] === 1 && - !visited[i]) { - return depthFirstSearch(i); - } - } - return false; - } - - /** - * Initializes the algorithm - * - * @private - * @param {array} inputGraph The input matrix of the graph - * @param {number} destination The destination - */ - function init(inputGraph, destination) { - graph = inputGraph; - target = destination; - visited = []; - for (var i = 0; i < graph.length; i += 1) - visited[i] = false; - } - - /** - * Finds whether there's a path between a given start node - * to given destination - * - * @public - * @param {array} graph A matrix representation of the graph - * @param {number} source The source node - * @param {number} destination The destination node - * @returns {boolean} true/false depending whether there's a path between the nodes - */ - return function (graph, source, destination) { - init(graph, destination); - return dfs(source); - }; -}(); diff --git a/src/graphs/dijkstra.js b/src/graphs/dijkstra.js deleted file mode 100644 index 3bbfdee5..00000000 --- a/src/graphs/dijkstra.js +++ /dev/null @@ -1,112 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * - - A sample distance matrix - -var graph = [[NaN, 7, 9, NaN, NaN, 16], - [7, NaN, 10, 15, NaN, NaN], - [9, 10, NaN, 11, NaN, 2], - [NaN, 15, 11, NaN, 6, NaN], - [NaN, NaN, NaN, 6, NaN, 9], - [16, NaN, 2, NaN, 9, NaN]]; - -* * * * * * * * * * * * * * * * * * * * * * * */ - - -/** - * Dijstra's shortest path algorithm. - * For the implementation is not used the most suitable data structure (Fibonacci heap) - * but the binary heap gives also good results. The implementation bellow finds - * the minimum distance between two given nodes using a distance matrix. - */ -var dijstra = function () { - - var Heap = require('../data-structures/heap.js').Heap, - current, - visited, - distance, - unvisited; - - - /** - * Creates a new node instance - * - * @constructor - * @private - * @param {number} id The id of the node - * @param {number} distance The distance from the beginning - */ - function Node(id, distance) { - this.node = id; - this.distance = distance; - } - - /** - * Compares the distances between two nodes. - * - * @private - * @param {object} a A node - * @param {object} b A graph node - * @returns {number} The - */ - function compareNodesDistance(a, b) { - return b.distance - a.distance; - } - - /** - * Initialize all variables used for the algorithm - * - * @private - * @param {number} src A start node - */ - function init(src) { - var currentTemp; - current = {}; - visited = []; - distance = []; - unvisited = new Heap(compareNodesDistance); - for (var i = 0; i < graph.length; i += 1) { - currentTemp = new Node(); - if (src === i) { - currentTemp.distance = 0; - } else { - currentTemp.distance = Infinity; - } - currentTemp.node = i; - visited[i] = false; - distance[i] = currentTemp; - unvisited.add(currentTemp); - } - current.node = src; - current.distance = 0; - } - - /** - * Dijkstra's shortest path algorithm - * - * @public - * @param {number} src Source node - * @param {number} dest Destination node - * @param {array} graph A distance matrix of the graph - * @returns {number} The shortest distance between the nodes - */ - return function (src, dest, graph) { - var tempDistance = 0; - init(src); - while (current.node != dest && current.distance != Infinity) { - for (var i = 0; i < graph.length; i += 1) { - if (current.node !== i && //if it's not the current node - !visited[i] && //and if we haven't visited this node - !isNaN(graph[i][current.node])) { //and this node is sibling of the current... - - tempDistance = current.distance + graph[i][current.node]; - if (tempDistance < distance[i].distance) { - distance[i].distance = tempDistance; - } - } - } - visited[current.node] = true; - current = unvisited.extract(); - } - return distance[dest].distance; - }; -}(); diff --git a/src/graphs/floyd.js b/src/graphs/floyd.js deleted file mode 100644 index 88180c6b..00000000 --- a/src/graphs/floyd.js +++ /dev/null @@ -1,74 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * - - A sample distance matrix - -var graph = [[NaN, 7, 9, NaN, NaN, 16], - [7, NaN, 10, 15, NaN, NaN], - [9, 10, NaN, 11, NaN, 2], - [NaN, 15, 11, NaN, 6, NaN], - [NaN, NaN, NaN, 6, NaN, 9], - [16, NaN, 2, NaN, 9, NaN]]; - -* * * * * * * * * * * * * * * * * * * * * * * */ - -/** - * Finds the shortest distance between all vertices of the graph - * using the Floyd-Warshall algorithm. - * - * Complexity O(n^3) - */ -var floydWarshall = (function () { - - /** - * Matrix used for the algorithm. - */ - var dist; - - /** - * Initialize the distance matrix - * - * @private - * @param {array} graph Distance matrix of the array - * @return {array} Distance matrix used for the algorithm - */ - function init(graph) { - var dist = []; - var size = graph.length; - for (var i = 0; i < size; i += 1) { - dist[i] = []; - for (var j = 0; j < size; j += 1) { - if (i === j) { - dist[i][j] = 0; - } else if (isNaN(graph[i][j])) { - dist[i][j] = Infinity; - } else { - dist[i][j] = graph[i][j]; - } - } - } - return dist; - } - - /** - * Finds the shortest path between each two vertices - * Complexity O(n^3) - * - * @public - * @param {array} graph The graph which should be processed - * @return {array} The array which contains the shortest distance between each two vertices - */ - return function (graph) { - dist = init(graph); - var size = graph.length; - for (var k = 0; k < size; k += 1) { - for (var i = 0; i < size; i += 1) { - for (var j = 0; j < size; j += 1) { - if (dist[i][j] > dist[i][k] + dist[k][j]) { - dist[i][j] = dist[i][k] + dist[k][j]; - } - } - } - } - return dist; - } -}()); diff --git a/src/graphs/prim.js b/src/graphs/prim.js deleted file mode 100644 index 14e8032b..00000000 --- a/src/graphs/prim.js +++ /dev/null @@ -1,171 +0,0 @@ -var Heap = require('../data-structures/heap').Heap; - -/** - * Graph vertex - * - * @constructor - * @public - * @param {number} id The id of the vertex - */ -function Vertex(id) { - this.id = id; -} - -/** - * Graph edge - * - * @constructor - * @public - * @param {Vertex} e Vertex which this edge connects - * @param {Vertex} v Vertex which this edge connects - * @param {number} distance Weight of the node - */ -function Edge(e, v, distance) { - this.e = e; - this.v = v; - this.distance = distance; -} - -/** - * Graph - * - * @constructor - * @public - */ -function Graph(edges) { - console.log(edges); - this.edges = edges || []; -} - -/** - * Prim's algorithm for minimum spanning tree - * - * @public - * @return {Graph} Graph which is the minimum spanning tree - */ -Graph.prototype.prim = (function () { - - var queue; - - /** - * Initialize the algorithm. - * - * @private - */ - function init() { - queue = new Heap(compareEdges); - this.edges.forEach(function (e) { - queue.add(e); - }); - } - - /** - * Used for comparitions in the heap - * - * @private - * @param {Vertex} a First operand of the comparition - * @param {Vertex} b Second operand of the comparition - * @return {number} Number which which is equal, greater or less then zero and - * indicates whether the first vertex is "greater" than the second. - */ - function compareEdges(a, b) { - return b.distance - a.distance; - } - - /** - * Prim's algorithm implementation - * - * @public - * @return {Graph} Minimum spanning tree. - */ - return function () { - init.call(this); - var inTheTree = {}, - current = queue.extract(), - spannigTree = []; - spannigTree.push(current); - inTheTree[current.e.id] = true; - while (queue.isEmpty()) { - current = queue.extract(); - if (!inTheTree[current.v.id] || - !inTheTree[current.e.id]) { - spannigTree.push(current); - inTheTree[current.e.id] = true; - inTheTree[current.v.id] = true; - } - } - return new Graph(spannigTree); - }; - -}()); - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * * * * * * * * * * * * * * Sample graph * * * * * * * * * * * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - -var graph; - -(function () { - var edges = []; - - edges.push(new Edge( - new Vertex(0), - new Vertex(1), - 7 - )); - - edges.push(new Edge( - new Vertex(0), - new Vertex(2), - 9 - )); - - edges.push(new Edge( - new Vertex(0), - new Vertex(5), - 16 - )); - - edges.push(new Edge( - new Vertex(1), - new Vertex(2), - 10 - )); - - edges.push(new Edge( - new Vertex(1), - new Vertex(3), - 15 - )); - - edges.push(new Edge( - new Vertex(2), - new Vertex(3), - 11 - )); - - edges.push(new Edge( - new Vertex(2), - new Vertex(5), - 2 - )); - - edges.push(new Edge( - new Vertex(3), - new Vertex(4), - 6 - )); - - edges.push(new Edge( - new Vertex(4), - new Vertex(5), - 9 - )); - - graph = new Graph(edges); - -}()); - -console.log(graph.prim()); - -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index 3bbfdee5..c1767411 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -20,7 +20,7 @@ var graph = [[NaN, 7, 9, NaN, NaN, 16], */ var dijstra = function () { - var Heap = require('../data-structures/heap.js').Heap, + var Heap = require('../../data-structures/heap.js').Heap, current, visited, distance, diff --git a/src/graphs/spanning-trees/prim.js b/src/graphs/spanning-trees/prim.js index 14e8032b..ea5e8b85 100644 --- a/src/graphs/spanning-trees/prim.js +++ b/src/graphs/spanning-trees/prim.js @@ -1,4 +1,4 @@ -var Heap = require('../data-structures/heap').Heap; +var Heap = require('../../data-structures/heap').Heap; /** * Graph vertex From 0c93b37990d945206cbf774e512d573e7f873f15 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Fri, 22 Feb 2013 18:11:31 +0200 Subject: [PATCH 022/613] Minor changes in the heap --- src/data-structures/heap.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index ea401c25..3d3bc7bb 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -13,7 +13,7 @@ function Heap(cmp) { return a - b; }; } -}; +} /** * Exchange indexes with start index given as argument @@ -98,7 +98,7 @@ Heap.prototype.top = function () { */ Heap.prototype.extract = function () { if (!this._heap.length) - throw new 'The heap is already empty!'; + throw 'The heap is already empty!'; var extr = this._heap.shift(); this._heapify(0); From cdb0695178cd9d4c00d441693e5dbc0962ee4542 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Sat, 23 Feb 2013 11:20:28 +0200 Subject: [PATCH 023/613] The whole repo is validated with JSHint --- src/graphs/shortest-path/floyd.js | 2 +- src/searching/recursive-binarysearch.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/graphs/shortest-path/floyd.js b/src/graphs/shortest-path/floyd.js index 88180c6b..c723aeb4 100644 --- a/src/graphs/shortest-path/floyd.js +++ b/src/graphs/shortest-path/floyd.js @@ -70,5 +70,5 @@ var floydWarshall = (function () { } } return dist; - } + }; }()); diff --git a/src/searching/recursive-binarysearch.js b/src/searching/recursive-binarysearch.js index 306fb95e..711ddeaa 100644 --- a/src/searching/recursive-binarysearch.js +++ b/src/searching/recursive-binarysearch.js @@ -40,7 +40,7 @@ var binarySearch = (function () { */ return function (array, key) { return recursiveBinarySearch(array, key, 0, array.length); - } + }; }()); From a641635b0ab60366edb8f9d0a5f1fe235a0702ef Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Mon, 25 Feb 2013 19:10:07 +0200 Subject: [PATCH 024/613] Few refactoring changes --- src/searching/{ => binarysearch}/binarysearch.js | 0 src/searching/{ => binarysearch}/recursive-binarysearch.js | 0 .../{ => subarray}/maximum-subarray-divide-and-conquer.js | 0 src/searching/{ => subarray}/maximum-subarray.js | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/searching/{ => binarysearch}/binarysearch.js (100%) rename src/searching/{ => binarysearch}/recursive-binarysearch.js (100%) rename src/searching/{ => subarray}/maximum-subarray-divide-and-conquer.js (100%) rename src/searching/{ => subarray}/maximum-subarray.js (100%) diff --git a/src/searching/binarysearch.js b/src/searching/binarysearch/binarysearch.js similarity index 100% rename from src/searching/binarysearch.js rename to src/searching/binarysearch/binarysearch.js diff --git a/src/searching/recursive-binarysearch.js b/src/searching/binarysearch/recursive-binarysearch.js similarity index 100% rename from src/searching/recursive-binarysearch.js rename to src/searching/binarysearch/recursive-binarysearch.js diff --git a/src/searching/maximum-subarray-divide-and-conquer.js b/src/searching/subarray/maximum-subarray-divide-and-conquer.js similarity index 100% rename from src/searching/maximum-subarray-divide-and-conquer.js rename to src/searching/subarray/maximum-subarray-divide-and-conquer.js diff --git a/src/searching/maximum-subarray.js b/src/searching/subarray/maximum-subarray.js similarity index 100% rename from src/searching/maximum-subarray.js rename to src/searching/subarray/maximum-subarray.js From 4ae7e5283a9d31adadd2553a7018e4882d00a707 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Thu, 18 Apr 2013 22:13:44 +0300 Subject: [PATCH 025/613] Removed useless console.log --- src/sorting/linearsort/bucketsort.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sorting/linearsort/bucketsort.js b/src/sorting/linearsort/bucketsort.js index b7c06a59..9403aa47 100644 --- a/src/sorting/linearsort/bucketsort.js +++ b/src/sorting/linearsort/bucketsort.js @@ -45,7 +45,6 @@ var bucketSort = (function () { sectorSize = 1 / array.length; for (var i = 0; i < array.length; i += 1) { current = array[i]; - console.log(current / sectorSize); currentBucket = Math.floor(current / sectorSize); if (buckets[currentBucket] === undefined) { buckets[currentBucket] = []; From 8a8f65385e7d2a78d9f08fc2309fd8df4450e51f Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Mon, 13 May 2013 18:19:22 +0300 Subject: [PATCH 026/613] Run-length added --- src/compression/runlength/runlength.js | 59 ++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/compression/runlength/runlength.js diff --git a/src/compression/runlength/runlength.js b/src/compression/runlength/runlength.js new file mode 100644 index 00000000..b6818686 --- /dev/null +++ b/src/compression/runlength/runlength.js @@ -0,0 +1,59 @@ +var str = 'Sample'; + +/** + * Run-length encoding. + * The idea of this algorithm is to remove the usless zeros and + * give us representation of string in binary which in which the + * zeros will be stripped and replaced with their count. + */ +var runLengthEncoding = (function () { + + 'use strict'; + + function convertToAscii(str) { + var result = '', + currentChar = '', + i = 0; + for (; i < str.length; i += 1) { + currentChar = str[i].charCodeAt(0).toString(2); + if (currentChar.length < 8) { + while (8 - currentChar.length) { + currentChar = '0' + currentChar; + } + } + result += currentChar; + } + return result; + } + + function runLength(vector) { + var result = '', + zeros = 0, + zerosTemp = '', + wordLength = 0, + i = 0; + for (; i < vector.length; i += 1) { + if (vector[i] === '0') { + zeros += 1; + } else { + zerosTemp = zeros.toString(2); + wordLength = zerosTemp.length - 1; + while (wordLength) { + result = result + '1'; + wordLength -= 1; + } + result += '0' + zerosTemp; + zeros = 0; + } + } + return result; + } + + return function (str) { + var asciiString = convertToAscii(str); + return runLength(asciiString); + } + +}()); + +console.log(runLengthEncoding(str)); From fb48c18fb387d0b4650d7106e8c3f1beeae3bda4 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Tue, 14 May 2013 10:25:23 +0300 Subject: [PATCH 027/613] Comments added to the run-length encoding --- src/compression/runlength/runlength.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/compression/runlength/runlength.js b/src/compression/runlength/runlength.js index b6818686..8db4b223 100644 --- a/src/compression/runlength/runlength.js +++ b/src/compression/runlength/runlength.js @@ -10,6 +10,10 @@ var runLengthEncoding = (function () { 'use strict'; + /** + * Convers a given string to sequence of numbers + * This takes O(n). + */ function convertToAscii(str) { var result = '', currentChar = '', @@ -25,7 +29,11 @@ var runLengthEncoding = (function () { } return result; } - + + /** + * Encodes the binary string to run-length encoding. + * Takes O(n^2). + */ function runLength(vector) { var result = '', zeros = 0, @@ -48,7 +56,11 @@ var runLengthEncoding = (function () { } return result; } - + + /** + * Accepts a string and returns it's run-length encoded binary representation. + * Takes O(n^2). + */ return function (str) { var asciiString = convertToAscii(str); return runLength(asciiString); From 51fae06bc86cbd20ab4c2f51ae579c48f576dc1e Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Thu, 16 May 2013 19:46:31 +0300 Subject: [PATCH 028/613] Shuffle added --- src/shuffle/richarddurstenfeld.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/shuffle/richarddurstenfeld.js diff --git a/src/shuffle/richarddurstenfeld.js b/src/shuffle/richarddurstenfeld.js new file mode 100644 index 00000000..26d507e3 --- /dev/null +++ b/src/shuffle/richarddurstenfeld.js @@ -0,0 +1,27 @@ +/** + * Shuffle of an array elements. + * This algorithm is modified version of Fisher-Yates shuffle + * algorithm and is introduced by Richard Durstenfeld. + */ + +var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + +/** + * Shuffles an array. Complexity O(n). + * + * @param {array} array An array which should be shuffled + * @returns {array} Shuffled array + */ +function shuffle(array) { + var arraySize = array.length - 1, + rand, temp; + for (var i = arraySize; i >= 0; i -= 1) { + rand = Math.round(Math.random() * arraySize); + temp = array[i]; + array[i] = array[rand]; + array[rand] = temp; + } + return array; +} + +console.log(shuffle(array)); From d446690213060e9a0d811479b8c7ff204e730d8e Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 29 Aug 2013 15:24:12 +0300 Subject: [PATCH 029/613] Quick find added --- src/graphs/searching/quickfind.js | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/graphs/searching/quickfind.js diff --git a/src/graphs/searching/quickfind.js b/src/graphs/searching/quickfind.js new file mode 100644 index 00000000..373c62f2 --- /dev/null +++ b/src/graphs/searching/quickfind.js @@ -0,0 +1,51 @@ +/** + * Checks whether there is a path between two nodes. + * The initialization is O(n). + * + * @constructor + * @param {numner} size The count of the nodes + */ +function QuickFind(size) { + this._ids = []; + for (var i = 0; i < size; i += 1) + this._ids[i] = i; +} + +/** + * Connects two nodes - p and q. + * Complexity O(n). + * + * @param {number} p The first node + * @param {number} q The second node + */ +QuickFind.prototype.union = function (p, q) { + var size = this._ids.length, + pval = this._ids[p], + qval = this._ids[q]; + for (var i = 0; i < size; i += 1) { + if (this._ids[i] === qval) + this._ids[i] = pval; + } +}; + +/** + * Checks whether two nodes are connected. + * Complexity O(1). + * + * @param {number} p The first node + * @param {number} q The second node + * + */ +QuickFind.prototype.connected = function (p, q) { + return this._ids[p] === this._ids[q]; +}; + +//var find = new QuickFind(10); +//find.union(0, 1); +//find.union(2, 1); +//find.union(3, 4); +//find.union(8, 9); +//find.union(4, 8); +// +//console.log(find.connected(0, 9)); //expected false +//console.log(find.connected(3, 9)); //expected true From 5ba6eef5c6e1d11f105225d87ecc91121286438b Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 31 Aug 2013 12:57:03 +0300 Subject: [PATCH 030/613] Quick Union added --- src/graphs/searching/quickunion.js | 61 ++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/graphs/searching/quickunion.js diff --git a/src/graphs/searching/quickunion.js b/src/graphs/searching/quickunion.js new file mode 100644 index 00000000..6e63e5f4 --- /dev/null +++ b/src/graphs/searching/quickunion.js @@ -0,0 +1,61 @@ +/** + * Checks whether path between two nodes exists. + * The initialization has O(n) complexity. + * + * @constructor + * @param {number} n Nodes count + * + */ +function QuickUnion(n) { + this._ids = []; + for (var i = 0; i < n; i += 1) { + this._ids[i] = i; + } +} + +/** + * Finds the root of given node. + * Complexity O(n). + * + * @param {number} i The given node + * @return {number} The root of the given node + */ +QuickUnion.prototype._root = function (i) { + while (i !== this._ids[i]) i = this._ids[i]; + return i; +}; + +/** + * Unions two nodes. + * Complexity O(n). + * + * @param {number} p The first node + * @param {number} q The second node + */ +QuickUnion.prototype.union = function (p, q) { + var pRoot = this._root(p), + qRoot = this._root(q); + this._ids[pRoot] = qRoot; +}; + +/** + * Checks whether two nodes are connected. + * Complexity O(n). + * + * @param {number} p The first node. + * @param {number} q The second node. + * @return {boolean} True/false depending on whether the nodes are connected. + */ +QuickUnion.prototype.connected = function (p, q) { + return this._root(p) === this._root(q); +}; + +//var union = new QuickUnion(10); +//union.union(0, 1); +//union.union(2, 1); +//union.union(3, 4); +//union.union(8, 9); +//union.union(4, 8); +// +//console.log(union.connected(0, 9)); //expected false +//console.log(union.connected(3, 9)); //expected true From 5a195f3866d6e875a56be06dae35d328dfc9227f Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 31 Aug 2013 18:11:02 +0300 Subject: [PATCH 031/613] Weight quick union --- src/graphs/searching/weightquickunion.js | 66 ++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/graphs/searching/weightquickunion.js diff --git a/src/graphs/searching/weightquickunion.js b/src/graphs/searching/weightquickunion.js new file mode 100644 index 00000000..c3c58c9d --- /dev/null +++ b/src/graphs/searching/weightquickunion.js @@ -0,0 +1,66 @@ +/** + * Checks whether there is a path between two nodes + * Complexity of the initialization O(n). + * + * @constructor + * @param {number} n The nodes count + */ +function QuickUnion(n) { + this._ids = []; + this._size = []; + for (var i = 0; i < n; i += 1) { + this._ids[i] = i; + this._size[i] = 1; + } +} + +/** + * Finds the root of given node. + * The complexity is around O(logn) + * + * @param {number} i The given node + * @return {number} The root of the node + */ +QuickUnion.prototype._root = function (i) { + while (i !== this._ids[i]) i = this._ids[i]; + return i; +}; + +/** + * Checks whether two nodes are connected. + * Complexity O(logn) + * + * @param {number} p The first node + * @param {number} q The second node + * @return {boolean} True/false depending on whether the nodes are connected + */ +QuickUnion.prototype.connected = function (p, q) { + return this._root(p) === this._root(q); +}; + +/** + * Unions two nodes. + * Complexity O(logn) + * + * @param {number} p The first node + * @param {number} q The second node + */ +QuickUnion.prototype.union = function (p, q) { + if (this._size[p] > this._size[q]) { + this._ids[this._root(p)] = this._root(q); + } else { + this._ids[this._root(q)] = this._root(p); + } + this._size[p] += this._size[q]; + this._size[q] = this._size[p]; +}; + +//var union = new QuickUnion(10); +//union.union(0, 1); +//union.union(2, 1); +//union.union(3, 4); +//union.union(8, 9); +//union.union(4, 8); +// +//console.log(union.connected(0, 9)); //expected false +//console.log(union.connected(3, 9)); //expected true From 30f4ab84fa06049cf6da241a5cb12161a9a744f4 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 2 Sep 2013 12:31:59 +0300 Subject: [PATCH 032/613] Enabling the path compression of the weight quick union --- src/graphs/searching/weightquickunion.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/graphs/searching/weightquickunion.js b/src/graphs/searching/weightquickunion.js index c3c58c9d..ae159634 100644 --- a/src/graphs/searching/weightquickunion.js +++ b/src/graphs/searching/weightquickunion.js @@ -22,7 +22,10 @@ function QuickUnion(n) { * @return {number} The root of the node */ QuickUnion.prototype._root = function (i) { - while (i !== this._ids[i]) i = this._ids[i]; + while (i !== this._ids[i]) { +// this._ids = this._ids[this._ids[i]]; //enables the path compression + i = this._ids[i]; + } return i; }; From f3fa1baf47e2dc8ee7e96186c0679b3c295d0fe0 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 2 Sep 2013 13:13:43 +0300 Subject: [PATCH 033/613] Fisher-Yates shuffling algorithm included --- src/shuffle/fisheryates.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/shuffle/fisheryates.js diff --git a/src/shuffle/fisheryates.js b/src/shuffle/fisheryates.js new file mode 100644 index 00000000..54032dc4 --- /dev/null +++ b/src/shuffle/fisheryates.js @@ -0,0 +1,22 @@ +/** + * The shuffling algorithm of + * Fisher-Yates. Complexity O(n) + * + * @param {array} array The array which should be shuffled + * @return {array} The shuffled array. + */ +function shuffle(array) { + var size = array.length, + rand, temp; + for (var i = 1; i < size; i += 1) { + rand = Math.round(Math.random() * i); + temp = array[rand]; + array[rand] = array[i]; + array[i] = temp; + } + return array; +} + +//var array = [1,2,3,4,5,6,7,8,9]; +//console.log(array); +//console.log(shuffle(array)); From 3bbb02f72d2018b61c5eda52d66f84a1d0ff9a4c Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 7 Sep 2013 21:28:50 +0300 Subject: [PATCH 034/613] Bresenham's line drawing algorithm added --- src/graphics/bresenham-line-drawing.js | 38 ++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/graphics/bresenham-line-drawing.js diff --git a/src/graphics/bresenham-line-drawing.js b/src/graphics/bresenham-line-drawing.js new file mode 100644 index 00000000..3e4fa39a --- /dev/null +++ b/src/graphics/bresenham-line-drawing.js @@ -0,0 +1,38 @@ +/** + * Bresenham's line drawing algorithm. + * It has complexity O(n) + * @param {number} x1 The first coordinate of the beginning of the line + * @param {number} y1 The second coordinate of the beginning of the line + * @param {number} x2 The first coordinate of the end of the line + * @param {number} y2 The second coordinate of the end of the line + */ +function drawLine(x1, y1, x2, y2) { + var dx = Math.abs(x2 - x1), + dy = Math.abs(y2 - y1), + cx = (x1 < x2) ? 1 : -1, + cy = (y1 < y2) ? 1 : -1, + error = dx - dy, + doubledError; + + while (x1 !== x2 || y1 !== y2) { + drawPoint(x1, y1); + doubledError = error + error; + if (doubledError > -dy) { + error -= dy; + x1 += cx; + } + if (doubledError < dx) { + error += dx; + y1 += cy; + } + } +} + +/** + * Draws (prints) the given coordinates + * @param {number} x The first coordinate of the point + * @param {number} y The second coordinate of the point + */ +function drawPoint(x, y) { + console.log(x, y); +} \ No newline at end of file From a6910835612378a1ccae2207cf8c093c9002f61b Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 7 Sep 2013 21:32:21 +0300 Subject: [PATCH 035/613] Trailing spaces from the binary search tree removed --- src/data-structures/binary-search-tree.js | 202 +++++++++++----------- 1 file changed, 101 insertions(+), 101 deletions(-) diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 11a412e9..3677c604 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -13,10 +13,10 @@ * @param {Node} Parent of the node */ function Node(value, left, right, parent) { - this.value = value; - this._left = left; - this._right = right; - this._parent = parent; + this.value = value; + this._left = left; + this._right = right; + this._parent = parent; } /** @@ -24,9 +24,9 @@ function Node(value, left, right, parent) { * * @public * @constructor - */ + */ function BinaryTree() { - this._root = null; + this._root = null; } /** @@ -36,23 +36,23 @@ function BinaryTree() { * @public * @param {number|string} Value * @param {[Node]} Current node - */ + */ BinaryTree.prototype.insert = function (value, current) { - if (this._root === null) { - this._root = new Node(value, null, null, null); - return; - } - - var insertKey; - current = current || this._root; - if (current.value > value) - insertKey = '_left'; - else - insertKey = '_right'; - if (!current[insertKey]) - current[insertKey] = new Node(value, null, null, current); - else - this.insert(value, current[insertKey]); + if (this._root === null) { + this._root = new Node(value, null, null, null); + return; + } + + var insertKey; + current = current || this._root; + if (current.value > value) + insertKey = '_left'; + else + insertKey = '_right'; + if (!current[insertKey]) + current[insertKey] = new Node(value, null, null, current); + else + this.insert(value, current[insertKey]); }; /** @@ -61,14 +61,14 @@ BinaryTree.prototype.insert = function (value, current) { * @private * @param {Node} Node from which to start the traversal * @param {Function} Callback which will be called for each traversed node - */ + */ BinaryTree.prototype._inorder = function (current, callback) { - if (!current) - return; - this._inorder(current._left, callback); - if (typeof callback === 'function') - callback(current); - this._inorder(current._right, callback); + if (!current) + return; + this._inorder(current._left, callback); + if (typeof callback === 'function') + callback(current); + this._inorder(current._right, callback); }; /** @@ -78,7 +78,7 @@ BinaryTree.prototype._inorder = function (current, callback) { * @param {Function} Callback which will be called for each traversed node */ BinaryTree.prototype.inorder = function (callback) { - return this._inorder(this._root, callback); + return this._inorder(this._root, callback); }; /** @@ -87,14 +87,14 @@ BinaryTree.prototype.inorder = function (callback) { * @private * @param {Node} Node from which to start the traversal * @param {Function} Callback which will be called for each traversed node - */ + */ BinaryTree.prototype._postorder = function (current, callback) { - if (!current) - return; - if (typeof callback === 'function') - callback(current); - this._postorder(current._left, callback); - this._postorder(current._right, callback); + if (!current) + return; + if (typeof callback === 'function') + callback(current); + this._postorder(current._left, callback); + this._postorder(current._right, callback); }; /** @@ -102,9 +102,9 @@ BinaryTree.prototype._postorder = function (current, callback) { * * @public * @param {Function} Callback which will be called for each traversed node - */ + */ BinaryTree.prototype.postorder = function (callback) { - return this._postorder(this._root, callback); + return this._postorder(this._root, callback); }; /** @@ -113,14 +113,14 @@ BinaryTree.prototype.postorder = function (callback) { * @private * @param {Node} Node from which to start the traversal * @param {Function} Callback which will be called for each traversed node - */ + */ BinaryTree.prototype._preorder = function (current, callback) { - if (!current) - return; - if (typeof callback === 'function') - callback(current); - this._preorder(current._left, callback); - this._preorder(current._right, callback); + if (!current) + return; + if (typeof callback === 'function') + callback(current); + this._preorder(current._left, callback); + this._preorder(current._right, callback); }; /** @@ -130,7 +130,7 @@ BinaryTree.prototype._preorder = function (current, callback) { * @param {Function} Callback which will be called for each traversed node */ BinaryTree.prototype.preorder = function (callback) { - return this._preorder(this._root, callback); + return this._preorder(this._root, callback); }; /** @@ -138,9 +138,9 @@ BinaryTree.prototype.preorder = function (callback) { * * @public * @param {number|string} Value of the node which should be found - */ + */ BinaryTree.prototype.find = function (value) { - return this._find(value, this._root); + return this._find(value, this._root); }; /** @@ -151,18 +151,18 @@ BinaryTree.prototype.find = function (value) { * @param {Node} Current node to be checked */ BinaryTree.prototype._find = function (value, current) { - if (!current) - return null; + if (!current) + return null; - if (current.value === value) - return current; + if (current.value === value) + return current; - if (current.value > value) - return this._find(value, current._left); + if (current.value > value) + return this._find(value, current._left); - if (current.value < value) - return this._find(value, current._right); - + if (current.value < value) + return this._find(value, current._right); + }; /** @@ -174,20 +174,20 @@ BinaryTree.prototype._find = function (value, current) { * @param {Node} Child replacement */ BinaryTree.prototype._replaceChild = function (parent, oldChild, newChild) { - if (!parent) { - this._root = newChild; - this._root._parent = null; - } else { + if (!parent) { + this._root = newChild; + this._root._parent = null; + } else { - if (parent._left === oldChild) - parent._left = newChild; - else - parent._right = newChild; + if (parent._left === oldChild) + parent._left = newChild; + else + parent._right = newChild; - if (newChild) { - newChild._parent = parent; - } + if (newChild) { + newChild._parent = parent; } + } }; /** @@ -196,27 +196,27 @@ BinaryTree.prototype._replaceChild = function (parent, oldChild, newChild) { * @public * @param {Node} Node to be removed * @returns {boolean} True/false depending on whether the given node is removed - */ + */ BinaryTree.prototype.remove = function (node) { - if (!node) - return false; + if (!node) + return false; - if (node._left && node._right) { - var min = this._findMin(node._right), - temp = node.value; + if (node._left && node._right) { + var min = this._findMin(node._right), + temp = node.value; - node.value = min.value; - min.value = temp; - return this.remove(min); - } else { - if (node._left) - this._replaceChild(node._parent, node, node._left); - else if (node._right) - this._replaceChild(node._parent, node, node._right); - else - this._replaceChild(node._parent, node, null); - return true; - } + node.value = min.value; + min.value = temp; + return this.remove(min); + } else { + if (node._left) + this._replaceChild(node._parent, node, node._left); + else if (node._right) + this._replaceChild(node._parent, node, node._right); + else + this._replaceChild(node._parent, node, null); + return true; + } }; /** @@ -228,12 +228,12 @@ BinaryTree.prototype.remove = function (node) { * @returns {Node} The node with minimum value in the sub-tree */ BinaryTree.prototype._findMin = function (node, current) { - current = current || { value: Infinity }; - if (!node) - return current; - if (current.value > node.value) - current = node; - return this._findMin(node._left, current); + current = current || { value: Infinity }; + if (!node) + return current; + if (current.value > node.value) + current = node; + return this._findMin(node._left, current); }; /** @@ -245,12 +245,12 @@ BinaryTree.prototype._findMin = function (node, current) { * @returns {Node} The node with maximum value in the sub-tree */ BinaryTree.prototype._findMax = function (node, current) { - current = current || { value: -Infinity }; - if (!node) - return current; - if (current.value < node.value) - current = node; - return this._findMax(node._right, current); + current = current || { value: -Infinity }; + if (!node) + return current; + if (current.value < node.value) + current = node; + return this._findMax(node._right, current); }; /** @@ -260,7 +260,7 @@ BinaryTree.prototype._findMax = function (node, current) { * @returns {Node} The minimum node of the tree */ BinaryTree.prototype.findMin = function () { - return this._findMin(this._root); + return this._findMin(this._root); }; /** @@ -271,5 +271,5 @@ BinaryTree.prototype.findMin = function () { * */ BinaryTree.prototype.findMax = function () { - return this._findMax(this._root); + return this._findMax(this._root); }; From 5c81f221cacec89014a573dbc404c28ab37e1c3e Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 22 Oct 2013 12:58:08 +0300 Subject: [PATCH 036/613] Longest increasing subsequence problem --- .../longest-increasing-subsequence.js | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js diff --git a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js new file mode 100644 index 00000000..8161771a --- /dev/null +++ b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js @@ -0,0 +1,61 @@ +exports.longestSubsequence = (function () { + + function max(array, cmp) { + if (!array || !array.length) return -1; + if (!cmp) { + cmp = function (a, b) { return a - b }; + } + var max = 0; + for (var i = 1; i < array.length; i += 1) + if (cmp(array[max], array[i]) < 0) max = i; + return max; + } + + function cmp(a, b) { + return a.distance - b.distance; + } + + function buildDag(array) { + var result = []; + for (var i = 0; i < array.length; i += 1) { + result[i] = []; + for (var j = i + 1; j < array.length; j += 1) { + if (array[i] < array[j]) result[i].push(j); + } + } + return result; + } + + function find(dag, node) { + node = node || 0; + var neighbours = dag[node], + neighboursDistance = [], + maxDist, maxNode, distance; + + if (!neighbours.length) return { distance: 1, neighbour: undefined }; + + for (var i = 0; i < neighbours.length; i += 1) + neighboursDistance[i] = find(dag, neighbours[i]); + + maxDist = max(neighboursDistance, cmp); + maxNode = neighbours[maxDist]; + distance = 1 + neighboursDistance[maxDist].distance; + return { distance: distance, neighbour: neighboursDistance[maxDist], node: node }; + } + + return function (array) { + var results = [], + dag = buildDag(array), + maxPath; + for (var i = 0; i < array.length; i += 1) { + results.push(find(dag, i)); + } + maxPath = results[max(results, cmp)]; + results = []; + while (maxPath.neighbour) { + results.push(array[maxPath.node]); + maxPath = maxPath.neighbour; + } + return results; + }; +})(); \ No newline at end of file From ea356732619bc6d9a8d15c572fc6e4af0168d948 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 22 Oct 2013 13:10:22 +0300 Subject: [PATCH 037/613] Issue fixed --- .../longest-increasing-subsequence.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js index 8161771a..3c6afbbc 100644 --- a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js +++ b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js @@ -32,7 +32,7 @@ exports.longestSubsequence = (function () { neighboursDistance = [], maxDist, maxNode, distance; - if (!neighbours.length) return { distance: 1, neighbour: undefined }; + if (!neighbours.length) return { distance: 1, neighbour: undefined, node: node }; for (var i = 0; i < neighbours.length; i += 1) neighboursDistance[i] = find(dag, neighbours[i]); @@ -52,7 +52,7 @@ exports.longestSubsequence = (function () { } maxPath = results[max(results, cmp)]; results = []; - while (maxPath.neighbour) { + while (maxPath) { results.push(array[maxPath.node]); maxPath = maxPath.neighbour; } From 7670a3c361890217680dadea0519edc2b40143a5 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 22 Oct 2013 13:10:39 +0300 Subject: [PATCH 038/613] Tests for the longest increasing subsequence --- .../longest-increasing-subsequence.spec.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js diff --git a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js new file mode 100644 index 00000000..5d6fc5a2 --- /dev/null +++ b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js @@ -0,0 +1,22 @@ +var longestSubsequence = require('./longest-increasing-subsequence').longestSubsequence; + +describe('longest subsequence', function () { + + beforeEach(function () { + module.sequence = [5, 2, 8, 6, 3, 6, 9, 7, 11]; + }); + + it('should give the right length', function () { + console.log(longestSubsequence(module.sequence)); + expect(longestSubsequence(module.sequence).length).toBe(5); + }); + + it('should work with empty arrays', function () { + expect(longestSubsequence([]).length).toBe(0); + }); + + it('should return the correct path', function () { + expect(longestSubsequence(module.sequence).toString()).toBe([2,3,6,9,11].toString()); + }); + +}); \ No newline at end of file From 4ae12c2f341d2668c6bb5a63529dc764c7d104ca Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 22 Oct 2013 13:35:49 +0300 Subject: [PATCH 039/613] Memorization included --- .../longest-increasing-subsequence.js | 7 +++++-- .../longest-increasing-subsequence.spec.js | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js index 3c6afbbc..8b94ad37 100644 --- a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js +++ b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js @@ -28,9 +28,10 @@ exports.longestSubsequence = (function () { function find(dag, node) { node = node || 0; + if (find.memo[node]) return find.memo[node]; var neighbours = dag[node], neighboursDistance = [], - maxDist, maxNode, distance; + maxDist, maxNode, distance, result; if (!neighbours.length) return { distance: 1, neighbour: undefined, node: node }; @@ -40,13 +41,15 @@ exports.longestSubsequence = (function () { maxDist = max(neighboursDistance, cmp); maxNode = neighbours[maxDist]; distance = 1 + neighboursDistance[maxDist].distance; - return { distance: distance, neighbour: neighboursDistance[maxDist], node: node }; + find.memo[node] = result = { distance: distance, neighbour: neighboursDistance[maxDist], node: node }; + return result; } return function (array) { var results = [], dag = buildDag(array), maxPath; + find.memo = []; for (var i = 0; i < array.length; i += 1) { results.push(find(dag, i)); } diff --git a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js index 5d6fc5a2..e0e1061b 100644 --- a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js +++ b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js @@ -7,7 +7,6 @@ describe('longest subsequence', function () { }); it('should give the right length', function () { - console.log(longestSubsequence(module.sequence)); expect(longestSubsequence(module.sequence).length).toBe(5); }); From 4e81e384dd372f32732dfd5fb9526c593c4a8d0a Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 22 Oct 2013 13:37:27 +0300 Subject: [PATCH 040/613] sequence added to global --- .../longest-increasing-subsequence.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js index e0e1061b..71a0cb43 100644 --- a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js +++ b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js @@ -3,11 +3,11 @@ var longestSubsequence = require('./longest-increasing-subsequence').longestSubs describe('longest subsequence', function () { beforeEach(function () { - module.sequence = [5, 2, 8, 6, 3, 6, 9, 7, 11]; + global.sequence = [5, 2, 8, 6, 3, 6, 9, 7, 11]; }); it('should give the right length', function () { - expect(longestSubsequence(module.sequence).length).toBe(5); + expect(longestSubsequence(sequence).length).toBe(5); }); it('should work with empty arrays', function () { @@ -15,7 +15,7 @@ describe('longest subsequence', function () { }); it('should return the correct path', function () { - expect(longestSubsequence(module.sequence).toString()).toBe([2,3,6,9,11].toString()); + expect(longestSubsequence(sequence).toString()).toBe([2,3,6,9,11].toString()); }); }); \ No newline at end of file From 16ad588ba190360a83eac0c7ad972873e31e7cac Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 24 Oct 2013 11:17:34 +0300 Subject: [PATCH 041/613] Comments in the longest increasing sub-sequence included --- .../longest-increasing-subsequence.js | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js index 8b94ad37..4b26268b 100644 --- a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js +++ b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js @@ -1,5 +1,23 @@ +/** + * Algorithm from dynamic programming. + * It finds the longest sub-sequence of + * increasing numbers. It is not required + * the numbers to be neighboring. + * + * Example: + * 1,5,2 + * The longest sub-sequence is 1,2. + */ exports.longestSubsequence = (function () { + /** + * Find the index of the first largest element in array. + * Complexity O(n). + * + * @param {Array} array The array in which the largest element should be found + * @param {Function} cmp Function used for comparison + * @return {number} The index of the first largest element + */ function max(array, cmp) { if (!array || !array.length) return -1; if (!cmp) { @@ -11,10 +29,22 @@ exports.longestSubsequence = (function () { return max; } + /** + * Default comparison method. + */ function cmp(a, b) { return a.distance - b.distance; } + /** + * Creates directed graph from given array. + * Each element's neighbours are the elements which can be + * after the element in the resulting sequence. + * Complexity O(n^2). + * + * @param {Array} array The input array + * @return {Object} Graph represented with list of neighbours + */ function buildDag(array) { var result = []; for (var i = 0; i < array.length; i += 1) { @@ -26,6 +56,14 @@ exports.longestSubsequence = (function () { return result; } + /** + * Finds the longest sub-sequence for given node. + * O(n^n). + * + * @param {Object} dag Graph represented with list of neighbours. + * @param {number} node The current node. + * @return {object} The longest sub-sequence for given node. + */ function find(dag, node) { node = node || 0; if (find.memo[node]) return find.memo[node]; From ed88fc3714102439413bf6a28c8a6fc4167e63e9 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 26 Oct 2013 17:24:00 +0300 Subject: [PATCH 042/613] Indentation in bubble sort fixed --- src/sorting/bubblesort/bubblesort.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/sorting/bubblesort/bubblesort.js b/src/sorting/bubblesort/bubblesort.js index 21c25bce..ceaff4ac 100644 --- a/src/sorting/bubblesort/bubblesort.js +++ b/src/sorting/bubblesort/bubblesort.js @@ -1,5 +1,3 @@ -var array = [3,5,2,4,7,9,6,4,5]; - /** * The bubblesort algorithm. Complexity O(n^2). * @@ -8,17 +6,17 @@ var array = [3,5,2,4,7,9,6,4,5]; * @returns {array} array Sorted array */ function bubbleSort(array) { - var temp; - for (var i = 0; i < array.length; i += 1) { - for (var j = i; j > 0; j -= 1) { - if (array[j] < array[j - 1]) { - temp = array[j]; - array[j] = array[j - 1]; - array[j - 1] = temp; - } - } + var temp; + for (var i = 0; i < array.length; i += 1) { + for (var j = i; j > 0; j -= 1) { + if (array[j] < array[j - 1]) { + temp = array[j]; + array[j] = array[j - 1]; + array[j - 1] = temp; + } } - return array; + } + return array; } -console.log(bubbleSort(array)); +exports.bubbleSort = bubbleSort; From e9cdc4b7f4c70d9a7740b8c4528653e002337185 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 2 Nov 2013 13:07:20 +0200 Subject: [PATCH 043/613] Tests for binary search added --- src/searching/binarysearch/binarysearch.js | 41 +++++++------------ .../binarysearch/binarysearch.spec.js | 26 ++++++++++++ 2 files changed, 40 insertions(+), 27 deletions(-) create mode 100644 src/searching/binarysearch/binarysearch.spec.js diff --git a/src/searching/binarysearch/binarysearch.js b/src/searching/binarysearch/binarysearch.js index 219d3ad0..65015372 100644 --- a/src/searching/binarysearch/binarysearch.js +++ b/src/searching/binarysearch/binarysearch.js @@ -1,5 +1,3 @@ -var array = [5, 8, 53, 56, 123, 322, 400, 2356, 8000, 23333]; - /** * Searchs for specific element in given array using the binary search algorithm. * It's complexity is O(log n) @@ -10,31 +8,20 @@ var array = [5, 8, 53, 56, 123, 322, 400, 2356, 8000, 23333]; * @returns {number} index The index of the element or -1 if not found */ function binarySearch(array, key) { - var middle = Math.round(array.length / 2), - left = 0, - right = array.length; - while (right >= left) { - if (array[middle] === key) { - return middle; - } else if (array[middle] > key) { - right = middle - 1; - } else { - left = middle + 1; - } - middle = Math.floor((left + right) / 2); + var middle = Math.floor(array.length / 2), + left = 0, + right = array.length; + while (right >= left) { + if (array[middle] === key) { + return middle; + } else if (array[middle] > key) { + right = middle - 1; + } else { + left = middle + 1; } - return -1; + middle = Math.floor((left + right) / 2); + } + return -1; } -console.log(array); -console.log(5, binarySearch(array, 5)); -console.log(8, binarySearch(array, 8)); -console.log(53, binarySearch(array, 53)); -console.log(56, binarySearch(array, 56)); -console.log(123, binarySearch(array, 123)); -console.log(322, binarySearch(array, 322)); -console.log(400, binarySearch(array, 400)); -console.log(2356, binarySearch(array, 2356)); -console.log(8000, binarySearch(array, 8000)); -console.log(8001, binarySearch(array, 8001)); -console.log(23333, binarySearch(array, 23333)); +module.exports.binarySearch = binarySearch; diff --git a/src/searching/binarysearch/binarysearch.spec.js b/src/searching/binarysearch/binarysearch.spec.js new file mode 100644 index 00000000..8613af73 --- /dev/null +++ b/src/searching/binarysearch/binarysearch.spec.js @@ -0,0 +1,26 @@ +var binarySearch = require('./binarysearch').binarySearch; + +describe('Binary search', function () { + + it('should find the element at position 0 ', function () { + expect(binarySearch([1,2,3,4,6,8], 1)).toBe(0); + }); + + it('should find the eleent in position arr.length', function () { + expect(binarySearch([1,2,3,4,6,8], 1)).toBe(0); + }); + + it('should work with arrays with 2 elements', function () { + expect(binarySearch([1,8], 1)).toBe(0); + expect(binarySearch([1,8], 8)).toBe(1); + }); + + it('should return -1 for missing elements', function () { + expect(binarySearch([1,2,3], 4)).toBe(-1); + }); + + it('should work with empty arrays', function () { + expect(binarySearch([], 4)).toBe(-1); + }); + +}); \ No newline at end of file From 5ed239226048ac42ab66c83e88254dd1c867da66 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 9 Nov 2013 19:31:11 +0200 Subject: [PATCH 044/613] trailing spaces removed, 4 to 2 spaces --- src/compression/runlength/runlength.js | 110 ++++++++++++------------- 1 file changed, 53 insertions(+), 57 deletions(-) diff --git a/src/compression/runlength/runlength.js b/src/compression/runlength/runlength.js index 8db4b223..1040d456 100644 --- a/src/compression/runlength/runlength.js +++ b/src/compression/runlength/runlength.js @@ -1,71 +1,67 @@ -var str = 'Sample'; - /** * Run-length encoding. * The idea of this algorithm is to remove the usless zeros and * give us representation of string in binary which in which the * zeros will be stripped and replaced with their count. */ -var runLengthEncoding = (function () { +var runLengthEncoding = (function () { - 'use strict'; + 'use strict'; - /** - * Convers a given string to sequence of numbers - * This takes O(n). - */ - function convertToAscii(str) { - var result = '', - currentChar = '', - i = 0; - for (; i < str.length; i += 1) { - currentChar = str[i].charCodeAt(0).toString(2); - if (currentChar.length < 8) { - while (8 - currentChar.length) { - currentChar = '0' + currentChar; - } - } - result += currentChar; - } - return result; - } - - /** - * Encodes the binary string to run-length encoding. - * Takes O(n^2). - */ - function runLength(vector) { - var result = '', - zeros = 0, - zerosTemp = '', - wordLength = 0, - i = 0; - for (; i < vector.length; i += 1) { - if (vector[i] === '0') { - zeros += 1; - } else { - zerosTemp = zeros.toString(2); - wordLength = zerosTemp.length - 1; - while (wordLength) { - result = result + '1'; - wordLength -= 1; - } - result += '0' + zerosTemp; - zeros = 0; - } + /** + * Convers a given string to sequence of numbers + * This takes O(n). + */ + function convertToAscii(str) { + var result = '', + currentChar = '', + i = 0; + for (; i < str.length; i += 1) { + currentChar = str[i].charCodeAt(0).toString(2); + if (currentChar.length < 8) { + while (8 - currentChar.length) { + currentChar = '0' + currentChar; } - return result; + } + result += currentChar; } + return result; + } - /** - * Accepts a string and returns it's run-length encoded binary representation. - * Takes O(n^2). - */ - return function (str) { - var asciiString = convertToAscii(str); - return runLength(asciiString); + /** + * Encodes the binary string to run-length encoding. + * Takes O(n^2). + */ + function runLength(vector) { + var result = '', + zeros = 0, + zerosTemp = '', + wordLength = 0, + i = 0; + for (; i < vector.length; i += 1) { + if (vector[i] === '0') { + zeros += 1; + } else { + zerosTemp = zeros.toString(2); + wordLength = zerosTemp.length - 1; + while (wordLength) { + result = result + '1'; + wordLength -= 1; + } + result += '0' + zerosTemp; + zeros = 0; + } } + return result; + } -}()); + /** + * Accepts a string and returns it's run-length encoded binary representation. + * Takes O(n^2). + */ + return function (str) { + var asciiString = convertToAscii(str); + return runLength(asciiString); + }; -console.log(runLengthEncoding(str)); +}()); \ No newline at end of file From 36ba31d94a236c655eb440b8207a5f0fb5a63c70 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 22 Nov 2013 10:11:42 +0200 Subject: [PATCH 045/613] Removed the global usage of exports --- src/data-structures/heap.js | 206 +++++++++--------- src/graphs/shortest-path/dijkstra.js | 8 +- src/searching/binarysearch/binarysearch.js | 52 +++-- .../longest-increasing-subsequence.js | 186 ++++++++-------- src/sorting/bubblesort/bubblesort.js | 39 ++-- 5 files changed, 252 insertions(+), 239 deletions(-) diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index 3d3bc7bb..e70bd756 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -1,112 +1,116 @@ -/** - * Constructor function of minimum heap - * - * @public - * @param {function} Function used for comparition between the elements - */ -function Heap(cmp) { - this._heap = []; - if (typeof cmp === 'function') { - this._cmp = cmp; - } else { - this._cmp = function (a, b) { - return a - b; - }; - } -} +(function (exports) { -/** - * Exchange indexes with start index given as argument - * to turn the tree into a valid heap. On a single call - * this method maintains only a single "branch" of the heap. Complexity O(log n) - * - * @private - * @param {number} index The parent - */ -Heap.prototype._heapify = function (index) { - var extr = index, - left = 2 * index + 1, - right = 2 * index + 2, - temp; + /** + * Constructor function of minimum heap + * + * @public + * @param {function} Function used for comparition between the elements + */ + function Heap(cmp) { + this._heap = []; + if (typeof cmp === 'function') { + this._cmp = cmp; + } else { + this._cmp = function (a, b) { + return a - b; + }; + } + } - if (left < this._heap.length && this._cmp(this._heap[left], this._heap[index]) > 0) - extr = left; + /** + * Exchange indexes with start index given as argument + * to turn the tree into a valid heap. On a single call + * this method maintains only a single "branch" of the heap. Complexity O(log n) + * + * @private + * @param {number} index The parent + */ + Heap.prototype._heapify = function (index) { + var extr = index, + left = 2 * index + 1, + right = 2 * index + 2, + temp; - if (right < this._heap.length && this._cmp(this._heap[right], this._heap[index]) > 0) - extr = right; + if (left < this._heap.length && this._cmp(this._heap[left], this._heap[index]) > 0) + extr = left; - if (index !== extr) { - temp = this._heap[index]; - this._heap[index] = this._heap[extr]; - this._heap[extr] = temp; - this._heapify(extr); - } -}; + if (right < this._heap.length && this._cmp(this._heap[right], this._heap[index]) > 0) + extr = right; -/** - * Changes the key for give index. Complexity O(log n). - * - * @public - * @param {number} index Index which key should be changed - * @param {number} value New value of the key - * @returns {number} parent The new position of the element - */ -Heap.prototype.changeKey = function (index, value) { - var elem = this._heap[index], - parent = Math.floor(index / 2), - temp; - if (elem !== undefined) { - while (parent >= 0 && this._cmp(elem, this._heap[parent]) > 0) { - temp = this._heap[parent]; - this._heap[parent] = elem; - this._heap[index] = temp; - index = parent; - parent = Math.floor(parent / 2); - } - } - return parent; -}; + if (index !== extr) { + temp = this._heap[index]; + this._heap[index] = this._heap[extr]; + this._heap[extr] = temp; + this._heapify(extr); + } + }; -/** - * Adds new element to the heap. Complexity O(log n). - * - * @public - * @param {number} value The new value which will be inserted - * @returns {number} The index of the inserted value - */ -Heap.prototype.add = function (value) { - this._heap.push(value); - return this.changeKey(this._heap.length - 1, value); -}; + /** + * Changes the key for give index. Complexity O(log n). + * + * @public + * @param {number} index Index which key should be changed + * @param {number} value New value of the key + * @returns {number} parent The new position of the element + */ + Heap.prototype.changeKey = function (index, value) { + var elem = this._heap[index], + parent = Math.floor(index / 2), + temp; + if (elem !== undefined) { + while (parent >= 0 && this._cmp(elem, this._heap[parent]) > 0) { + temp = this._heap[parent]; + this._heap[parent] = elem; + this._heap[index] = temp; + index = parent; + parent = Math.floor(parent / 2); + } + } + return parent; + }; -/** - * Gets the current value which is on the top of the heap. Complexity O(1). - * - * @public - * returns {numner} The current top value. - */ -Heap.prototype.top = function () { - return this._heap[0]; -}; + /** + * Adds new element to the heap. Complexity O(log n). + * + * @public + * @param {number} value The new value which will be inserted + * @returns {number} The index of the inserted value + */ + Heap.prototype.add = function (value) { + this._heap.push(value); + return this.changeKey(this._heap.length - 1, value); + }; -/** - * Removes and returns the current extremum value which is on the top of the heap. - * Complexity O(log n). - * - * @public - * @returns {number} The extremum value - */ -Heap.prototype.extract = function () { - if (!this._heap.length) - throw 'The heap is already empty!'; + /** + * Gets the current value which is on the top of the heap. Complexity O(1). + * + * @public + * returns {numner} The current top value. + */ + Heap.prototype.top = function () { + return this._heap[0]; + }; - var extr = this._heap.shift(); - this._heapify(0); - return extr; -}; + /** + * Removes and returns the current extremum value which is on the top of the heap. + * Complexity O(log n). + * + * @public + * @returns {number} The extremum value + */ + Heap.prototype.extract = function () { + if (!this._heap.length) + throw 'The heap is already empty!'; -Heap.prototype.isEmpty = function () { - return !this._heapify.length; -}; + var extr = this._heap.shift(); + this._heapify(0); + return extr; + }; -exports.Heap = Heap; + Heap.prototype.isEmpty = function () { + return !this._heapify.length; + }; + + exports.Heap = Heap; + +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index c1767411..2a83d404 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -1,5 +1,4 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * - +/*********************************************** A sample distance matrix var graph = [[NaN, 7, 9, NaN, NaN, 16], @@ -8,8 +7,7 @@ var graph = [[NaN, 7, 9, NaN, NaN, 16], [NaN, 15, 11, NaN, 6, NaN], [NaN, NaN, NaN, 6, NaN, 9], [16, NaN, 2, NaN, 9, NaN]]; - -* * * * * * * * * * * * * * * * * * * * * * * */ +***********************************************/ /** @@ -97,7 +95,7 @@ var dijstra = function () { if (current.node !== i && //if it's not the current node !visited[i] && //and if we haven't visited this node !isNaN(graph[i][current.node])) { //and this node is sibling of the current... - + tempDistance = current.distance + graph[i][current.node]; if (tempDistance < distance[i].distance) { distance[i].distance = tempDistance; diff --git a/src/searching/binarysearch/binarysearch.js b/src/searching/binarysearch/binarysearch.js index 65015372..ed6d1e8d 100644 --- a/src/searching/binarysearch/binarysearch.js +++ b/src/searching/binarysearch/binarysearch.js @@ -1,27 +1,31 @@ -/** - * Searchs for specific element in given array using the binary search algorithm. - * It's complexity is O(log n) - * - * @public - * @param {array} array Input array - * @param {number} key The key of the element which index we should find - * @returns {number} index The index of the element or -1 if not found - */ -function binarySearch(array, key) { - var middle = Math.floor(array.length / 2), - left = 0, - right = array.length; - while (right >= left) { - if (array[middle] === key) { - return middle; - } else if (array[middle] > key) { - right = middle - 1; - } else { - left = middle + 1; +(function (exports) { + + /** + * Searchs for specific element in given array using the binary search algorithm. + * It's complexity is O(log n) + * + * @public + * @param {array} array Input array + * @param {number} key The key of the element which index we should find + * @returns {number} index The index of the element or -1 if not found + */ + function binarySearch(array, key) { + var middle = Math.floor(array.length / 2), + left = 0, + right = array.length; + while (right >= left) { + if (array[middle] === key) { + return middle; + } else if (array[middle] > key) { + right = middle - 1; + } else { + left = middle + 1; + } + middle = Math.floor((left + right) / 2); } - middle = Math.floor((left + right) / 2); + return -1; } - return -1; -} -module.exports.binarySearch = binarySearch; + exports.binarySearch = binarySearch; + +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js index 4b26268b..5a1084bb 100644 --- a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js +++ b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js @@ -1,102 +1,106 @@ -/** - * Algorithm from dynamic programming. - * It finds the longest sub-sequence of - * increasing numbers. It is not required - * the numbers to be neighboring. - * - * Example: - * 1,5,2 - * The longest sub-sequence is 1,2. - */ -exports.longestSubsequence = (function () { +(function (exports) { - /** - * Find the index of the first largest element in array. - * Complexity O(n). - * - * @param {Array} array The array in which the largest element should be found - * @param {Function} cmp Function used for comparison - * @return {number} The index of the first largest element - */ - function max(array, cmp) { - if (!array || !array.length) return -1; - if (!cmp) { - cmp = function (a, b) { return a - b }; + /** + * Algorithm from dynamic programming. + * It finds the longest sub-sequence of + * increasing numbers. It is not required + * the numbers to be neighboring. + * + * Example: + * 1,5,2 + * The longest sub-sequence is 1,2. + */ + exports.longestSubsequence = (function () { + + /** + * Find the index of the first largest element in array. + * Complexity O(n). + * + * @param {Array} array The array in which the largest element should be found + * @param {Function} cmp Function used for comparison + * @return {number} The index of the first largest element + */ + function max(array, cmp) { + if (!array || !array.length) return -1; + if (!cmp) { + cmp = function (a, b) { return a - b }; + } + var max = 0; + for (var i = 1; i < array.length; i += 1) + if (cmp(array[max], array[i]) < 0) max = i; + return max; } - var max = 0; - for (var i = 1; i < array.length; i += 1) - if (cmp(array[max], array[i]) < 0) max = i; - return max; - } - /** - * Default comparison method. - */ - function cmp(a, b) { - return a.distance - b.distance; - } + /** + * Default comparison method. + */ + function cmp(a, b) { + return a.distance - b.distance; + } - /** - * Creates directed graph from given array. - * Each element's neighbours are the elements which can be - * after the element in the resulting sequence. - * Complexity O(n^2). - * - * @param {Array} array The input array - * @return {Object} Graph represented with list of neighbours - */ - function buildDag(array) { - var result = []; - for (var i = 0; i < array.length; i += 1) { - result[i] = []; - for (var j = i + 1; j < array.length; j += 1) { - if (array[i] < array[j]) result[i].push(j); + /** + * Creates directed graph from given array. + * Each element's neighbours are the elements which can be + * after the element in the resulting sequence. + * Complexity O(n^2). + * + * @param {Array} array The input array + * @return {Object} Graph represented with list of neighbours + */ + function buildDag(array) { + var result = []; + for (var i = 0; i < array.length; i += 1) { + result[i] = []; + for (var j = i + 1; j < array.length; j += 1) { + if (array[i] < array[j]) result[i].push(j); + } } + return result; } - return result; - } - /** - * Finds the longest sub-sequence for given node. - * O(n^n). - * - * @param {Object} dag Graph represented with list of neighbours. - * @param {number} node The current node. - * @return {object} The longest sub-sequence for given node. - */ - function find(dag, node) { - node = node || 0; - if (find.memo[node]) return find.memo[node]; - var neighbours = dag[node], - neighboursDistance = [], - maxDist, maxNode, distance, result; + /** + * Finds the longest sub-sequence for given node. + * O(n^n). + * + * @param {Object} dag Graph represented with list of neighbours. + * @param {number} node The current node. + * @return {object} The longest sub-sequence for given node. + */ + function find(dag, node) { + node = node || 0; + if (find.memo[node]) return find.memo[node]; + var neighbours = dag[node], + neighboursDistance = [], + maxDist, maxNode, distance, result; - if (!neighbours.length) return { distance: 1, neighbour: undefined, node: node }; + if (!neighbours.length) return { distance: 1, neighbour: undefined, node: node }; - for (var i = 0; i < neighbours.length; i += 1) - neighboursDistance[i] = find(dag, neighbours[i]); + for (var i = 0; i < neighbours.length; i += 1) + neighboursDistance[i] = find(dag, neighbours[i]); - maxDist = max(neighboursDistance, cmp); - maxNode = neighbours[maxDist]; - distance = 1 + neighboursDistance[maxDist].distance; - find.memo[node] = result = { distance: distance, neighbour: neighboursDistance[maxDist], node: node }; - return result; - } - - return function (array) { - var results = [], - dag = buildDag(array), - maxPath; - find.memo = []; - for (var i = 0; i < array.length; i += 1) { - results.push(find(dag, i)); - } - maxPath = results[max(results, cmp)]; - results = []; - while (maxPath) { - results.push(array[maxPath.node]); - maxPath = maxPath.neighbour; + maxDist = max(neighboursDistance, cmp); + maxNode = neighbours[maxDist]; + distance = 1 + neighboursDistance[maxDist].distance; + find.memo[node] = result = { distance: distance, neighbour: neighboursDistance[maxDist], node: node }; + return result; } - return results; - }; -})(); \ No newline at end of file + + return function (array) { + var results = [], + dag = buildDag(array), + maxPath; + find.memo = []; + for (var i = 0; i < array.length; i += 1) { + results.push(find(dag, i)); + } + maxPath = results[max(results, cmp)]; + results = []; + while (maxPath) { + results.push(array[maxPath.node]); + maxPath = maxPath.neighbour; + } + return results; + }; + })(); + +}(typeof exports === 'undefined' ? exports : this)); \ No newline at end of file diff --git a/src/sorting/bubblesort/bubblesort.js b/src/sorting/bubblesort/bubblesort.js index ceaff4ac..3e77fe7e 100644 --- a/src/sorting/bubblesort/bubblesort.js +++ b/src/sorting/bubblesort/bubblesort.js @@ -1,22 +1,25 @@ -/** - * The bubblesort algorithm. Complexity O(n^2). - * - * @public - * @param {array} array Input array - * @returns {array} array Sorted array - */ -function bubbleSort(array) { - var temp; - for (var i = 0; i < array.length; i += 1) { - for (var j = i; j > 0; j -= 1) { - if (array[j] < array[j - 1]) { - temp = array[j]; - array[j] = array[j - 1]; - array[j - 1] = temp; +(function (exports) { + /** + * The bubblesort algorithm. Complexity O(n^2). + * + * @public + * @param {array} array Input array + * @returns {array} array Sorted array + */ + function bubbleSort(array) { + var temp; + for (var i = 0; i < array.length; i += 1) { + for (var j = i; j > 0; j -= 1) { + if (array[j] < array[j - 1]) { + temp = array[j]; + array[j] = array[j - 1]; + array[j - 1] = temp; + } } } + return array; } - return array; -} -exports.bubbleSort = bubbleSort; + exports.bubbleSort = bubbleSort; + +}(typeof exports === 'undefined' ? window : exports)); From 8f7681fbf4371f24a210389bdc58c926b907258a Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 26 Nov 2013 18:28:21 +0100 Subject: [PATCH 046/613] Change indentation to 2 spaces in the heap implementation --- src/data-structures/heap.js | 86 ++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index e70bd756..231794e5 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -7,14 +7,14 @@ * @param {function} Function used for comparition between the elements */ function Heap(cmp) { - this._heap = []; - if (typeof cmp === 'function') { - this._cmp = cmp; - } else { - this._cmp = function (a, b) { - return a - b; - }; - } + this._heap = []; + if (typeof cmp === 'function') { + this._cmp = cmp; + } else { + this._cmp = function (a, b) { + return a - b; + }; + } } /** @@ -26,23 +26,23 @@ * @param {number} index The parent */ Heap.prototype._heapify = function (index) { - var extr = index, - left = 2 * index + 1, - right = 2 * index + 2, - temp; + var extr = index, + left = 2 * index + 1, + right = 2 * index + 2, + temp; - if (left < this._heap.length && this._cmp(this._heap[left], this._heap[index]) > 0) - extr = left; + if (left < this._heap.length && this._cmp(this._heap[left], this._heap[index]) > 0) + extr = left; - if (right < this._heap.length && this._cmp(this._heap[right], this._heap[index]) > 0) - extr = right; + if (right < this._heap.length && this._cmp(this._heap[right], this._heap[index]) > 0) + extr = right; - if (index !== extr) { - temp = this._heap[index]; - this._heap[index] = this._heap[extr]; - this._heap[extr] = temp; - this._heapify(extr); - } + if (index !== extr) { + temp = this._heap[index]; + this._heap[index] = this._heap[extr]; + this._heap[extr] = temp; + this._heapify(extr); + } }; /** @@ -54,19 +54,19 @@ * @returns {number} parent The new position of the element */ Heap.prototype.changeKey = function (index, value) { - var elem = this._heap[index], - parent = Math.floor(index / 2), - temp; - if (elem !== undefined) { - while (parent >= 0 && this._cmp(elem, this._heap[parent]) > 0) { - temp = this._heap[parent]; - this._heap[parent] = elem; - this._heap[index] = temp; - index = parent; - parent = Math.floor(parent / 2); - } + var elem = this._heap[index], + parent = Math.floor(index / 2), + temp; + if (elem !== undefined) { + while (parent >= 0 && this._cmp(elem, this._heap[parent]) > 0) { + temp = this._heap[parent]; + this._heap[parent] = elem; + this._heap[index] = temp; + index = parent; + parent = Math.floor(parent / 2); } - return parent; + } + return parent; }; /** @@ -77,8 +77,8 @@ * @returns {number} The index of the inserted value */ Heap.prototype.add = function (value) { - this._heap.push(value); - return this.changeKey(this._heap.length - 1, value); + this._heap.push(value); + return this.changeKey(this._heap.length - 1, value); }; /** @@ -88,7 +88,7 @@ * returns {numner} The current top value. */ Heap.prototype.top = function () { - return this._heap[0]; + return this._heap[0]; }; /** @@ -99,16 +99,16 @@ * @returns {number} The extremum value */ Heap.prototype.extract = function () { - if (!this._heap.length) - throw 'The heap is already empty!'; + if (!this._heap.length) + throw 'The heap is already empty!'; - var extr = this._heap.shift(); - this._heapify(0); - return extr; + var extr = this._heap.shift(); + this._heapify(0); + return extr; }; Heap.prototype.isEmpty = function () { - return !this._heapify.length; + return !this._heapify.length; }; exports.Heap = Heap; From 98cb974b07ed75ecd9b6ada565f7713c017b118b Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Sat, 4 Jan 2014 16:55:10 +0200 Subject: [PATCH 047/613] Update readme.md --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 42fd5d05..a0408617 100644 --- a/readme.md +++ b/readme.md @@ -3,3 +3,5 @@ This repository contains different famous Computer Science algorithms implemente ##License The code in this repository is distributed under the terms of the MIT license. + +[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/mgechev/javascript-algorithms/trend.png)](https://bitdeli.com/free "Bitdeli Badge") From b46f04117bbe187e5eac171bdf12e7fca6e8fcae Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 6 Feb 2014 16:36:31 +0200 Subject: [PATCH 048/613] Remove test data and trailing spaces --- .../binarysearch/recursive-binarysearch.js | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/searching/binarysearch/recursive-binarysearch.js b/src/searching/binarysearch/recursive-binarysearch.js index 711ddeaa..7e1c3c61 100644 --- a/src/searching/binarysearch/recursive-binarysearch.js +++ b/src/searching/binarysearch/recursive-binarysearch.js @@ -1,13 +1,10 @@ -var array = [5, 8, 53, 56, 123, 322, 400, 2356, 8000, 23333]; - - /** * Recursive version of binary search. It's complexity is O(log n). * * @public */ var binarySearch = (function () { - + /** * Binary search. * @@ -18,14 +15,14 @@ var binarySearch = (function () { * @param {number} right Right index * @returns {number} index The index of the element or -1 if not found * - */ + */ function recursiveBinarySearch(array, key, left, right) { if (left > right) return -1; var middle = Math.floor((right + left) / 2); if (array[middle] === key) return middle; - else if (array[middle] > key) + else if (array[middle] > key) return recursiveBinarySearch(array, key, left, middle - 1); else return recursiveBinarySearch(array, key, middle + 1, right); @@ -43,18 +40,3 @@ var binarySearch = (function () { }; }()); - - - -console.log(array); -console.log(5, binarySearch(array, 5)); -console.log(8, binarySearch(array, 8)); -console.log(53, binarySearch(array, 53)); -console.log(56, binarySearch(array, 56)); -console.log(123, binarySearch(array, 123)); -console.log(322, binarySearch(array, 322)); -console.log(400, binarySearch(array, 400)); -console.log(2356, binarySearch(array, 2356)); -console.log(8000, binarySearch(array, 8000)); -console.log(8001, binarySearch(array, 8001)); -console.log(23333, binarySearch(array, 23333)); From 7881ca9ce37d415cc438882cc1d426838584e459 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 11 Feb 2014 13:51:23 +0200 Subject: [PATCH 049/613] Remove tests from the src folder --- .../binarysearch/binarysearch.spec.js | 26 ------------------- .../longest-increasing-subsequence.spec.js | 21 --------------- 2 files changed, 47 deletions(-) delete mode 100644 src/searching/binarysearch/binarysearch.spec.js delete mode 100644 src/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js diff --git a/src/searching/binarysearch/binarysearch.spec.js b/src/searching/binarysearch/binarysearch.spec.js deleted file mode 100644 index 8613af73..00000000 --- a/src/searching/binarysearch/binarysearch.spec.js +++ /dev/null @@ -1,26 +0,0 @@ -var binarySearch = require('./binarysearch').binarySearch; - -describe('Binary search', function () { - - it('should find the element at position 0 ', function () { - expect(binarySearch([1,2,3,4,6,8], 1)).toBe(0); - }); - - it('should find the eleent in position arr.length', function () { - expect(binarySearch([1,2,3,4,6,8], 1)).toBe(0); - }); - - it('should work with arrays with 2 elements', function () { - expect(binarySearch([1,8], 1)).toBe(0); - expect(binarySearch([1,8], 8)).toBe(1); - }); - - it('should return -1 for missing elements', function () { - expect(binarySearch([1,2,3], 4)).toBe(-1); - }); - - it('should work with empty arrays', function () { - expect(binarySearch([], 4)).toBe(-1); - }); - -}); \ No newline at end of file diff --git a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js deleted file mode 100644 index 71a0cb43..00000000 --- a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js +++ /dev/null @@ -1,21 +0,0 @@ -var longestSubsequence = require('./longest-increasing-subsequence').longestSubsequence; - -describe('longest subsequence', function () { - - beforeEach(function () { - global.sequence = [5, 2, 8, 6, 3, 6, 9, 7, 11]; - }); - - it('should give the right length', function () { - expect(longestSubsequence(sequence).length).toBe(5); - }); - - it('should work with empty arrays', function () { - expect(longestSubsequence([]).length).toBe(0); - }); - - it('should return the correct path', function () { - expect(longestSubsequence(sequence).toString()).toBe([2,3,6,9,11].toString()); - }); - -}); \ No newline at end of file From bccfb5717b1f48271db61d95a918d99586e064e5 Mon Sep 17 00:00:00 2001 From: Eric Schoffstall Date: Tue, 11 Feb 2014 21:36:09 -0700 Subject: [PATCH 050/613] closes #2 --- src/graphs/searching/weightquickunion.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/graphs/searching/weightquickunion.js b/src/graphs/searching/weightquickunion.js index ae159634..22142ff9 100644 --- a/src/graphs/searching/weightquickunion.js +++ b/src/graphs/searching/weightquickunion.js @@ -49,13 +49,18 @@ QuickUnion.prototype.connected = function (p, q) { * @param {number} q The second node */ QuickUnion.prototype.union = function (p, q) { - if (this._size[p] > this._size[q]) { - this._ids[this._root(p)] = this._root(q); + var pf = this._root(p); + var qf = this._root(q); + if (pf == qf) return; // already linked + var psz = this._size[qf]; + var qsz = this._size[pf]; + if (psz < qsz) { + this._ids[pf] = qf; + this._size[qf] += psz; } else { - this._ids[this._root(q)] = this._root(p); + this._ids[qf] = pf; + this._size[pf] += qsz; } - this._size[p] += this._size[q]; - this._size[q] = this._size[p]; }; //var union = new QuickUnion(10); From c06f092ed3cbd2610749ebe17595800599e9622c Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 13 Feb 2014 10:25:03 +0200 Subject: [PATCH 051/613] Adds tests to test directory --- test/binarysearch.spec.js | 26 +++++++++++++++++++++ test/longest-increasing-subsequence.spec.js | 21 +++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 test/binarysearch.spec.js create mode 100644 test/longest-increasing-subsequence.spec.js diff --git a/test/binarysearch.spec.js b/test/binarysearch.spec.js new file mode 100644 index 00000000..15a17524 --- /dev/null +++ b/test/binarysearch.spec.js @@ -0,0 +1,26 @@ +var binarySearch = require('./../src/searching/binarysearch/binarysearch').binarySearch; + +describe('Binary search', function () { + + it('should find the element at position 0 ', function () { + expect(binarySearch([1,2,3,4,6,8], 1)).toBe(0); + }); + + it('should find the eleent in position arr.length', function () { + expect(binarySearch([1,2,3,4,6,8], 1)).toBe(0); + }); + + it('should work with arrays with 2 elements', function () { + expect(binarySearch([1,8], 1)).toBe(0); + expect(binarySearch([1,8], 8)).toBe(1); + }); + + it('should return -1 for missing elements', function () { + expect(binarySearch([1,2,3], 4)).toBe(-1); + }); + + it('should work with empty arrays', function () { + expect(binarySearch([], 4)).toBe(-1); + }); + +}); \ No newline at end of file diff --git a/test/longest-increasing-subsequence.spec.js b/test/longest-increasing-subsequence.spec.js new file mode 100644 index 00000000..91139d1f --- /dev/null +++ b/test/longest-increasing-subsequence.spec.js @@ -0,0 +1,21 @@ +var longestSubsequence = require('./../src/searching/longest-increasing-subsequence/longest-increasing-subsequence').longestSubsequence; + +describe('longest subsequence', function () { + + beforeEach(function () { + global.sequence = [5, 2, 8, 6, 3, 6, 9, 7, 11]; + }); + + it('should give the right length', function () { + expect(longestSubsequence(sequence).length).toBe(5); + }); + + it('should work with empty arrays', function () { + expect(longestSubsequence([]).length).toBe(0); + }); + + it('should return the correct path', function () { + expect(longestSubsequence(sequence).toString()).toBe([2,3,6,9,11].toString()); + }); + +}); \ No newline at end of file From 50f812fd9eac812ea9f8486fe43b64de0a1e13e3 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 14 Feb 2014 10:41:31 +0200 Subject: [PATCH 052/613] Add tests for bubble sort --- src/sorting/bubblesort/bubblesort.js | 2 +- test/bubblesort.spec.js | 36 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 test/bubblesort.spec.js diff --git a/src/sorting/bubblesort/bubblesort.js b/src/sorting/bubblesort/bubblesort.js index 3e77fe7e..b1fe8136 100644 --- a/src/sorting/bubblesort/bubblesort.js +++ b/src/sorting/bubblesort/bubblesort.js @@ -20,6 +20,6 @@ return array; } - exports.bubbleSort = bubbleSort; + module.exports = bubbleSort; }(typeof exports === 'undefined' ? window : exports)); diff --git a/test/bubblesort.spec.js b/test/bubblesort.spec.js new file mode 100644 index 00000000..a7d31381 --- /dev/null +++ b/test/bubblesort.spec.js @@ -0,0 +1,36 @@ +var bubbleSort = require('../src/sorting/bubblesort/bubblesort.js') + +describe('Bubble sort', function () { + + it('should work with empty array', function () { + expect(bubbleSort([])).toEqual([]); + }); + + it('should work with sorted arrays', function () { + expect(bubbleSort([1,2,3,4])).toEqual([1,2,3,4]); + }); + + it('should work with random non-sorted arrays', function () { + + function createRandomArray(options) { + options = options || {}; + var size = options.size || 100, + precision = options.precision || 2, + multiplier = options.multiplier || 100; + + var result = []; + for (var i = size; i > 0; i -= 1) { + result.push(parseFloat((Math.random() * multiplier).toFixed(precision))); + } + return result; + } + + var array = createRandomArray(); + bubbleSort(array); + + for (var i = 0; i < array.length - 1; i += 1) { + expect(array[i] <= array[i + 1]).toBeTruthy(); + } + }); + +}); \ No newline at end of file From 4e820cc8997934b6ca0176cf10d97e24d6be2595 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 14 Feb 2014 10:45:28 +0200 Subject: [PATCH 053/613] Adds comparator for bubble sort --- src/sorting/bubblesort/bubblesort.js | 10 +++++-- test/bubblesort.spec.js | 39 ++++++++++++++++++---------- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/sorting/bubblesort/bubblesort.js b/src/sorting/bubblesort/bubblesort.js index b1fe8136..30cad65d 100644 --- a/src/sorting/bubblesort/bubblesort.js +++ b/src/sorting/bubblesort/bubblesort.js @@ -1,4 +1,9 @@ (function (exports) { + + function comparator(a, b) { + return a - b; + } + /** * The bubblesort algorithm. Complexity O(n^2). * @@ -6,11 +11,12 @@ * @param {array} array Input array * @returns {array} array Sorted array */ - function bubbleSort(array) { + function bubbleSort(array, cmp) { + cmp = cmp || comparator; var temp; for (var i = 0; i < array.length; i += 1) { for (var j = i; j > 0; j -= 1) { - if (array[j] < array[j - 1]) { + if (cmp(array[j], array[j - 1]) < 0) { temp = array[j]; array[j] = array[j - 1]; array[j - 1] = temp; diff --git a/test/bubblesort.spec.js b/test/bubblesort.spec.js index a7d31381..e59a39c7 100644 --- a/test/bubblesort.spec.js +++ b/test/bubblesort.spec.js @@ -2,6 +2,19 @@ var bubbleSort = require('../src/sorting/bubblesort/bubblesort.js') describe('Bubble sort', function () { + function createRandomArray(options) { + options = options || {}; + var size = options.size || 100, + precision = options.precision || 2, + multiplier = options.multiplier || 100; + + var result = []; + for (var i = size; i > 0; i -= 1) { + result.push(parseFloat((Math.random() * multiplier).toFixed(precision))); + } + return result; + } + it('should work with empty array', function () { expect(bubbleSort([])).toEqual([]); }); @@ -12,19 +25,6 @@ describe('Bubble sort', function () { it('should work with random non-sorted arrays', function () { - function createRandomArray(options) { - options = options || {}; - var size = options.size || 100, - precision = options.precision || 2, - multiplier = options.multiplier || 100; - - var result = []; - for (var i = size; i > 0; i -= 1) { - result.push(parseFloat((Math.random() * multiplier).toFixed(precision))); - } - return result; - } - var array = createRandomArray(); bubbleSort(array); @@ -33,4 +33,17 @@ describe('Bubble sort', function () { } }); + it('should sort the numbers in descending order when such comparator is provided', function () { + function comparator(a, b) { + return b - a; + } + + var array = createRandomArray(); + bubbleSort(array, comparator); + + for (var i = 0; i < array.length - 1; i += 1) { + expect(array[i] >= array[i + 1]).toBeTruthy(); + } + }); + }); \ No newline at end of file From ca74b8d4357ec2d4fc4195b1cfc558a4c6b68303 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 15 Feb 2014 11:56:12 +0200 Subject: [PATCH 054/613] Update README.md --- readme.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index a0408617..cd9bd4ee 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,22 @@ -##About +## About + This repository contains different famous Computer Science algorithms implemented in JavaScript -##License +In order to run the tests use: + +```Bash +jasmine-node test/ +``` + +and all `*.spec.js` files will be executed. + +## Contributions + +Fork the repo and make requred changes. After that push your changes in branch, which is named according to the changes you did. +Initiate the PR. + +## License + The code in this repository is distributed under the terms of the MIT license. [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/mgechev/javascript-algorithms/trend.png)](https://bitdeli.com/free "Bitdeli Badge") From 3fb3e4b66fbdb467766046e421f3633760f354cf Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 16 Feb 2014 10:17:59 +0200 Subject: [PATCH 055/613] Creates common test case for sorting algorithms --- test/bubblesort.spec.js | 51 +++-------------------------------------- test/sort.testcase.js | 49 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 48 deletions(-) create mode 100644 test/sort.testcase.js diff --git a/test/bubblesort.spec.js b/test/bubblesort.spec.js index e59a39c7..6647e823 100644 --- a/test/bubblesort.spec.js +++ b/test/bubblesort.spec.js @@ -1,49 +1,4 @@ -var bubbleSort = require('../src/sorting/bubblesort/bubblesort.js') +var sortTestCase = require('./sort.testcase.js'), + bubbleSort = require('../src/sorting/bubblesort/bubblesort.js'); -describe('Bubble sort', function () { - - function createRandomArray(options) { - options = options || {}; - var size = options.size || 100, - precision = options.precision || 2, - multiplier = options.multiplier || 100; - - var result = []; - for (var i = size; i > 0; i -= 1) { - result.push(parseFloat((Math.random() * multiplier).toFixed(precision))); - } - return result; - } - - it('should work with empty array', function () { - expect(bubbleSort([])).toEqual([]); - }); - - it('should work with sorted arrays', function () { - expect(bubbleSort([1,2,3,4])).toEqual([1,2,3,4]); - }); - - it('should work with random non-sorted arrays', function () { - - var array = createRandomArray(); - bubbleSort(array); - - for (var i = 0; i < array.length - 1; i += 1) { - expect(array[i] <= array[i + 1]).toBeTruthy(); - } - }); - - it('should sort the numbers in descending order when such comparator is provided', function () { - function comparator(a, b) { - return b - a; - } - - var array = createRandomArray(); - bubbleSort(array, comparator); - - for (var i = 0; i < array.length - 1; i += 1) { - expect(array[i] >= array[i + 1]).toBeTruthy(); - } - }); - -}); \ No newline at end of file +sortTestCase(bubbleSort); \ No newline at end of file diff --git a/test/sort.testcase.js b/test/sort.testcase.js new file mode 100644 index 00000000..7b7933ba --- /dev/null +++ b/test/sort.testcase.js @@ -0,0 +1,49 @@ +module.exports = function (sort) { + describe('Bubble sort', function () { + + function createRandomArray(options) { + options = options || {}; + var size = options.size || 100, + precision = options.precision || 2, + multiplier = options.multiplier || 100; + + var result = []; + for (var i = size; i > 0; i -= 1) { + result.push(parseFloat((Math.random() * multiplier).toFixed(precision))); + } + return result; + } + + it('should work with empty array', function () { + expect(sort([])).toEqual([]); + }); + + it('should work with sorted arrays', function () { + expect(sort([1,2,3,4])).toEqual([1,2,3,4]); + }); + + it('should work with random non-sorted arrays', function () { + + var array = createRandomArray(); + sort(array); + + for (var i = 0; i < array.length - 1; i += 1) { + expect(array[i] <= array[i + 1]).toBeTruthy(); + } + }); + + it('should sort the numbers in descending order when such comparator is provided', function () { + function comparator(a, b) { + return b - a; + } + + var array = createRandomArray(); + sort(array, comparator); + + for (var i = 0; i < array.length - 1; i += 1) { + expect(array[i] >= array[i + 1]).toBeTruthy(); + } + }); + + }); +}; \ No newline at end of file From 89648f41b341a8ab56f676dc1c93ac1c1b48eb6c Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 16 Feb 2014 10:20:50 +0200 Subject: [PATCH 056/613] Transforms heapsort from 4 to 2 spaces --- src/sorting/heapsort/heapsort.js | 110 +++++++++++++++---------------- test/bubblesort.spec.js | 2 +- test/sort.testcase.js | 4 +- 3 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/sorting/heapsort/heapsort.js b/src/sorting/heapsort/heapsort.js index 6bbb7088..f890938f 100644 --- a/src/sorting/heapsort/heapsort.js +++ b/src/sorting/heapsort/heapsort.js @@ -7,66 +7,66 @@ var array = [3,4,6,2,3,6,8,9]; */ var heapSort = (function () { - /** - * Finds the correct place of given element in given max heap. - * - * @private - * @param {array} array Array - * @param {number} index Index of the element which palce in the max heap should be found. - */ - function heapify(array, index, heapSize) { - var left = 2 * index + 1, - right = 2 * index + 2, - largest = index; - - if (left < heapSize && array[left] > array[index]) - largest = left; + /** + * Finds the correct place of given element in given max heap. + * + * @private + * @param {array} array Array + * @param {number} index Index of the element which palce in the max heap should be found. + */ + function heapify(array, index, heapSize) { + var left = 2 * index + 1, + right = 2 * index + 2, + largest = index; - if (right < heapSize && array[right] > array[largest]) - largest = right; - - if (largest !== index) { - var temp = array[index]; - array[index] = array[largest]; - array[largest] = temp; - heapify(array, largest, heapSize); - } + if (left < heapSize && array[left] > array[index]) + largest = left; + + if (right < heapSize && array[right] > array[largest]) + largest = right; + + if (largest !== index) { + var temp = array[index]; + array[index] = array[largest]; + array[largest] = temp; + heapify(array, largest, heapSize); } + } - /** - * Builds max heap from given array. - * - * @private - * @param {array} array Array which should be turned into max heap - * @returns {array} array Array turned into max heap - */ - function buildMaxHeap(array) { - for (var i = Math.floor(array.length / 2); i >= 0; i -= 1) { - heapify(array, i, array.length); - } - return array; + /** + * Builds max heap from given array. + * + * @private + * @param {array} array Array which should be turned into max heap + * @returns {array} array Array turned into max heap + */ + function buildMaxHeap(array) { + for (var i = Math.floor(array.length / 2); i >= 0; i -= 1) { + heapify(array, i, array.length); } + return array; + } - /** - * Heapsort. Turns the input array into max heap and after that sorts it. - * - * @public - * @param {array} array Input array - * @returns {array} array Sorted array - */ - return function (array) { - var size = array.length, - temp; - buildMaxHeap(array); - for (var i = array.length - 1; i > 0; i -= 1) { - temp = array[0]; - array[0] = array[i]; - array[i] = temp; - size -= 1; - heapify(array, 0, size); - } - return array; - }; + /** + * Heapsort. Turns the input array into max heap and after that sorts it. + * + * @public + * @param {array} array Input array + * @returns {array} array Sorted array + */ + return function (array) { + var size = array.length, + temp; + buildMaxHeap(array); + for (var i = array.length - 1; i > 0; i -= 1) { + temp = array[0]; + array[0] = array[i]; + array[i] = temp; + size -= 1; + heapify(array, 0, size); + } + return array; + }; }()); console.log(heapSort(array)); diff --git a/test/bubblesort.spec.js b/test/bubblesort.spec.js index 6647e823..b2dfe7f5 100644 --- a/test/bubblesort.spec.js +++ b/test/bubblesort.spec.js @@ -1,4 +1,4 @@ var sortTestCase = require('./sort.testcase.js'), bubbleSort = require('../src/sorting/bubblesort/bubblesort.js'); -sortTestCase(bubbleSort); \ No newline at end of file +sortTestCase(bubbleSort, 'Bubble sort'); \ No newline at end of file diff --git a/test/sort.testcase.js b/test/sort.testcase.js index 7b7933ba..d186c323 100644 --- a/test/sort.testcase.js +++ b/test/sort.testcase.js @@ -1,5 +1,5 @@ -module.exports = function (sort) { - describe('Bubble sort', function () { +module.exports = function (sort, algorithmName) { + describe(algorithmName, function () { function createRandomArray(options) { options = options || {}; From 208535440a267dded24e8a4e71805b17551b8a16 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 16 Feb 2014 10:23:14 +0200 Subject: [PATCH 057/613] Exports heap sort --- src/sorting/bubblesort/bubblesort.js | 2 +- src/sorting/heapsort/heapsort.js | 122 ++++++++++++++------------- test/bubblesort.spec.js | 2 +- 3 files changed, 64 insertions(+), 62 deletions(-) diff --git a/src/sorting/bubblesort/bubblesort.js b/src/sorting/bubblesort/bubblesort.js index 30cad65d..9a481b89 100644 --- a/src/sorting/bubblesort/bubblesort.js +++ b/src/sorting/bubblesort/bubblesort.js @@ -26,6 +26,6 @@ return array; } - module.exports = bubbleSort; + exports.bubbleSort = bubbleSort; }(typeof exports === 'undefined' ? window : exports)); diff --git a/src/sorting/heapsort/heapsort.js b/src/sorting/heapsort/heapsort.js index f890938f..abdcd3d1 100644 --- a/src/sorting/heapsort/heapsort.js +++ b/src/sorting/heapsort/heapsort.js @@ -1,72 +1,74 @@ -var array = [3,4,6,2,3,6,8,9]; - -/** - * The heapsort algorithm. It's complexity is O(nlog n). - * - * @public - */ -var heapSort = (function () { +(function (exports) { /** - * Finds the correct place of given element in given max heap. + * The heapsort algorithm. It's complexity is O(nlog n). * - * @private - * @param {array} array Array - * @param {number} index Index of the element which palce in the max heap should be found. + * @public */ - function heapify(array, index, heapSize) { - var left = 2 * index + 1, - right = 2 * index + 2, - largest = index; + var heapSort = (function () { - if (left < heapSize && array[left] > array[index]) - largest = left; + /** + * Finds the correct place of given element in given max heap. + * + * @private + * @param {array} array Array + * @param {number} index Index of the element which palce in the max heap should be found. + */ + function heapify(array, index, heapSize) { + var left = 2 * index + 1, + right = 2 * index + 2, + largest = index; - if (right < heapSize && array[right] > array[largest]) - largest = right; + if (left < heapSize && array[left] > array[index]) + largest = left; - if (largest !== index) { - var temp = array[index]; - array[index] = array[largest]; - array[largest] = temp; - heapify(array, largest, heapSize); - } - } + if (right < heapSize && array[right] > array[largest]) + largest = right; - /** - * Builds max heap from given array. - * - * @private - * @param {array} array Array which should be turned into max heap - * @returns {array} array Array turned into max heap - */ - function buildMaxHeap(array) { - for (var i = Math.floor(array.length / 2); i >= 0; i -= 1) { - heapify(array, i, array.length); + if (largest !== index) { + var temp = array[index]; + array[index] = array[largest]; + array[largest] = temp; + heapify(array, largest, heapSize); + } } - return array; - } - /** - * Heapsort. Turns the input array into max heap and after that sorts it. - * - * @public - * @param {array} array Input array - * @returns {array} array Sorted array - */ - return function (array) { - var size = array.length, - temp; - buildMaxHeap(array); - for (var i = array.length - 1; i > 0; i -= 1) { - temp = array[0]; - array[0] = array[i]; - array[i] = temp; - size -= 1; - heapify(array, 0, size); + /** + * Builds max heap from given array. + * + * @private + * @param {array} array Array which should be turned into max heap + * @returns {array} array Array turned into max heap + */ + function buildMaxHeap(array) { + for (var i = Math.floor(array.length / 2); i >= 0; i -= 1) { + heapify(array, i, array.length); + } + return array; } - return array; - }; -}()); -console.log(heapSort(array)); + /** + * Heapsort. Turns the input array into max heap and after that sorts it. + * + * @public + * @param {array} array Input array + * @returns {array} array Sorted array + */ + return function (array) { + var size = array.length, + temp; + buildMaxHeap(array); + for (var i = array.length - 1; i > 0; i -= 1) { + temp = array[0]; + array[0] = array[i]; + array[i] = temp; + size -= 1; + heapify(array, 0, size); + } + return array; + }; + }()); + + exports.heapSort = heapSort; + +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file diff --git a/test/bubblesort.spec.js b/test/bubblesort.spec.js index b2dfe7f5..102ee4dd 100644 --- a/test/bubblesort.spec.js +++ b/test/bubblesort.spec.js @@ -1,4 +1,4 @@ var sortTestCase = require('./sort.testcase.js'), - bubbleSort = require('../src/sorting/bubblesort/bubblesort.js'); + bubbleSort = require('../src/sorting/bubblesort/bubblesort.js').bubbleSort; sortTestCase(bubbleSort, 'Bubble sort'); \ No newline at end of file From 3a77e0ee89cfe0af7e485cfbdd40b2ab4d94826e Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 16 Feb 2014 10:26:32 +0200 Subject: [PATCH 058/613] Adds comparator to heap sort --- src/sorting/heapsort/heapsort.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/sorting/heapsort/heapsort.js b/src/sorting/heapsort/heapsort.js index abdcd3d1..0bd7ec5d 100644 --- a/src/sorting/heapsort/heapsort.js +++ b/src/sorting/heapsort/heapsort.js @@ -1,5 +1,9 @@ (function (exports) { + function comparator(a, b) { + return a - b; + } + /** * The heapsort algorithm. It's complexity is O(nlog n). * @@ -14,22 +18,22 @@ * @param {array} array Array * @param {number} index Index of the element which palce in the max heap should be found. */ - function heapify(array, index, heapSize) { + function heapify(array, index, heapSize, cmp) { var left = 2 * index + 1, right = 2 * index + 2, largest = index; - if (left < heapSize && array[left] > array[index]) + if (left < heapSize && cmp(array[left], array[index]) > 0) largest = left; - if (right < heapSize && array[right] > array[largest]) + if (right < heapSize && cmp(array[right], array[largest]) > 0) largest = right; if (largest !== index) { var temp = array[index]; array[index] = array[largest]; array[largest] = temp; - heapify(array, largest, heapSize); + heapify(array, largest, heapSize, cmp); } } @@ -40,9 +44,9 @@ * @param {array} array Array which should be turned into max heap * @returns {array} array Array turned into max heap */ - function buildMaxHeap(array) { + function buildMaxHeap(array, cmp) { for (var i = Math.floor(array.length / 2); i >= 0; i -= 1) { - heapify(array, i, array.length); + heapify(array, i, array.length, cmp); } return array; } @@ -54,16 +58,17 @@ * @param {array} array Input array * @returns {array} array Sorted array */ - return function (array) { + return function (array, cmp) { + cmp = cmp || comparator; var size = array.length, temp; - buildMaxHeap(array); + buildMaxHeap(array, cmp); for (var i = array.length - 1; i > 0; i -= 1) { temp = array[0]; array[0] = array[i]; array[i] = temp; size -= 1; - heapify(array, 0, size); + heapify(array, 0, size, cmp); } return array; }; From cc50184ebd9bb4c0296a5f1609f92c49aff3afd9 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 18 Feb 2014 10:23:14 +0200 Subject: [PATCH 059/613] Fixes indentation in insertion sort --- src/sorting/insertionsort/insertionsort.js | 26 +++++++++------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/sorting/insertionsort/insertionsort.js b/src/sorting/insertionsort/insertionsort.js index 4e9546da..23a2ff60 100644 --- a/src/sorting/insertionsort/insertionsort.js +++ b/src/sorting/insertionsort/insertionsort.js @@ -1,5 +1,3 @@ -var array = [2,3,5,1,2,4,7,9,0,3,3]; - /** * Insertionsort algorithm. It's complexity is O(n^2). * @@ -8,18 +6,16 @@ var array = [2,3,5,1,2,4,7,9,0,3,3]; * @returns {array} array Sorted array */ function insertionSort(array) { - var current, - j; - for (var i = 1; i < array.length; i += 1) { - current = array[i]; - j = i - 1; - while (j >= 0 && array[j] > current) { - array[j + 1] = array[j]; - j -= 1; - } - array[j + 1] = current; + var current, + j; + for (var i = 1; i < array.length; i += 1) { + current = array[i]; + j = i - 1; + while (j >= 0 && array[j] > current) { + array[j + 1] = array[j]; + j -= 1; } - return array; + array[j + 1] = current; + } + return array; } - -console.log(insertionSort(array)); From c4edde30ae427091164efd300419290591359e45 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 18 Feb 2014 10:32:10 +0200 Subject: [PATCH 060/613] Exports insertion sort and adds compare callback --- src/sorting/insertionsort/insertionsort.js | 51 ++++++++++++++-------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/src/sorting/insertionsort/insertionsort.js b/src/sorting/insertionsort/insertionsort.js index 23a2ff60..ef7bc1a1 100644 --- a/src/sorting/insertionsort/insertionsort.js +++ b/src/sorting/insertionsort/insertionsort.js @@ -1,21 +1,34 @@ -/** - * Insertionsort algorithm. It's complexity is O(n^2). - * - * @public - * @param {array} array Input array - * @returns {array} array Sorted array - */ -function insertionSort(array) { - var current, - j; - for (var i = 1; i < array.length; i += 1) { - current = array[i]; - j = i - 1; - while (j >= 0 && array[j] > current) { - array[j + 1] = array[j]; - j -= 1; +(function (exports) { + + 'use strict'; + + function compare(a, b) { + return a - b; + } + + /** + * Insertionsort algorithm. It's complexity is O(n^2). + * + * @public + * @param {array} array Input array + * @returns {array} array Sorted array + */ + function insertionSort(array, cmp) { + cmp = cmp || compare; + var current, + j; + for (var i = 1; i < array.length; i += 1) { + current = array[i]; + j = i - 1; + while (j >= 0 && cmp(array[j], current) > 0) { + array[j + 1] = array[j]; + j -= 1; + } + array[j + 1] = current; } - array[j + 1] = current; + return array; } - return array; -} + + exports.insertionSort = insertionSort; + +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file From a253cf87ab975426b711173e99a44ac302e78d44 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 18 Feb 2014 10:32:26 +0200 Subject: [PATCH 061/613] Adds tests for insertion sort and heap sort --- test/heapsort.spec.js | 4 ++++ test/insertionsort.spec.js | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 test/heapsort.spec.js create mode 100644 test/insertionsort.spec.js diff --git a/test/heapsort.spec.js b/test/heapsort.spec.js new file mode 100644 index 00000000..3170dae4 --- /dev/null +++ b/test/heapsort.spec.js @@ -0,0 +1,4 @@ +var sortTestCase = require('./sort.testcase.js'), + heapSort = require('../src/sorting/heapsort/heapsort.js').heapSort; + +sortTestCase(heapSort, 'Heap sort'); \ No newline at end of file diff --git a/test/insertionsort.spec.js b/test/insertionsort.spec.js new file mode 100644 index 00000000..f0e8fd0a --- /dev/null +++ b/test/insertionsort.spec.js @@ -0,0 +1,4 @@ +var sortTestCase = require('./sort.testcase.js'), + insertionSort = require('../src/sorting/insertionsort/insertionsort.js').insertionSort; + +sortTestCase(insertionSort, 'Insertion sort'); \ No newline at end of file From 369fe0509522a5a84fbe26297eb96e75ff4be81f Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 21 Feb 2014 12:53:45 +0200 Subject: [PATCH 062/613] Adds test case for merge sort --- test/mergesort.spec.js | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 test/mergesort.spec.js diff --git a/test/mergesort.spec.js b/test/mergesort.spec.js new file mode 100644 index 00000000..c3db9ce9 --- /dev/null +++ b/test/mergesort.spec.js @@ -0,0 +1,4 @@ +var sortTestCase = require('./sort.testcase.js'), + mergeSort = require('../src/sorting/mergesort/mergesort.js').mergeSort; + +sortTestCase(mergeSort, 'Merge sort'); \ No newline at end of file From fd3d3ce9699763c94bce498dd4a23eb5f2806327 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 21 Feb 2014 12:55:23 +0200 Subject: [PATCH 063/613] Changes the merge sort indentation --- src/sorting/mergesort/mergesort.js | 139 +++++++++++++++-------------- 1 file changed, 70 insertions(+), 69 deletions(-) diff --git a/src/sorting/mergesort/mergesort.js b/src/sorting/mergesort/mergesort.js index 5b9b3a67..db6f33f6 100644 --- a/src/sorting/mergesort/mergesort.js +++ b/src/sorting/mergesort/mergesort.js @@ -1,80 +1,81 @@ var mergeSort = (function () { - /** - * Mergesort method which is recursively called for sorting the input array. - * - * @private - * @param {array} array The array which should be sorted - * @param {number} start Left side of the subarray - * @param {number} end Right side of the subarray - * @returns {array} Array with sorted subarray - */ - function mergesort(array, start, end) { - if (Math.abs(end - start) <= 1) { - return []; - } - var middle = Math.ceil((start + end) / 2); - - mergesort(array, start, middle); - mergesort(array, middle, end); - return merge(array, start, middle, end); + /** + * Mergesort method which is recursively called for sorting the input array. + * + * @private + * @param {array} array The array which should be sorted + * @param {number} start Left side of the subarray + * @param {number} end Right side of the subarray + * @returns {array} Array with sorted subarray + */ + function mergesort(array, start, end) { + if (Math.abs(end - start) <= 1) { + return []; } + var middle = Math.ceil((start + end) / 2); - /** - * Devides and sort merges two subarrays of given array - * - * @private - * @param {array} array The array which subarrays should be sorted - * @param {number} start The start of the first subarray. This subarray is with end middle - 1. - * @param {number} middle The start of the second array - * @param {number} end end - 1 is the end of the second array - * @returns {array} The array with sorted subarray - */ - function merge(array, start, middle, end) { - var left = [], - right = [], - leftSize = middle - start, - rightSize = end - middle, - maxSize = Math.max(leftSize, rightSize), - size = end - start, - i; + mergesort(array, start, middle); + mergesort(array, middle, end); - for (i = 0; i < maxSize; i += 1) { - if (i < leftSize) { - left[i] = array[start + i]; - } - if (i < rightSize) { - right[i] = array[middle + i]; - } - } - i = 0; - while (i < size) { - if (left.length && right.length) { - if (left[0] >= right[0]) { - array[start + i] = right.shift(); - } else { - array[start + i] = left.shift(); - } - } else if (left.length) { - array[start + i] = left.shift(); - } else { - array[start + i] = right.shift(); - } - i += 1; + return merge(array, start, middle, end); + } + + /** + * Devides and sort merges two subarrays of given array + * + * @private + * @param {array} array The array which subarrays should be sorted + * @param {number} start The start of the first subarray. This subarray is with end middle - 1. + * @param {number} middle The start of the second array + * @param {number} end end - 1 is the end of the second array + * @returns {array} The array with sorted subarray + */ + function merge(array, start, middle, end) { + var left = [], + right = [], + leftSize = middle - start, + rightSize = end - middle, + maxSize = Math.max(leftSize, rightSize), + size = end - start, + i; + + for (i = 0; i < maxSize; i += 1) { + if (i < leftSize) { + left[i] = array[start + i]; + } + if (i < rightSize) { + right[i] = array[middle + i]; + } + } + i = 0; + while (i < size) { + if (left.length && right.length) { + if (left[0] >= right[0]) { + array[start + i] = right.shift(); + } else { + array[start + i] = left.shift(); } - return array; + } else if (left.length) { + array[start + i] = left.shift(); + } else { + array[start + i] = right.shift(); + } + i += 1; } + return array; + } - /** - * Initial call to the mergesort method - * - * @public - * @param {array} array The array which will be sorted - * @returns {array} Sorted array - */ - return function (array) { - return mergesort(array, 0, array.length); - }; + /** + * Initial call to the mergesort method + * + * @public + * @param {array} array The array which will be sorted + * @returns {array} Sorted array + */ + return function (array) { + return mergesort(array, 0, array.length); + }; }()); From fcd0f7e604c83eea916d1dd5c777beb1693309f6 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 21 Feb 2014 12:56:27 +0200 Subject: [PATCH 064/613] Exports merge sort function --- src/sorting/mergesort/mergesort.js | 143 +++++++++++++++-------------- 1 file changed, 75 insertions(+), 68 deletions(-) diff --git a/src/sorting/mergesort/mergesort.js b/src/sorting/mergesort/mergesort.js index db6f33f6..58389993 100644 --- a/src/sorting/mergesort/mergesort.js +++ b/src/sorting/mergesort/mergesort.js @@ -1,81 +1,88 @@ +(function (exports) { -var mergeSort = (function () { + 'use strict'; - /** - * Mergesort method which is recursively called for sorting the input array. - * - * @private - * @param {array} array The array which should be sorted - * @param {number} start Left side of the subarray - * @param {number} end Right side of the subarray - * @returns {array} Array with sorted subarray - */ - function mergesort(array, start, end) { - if (Math.abs(end - start) <= 1) { - return []; - } - var middle = Math.ceil((start + end) / 2); + var mergeSort = (function () { - mergesort(array, start, middle); - mergesort(array, middle, end); + /** + * Mergesort method which is recursively called for sorting the input array. + * + * @private + * @param {array} array The array which should be sorted + * @param {number} start Left side of the subarray + * @param {number} end Right side of the subarray + * @returns {array} Array with sorted subarray + */ + function mergesort(array, start, end) { + if (Math.abs(end - start) <= 1) { + return []; + } + var middle = Math.ceil((start + end) / 2); - return merge(array, start, middle, end); - } + mergesort(array, start, middle); + mergesort(array, middle, end); - /** - * Devides and sort merges two subarrays of given array - * - * @private - * @param {array} array The array which subarrays should be sorted - * @param {number} start The start of the first subarray. This subarray is with end middle - 1. - * @param {number} middle The start of the second array - * @param {number} end end - 1 is the end of the second array - * @returns {array} The array with sorted subarray - */ - function merge(array, start, middle, end) { - var left = [], - right = [], - leftSize = middle - start, - rightSize = end - middle, - maxSize = Math.max(leftSize, rightSize), - size = end - start, - i; + return merge(array, start, middle, end); + } - for (i = 0; i < maxSize; i += 1) { - if (i < leftSize) { - left[i] = array[start + i]; - } - if (i < rightSize) { - right[i] = array[middle + i]; + /** + * Devides and sort merges two subarrays of given array + * + * @private + * @param {array} array The array which subarrays should be sorted + * @param {number} start The start of the first subarray. This subarray is with end middle - 1. + * @param {number} middle The start of the second array + * @param {number} end end - 1 is the end of the second array + * @returns {array} The array with sorted subarray + */ + function merge(array, start, middle, end) { + var left = [], + right = [], + leftSize = middle - start, + rightSize = end - middle, + maxSize = Math.max(leftSize, rightSize), + size = end - start, + i; + + for (i = 0; i < maxSize; i += 1) { + if (i < leftSize) { + left[i] = array[start + i]; + } + if (i < rightSize) { + right[i] = array[middle + i]; + } } - } - i = 0; - while (i < size) { - if (left.length && right.length) { - if (left[0] >= right[0]) { - array[start + i] = right.shift(); - } else { + i = 0; + while (i < size) { + if (left.length && right.length) { + if (left[0] >= right[0]) { + array[start + i] = right.shift(); + } else { + array[start + i] = left.shift(); + } + } else if (left.length) { array[start + i] = left.shift(); + } else { + array[start + i] = right.shift(); } - } else if (left.length) { - array[start + i] = left.shift(); - } else { - array[start + i] = right.shift(); + i += 1; } - i += 1; + return array; } - return array; - } - /** - * Initial call to the mergesort method - * - * @public - * @param {array} array The array which will be sorted - * @returns {array} Sorted array - */ - return function (array) { - return mergesort(array, 0, array.length); - }; + /** + * Initial call to the mergesort method + * + * @public + * @param {array} array The array which will be sorted + * @returns {array} Sorted array + */ + return function (array) { + return mergesort(array, 0, array.length); + }; + + }()); + + exports.mergeSort = mergeSort; -}()); +}(typeof exports === 'undefined' ? window : exports)); From 2332b57b6f487c153959e6b786b6d5a2640a4bae Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 21 Feb 2014 12:58:27 +0200 Subject: [PATCH 065/613] Adds compare callback --- src/sorting/mergesort/mergesort.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/sorting/mergesort/mergesort.js b/src/sorting/mergesort/mergesort.js index 58389993..506411f0 100644 --- a/src/sorting/mergesort/mergesort.js +++ b/src/sorting/mergesort/mergesort.js @@ -4,6 +4,10 @@ var mergeSort = (function () { + function compare(a, b) { + return a - b; + } + /** * Mergesort method which is recursively called for sorting the input array. * @@ -13,16 +17,16 @@ * @param {number} end Right side of the subarray * @returns {array} Array with sorted subarray */ - function mergesort(array, start, end) { + function mergesort(array, start, end, cmp) { if (Math.abs(end - start) <= 1) { return []; } var middle = Math.ceil((start + end) / 2); - mergesort(array, start, middle); - mergesort(array, middle, end); + mergesort(array, start, middle, cmp); + mergesort(array, middle, end, cmp); - return merge(array, start, middle, end); + return merge(array, start, middle, end, cmp); } /** @@ -35,7 +39,7 @@ * @param {number} end end - 1 is the end of the second array * @returns {array} The array with sorted subarray */ - function merge(array, start, middle, end) { + function merge(array, start, middle, end, cmp) { var left = [], right = [], leftSize = middle - start, @@ -55,7 +59,7 @@ i = 0; while (i < size) { if (left.length && right.length) { - if (left[0] >= right[0]) { + if (cmp(left[0], right[0]) > 0) { array[start + i] = right.shift(); } else { array[start + i] = left.shift(); @@ -77,8 +81,9 @@ * @param {array} array The array which will be sorted * @returns {array} Sorted array */ - return function (array) { - return mergesort(array, 0, array.length); + return function (array, cmp) { + cmp = cmp || compare; + return mergesort(array, 0, array.length, cmp); }; }()); From 63fc961ba9cd3b09378ca3d006f09262cd50e07a Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 22 Feb 2014 14:12:32 +0200 Subject: [PATCH 066/613] Remove useless calls and trailing spaces --- src/sorting/quicksort/quicksort.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/sorting/quicksort/quicksort.js b/src/sorting/quicksort/quicksort.js index ffb66797..833f5124 100644 --- a/src/sorting/quicksort/quicksort.js +++ b/src/sorting/quicksort/quicksort.js @@ -1,5 +1,3 @@ -var array = [3,4,7,3,3,5,8,3,34,3,7,9]; - /** * The quicksort algorithm. It's complexity is O(nlog n). * @@ -44,7 +42,7 @@ var quickSort = (function () { array[j] = temp; return array; } - + /** * Sorts given array. * @@ -53,7 +51,7 @@ var quickSort = (function () { * @param {number} left The start of the subarray which should be handled * @param {number} right The end of the subarray which should be handled * @returns {array} array Sorted array - */ + */ function quickSort(array, left, right) { if (left < right) { var p = partition(array, left, right); @@ -73,6 +71,4 @@ var quickSort = (function () { return function (array) { return quickSort(array, 0, array.length); }; -}()); - -console.log(quickSort(array)); +}()); \ No newline at end of file From 50717344ec5b52ffffc20ed6b9b4036516714b01 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 22 Feb 2014 14:13:16 +0200 Subject: [PATCH 067/613] Changes to 2 spaces indentation --- src/sorting/quicksort/quicksort.js | 122 ++++++++++++++--------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/src/sorting/quicksort/quicksort.js b/src/sorting/quicksort/quicksort.js index 833f5124..eab07a37 100644 --- a/src/sorting/quicksort/quicksort.js +++ b/src/sorting/quicksort/quicksort.js @@ -5,70 +5,70 @@ */ var quickSort = (function () { - /** - * Partitions given subarray. - * - * @private - * @param {array} array Input array - * @param {number} left The start of the subarray - * @param {number} right The end of the subarray - */ - function partition(array, left, right) { - var cmp = array[right - 1], - minEnd = left, - maxEnd; - for (maxEnd = left; maxEnd < right - 1; maxEnd += 1) { - if (array[maxEnd] <= cmp) { - swap(array, maxEnd, minEnd); - minEnd += 1; - } - } - swap(array, minEnd, right - 1); - return minEnd; + /** + * Partitions given subarray. + * + * @private + * @param {array} array Input array + * @param {number} left The start of the subarray + * @param {number} right The end of the subarray + */ + function partition(array, left, right) { + var cmp = array[right - 1], + minEnd = left, + maxEnd; + for (maxEnd = left; maxEnd < right - 1; maxEnd += 1) { + if (array[maxEnd] <= cmp) { + swap(array, maxEnd, minEnd); + minEnd += 1; + } } + swap(array, minEnd, right - 1); + return minEnd; + } - /** - * Swap the places of two elements - * - * @private - * @param {array} array The array which contains the elements - * @param {number} i The index of the first element - * @param {number} j The index of the second element - * @returns {array} array The array with swaped elements - */ - function swap(array, i, j) { - var temp = array[i]; - array[i] = array[j]; - array[j] = temp; - return array; - } + /** + * Swap the places of two elements + * + * @private + * @param {array} array The array which contains the elements + * @param {number} i The index of the first element + * @param {number} j The index of the second element + * @returns {array} array The array with swaped elements + */ + function swap(array, i, j) { + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + return array; + } - /** - * Sorts given array. - * - * @private - * @param {array} array Array which should be sorted - * @param {number} left The start of the subarray which should be handled - * @param {number} right The end of the subarray which should be handled - * @returns {array} array Sorted array - */ - function quickSort(array, left, right) { - if (left < right) { - var p = partition(array, left, right); - quickSort(array, left, p); - quickSort(array, p + 1, right); - } - return array; + /** + * Sorts given array. + * + * @private + * @param {array} array Array which should be sorted + * @param {number} left The start of the subarray which should be handled + * @param {number} right The end of the subarray which should be handled + * @returns {array} array Sorted array + */ + function quickSort(array, left, right) { + if (left < right) { + var p = partition(array, left, right); + quickSort(array, left, p); + quickSort(array, p + 1, right); } + return array; + } - /** - * Calls the quicksort function with it's initial values. - * - * @public - * @param {array} array The input array which should be sorted - * @returns {array} array Sorted array - */ - return function (array) { - return quickSort(array, 0, array.length); - }; + /** + * Calls the quicksort function with it's initial values. + * + * @public + * @param {array} array The input array which should be sorted + * @returns {array} array Sorted array + */ + return function (array) { + return quickSort(array, 0, array.length); + }; }()); \ No newline at end of file From b012879fbb9b3c47971ada9e102a1c4a1fc578d9 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 22 Feb 2014 14:14:10 +0200 Subject: [PATCH 068/613] Exports the function and adds use strict --- src/sorting/quicksort/quicksort.js | 136 +++++++++++++++-------------- 1 file changed, 72 insertions(+), 64 deletions(-) diff --git a/src/sorting/quicksort/quicksort.js b/src/sorting/quicksort/quicksort.js index eab07a37..a985d000 100644 --- a/src/sorting/quicksort/quicksort.js +++ b/src/sorting/quicksort/quicksort.js @@ -1,74 +1,82 @@ -/** - * The quicksort algorithm. It's complexity is O(nlog n). - * - * @public - */ -var quickSort = (function () { +(function (exports) { + + 'use strict'; /** - * Partitions given subarray. + * The quicksort algorithm. It's complexity is O(nlog n). * - * @private - * @param {array} array Input array - * @param {number} left The start of the subarray - * @param {number} right The end of the subarray + * @public */ - function partition(array, left, right) { - var cmp = array[right - 1], - minEnd = left, - maxEnd; - for (maxEnd = left; maxEnd < right - 1; maxEnd += 1) { - if (array[maxEnd] <= cmp) { - swap(array, maxEnd, minEnd); - minEnd += 1; + var quickSort = (function () { + + /** + * Partitions given subarray. + * + * @private + * @param {array} array Input array + * @param {number} left The start of the subarray + * @param {number} right The end of the subarray + */ + function partition(array, left, right) { + var cmp = array[right - 1], + minEnd = left, + maxEnd; + for (maxEnd = left; maxEnd < right - 1; maxEnd += 1) { + if (array[maxEnd] <= cmp) { + swap(array, maxEnd, minEnd); + minEnd += 1; + } } + swap(array, minEnd, right - 1); + return minEnd; } - swap(array, minEnd, right - 1); - return minEnd; - } - /** - * Swap the places of two elements - * - * @private - * @param {array} array The array which contains the elements - * @param {number} i The index of the first element - * @param {number} j The index of the second element - * @returns {array} array The array with swaped elements - */ - function swap(array, i, j) { - var temp = array[i]; - array[i] = array[j]; - array[j] = temp; - return array; - } + /** + * Swap the places of two elements + * + * @private + * @param {array} array The array which contains the elements + * @param {number} i The index of the first element + * @param {number} j The index of the second element + * @returns {array} array The array with swaped elements + */ + function swap(array, i, j) { + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + return array; + } - /** - * Sorts given array. - * - * @private - * @param {array} array Array which should be sorted - * @param {number} left The start of the subarray which should be handled - * @param {number} right The end of the subarray which should be handled - * @returns {array} array Sorted array - */ - function quickSort(array, left, right) { - if (left < right) { - var p = partition(array, left, right); - quickSort(array, left, p); - quickSort(array, p + 1, right); + /** + * Sorts given array. + * + * @private + * @param {array} array Array which should be sorted + * @param {number} left The start of the subarray which should be handled + * @param {number} right The end of the subarray which should be handled + * @returns {array} array Sorted array + */ + function quickSort(array, left, right) { + if (left < right) { + var p = partition(array, left, right); + quickSort(array, left, p); + quickSort(array, p + 1, right); + } + return array; } - return array; - } - /** - * Calls the quicksort function with it's initial values. - * - * @public - * @param {array} array The input array which should be sorted - * @returns {array} array Sorted array - */ - return function (array) { - return quickSort(array, 0, array.length); - }; -}()); \ No newline at end of file + /** + * Calls the quicksort function with it's initial values. + * + * @public + * @param {array} array The input array which should be sorted + * @returns {array} array Sorted array + */ + return function (array) { + return quickSort(array, 0, array.length); + }; + }()); + + exports.quickSort = quickSort; + +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file From 8d4af1f434e2f8d5e522758c8951fdd17d6ecd73 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 22 Feb 2014 14:16:56 +0200 Subject: [PATCH 069/613] Adds compare method --- src/sorting/quicksort/quicksort.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/sorting/quicksort/quicksort.js b/src/sorting/quicksort/quicksort.js index a985d000..0650c786 100644 --- a/src/sorting/quicksort/quicksort.js +++ b/src/sorting/quicksort/quicksort.js @@ -9,6 +9,10 @@ */ var quickSort = (function () { + function compare(a, b) { + return a - b; + } + /** * Partitions given subarray. * @@ -17,12 +21,12 @@ * @param {number} left The start of the subarray * @param {number} right The end of the subarray */ - function partition(array, left, right) { + function partition(array, left, right, compare) { var cmp = array[right - 1], minEnd = left, maxEnd; for (maxEnd = left; maxEnd < right - 1; maxEnd += 1) { - if (array[maxEnd] <= cmp) { + if (compare(array[maxEnd], cmp) < 0) { swap(array, maxEnd, minEnd); minEnd += 1; } @@ -56,11 +60,11 @@ * @param {number} right The end of the subarray which should be handled * @returns {array} array Sorted array */ - function quickSort(array, left, right) { + function quickSort(array, left, right, cmp) { if (left < right) { - var p = partition(array, left, right); - quickSort(array, left, p); - quickSort(array, p + 1, right); + var p = partition(array, left, right, cmp); + quickSort(array, left, p, cmp); + quickSort(array, p + 1, right, cmp); } return array; } @@ -72,8 +76,9 @@ * @param {array} array The input array which should be sorted * @returns {array} array Sorted array */ - return function (array) { - return quickSort(array, 0, array.length); + return function (array, cmp) { + cmp = cmp || compare; + return quickSort(array, 0, array.length, cmp); }; }()); From 28712ff361b02075b43cd1cb0f7d969f33f863c7 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 22 Feb 2014 14:17:06 +0200 Subject: [PATCH 070/613] Adds spec for quick sort --- test/quicksort.spec.js | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 test/quicksort.spec.js diff --git a/test/quicksort.spec.js b/test/quicksort.spec.js new file mode 100644 index 00000000..10d1c661 --- /dev/null +++ b/test/quicksort.spec.js @@ -0,0 +1,4 @@ +var sortTestCase = require('./sort.testcase.js'), + quickSort = require('../src/sorting/quicksort/quicksort.js').quickSort; + +sortTestCase(quickSort, 'Quick sort'); \ No newline at end of file From 34676b3eb0bd65d20038f84f61713edb4310d9f5 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 23 Feb 2014 12:51:10 +0200 Subject: [PATCH 071/613] Changes the indentation in shellsort --- src/sorting/shellsort/shellsort.js | 44 +++++++++++++++++------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/sorting/shellsort/shellsort.js b/src/sorting/shellsort/shellsort.js index b340f6f9..bc196166 100644 --- a/src/sorting/shellsort/shellsort.js +++ b/src/sorting/shellsort/shellsort.js @@ -1,10 +1,12 @@ -/** - * Shellsort - * - * Shellsort uses the gaps 701, 301, 132, 57, 23, 10, 4, 1 and uses insertion sort - * to sort the sub-arrays which match for the different gaps. - */ -var shellsort = (function () { +(function (exports) { + + /** + * Shellsort + * + * Shellsort uses the gaps 701, 301, 132, 57, 23, 10, 4, 1 and uses insertion sort + * to sort the sub-arrays which match for the different gaps. + */ + var shellSort = (function () { var gaps = [701, 301, 132, 57, 23, 10, 4, 1]; @@ -16,19 +18,23 @@ var shellsort = (function () { * @return {array} Sorted array */ return function (array) { - var gap, current; + var gap, current; - for (var k = 0; k < gaps.length; k += 1) { - gap = gaps[k]; - for (var i = gap; i < array.length; i += gap) { - current = array[i]; - for (var j = i; j >= gap && array[j - gap] > current; j -= gap) { - array[j] = array[j - gap]; - } - array[j] = current; - } + for (var k = 0; k < gaps.length; k += 1) { + gap = gaps[k]; + for (var i = gap; i < array.length; i += gap) { + current = array[i]; + for (var j = i; j >= gap && array[j - gap] > current; j -= gap) { + array[j] = array[j - gap]; + } + array[j] = current; } - return array; + } + return array; }; -}()); + }()); + + exports.shellSort = shellSort; + +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file From 4e7529c30f65e2a06a7afcccaeab12d3a4f8992b Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 23 Feb 2014 12:52:12 +0200 Subject: [PATCH 072/613] Adds use strict and fixes too long line --- src/sorting/shellsort/shellsort.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sorting/shellsort/shellsort.js b/src/sorting/shellsort/shellsort.js index bc196166..41000221 100644 --- a/src/sorting/shellsort/shellsort.js +++ b/src/sorting/shellsort/shellsort.js @@ -1,10 +1,12 @@ (function (exports) { + 'use strict'; + /** * Shellsort * - * Shellsort uses the gaps 701, 301, 132, 57, 23, 10, 4, 1 and uses insertion sort - * to sort the sub-arrays which match for the different gaps. + * Shellsort uses the gaps 701, 301, 132, 57, 23, 10, 4, 1 and uses + * insertion sort to sort the sub-arrays which match for the different gaps. */ var shellSort = (function () { From 9b31b092e09105d3699dd3ea62629a37e1937098 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 24 Feb 2014 11:43:01 +0200 Subject: [PATCH 073/613] Adds comparator to shell sort --- src/sorting/shellsort/shellsort.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/sorting/shellsort/shellsort.js b/src/sorting/shellsort/shellsort.js index 41000221..ba340aac 100644 --- a/src/sorting/shellsort/shellsort.js +++ b/src/sorting/shellsort/shellsort.js @@ -2,6 +2,11 @@ 'use strict'; + + function compare(a, b) { + return a - b; + } + /** * Shellsort * @@ -19,14 +24,16 @@ * @param {array} array Array which should be sorted * @return {array} Sorted array */ - return function (array) { - var gap, current; + return function (array, cmp) { + cmp = cmp || compare; + var gap, current; for (var k = 0; k < gaps.length; k += 1) { gap = gaps[k]; for (var i = gap; i < array.length; i += gap) { current = array[i]; - for (var j = i; j >= gap && array[j - gap] > current; j -= gap) { + for (var j = i; + j >= gap && cmp(array[j - gap], current) > 0; j -= gap) { array[j] = array[j - gap]; } array[j] = current; From 20fec89ccc30430005acdb3faec9f836c4a662d9 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 24 Feb 2014 11:43:24 +0200 Subject: [PATCH 074/613] Adds spec for shell sort --- test/shellsort.spec.js | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 test/shellsort.spec.js diff --git a/test/shellsort.spec.js b/test/shellsort.spec.js new file mode 100644 index 00000000..42a5098b --- /dev/null +++ b/test/shellsort.spec.js @@ -0,0 +1,4 @@ +var sortTestCase = require('./sort.testcase.js'), + shellSort = require('../src/sorting/shellsort/shellsort.js').shellSort; + +sortTestCase(shellSort, 'Shell sort'); \ No newline at end of file From 527ffa7d45fd0ed3e2f9f33c1354f31f2fef7dea Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 26 Feb 2014 10:14:05 +0200 Subject: [PATCH 075/613] Exports quickSort --- src/sorting/quicksort/quicksort-middle.js | 120 ++++++++++++---------- 1 file changed, 63 insertions(+), 57 deletions(-) diff --git a/src/sorting/quicksort/quicksort-middle.js b/src/sorting/quicksort/quicksort-middle.js index f5f63077..b09c5fb1 100644 --- a/src/sorting/quicksort/quicksort-middle.js +++ b/src/sorting/quicksort/quicksort-middle.js @@ -4,69 +4,75 @@ * array for pivot. */ +(function (exports) { -/** - * Quicksort algorithm - * - * @public - * @param {array} array Array which should be sorted. - * @return {array} Sorted array. - */ -var quicksort = (function () { - + 'use strict'; /** - * Partitions the array in two parts by the middle elements. - * All elemnts which are less than the chosen one goes left from it - * all which are greater goes right from it. + * Quicksort algorithm * - * @param {array} array Array which should be partitioned - * @param {number} left Left part of the array - * @param {number} right Right part of the array - * @return {number} + * @public + * @param {array} array Array which should be sorted. + * @return {array} Sorted array. */ - function partition(array, left, right) { - var pivot = array[Math.floor((left + right) / 2)], - temp; - while (left <= right) { - while (array[left] < pivot) - left += 1; - while (array[right] > pivot) - right -= 1; - if (left <= right) { - temp = array[left]; - array[left] = array[right]; - array[right] = temp; - left += 1; - right -= 1; + var quickSort = (function () { + + /** + * Partitions the array in two parts by the middle elements. + * All elemnts which are less than the chosen one goes left from it + * all which are greater goes right from it. + * + * @param {array} array Array which should be partitioned + * @param {number} left Left part of the array + * @param {number} right Right part of the array + * @return {number} + */ + function partition(array, left, right) { + var pivot = array[Math.floor((left + right) / 2)], + temp; + while (left <= right) { + while (array[left] < pivot) + left += 1; + while (array[right] > pivot) + right -= 1; + if (left <= right) { + temp = array[left]; + array[left] = array[right]; + array[right] = temp; + left += 1; + right -= 1; + } } + return left; } - return left; - } - /** - * Recursively calls itself with different values for - * left/right part of the array which should be processed - * - * @private - * @param {array} array Array which should be processed - * @param {number} left Left part of the array which should be processed - * @param {number} right Right part of the array which should be processed - */ - function quicksort(array, left, right) { - var mid = partition(array, left, right); - if (left < mid - 1) - quicksort(array, left, mid - 1); - if (right > mid) - quicksort(array, mid, right); - } + /** + * Recursively calls itself with different values for + * left/right part of the array which should be processed + * + * @private + * @param {array} array Array which should be processed + * @param {number} left Left part of the array which should be processed + * @param {number} right Right part of the array which should be processed + */ + function quicksort(array, left, right) { + var mid = partition(array, left, right); + if (left < mid - 1) + quicksort(array, left, mid - 1); + if (right > mid) + quicksort(array, mid, right); + } - /** - * Quicksort's initial point - * @public - */ - return function (array) { - quicksort(array, 0, array.length - 1); - return array; - }; + /** + * Quicksort's initial point + * @public + */ + return function (array) { + quicksort(array, 0, array.length - 1); + return array; + }; + + }()); + + exports.quickSort = quickSort; -}()); +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file From 1e9d70610aca69220e2408567939f7303eebd66a Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 26 Feb 2014 10:15:18 +0200 Subject: [PATCH 076/613] Fixes the indentation --- src/sorting/quicksort/quicksort-middle.js | 121 +++++++++++----------- 1 file changed, 63 insertions(+), 58 deletions(-) diff --git a/src/sorting/quicksort/quicksort-middle.js b/src/sorting/quicksort/quicksort-middle.js index b09c5fb1..909def60 100644 --- a/src/sorting/quicksort/quicksort-middle.js +++ b/src/sorting/quicksort/quicksort-middle.js @@ -7,71 +7,76 @@ (function (exports) { 'use strict'; + + /** + * Quicksort algorithm + * + * @public + * @param {array} array Array which should be sorted. + * @return {array} Sorted array. + */ + var quickSort = (function () { + /** - * Quicksort algorithm + * Partitions the array in two parts by the middle elements. + * All elemnts which are less than the chosen one goes left from it + * all which are greater goes right from it. * - * @public - * @param {array} array Array which should be sorted. - * @return {array} Sorted array. + * @param {array} array Array which should be partitioned + * @param {number} left Left part of the array + * @param {number} right Right part of the array + * @return {number} */ - var quickSort = (function () { - - /** - * Partitions the array in two parts by the middle elements. - * All elemnts which are less than the chosen one goes left from it - * all which are greater goes right from it. - * - * @param {array} array Array which should be partitioned - * @param {number} left Left part of the array - * @param {number} right Right part of the array - * @return {number} - */ - function partition(array, left, right) { - var pivot = array[Math.floor((left + right) / 2)], - temp; - while (left <= right) { - while (array[left] < pivot) - left += 1; - while (array[right] > pivot) - right -= 1; - if (left <= right) { - temp = array[left]; - array[left] = array[right]; - array[right] = temp; - left += 1; - right -= 1; - } - } - return left; + function partition(array, left, right) { + var pivot = array[Math.floor((left + right) / 2)], + temp; + while (left <= right) { + while (array[left] < pivot) { + left += 1; } - - /** - * Recursively calls itself with different values for - * left/right part of the array which should be processed - * - * @private - * @param {array} array Array which should be processed - * @param {number} left Left part of the array which should be processed - * @param {number} right Right part of the array which should be processed - */ - function quicksort(array, left, right) { - var mid = partition(array, left, right); - if (left < mid - 1) - quicksort(array, left, mid - 1); - if (right > mid) - quicksort(array, mid, right); + while (array[right] > pivot) { + right -= 1; + } + if (left <= right) { + temp = array[left]; + array[left] = array[right]; + array[right] = temp; + left += 1; + right -= 1; } + } + return left; + } - /** - * Quicksort's initial point - * @public - */ - return function (array) { - quicksort(array, 0, array.length - 1); - return array; - }; + /** + * Recursively calls itself with different values for + * left/right part of the array which should be processed + * + * @private + * @param {array} array Array which should be processed + * @param {number} left Left part of the array which should be processed + * @param {number} right Right part of the array which should be processed + */ + function quicksort(array, left, right) { + var mid = partition(array, left, right); + if (left < mid - 1) { + quicksort(array, left, mid - 1); + } + if (right > mid) { + quicksort(array, mid, right); + } + } + + /** + * Quicksort's initial point + * @public + */ + return function (array) { + quicksort(array, 0, array.length - 1); + return array; + }; - }()); + }()); exports.quickSort = quickSort; From 125ed980e9bacbdffe6361aa7766d51b98414ac2 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 26 Feb 2014 10:18:44 +0200 Subject: [PATCH 077/613] Adds compare callback --- src/sorting/quicksort/quicksort-middle.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/sorting/quicksort/quicksort-middle.js b/src/sorting/quicksort/quicksort-middle.js index 909def60..c85cdc8e 100644 --- a/src/sorting/quicksort/quicksort-middle.js +++ b/src/sorting/quicksort/quicksort-middle.js @@ -8,6 +8,10 @@ 'use strict'; + function compare(a, b) { + return a - b; + } + /** * Quicksort algorithm * @@ -27,14 +31,14 @@ * @param {number} right Right part of the array * @return {number} */ - function partition(array, left, right) { + function partition(array, left, right, cmp) { var pivot = array[Math.floor((left + right) / 2)], temp; while (left <= right) { - while (array[left] < pivot) { + while (cmp(array[left], pivot) < 0) { left += 1; } - while (array[right] > pivot) { + while (cmp(array[right], pivot) > 0) { right -= 1; } if (left <= right) { @@ -57,13 +61,13 @@ * @param {number} left Left part of the array which should be processed * @param {number} right Right part of the array which should be processed */ - function quicksort(array, left, right) { - var mid = partition(array, left, right); + function quicksort(array, left, right, cmp) { + var mid = partition(array, left, right, cmp); if (left < mid - 1) { - quicksort(array, left, mid - 1); + quicksort(array, left, mid - 1, cmp); } if (right > mid) { - quicksort(array, mid, right); + quicksort(array, mid, right, cmp); } } @@ -71,8 +75,9 @@ * Quicksort's initial point * @public */ - return function (array) { - quicksort(array, 0, array.length - 1); + return function (array, cmp) { + cmp = cmp || compare; + quicksort(array, 0, array.length - 1, cmp); return array; }; From baa3f221be81868c0f5038275dab0d601e9f012b Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 26 Feb 2014 10:18:59 +0200 Subject: [PATCH 078/613] Adds test case for quick sort --- test/quicksort-middle.spec.js | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 test/quicksort-middle.spec.js diff --git a/test/quicksort-middle.spec.js b/test/quicksort-middle.spec.js new file mode 100644 index 00000000..e4e1613f --- /dev/null +++ b/test/quicksort-middle.spec.js @@ -0,0 +1,4 @@ +var sortTestCase = require('./sort.testcase.js'), + quickSort = require('../src/sorting/quicksort/quicksort-middle.js').quickSort; + +sortTestCase(quickSort, 'Quick sort'); \ No newline at end of file From 55824fcbf7d55a0ec76163801f1baffe00004a53 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 27 Feb 2014 10:19:43 +0200 Subject: [PATCH 079/613] Change indentation in selection sort --- src/sorting/selectionsort/selectionsort.js | 31 +++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/sorting/selectionsort/selectionsort.js b/src/sorting/selectionsort/selectionsort.js index 92c862bb..4688c040 100644 --- a/src/sorting/selectionsort/selectionsort.js +++ b/src/sorting/selectionsort/selectionsort.js @@ -6,20 +6,19 @@ * @return {array} The sorted array */ function selectionSort(array) { - var min, idx, temp; - for (var i = 0; i < array.length; i += 1) { - idx = i; - min = array[i]; - for (var j = i + 1; j < array.length; j += 1) { - if (min > array[j]) { - min = array[j]; - idx = j; - } - } - temp = array[i]; - array[i] = min; - array[idx] = temp; + var min, idx, temp; + for (var i = 0; i < array.length; i += 1) { + idx = i; + min = array[i]; + for (var j = i + 1; j < array.length; j += 1) { + if (min > array[j]) { + min = array[j]; + idx = j; + } } - return array; -} - + temp = array[i]; + array[i] = min; + array[idx] = temp; + } + return array; +} \ No newline at end of file From d9781bef3b5f124d2420a87c6e973d8ffe03b93d Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 27 Feb 2014 10:20:37 +0200 Subject: [PATCH 080/613] Export selection sort --- src/sorting/selectionsort/selectionsort.js | 52 +++++++++++++--------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/src/sorting/selectionsort/selectionsort.js b/src/sorting/selectionsort/selectionsort.js index 4688c040..0227f3a2 100644 --- a/src/sorting/selectionsort/selectionsort.js +++ b/src/sorting/selectionsort/selectionsort.js @@ -1,24 +1,32 @@ -/** - * Selection sort. It's complexity is O(n^2) - * - * @public - * @param {array} array Array to be sorted - * @return {array} The sorted array - */ -function selectionSort(array) { - var min, idx, temp; - for (var i = 0; i < array.length; i += 1) { - idx = i; - min = array[i]; - for (var j = i + 1; j < array.length; j += 1) { - if (min > array[j]) { - min = array[j]; - idx = j; +(function (exports) { + + 'use strict'; + + /** + * Selection sort. It's complexity is O(n^2) + * + * @public + * @param {array} array Array to be sorted + * @return {array} The sorted array + */ + var selectionSort = function (array) { + var min, idx, temp; + for (var i = 0; i < array.length; i += 1) { + idx = i; + min = array[i]; + for (var j = i + 1; j < array.length; j += 1) { + if (min > array[j]) { + min = array[j]; + idx = j; + } } + temp = array[i]; + array[i] = min; + array[idx] = temp; } - temp = array[i]; - array[i] = min; - array[idx] = temp; - } - return array; -} \ No newline at end of file + return array; + }; + + exports.selectionSort = selectionSort; + +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file From e1bc8df1329675c88501524826f9af2bac39ac11 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 27 Feb 2014 10:21:33 +0200 Subject: [PATCH 081/613] Add comparator --- src/sorting/selectionsort/selectionsort.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sorting/selectionsort/selectionsort.js b/src/sorting/selectionsort/selectionsort.js index 0227f3a2..d24a5762 100644 --- a/src/sorting/selectionsort/selectionsort.js +++ b/src/sorting/selectionsort/selectionsort.js @@ -2,6 +2,10 @@ 'use strict'; + function compare(a, b) { + return a - b; + } + /** * Selection sort. It's complexity is O(n^2) * @@ -9,13 +13,14 @@ * @param {array} array Array to be sorted * @return {array} The sorted array */ - var selectionSort = function (array) { + var selectionSort = function (array, cmp) { + cmp = cmp || compare; var min, idx, temp; for (var i = 0; i < array.length; i += 1) { idx = i; min = array[i]; for (var j = i + 1; j < array.length; j += 1) { - if (min > array[j]) { + if (cmp(min, array[j]) > 0) { min = array[j]; idx = j; } From 276ede0c528acaaefecf8a9cdbc15bf0f3e67980 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 27 Feb 2014 10:22:42 +0200 Subject: [PATCH 082/613] Add tests for selection sort --- test/selectionsort.spec.js | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/selectionsort.spec.js diff --git a/test/selectionsort.spec.js b/test/selectionsort.spec.js new file mode 100644 index 00000000..413badc4 --- /dev/null +++ b/test/selectionsort.spec.js @@ -0,0 +1,5 @@ +var sortTestCase = require('./sort.testcase.js'), + selectionSort = require('../src/sorting/selectionsort/selectionsort.js') + .selectionSort; + +sortTestCase(selectionSort, 'Selection sort'); \ No newline at end of file From c286ba46ea72855b6e62b0c065c5797d32a94217 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 28 Feb 2014 14:56:18 +0200 Subject: [PATCH 083/613] Fix the indentation & codding style of insertion binary sort --- .../insertionsort/insertion-binary-sort.js | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/sorting/insertionsort/insertion-binary-sort.js b/src/sorting/insertionsort/insertion-binary-sort.js index 86e780fd..91e60311 100644 --- a/src/sorting/insertionsort/insertion-binary-sort.js +++ b/src/sorting/insertionsort/insertion-binary-sort.js @@ -1,5 +1,3 @@ -var array = [5,6,3,3,6,8,9,4,3]; - /** * Modified version of insertionsort. It uses binary search for finding * where the current element should be inserted. It's correct because @@ -11,27 +9,27 @@ var array = [5,6,3,3,6,8,9,4,3]; * @param {array} array Sorted array */ function insertionBinarySort(array) { - var current, - middle, - left, - right; - for (var i = 1; i < array.length; i += 1) { - current = array[i]; - left = 0; - right = i; - middle = Math.floor((left + right) / 2); - while (left < right) { - if (array[middle] <= current) - left = middle + 1; - else - right = middle - 1; - middle = Math.floor((left + right) / 2); - } - for (var j = i; j > middle; j -= 1) - array[j] = array[j - 1]; - array[j] = current; + var current, + middle, + left, + right; + for (var i = 1; i < array.length; i += 1) { + current = array[i]; + left = 0; + right = i; + middle = Math.floor((left + right) / 2); + while (left < right) { + if (array[middle] <= current) { + left = middle + 1; + } else { + right = middle - 1; + } + middle = Math.floor((left + right) / 2); } - return array; -} - -console.log(insertionBinarySort(array)); + for (var j = i; j > middle; j -= 1) { + array[j] = array[j - 1]; + } + array[j] = current; + } + return array; +} \ No newline at end of file From 823e33279936483c5f3eba90d778470dfe939cfc Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 1 Mar 2014 14:45:50 +0200 Subject: [PATCH 084/613] Export binary insertion sort --- .../insertionsort/insertion-binary-sort.js | 72 ++++++++++--------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/src/sorting/insertionsort/insertion-binary-sort.js b/src/sorting/insertionsort/insertion-binary-sort.js index 91e60311..4e30d9ba 100644 --- a/src/sorting/insertionsort/insertion-binary-sort.js +++ b/src/sorting/insertionsort/insertion-binary-sort.js @@ -1,35 +1,43 @@ -/** - * Modified version of insertionsort. It uses binary search for finding - * where the current element should be inserted. It's correct because - * the binary search looks just in the first part of the array - * which is actually sorted. It's complexity is O(n^2) - * - * @public - * @param {array} array Input array - * @param {array} array Sorted array - */ -function insertionBinarySort(array) { - var current, - middle, - left, - right; - for (var i = 1; i < array.length; i += 1) { - current = array[i]; - left = 0; - right = i; - middle = Math.floor((left + right) / 2); - while (left < right) { - if (array[middle] <= current) { - left = middle + 1; - } else { - right = middle - 1; - } +(function (exports) { + + 'use strict'; + + /** + * Modified version of insertionsort. It uses binary search for finding + * where the current element should be inserted. It's correct because + * the binary search looks just in the first part of the array + * which is actually sorted. It's complexity is O(n^2) + * + * @public + * @param {array} array Input array + * @param {array} array Sorted array + */ + function insertionBinarySort(array) { + var current, + middle, + left, + right; + for (var i = 1; i < array.length; i += 1) { + current = array[i]; + left = 0; + right = i; middle = Math.floor((left + right) / 2); + while (left < right) { + if (array[middle] <= current) { + left = middle + 1; + } else { + right = middle - 1; + } + middle = Math.floor((left + right) / 2); + } + for (var j = i; j > middle; j -= 1) { + array[j] = array[j - 1]; + } + array[j] = current; } - for (var j = i; j > middle; j -= 1) { - array[j] = array[j - 1]; - } - array[j] = current; + return array; } - return array; -} \ No newline at end of file + + exports.insertionBinarySort = insertionBinarySort; + +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file From 2743b7ca8333ce6c652af44c0b2679a268f2ac99 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 1 Mar 2014 14:46:34 +0200 Subject: [PATCH 085/613] Add use strict to heap sort --- src/sorting/heapsort/heapsort.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/sorting/heapsort/heapsort.js b/src/sorting/heapsort/heapsort.js index 0bd7ec5d..aeb2df1d 100644 --- a/src/sorting/heapsort/heapsort.js +++ b/src/sorting/heapsort/heapsort.js @@ -1,5 +1,7 @@ (function (exports) { + 'use strict'; + function comparator(a, b) { return a - b; } @@ -16,18 +18,21 @@ * * @private * @param {array} array Array - * @param {number} index Index of the element which palce in the max heap should be found. + * @param {number} index Index of the element which palce in + * the max heap should be found. */ function heapify(array, index, heapSize, cmp) { var left = 2 * index + 1, right = 2 * index + 2, largest = index; - if (left < heapSize && cmp(array[left], array[index]) > 0) + if (left < heapSize && cmp(array[left], array[index]) > 0) { largest = left; + } - if (right < heapSize && cmp(array[right], array[largest]) > 0) + if (right < heapSize && cmp(array[right], array[largest]) > 0) { largest = right; + } if (largest !== index) { var temp = array[index]; From 9f82f3c626e795f9ea4e15c78431ca813c464d05 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 1 Mar 2014 15:36:29 +0200 Subject: [PATCH 086/613] Fix issue in insertion binary sort --- .../insertionsort/insertion-binary-sort.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/sorting/insertionsort/insertion-binary-sort.js b/src/sorting/insertionsort/insertion-binary-sort.js index 4e30d9ba..1b632f88 100644 --- a/src/sorting/insertionsort/insertion-binary-sort.js +++ b/src/sorting/insertionsort/insertion-binary-sort.js @@ -2,6 +2,10 @@ 'use strict'; + function comparator(a, b) { + return a - b; + } + /** * Modified version of insertionsort. It uses binary search for finding * where the current element should be inserted. It's correct because @@ -12,7 +16,8 @@ * @param {array} array Input array * @param {array} array Sorted array */ - function insertionBinarySort(array) { + function insertionBinarySort(array, cmp) { + cmp = cmp || comparator; var current, middle, left, @@ -22,15 +27,15 @@ left = 0; right = i; middle = Math.floor((left + right) / 2); - while (left < right) { - if (array[middle] <= current) { + while (left <= right) { + if (cmp(array[middle], current) <= 0) { left = middle + 1; - } else { + } else if (cmp(array[middle], current) > 0) { right = middle - 1; } - middle = Math.floor((left + right) / 2); + middle = Math.floor((right + left) / 2); } - for (var j = i; j > middle; j -= 1) { + for (var j = i; j > left; j -= 1) { array[j] = array[j - 1]; } array[j] = current; From 1dbaf8928cad19464e01e1f3cfd62b4b8b78e3ec Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 1 Mar 2014 15:37:40 +0200 Subject: [PATCH 087/613] Add spec for insertion binary sort --- test/insertionbinarysort.spec.js | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 test/insertionbinarysort.spec.js diff --git a/test/insertionbinarysort.spec.js b/test/insertionbinarysort.spec.js new file mode 100644 index 00000000..84453bad --- /dev/null +++ b/test/insertionbinarysort.spec.js @@ -0,0 +1,4 @@ +var sortTestCase = require('./sort.testcase.js'), + insertionBinarySort = require('../src/sorting/insertionsort/insertion-binary-sort.js').insertionBinarySort; + +sortTestCase(insertionBinarySort, 'Insertion binary sort'); \ No newline at end of file From 1461a4dcbe0d6bda938b9daacb9eedf09e8468d1 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 2 Mar 2014 12:45:19 +0200 Subject: [PATCH 088/613] Remove useless code --- src/sorting/insertionsort/recursive-insertionsort.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/sorting/insertionsort/recursive-insertionsort.js b/src/sorting/insertionsort/recursive-insertionsort.js index 4c58a342..b523bdf2 100644 --- a/src/sorting/insertionsort/recursive-insertionsort.js +++ b/src/sorting/insertionsort/recursive-insertionsort.js @@ -1,5 +1,3 @@ -var array = [4,6,2,2,4,56,7,7,51,23,5,7]; - /** * Recursive version of insertionsort. Complexity O(n^2). * @@ -17,6 +15,4 @@ function recursiveInsertionSort(array, max) { array[i + 1] = array[i]; array[i + 1] = current; return array; -} - -console.log(recursiveInsertionSort(array)); +} \ No newline at end of file From be3bd1223033f257b5555241b5bda0fc661ccfdd Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 2 Mar 2014 12:45:31 +0200 Subject: [PATCH 089/613] Remove trailing space --- src/sorting/insertionsort/recursive-insertionsort.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sorting/insertionsort/recursive-insertionsort.js b/src/sorting/insertionsort/recursive-insertionsort.js index b523bdf2..eca844d4 100644 --- a/src/sorting/insertionsort/recursive-insertionsort.js +++ b/src/sorting/insertionsort/recursive-insertionsort.js @@ -8,10 +8,10 @@ function recursiveInsertionSort(array, max) { if (max <= 0) return array; - if (max === undefined) + if (max === undefined) max = array.length - 1; recursiveInsertionSort(array, max - 1); - for (var i = max - 1, current = array[max]; i >= 0 && current < array[i]; i -= 1) + for (var i = max - 1, current = array[max]; i >= 0 && current < array[i]; i -= 1) array[i + 1] = array[i]; array[i + 1] = current; return array; From 115f607f45ace039c4c202aff4e562d612e25d4f Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 2 Mar 2014 12:46:15 +0200 Subject: [PATCH 090/613] Fix indentation --- .../insertionsort/recursive-insertionsort.js | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/sorting/insertionsort/recursive-insertionsort.js b/src/sorting/insertionsort/recursive-insertionsort.js index eca844d4..0a180f22 100644 --- a/src/sorting/insertionsort/recursive-insertionsort.js +++ b/src/sorting/insertionsort/recursive-insertionsort.js @@ -3,16 +3,21 @@ * * @public * @param {array} array Input array - * @param {number} [max] Index of the element which place we should find in the current function call + * @param {number} [max] Index of the element which place we should find + * in the current function call */ function recursiveInsertionSort(array, max) { - if (max <= 0) - return array; - if (max === undefined) - max = array.length - 1; - recursiveInsertionSort(array, max - 1); - for (var i = max - 1, current = array[max]; i >= 0 && current < array[i]; i -= 1) - array[i + 1] = array[i]; - array[i + 1] = current; + if (max <= 0) { return array; + } + if (max === undefined) { + max = array.length - 1; + } + recursiveInsertionSort(array, max - 1); + for (var i = max - 1, current = array[max]; + i >= 0 && current < array[i]; i -= 1) { + array[i + 1] = array[i]; + } + array[i + 1] = current; + return array; } \ No newline at end of file From 124eba27e8d2fade8d5a861967de9f5d80b23f99 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 2 Mar 2014 15:37:07 +0200 Subject: [PATCH 091/613] Wrap in IIFE + use strict --- .../insertionsort/recursive-insertionsort.js | 50 +++++++++++-------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/src/sorting/insertionsort/recursive-insertionsort.js b/src/sorting/insertionsort/recursive-insertionsort.js index 0a180f22..520298fc 100644 --- a/src/sorting/insertionsort/recursive-insertionsort.js +++ b/src/sorting/insertionsort/recursive-insertionsort.js @@ -1,23 +1,31 @@ -/** - * Recursive version of insertionsort. Complexity O(n^2). - * - * @public - * @param {array} array Input array - * @param {number} [max] Index of the element which place we should find - * in the current function call - */ -function recursiveInsertionSort(array, max) { - if (max <= 0) { +(function (exports) { + + 'use strict'; + + /** + * Recursive version of insertionsort. Complexity O(n^2). + * + * @public + * @param {array} array Input array + * @param {number} [max] Index of the element which place we should find + * in the current function call + */ + function recursiveInsertionSort(array, max) { + if (max <= 0) { + return array; + } + if (max === undefined) { + max = array.length - 1; + } + recursiveInsertionSort(array, max - 1); + for (var i = max - 1, current = array[max]; + i >= 0 && current < array[i]; i -= 1) { + array[i + 1] = array[i]; + } + array[i + 1] = current; return array; } - if (max === undefined) { - max = array.length - 1; - } - recursiveInsertionSort(array, max - 1); - for (var i = max - 1, current = array[max]; - i >= 0 && current < array[i]; i -= 1) { - array[i + 1] = array[i]; - } - array[i + 1] = current; - return array; -} \ No newline at end of file + + exports.recursiveInsertionSort = recursiveInsertionSort; + +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file From 4d8d21fa3ee81e0f5683805ae1fbf774877c4d56 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 3 Mar 2014 10:40:06 +0200 Subject: [PATCH 092/613] Add compare callback --- src/sorting/insertionsort/recursive-insertionsort.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/sorting/insertionsort/recursive-insertionsort.js b/src/sorting/insertionsort/recursive-insertionsort.js index 520298fc..fb94a3bd 100644 --- a/src/sorting/insertionsort/recursive-insertionsort.js +++ b/src/sorting/insertionsort/recursive-insertionsort.js @@ -2,6 +2,10 @@ 'use strict'; + function compare(a, b) { + return a - b; + } + /** * Recursive version of insertionsort. Complexity O(n^2). * @@ -10,16 +14,17 @@ * @param {number} [max] Index of the element which place we should find * in the current function call */ - function recursiveInsertionSort(array, max) { + function recursiveInsertionSort(array, cmp, max) { + cmp = cmp || compare; if (max <= 0) { return array; } if (max === undefined) { max = array.length - 1; } - recursiveInsertionSort(array, max - 1); + recursiveInsertionSort(array, cmp, max - 1); for (var i = max - 1, current = array[max]; - i >= 0 && current < array[i]; i -= 1) { + i >= 0 && cmp(current, array[i]) < 0; i -= 1) { array[i + 1] = array[i]; } array[i + 1] = current; From 9022cd811c3f083e800a3b7248e3b059a6692bcf Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 3 Mar 2014 10:40:36 +0200 Subject: [PATCH 093/613] Add tests for the recursive insertion sort --- test/recursiveinsertionsort.spec.js | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 test/recursiveinsertionsort.spec.js diff --git a/test/recursiveinsertionsort.spec.js b/test/recursiveinsertionsort.spec.js new file mode 100644 index 00000000..9f7a8d31 --- /dev/null +++ b/test/recursiveinsertionsort.spec.js @@ -0,0 +1,4 @@ +var sortTestCase = require('./sort.testcase.js'), + recursiveInsertionSort = require('../src/sorting/insertionsort/recursive-insertionsort.js').recursiveInsertionSort; + +sortTestCase(recursiveInsertionSort, 'Recursive insertion sort'); \ No newline at end of file From 79c8e2f9e85a7b50462f3841c455dec71ddba0ea Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 7 Mar 2014 10:23:05 +0200 Subject: [PATCH 094/613] Move spec files to directories --- test/{ => searching/binarysearch}/binarysearch.spec.js | 0 .../longest-increasing-subsequence.spec.js | 0 test/{ => sorting/bubblesort}/bubblesort.spec.js | 0 test/{ => sorting/heapsort}/heapsort.spec.js | 0 test/{ => sorting/insertionsort}/insertionbinarysort.spec.js | 0 test/{ => sorting/insertionsort}/insertionsort.spec.js | 0 test/{ => sorting/insertionsort}/recursiveinsertionsort.spec.js | 0 test/{ => sorting/mergesort}/mergesort.spec.js | 0 test/{ => sorting/quicksort}/quicksort-middle.spec.js | 0 test/{ => sorting/quicksort}/quicksort.spec.js | 0 test/{ => sorting/selectionsort}/selectionsort.spec.js | 0 test/{ => sorting/shellsort}/shellsort.spec.js | 0 test/{ => sorting}/sort.testcase.js | 0 13 files changed, 0 insertions(+), 0 deletions(-) rename test/{ => searching/binarysearch}/binarysearch.spec.js (100%) rename test/{ => searching/longest-increasing-subsequence}/longest-increasing-subsequence.spec.js (100%) rename test/{ => sorting/bubblesort}/bubblesort.spec.js (100%) rename test/{ => sorting/heapsort}/heapsort.spec.js (100%) rename test/{ => sorting/insertionsort}/insertionbinarysort.spec.js (100%) rename test/{ => sorting/insertionsort}/insertionsort.spec.js (100%) rename test/{ => sorting/insertionsort}/recursiveinsertionsort.spec.js (100%) rename test/{ => sorting/mergesort}/mergesort.spec.js (100%) rename test/{ => sorting/quicksort}/quicksort-middle.spec.js (100%) rename test/{ => sorting/quicksort}/quicksort.spec.js (100%) rename test/{ => sorting/selectionsort}/selectionsort.spec.js (100%) rename test/{ => sorting/shellsort}/shellsort.spec.js (100%) rename test/{ => sorting}/sort.testcase.js (100%) diff --git a/test/binarysearch.spec.js b/test/searching/binarysearch/binarysearch.spec.js similarity index 100% rename from test/binarysearch.spec.js rename to test/searching/binarysearch/binarysearch.spec.js diff --git a/test/longest-increasing-subsequence.spec.js b/test/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js similarity index 100% rename from test/longest-increasing-subsequence.spec.js rename to test/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js diff --git a/test/bubblesort.spec.js b/test/sorting/bubblesort/bubblesort.spec.js similarity index 100% rename from test/bubblesort.spec.js rename to test/sorting/bubblesort/bubblesort.spec.js diff --git a/test/heapsort.spec.js b/test/sorting/heapsort/heapsort.spec.js similarity index 100% rename from test/heapsort.spec.js rename to test/sorting/heapsort/heapsort.spec.js diff --git a/test/insertionbinarysort.spec.js b/test/sorting/insertionsort/insertionbinarysort.spec.js similarity index 100% rename from test/insertionbinarysort.spec.js rename to test/sorting/insertionsort/insertionbinarysort.spec.js diff --git a/test/insertionsort.spec.js b/test/sorting/insertionsort/insertionsort.spec.js similarity index 100% rename from test/insertionsort.spec.js rename to test/sorting/insertionsort/insertionsort.spec.js diff --git a/test/recursiveinsertionsort.spec.js b/test/sorting/insertionsort/recursiveinsertionsort.spec.js similarity index 100% rename from test/recursiveinsertionsort.spec.js rename to test/sorting/insertionsort/recursiveinsertionsort.spec.js diff --git a/test/mergesort.spec.js b/test/sorting/mergesort/mergesort.spec.js similarity index 100% rename from test/mergesort.spec.js rename to test/sorting/mergesort/mergesort.spec.js diff --git a/test/quicksort-middle.spec.js b/test/sorting/quicksort/quicksort-middle.spec.js similarity index 100% rename from test/quicksort-middle.spec.js rename to test/sorting/quicksort/quicksort-middle.spec.js diff --git a/test/quicksort.spec.js b/test/sorting/quicksort/quicksort.spec.js similarity index 100% rename from test/quicksort.spec.js rename to test/sorting/quicksort/quicksort.spec.js diff --git a/test/selectionsort.spec.js b/test/sorting/selectionsort/selectionsort.spec.js similarity index 100% rename from test/selectionsort.spec.js rename to test/sorting/selectionsort/selectionsort.spec.js diff --git a/test/shellsort.spec.js b/test/sorting/shellsort/shellsort.spec.js similarity index 100% rename from test/shellsort.spec.js rename to test/sorting/shellsort/shellsort.spec.js diff --git a/test/sort.testcase.js b/test/sorting/sort.testcase.js similarity index 100% rename from test/sort.testcase.js rename to test/sorting/sort.testcase.js From c21abdfa4c781884cdb110e7015b2a0069978f3d Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 7 Mar 2014 10:26:35 +0200 Subject: [PATCH 095/613] Fix the paths --- test/searching/binarysearch/binarysearch.spec.js | 2 +- .../longest-increasing-subsequence.spec.js | 4 ++-- test/sorting/bubblesort/bubblesort.spec.js | 4 ++-- test/sorting/heapsort/heapsort.spec.js | 4 ++-- test/sorting/insertionsort/insertionbinarysort.spec.js | 4 ++-- test/sorting/insertionsort/insertionsort.spec.js | 4 ++-- test/sorting/insertionsort/recursiveinsertionsort.spec.js | 4 ++-- test/sorting/mergesort/mergesort.spec.js | 4 ++-- test/sorting/quicksort/quicksort-middle.spec.js | 4 ++-- test/sorting/quicksort/quicksort.spec.js | 4 ++-- test/sorting/selectionsort/selectionsort.spec.js | 4 ++-- test/sorting/shellsort/shellsort.spec.js | 4 ++-- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/test/searching/binarysearch/binarysearch.spec.js b/test/searching/binarysearch/binarysearch.spec.js index 15a17524..881b1c39 100644 --- a/test/searching/binarysearch/binarysearch.spec.js +++ b/test/searching/binarysearch/binarysearch.spec.js @@ -1,4 +1,4 @@ -var binarySearch = require('./../src/searching/binarysearch/binarysearch').binarySearch; +var binarySearch = require('../../../src/searching/binarysearch/binarysearch').binarySearch; describe('Binary search', function () { diff --git a/test/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js b/test/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js index 91139d1f..4cb6c4f8 100644 --- a/test/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js +++ b/test/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js @@ -1,4 +1,4 @@ -var longestSubsequence = require('./../src/searching/longest-increasing-subsequence/longest-increasing-subsequence').longestSubsequence; +var longestSubsequence = require('../../../src/searching/longest-increasing-subsequence/longest-increasing-subsequence').longestSubsequence; describe('longest subsequence', function () { @@ -9,7 +9,7 @@ describe('longest subsequence', function () { it('should give the right length', function () { expect(longestSubsequence(sequence).length).toBe(5); }); - + it('should work with empty arrays', function () { expect(longestSubsequence([]).length).toBe(0); }); diff --git a/test/sorting/bubblesort/bubblesort.spec.js b/test/sorting/bubblesort/bubblesort.spec.js index 102ee4dd..706cba72 100644 --- a/test/sorting/bubblesort/bubblesort.spec.js +++ b/test/sorting/bubblesort/bubblesort.spec.js @@ -1,4 +1,4 @@ -var sortTestCase = require('./sort.testcase.js'), - bubbleSort = require('../src/sorting/bubblesort/bubblesort.js').bubbleSort; +var sortTestCase = require('../sort.testcase.js'), + bubbleSort = require('../../../src/sorting/bubblesort/bubblesort.js').bubbleSort; sortTestCase(bubbleSort, 'Bubble sort'); \ No newline at end of file diff --git a/test/sorting/heapsort/heapsort.spec.js b/test/sorting/heapsort/heapsort.spec.js index 3170dae4..25e3173f 100644 --- a/test/sorting/heapsort/heapsort.spec.js +++ b/test/sorting/heapsort/heapsort.spec.js @@ -1,4 +1,4 @@ -var sortTestCase = require('./sort.testcase.js'), - heapSort = require('../src/sorting/heapsort/heapsort.js').heapSort; +var sortTestCase = require('../sort.testcase.js'), + heapSort = require('../../../src/sorting/heapsort/heapsort.js').heapSort; sortTestCase(heapSort, 'Heap sort'); \ No newline at end of file diff --git a/test/sorting/insertionsort/insertionbinarysort.spec.js b/test/sorting/insertionsort/insertionbinarysort.spec.js index 84453bad..a7bc4861 100644 --- a/test/sorting/insertionsort/insertionbinarysort.spec.js +++ b/test/sorting/insertionsort/insertionbinarysort.spec.js @@ -1,4 +1,4 @@ -var sortTestCase = require('./sort.testcase.js'), - insertionBinarySort = require('../src/sorting/insertionsort/insertion-binary-sort.js').insertionBinarySort; +var sortTestCase = require('../sort.testcase.js'), + insertionBinarySort = require('../../../src/sorting/insertionsort/insertion-binary-sort.js').insertionBinarySort; sortTestCase(insertionBinarySort, 'Insertion binary sort'); \ No newline at end of file diff --git a/test/sorting/insertionsort/insertionsort.spec.js b/test/sorting/insertionsort/insertionsort.spec.js index f0e8fd0a..34057e4a 100644 --- a/test/sorting/insertionsort/insertionsort.spec.js +++ b/test/sorting/insertionsort/insertionsort.spec.js @@ -1,4 +1,4 @@ -var sortTestCase = require('./sort.testcase.js'), - insertionSort = require('../src/sorting/insertionsort/insertionsort.js').insertionSort; +var sortTestCase = require('../sort.testcase.js'), + insertionSort = require('../../../src/sorting/insertionsort/insertionsort.js').insertionSort; sortTestCase(insertionSort, 'Insertion sort'); \ No newline at end of file diff --git a/test/sorting/insertionsort/recursiveinsertionsort.spec.js b/test/sorting/insertionsort/recursiveinsertionsort.spec.js index 9f7a8d31..6e96eafd 100644 --- a/test/sorting/insertionsort/recursiveinsertionsort.spec.js +++ b/test/sorting/insertionsort/recursiveinsertionsort.spec.js @@ -1,4 +1,4 @@ -var sortTestCase = require('./sort.testcase.js'), - recursiveInsertionSort = require('../src/sorting/insertionsort/recursive-insertionsort.js').recursiveInsertionSort; +var sortTestCase = require('../sort.testcase.js'), + recursiveInsertionSort = require('../../../src/sorting/insertionsort/recursive-insertionsort.js').recursiveInsertionSort; sortTestCase(recursiveInsertionSort, 'Recursive insertion sort'); \ No newline at end of file diff --git a/test/sorting/mergesort/mergesort.spec.js b/test/sorting/mergesort/mergesort.spec.js index c3db9ce9..31d6028e 100644 --- a/test/sorting/mergesort/mergesort.spec.js +++ b/test/sorting/mergesort/mergesort.spec.js @@ -1,4 +1,4 @@ -var sortTestCase = require('./sort.testcase.js'), - mergeSort = require('../src/sorting/mergesort/mergesort.js').mergeSort; +var sortTestCase = require('../sort.testcase.js'), + mergeSort = require('../../../src/sorting/mergesort/mergesort.js').mergeSort; sortTestCase(mergeSort, 'Merge sort'); \ No newline at end of file diff --git a/test/sorting/quicksort/quicksort-middle.spec.js b/test/sorting/quicksort/quicksort-middle.spec.js index e4e1613f..d12276b8 100644 --- a/test/sorting/quicksort/quicksort-middle.spec.js +++ b/test/sorting/quicksort/quicksort-middle.spec.js @@ -1,4 +1,4 @@ -var sortTestCase = require('./sort.testcase.js'), - quickSort = require('../src/sorting/quicksort/quicksort-middle.js').quickSort; +var sortTestCase = require('../sort.testcase.js'), + quickSort = require('../../../src/sorting/quicksort/quicksort-middle.js').quickSort; sortTestCase(quickSort, 'Quick sort'); \ No newline at end of file diff --git a/test/sorting/quicksort/quicksort.spec.js b/test/sorting/quicksort/quicksort.spec.js index 10d1c661..e6f84a8f 100644 --- a/test/sorting/quicksort/quicksort.spec.js +++ b/test/sorting/quicksort/quicksort.spec.js @@ -1,4 +1,4 @@ -var sortTestCase = require('./sort.testcase.js'), - quickSort = require('../src/sorting/quicksort/quicksort.js').quickSort; +var sortTestCase = require('../sort.testcase.js'), + quickSort = require('../../../src/sorting/quicksort/quicksort.js').quickSort; sortTestCase(quickSort, 'Quick sort'); \ No newline at end of file diff --git a/test/sorting/selectionsort/selectionsort.spec.js b/test/sorting/selectionsort/selectionsort.spec.js index 413badc4..73718b13 100644 --- a/test/sorting/selectionsort/selectionsort.spec.js +++ b/test/sorting/selectionsort/selectionsort.spec.js @@ -1,5 +1,5 @@ -var sortTestCase = require('./sort.testcase.js'), - selectionSort = require('../src/sorting/selectionsort/selectionsort.js') +var sortTestCase = require('../sort.testcase.js'), + selectionSort = require('../../../src/sorting/selectionsort/selectionsort.js') .selectionSort; sortTestCase(selectionSort, 'Selection sort'); \ No newline at end of file diff --git a/test/sorting/shellsort/shellsort.spec.js b/test/sorting/shellsort/shellsort.spec.js index 42a5098b..ef8c1edc 100644 --- a/test/sorting/shellsort/shellsort.spec.js +++ b/test/sorting/shellsort/shellsort.spec.js @@ -1,4 +1,4 @@ -var sortTestCase = require('./sort.testcase.js'), - shellSort = require('../src/sorting/shellsort/shellsort.js').shellSort; +var sortTestCase = require('../sort.testcase.js'), + shellSort = require('../../../src/sorting/shellsort/shellsort.js').shellSort; sortTestCase(shellSort, 'Shell sort'); \ No newline at end of file From 57d304878e607924100a115429af23867f39050d Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 7 Mar 2014 10:27:15 +0200 Subject: [PATCH 096/613] Add jshintrc --- .jshintrc | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .jshintrc diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 00000000..6cf513ee --- /dev/null +++ b/.jshintrc @@ -0,0 +1,3 @@ +{ + "node": true +} \ No newline at end of file From 370e8c7b44a64bbd2319d0ffdcc1c24256410f52 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 8 Mar 2014 16:25:30 +0200 Subject: [PATCH 097/613] Fix the indentation of bucketsort --- src/sorting/linearsort/bucketsort.js | 177 +++++++++++++-------------- 1 file changed, 87 insertions(+), 90 deletions(-) diff --git a/src/sorting/linearsort/bucketsort.js b/src/sorting/linearsort/bucketsort.js index 9403aa47..0d9614fe 100644 --- a/src/sorting/linearsort/bucketsort.js +++ b/src/sorting/linearsort/bucketsort.js @@ -1,5 +1,3 @@ -var array = [0.21, 0.44, 0.221, 0.01, 0.88]; - /** * Bucketsort. This algorithm has complexity O(n) but it's not * correct for every input. @@ -8,100 +6,99 @@ var array = [0.21, 0.44, 0.221, 0.01, 0.88]; */ var bucketSort = (function () { - /** - * Insertionsort. - * - * @private - * @param {array} array Input array - * @returns {array} array Sorted input array - */ - function insertionSort(array) { - var current, - j; - for (var i = 1; i < array.length; i += 1) { - current = array[i]; - j = i - 1; - while (j >= 0 && current < array[j]) { - array[j + 1] = array[j]; - j -= 1; - } - array[j + 1] = current; - } - return array; + /** + * Insertionsort. + * + * @private + * @param {array} array Input array + * @returns {array} array Sorted input array + */ + function insertionSort(array) { + var current, + j; + for (var i = 1; i < array.length; i += 1) { + current = array[i]; + j = i - 1; + while (j >= 0 && current < array[j]) { + array[j + 1] = array[j]; + j -= 1; + } + array[j + 1] = current; } + return array; + } - /** - * Creates buckets for given array - * - * @private - * @param {array} array Input array - * @returns {array} buckets Array whith array for each bucket. - * Each bucket contains an array with all elements from the input which are with suitable size. - */ - function createBuckets(array) { - var buckets = [], - currentBucket, - current, - sectorSize = 1 / array.length; - for (var i = 0; i < array.length; i += 1) { - current = array[i]; - currentBucket = Math.floor(current / sectorSize); - if (buckets[currentBucket] === undefined) { - buckets[currentBucket] = []; - } - buckets[currentBucket].push(current); - } - return buckets; + /** + * Creates buckets for given array + * + * @private + * @param {array} array Input array + * @returns {array} buckets Array whith array for each bucket. + * Each bucket contains an array with all elements from the input which are with suitable size. + */ + function createBuckets(array) { + var buckets = [], + currentBucket, + current, + sectorSize = 1 / array.length; + for (var i = 0; i < array.length; i += 1) { + current = array[i]; + currentBucket = Math.floor(current / sectorSize); + if (buckets[currentBucket] === undefined) { + buckets[currentBucket] = []; + } + buckets[currentBucket].push(current); } + return buckets; + } - /** - * Sorts the arrays from each bucket. - * - * @private - * @param {array} buckets Given buckets - * @returns {array} buckets Buckets with sorted arrays for each bucket - */ - function sortBuckets(buckets) { - for (var i = 0; i < buckets.length; i += 1) { - if (buckets[i] !== undefined) - insertionSort(buckets[i]); - } - return buckets; + /** + * Sorts the arrays from each bucket. + * + * @private + * @param {array} buckets Given buckets + * @returns {array} buckets Buckets with sorted arrays for each bucket + */ + function sortBuckets(buckets) { + for (var i = 0; i < buckets.length; i += 1) { + if (buckets[i] !== undefined) { + insertionSort(buckets[i]); + } } + return buckets; + } - /** - * Unions all buckets' arrays - * - * @private - * @param {array} buckets Input buckets - * @returns {array} result Sorted array which contains all elements form each bucket - */ - function unionBuckets(buckets) { - var result = [], - currentBucket; - for (var i = 0; i < buckets.length; i += 1) { - currentBucket = buckets[i]; - if (currentBucket !== undefined) { - for (var j = 0; j < currentBucket.length; j += 1) { - result.push(currentBucket[j]); - } - } + /** + * Unions all buckets' arrays + * + * @private + * @param {array} buckets Input buckets + * @returns {array} result Sorted array which contains all elements form each bucket + */ + function unionBuckets(buckets) { + var result = [], + currentBucket; + for (var i = 0; i < buckets.length; i += 1) { + currentBucket = buckets[i]; + if (currentBucket !== undefined) { + for (var j = 0; j < currentBucket.length; j += 1) { + result.push(currentBucket[j]); } - return result; + } } + return result; + } - /** - * Sorts given array with bucketsort - * - * @public - * @param {array} array Input array which should be sorted - * @returns {array} Sorted array - */ - return function (array) { - var buckets = createBuckets(array); - sortBuckets(buckets); - return unionBuckets(buckets); - }; -}()); - -console.log(bucketSort(array)); + /** + * Sorts given array with bucketsort + * + * @public + * @param {array} array Input array which should be sorted + * @returns {array} Sorted array + */ + return function (array) { + var buckets = createBuckets(array); + sortBuckets(buckets); + return unionBuckets(buckets); + }; +}()); \ No newline at end of file From c27a8458cd83e24e853c127d94e99ecf4248aaf2 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 8 Mar 2014 16:27:04 +0200 Subject: [PATCH 098/613] Add use strict --- src/sorting/linearsort/bucketsort.js | 182 ++++++++++++++------------- 1 file changed, 95 insertions(+), 87 deletions(-) diff --git a/src/sorting/linearsort/bucketsort.js b/src/sorting/linearsort/bucketsort.js index 0d9614fe..fc21e2c9 100644 --- a/src/sorting/linearsort/bucketsort.js +++ b/src/sorting/linearsort/bucketsort.js @@ -1,104 +1,112 @@ -/** - * Bucketsort. This algorithm has complexity O(n) but it's not - * correct for every input. - * - * @public - */ -var bucketSort = (function () { +(function (exports) { + + 'use strict'; /** - * Insertionsort. + * Bucketsort. This algorithm has complexity O(n) but it's not + * correct for every input. * - * @private - * @param {array} array Input array - * @returns {array} array Sorted input array + * @public */ - function insertionSort(array) { - var current, - j; - for (var i = 1; i < array.length; i += 1) { - current = array[i]; - j = i - 1; - while (j >= 0 && current < array[j]) { - array[j + 1] = array[j]; - j -= 1; + var bucketSort = (function () { + + /** + * Insertionsort. + * + * @private + * @param {array} array Input array + * @returns {array} array Sorted input array + */ + function insertionSort(array) { + var current, + j; + for (var i = 1; i < array.length; i += 1) { + current = array[i]; + j = i - 1; + while (j >= 0 && current < array[j]) { + array[j + 1] = array[j]; + j -= 1; + } + array[j + 1] = current; } - array[j + 1] = current; + return array; } - return array; - } - /** - * Creates buckets for given array - * - * @private - * @param {array} array Input array - * @returns {array} buckets Array whith array for each bucket. - * Each bucket contains an array with all elements from the input which are with suitable size. - */ - function createBuckets(array) { - var buckets = [], - currentBucket, - current, - sectorSize = 1 / array.length; - for (var i = 0; i < array.length; i += 1) { - current = array[i]; - currentBucket = Math.floor(current / sectorSize); - if (buckets[currentBucket] === undefined) { - buckets[currentBucket] = []; + /** + * Creates buckets for given array + * + * @private + * @param {array} array Input array + * @returns {array} buckets Array whith array for each bucket. + * Each bucket contains an array with all elements from the input which are with suitable size. + */ + function createBuckets(array) { + var buckets = [], + currentBucket, + current, + sectorSize = 1 / array.length; + for (var i = 0; i < array.length; i += 1) { + current = array[i]; + currentBucket = Math.floor(current / sectorSize); + if (buckets[currentBucket] === undefined) { + buckets[currentBucket] = []; + } + buckets[currentBucket].push(current); } - buckets[currentBucket].push(current); + return buckets; } - return buckets; - } - /** - * Sorts the arrays from each bucket. - * - * @private - * @param {array} buckets Given buckets - * @returns {array} buckets Buckets with sorted arrays for each bucket - */ - function sortBuckets(buckets) { - for (var i = 0; i < buckets.length; i += 1) { - if (buckets[i] !== undefined) { - insertionSort(buckets[i]); + /** + * Sorts the arrays from each bucket. + * + * @private + * @param {array} buckets Given buckets + * @returns {array} buckets Buckets with sorted arrays for each bucket + */ + function sortBuckets(buckets) { + for (var i = 0; i < buckets.length; i += 1) { + if (buckets[i] !== undefined) { + insertionSort(buckets[i]); + } } + return buckets; } - return buckets; - } - /** - * Unions all buckets' arrays - * - * @private - * @param {array} buckets Input buckets - * @returns {array} result Sorted array which contains all elements form each bucket - */ - function unionBuckets(buckets) { - var result = [], - currentBucket; - for (var i = 0; i < buckets.length; i += 1) { - currentBucket = buckets[i]; - if (currentBucket !== undefined) { - for (var j = 0; j < currentBucket.length; j += 1) { - result.push(currentBucket[j]); + /** + * Unions all buckets' arrays + * + * @private + * @param {array} buckets Input buckets + * @returns {array} result Sorted array which contains all elements form each bucket + */ + function unionBuckets(buckets) { + var result = [], + currentBucket; + for (var i = 0; i < buckets.length; i += 1) { + currentBucket = buckets[i]; + if (currentBucket !== undefined) { + for (var j = 0; j < currentBucket.length; j += 1) { + result.push(currentBucket[j]); + } } } + return result; } - return result; - } - /** - * Sorts given array with bucketsort - * - * @public - * @param {array} array Input array which should be sorted - * @returns {array} Sorted array - */ - return function (array) { - var buckets = createBuckets(array); - sortBuckets(buckets); - return unionBuckets(buckets); - }; -}()); \ No newline at end of file + /** + * Sorts given array with bucketsort + * + * @public + * @param {array} array Input array which should be sorted + * @returns {array} Sorted array + */ + return function (array) { + var buckets = createBuckets(array); + sortBuckets(buckets); + return unionBuckets(buckets); + }; + }()); + + exports.bucketSort = bucketSort; + +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file From fb637ca333d2d2467c6922bf46a9b1f9fc9c72d3 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 8 Mar 2014 16:30:48 +0200 Subject: [PATCH 099/613] Fix the indentation of counting sort --- src/sorting/linearsort/bucketsort.js | 2 +- src/sorting/linearsort/countingsort.js | 144 ++++++++++++------------- 2 files changed, 71 insertions(+), 75 deletions(-) diff --git a/src/sorting/linearsort/bucketsort.js b/src/sorting/linearsort/bucketsort.js index fc21e2c9..b8e1810d 100644 --- a/src/sorting/linearsort/bucketsort.js +++ b/src/sorting/linearsort/bucketsort.js @@ -4,7 +4,7 @@ /** * Bucketsort. This algorithm has complexity O(n) but it's not - * correct for every input. + * correct for each input. * * @public */ diff --git a/src/sorting/linearsort/countingsort.js b/src/sorting/linearsort/countingsort.js index d98a8c4c..b04d86f8 100644 --- a/src/sorting/linearsort/countingsort.js +++ b/src/sorting/linearsort/countingsort.js @@ -1,5 +1,3 @@ -var array = [44,2,34,6,7,34,4,4,2,3,6,8]; - /** * Counting sort algorithm. It's with complexity O(n) but it's * correct for specific input. @@ -8,81 +6,79 @@ var array = [44,2,34,6,7,34,4,4,2,3,6,8]; */ var countingSort = function () { - /** - * Gets the count of the elements into the input array - * - * @private - * @param {array} array The input array - * @returns {array} count The count of each element from the input array - */ - function getCount(array) { - var count = [], - current; - for (var i = 0; i < array.length; i += 1) { - current = array[i]; - if (count[current] !== undefined) { - count[current] += 1; - } else { - count[current] = 1; - } - } - return count; + /** + * Gets the count of the elements into the input array + * + * @private + * @param {array} array The input array + * @returns {array} count The count of each element from the input array + */ + function getCount(array) { + var count = [], + current; + for (var i = 0; i < array.length; i += 1) { + current = array[i]; + if (count[current] !== undefined) { + count[current] += 1; + } else { + count[current] = 1; + } } + return count; + } - /** - * Gets the count of the elements which are less than a given - * - * @private - * @param {array} array The input array - * @returns {array} less The count of the elements which are less than each element from the input - */ - function getLessCount(array) { - var less = [], - last; - less[0] = array[0] || 0; - for (var i = 1; i < array.length; i += 1) { - last = array[i - 1] || 0; - less[i] = last + less[i - 1]; - } - return less; + /** + * Gets the count of the elements which are less than a given + * + * @private + * @param {array} array The input array + * @returns {array} less The count of the elements which are less than each element from the input + */ + function getLessCount(array) { + var less = [], + last; + less[0] = array[0] || 0; + for (var i = 1; i < array.length; i += 1) { + last = array[i - 1] || 0; + less[i] = last + less[i - 1]; } + return less; + } - /** - * Sorts the input array - * - * @private - * @param {array} array Input which should be sorted - * @param {array} less Count of the less elements for each element - * @returns {array} result The sorted input - */ - function sort(array, less) { - var result = [], - currentPositions = [], - current, - position; - for (var i = 0; i < array.length; i += 1) { - current = array[i]; - position = less[current]; - if (currentPositions[current] === undefined) { - currentPositions[current] = position; - } - result[currentPositions[current]] = current; - currentPositions[current] += 1; - } - return result; + /** + * Sorts the input array + * + * @private + * @param {array} array Input which should be sorted + * @param {array} less Count of the less elements for each element + * @returns {array} result The sorted input + */ + function sort(array, less) { + var result = [], + currentPositions = [], + current, + position; + for (var i = 0; i < array.length; i += 1) { + current = array[i]; + position = less[current]; + if (currentPositions[current] === undefined) { + currentPositions[current] = position; + } + result[currentPositions[current]] = current; + currentPositions[current] += 1; } + return result; + } - /** - * Sorts a given array - * - * @public - * @param {array} array Array which should be sorted - * @returns {array} array Sorted array - */ - return function (array) { - var less = getLessCount(getCount(array)); - return sort(array, less); - }; -}(); - -console.log(countingSort(array)); + /** + * Sorts a given array + * + * @public + * @param {array} array Array which should be sorted + * @returns {array} array Sorted array + */ + return function (array) { + var less = getLessCount(getCount(array)); + return sort(array, less); + }; +}(); \ No newline at end of file From 53de90ee924c08fd696460ceeb1742f2d616ae82 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 8 Mar 2014 16:31:27 +0200 Subject: [PATCH 100/613] Export counting sort --- src/sorting/linearsort/countingsort.js | 152 +++++++++++++------------ 1 file changed, 80 insertions(+), 72 deletions(-) diff --git a/src/sorting/linearsort/countingsort.js b/src/sorting/linearsort/countingsort.js index b04d86f8..0a132b07 100644 --- a/src/sorting/linearsort/countingsort.js +++ b/src/sorting/linearsort/countingsort.js @@ -1,84 +1,92 @@ -/** - * Counting sort algorithm. It's with complexity O(n) but it's - * correct for specific input. - * - * @public - */ -var countingSort = function () { +(function (exports) { + + 'use strict'; /** - * Gets the count of the elements into the input array + * Counting sort algorithm. It's with complexity O(n) but it's + * correct for specific input. * - * @private - * @param {array} array The input array - * @returns {array} count The count of each element from the input array + * @public */ - function getCount(array) { - var count = [], - current; - for (var i = 0; i < array.length; i += 1) { - current = array[i]; - if (count[current] !== undefined) { - count[current] += 1; - } else { - count[current] = 1; + var countingSort = function () { + + /** + * Gets the count of the elements into the input array + * + * @private + * @param {array} array The input array + * @returns {array} count The count of each element from the input array + */ + function getCount(array) { + var count = [], + current; + for (var i = 0; i < array.length; i += 1) { + current = array[i]; + if (count[current] !== undefined) { + count[current] += 1; + } else { + count[current] = 1; + } } + return count; } - return count; - } - /** - * Gets the count of the elements which are less than a given - * - * @private - * @param {array} array The input array - * @returns {array} less The count of the elements which are less than each element from the input - */ - function getLessCount(array) { - var less = [], - last; - less[0] = array[0] || 0; - for (var i = 1; i < array.length; i += 1) { - last = array[i - 1] || 0; - less[i] = last + less[i - 1]; + /** + * Gets the count of the elements which are less than a given + * + * @private + * @param {array} array The input array + * @returns {array} less The count of the elements which are less than each element from the input + */ + function getLessCount(array) { + var less = [], + last; + less[0] = array[0] || 0; + for (var i = 1; i < array.length; i += 1) { + last = array[i - 1] || 0; + less[i] = last + less[i - 1]; + } + return less; } - return less; - } - /** - * Sorts the input array - * - * @private - * @param {array} array Input which should be sorted - * @param {array} less Count of the less elements for each element - * @returns {array} result The sorted input - */ - function sort(array, less) { - var result = [], - currentPositions = [], - current, - position; - for (var i = 0; i < array.length; i += 1) { - current = array[i]; - position = less[current]; - if (currentPositions[current] === undefined) { - currentPositions[current] = position; + /** + * Sorts the input array + * + * @private + * @param {array} array Input which should be sorted + * @param {array} less Count of the less elements for each element + * @returns {array} result The sorted input + */ + function sort(array, less) { + var result = [], + currentPositions = [], + current, + position; + for (var i = 0; i < array.length; i += 1) { + current = array[i]; + position = less[current]; + if (currentPositions[current] === undefined) { + currentPositions[current] = position; + } + result[currentPositions[current]] = current; + currentPositions[current] += 1; } - result[currentPositions[current]] = current; - currentPositions[current] += 1; + return result; } - return result; - } - /** - * Sorts a given array - * - * @public - * @param {array} array Array which should be sorted - * @returns {array} array Sorted array - */ - return function (array) { - var less = getLessCount(getCount(array)); - return sort(array, less); - }; -}(); \ No newline at end of file + /** + * Sorts a given array + * + * @public + * @param {array} array Array which should be sorted + * @returns {array} array Sorted array + */ + return function (array) { + var less = getLessCount(getCount(array)); + return sort(array, less); + }; + }(); + + exports.countingSort = countingSort; + +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file From 32a7b4c4ee7c0582215356f427a18433cc892e7c Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 8 Mar 2014 16:44:00 +0200 Subject: [PATCH 101/613] Update .jshintrc --- .jshintrc | 32 ++++++++++++++++++++++++++-- src/sorting/linearsort/bucketsort.js | 6 ++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/.jshintrc b/.jshintrc index 6cf513ee..a4d22492 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,3 +1,31 @@ { - "node": true -} \ No newline at end of file + "node": true, + "esnext": true, + "bitwise": true, + "camelcase": true, + "curly": true, + "eqeqeq": true, + "indent": 2, + "latedef": true, + "noarg": true, + "newcap": false, + "quotmark": "single", + "unused": true, + "strict": true, + "trailing": true, + "smarttabs": true, + "white": true, + "freeze": true, + "immed": true, + "noempty": true, + "plusplus": true, + "undef": true, + "laxbreak": true, + "maxdepth": 3, + "loopfunc": true, + "maxcomplexity": 9, + "maxlen": 80, + "globals": { + "window": true + } +} diff --git a/src/sorting/linearsort/bucketsort.js b/src/sorting/linearsort/bucketsort.js index b8e1810d..616f8f89 100644 --- a/src/sorting/linearsort/bucketsort.js +++ b/src/sorting/linearsort/bucketsort.js @@ -38,7 +38,8 @@ * @private * @param {array} array Input array * @returns {array} buckets Array whith array for each bucket. - * Each bucket contains an array with all elements from the input which are with suitable size. + * Each bucket contains an array with all elements + * from the input which are with suitable size. */ function createBuckets(array) { var buckets = [], @@ -77,7 +78,8 @@ * * @private * @param {array} buckets Input buckets - * @returns {array} result Sorted array which contains all elements form each bucket + * @returns {array} result Sorted array which contains + * all elements form each bucket */ function unionBuckets(buckets) { var result = [], From 1a14fd0988d774dcb5515997fef76e4dbd0af50b Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 8 Mar 2014 17:05:33 +0200 Subject: [PATCH 102/613] Change the count of the buckets --- src/sorting/linearsort/bucketsort.js | 11 ++++------- src/sorting/linearsort/countingsort.js | 7 ++++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/sorting/linearsort/bucketsort.js b/src/sorting/linearsort/bucketsort.js index 616f8f89..e82e056c 100644 --- a/src/sorting/linearsort/bucketsort.js +++ b/src/sorting/linearsort/bucketsort.js @@ -43,15 +43,12 @@ */ function createBuckets(array) { var buckets = [], - currentBucket, - current, - sectorSize = 1 / array.length; + length = array.length, + currentBucket, current; for (var i = 0; i < array.length; i += 1) { current = array[i]; - currentBucket = Math.floor(current / sectorSize); - if (buckets[currentBucket] === undefined) { - buckets[currentBucket] = []; - } + currentBucket = Math.floor(length % current); + buckets[currentBucket] = buckets[currentBucket] || []; buckets[currentBucket].push(current); } return buckets; diff --git a/src/sorting/linearsort/countingsort.js b/src/sorting/linearsort/countingsort.js index 0a132b07..e8860876 100644 --- a/src/sorting/linearsort/countingsort.js +++ b/src/sorting/linearsort/countingsort.js @@ -8,7 +8,7 @@ * * @public */ - var countingSort = function () { + var countingSort = (function () { /** * Gets the count of the elements into the input array @@ -36,7 +36,8 @@ * * @private * @param {array} array The input array - * @returns {array} less The count of the elements which are less than each element from the input + * @returns {array} less The count of the elements which + * are less than each element from the input */ function getLessCount(array) { var less = [], @@ -85,7 +86,7 @@ var less = getLessCount(getCount(array)); return sort(array, less); }; - }(); + }()); exports.countingSort = countingSort; From bfac601927d38f125b4b535791ec15937ced4c08 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 8 Mar 2014 17:07:13 +0200 Subject: [PATCH 103/613] Fix comments --- src/sorting/linearsort/bucketsort.js | 4 ++-- src/sorting/linearsort/countingsort.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sorting/linearsort/bucketsort.js b/src/sorting/linearsort/bucketsort.js index e82e056c..fa249688 100644 --- a/src/sorting/linearsort/bucketsort.js +++ b/src/sorting/linearsort/bucketsort.js @@ -3,8 +3,8 @@ 'use strict'; /** - * Bucketsort. This algorithm has complexity O(n) but it's not - * correct for each input. + * Bucket sort. This algorithm has complexity O(n) in case the + * data is with uniform distribution. * * @public */ diff --git a/src/sorting/linearsort/countingsort.js b/src/sorting/linearsort/countingsort.js index e8860876..5073c44b 100644 --- a/src/sorting/linearsort/countingsort.js +++ b/src/sorting/linearsort/countingsort.js @@ -4,7 +4,7 @@ /** * Counting sort algorithm. It's with complexity O(n) but it's - * correct for specific input. + * correct only for array of integers. * * @public */ From 4be8c885c7e6a2ea4159e700d184a21db3dea76e Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 8 Mar 2014 17:10:43 +0200 Subject: [PATCH 104/613] Make the code not that verbose --- src/sorting/linearsort/countingsort.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/sorting/linearsort/countingsort.js b/src/sorting/linearsort/countingsort.js index 5073c44b..b235f803 100644 --- a/src/sorting/linearsort/countingsort.js +++ b/src/sorting/linearsort/countingsort.js @@ -22,11 +22,7 @@ current; for (var i = 0; i < array.length; i += 1) { current = array[i]; - if (count[current] !== undefined) { - count[current] += 1; - } else { - count[current] = 1; - } + count[current] = (count[current] || 0) + 1; } return count; } From 91d8a6090a15e56e72091ca7e615b7778dae51fb Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 8 Mar 2014 17:16:48 +0200 Subject: [PATCH 105/613] Fix .jshintrc and the sorting test case --- .jshintrc | 6 +++++- test/sorting/sort.testcase.js | 11 ++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.jshintrc b/.jshintrc index a4d22492..f715520a 100644 --- a/.jshintrc +++ b/.jshintrc @@ -26,6 +26,10 @@ "maxcomplexity": 9, "maxlen": 80, "globals": { - "window": true + "window": true, + "it": true, + "beforeEach": true, + "describe": true, + "expect": true } } diff --git a/test/sorting/sort.testcase.js b/test/sorting/sort.testcase.js index d186c323..f39568c8 100644 --- a/test/sorting/sort.testcase.js +++ b/test/sorting/sort.testcase.js @@ -1,4 +1,7 @@ module.exports = function (sort, algorithmName) { + + 'use strict'; + describe(algorithmName, function () { function createRandomArray(options) { @@ -9,7 +12,8 @@ module.exports = function (sort, algorithmName) { var result = []; for (var i = size; i > 0; i -= 1) { - result.push(parseFloat((Math.random() * multiplier).toFixed(precision))); + result.push(parseFloat((Math.random() * + multiplier).toFixed(precision))); } return result; } @@ -19,7 +23,7 @@ module.exports = function (sort, algorithmName) { }); it('should work with sorted arrays', function () { - expect(sort([1,2,3,4])).toEqual([1,2,3,4]); + expect(sort([1, 2, 3, 4])).toEqual([1, 2, 3, 4]); }); it('should work with random non-sorted arrays', function () { @@ -32,7 +36,8 @@ module.exports = function (sort, algorithmName) { } }); - it('should sort the numbers in descending order when such comparator is provided', function () { + it('should sort the numbers in descending order ' + + 'when such comparator is provided', function () { function comparator(a, b) { return b - a; } From 3da6df70fac77258416a7363b7052b084d2525b6 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 8 Mar 2014 18:12:09 +0200 Subject: [PATCH 106/613] Changes in bucketsort --- src/sorting/linearsort/bucketsort.js | 7 +--- test/sorting/shellsort/shellsort.spec.js | 3 +- test/sorting/sort.testcase.js | 52 +++++++++++++++--------- 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/sorting/linearsort/bucketsort.js b/src/sorting/linearsort/bucketsort.js index fa249688..b77c671e 100644 --- a/src/sorting/linearsort/bucketsort.js +++ b/src/sorting/linearsort/bucketsort.js @@ -43,11 +43,10 @@ */ function createBuckets(array) { var buckets = [], - length = array.length, currentBucket, current; for (var i = 0; i < array.length; i += 1) { current = array[i]; - currentBucket = Math.floor(length % current); + currentBucket = Math.floor(current); buckets[currentBucket] = buckets[currentBucket] || []; buckets[currentBucket].push(current); } @@ -84,9 +83,7 @@ for (var i = 0; i < buckets.length; i += 1) { currentBucket = buckets[i]; if (currentBucket !== undefined) { - for (var j = 0; j < currentBucket.length; j += 1) { - result.push(currentBucket[j]); - } + result = result.concat(currentBucket); } } return result; diff --git a/test/sorting/shellsort/shellsort.spec.js b/test/sorting/shellsort/shellsort.spec.js index ef8c1edc..ec2a8674 100644 --- a/test/sorting/shellsort/shellsort.spec.js +++ b/test/sorting/shellsort/shellsort.spec.js @@ -1,4 +1,5 @@ var sortTestCase = require('../sort.testcase.js'), - shellSort = require('../../../src/sorting/shellsort/shellsort.js').shellSort; + shellSort = require('../../../src/sorting/shellsort/shellsort.js') + .shellSort; sortTestCase(shellSort, 'Shell sort'); \ No newline at end of file diff --git a/test/sorting/sort.testcase.js b/test/sorting/sort.testcase.js index f39568c8..68382432 100644 --- a/test/sorting/sort.testcase.js +++ b/test/sorting/sort.testcase.js @@ -1,14 +1,19 @@ -module.exports = function (sort, algorithmName) { +module.exports = function (sort, algorithmName, options) { 'use strict'; + options = options || { + integers: false, + reverse : true + }; + describe(algorithmName, function () { - function createRandomArray(options) { - options = options || {}; - var size = options.size || 100, - precision = options.precision || 2, - multiplier = options.multiplier || 100; + function createRandomArray(config) { + config = config || {}; + var size = config.size || 100, + precision = config.precision || 2, + multiplier = config.multiplier || 100; var result = []; for (var i = size; i > 0; i -= 1) { @@ -27,28 +32,35 @@ module.exports = function (sort, algorithmName) { }); it('should work with random non-sorted arrays', function () { - - var array = createRandomArray(); + var array; + if (options.integers) { + array = createRandomArray(); + } else { + array = createRandomArray({ + precision: 0 + }); + } sort(array); - for (var i = 0; i < array.length - 1; i += 1) { expect(array[i] <= array[i + 1]).toBeTruthy(); } }); - it('should sort the numbers in descending order ' + - 'when such comparator is provided', function () { - function comparator(a, b) { - return b - a; - } + if (options.reverse) { + it('should sort the numbers in descending order ' + + 'when such comparator is provided', function () { + function comparator(a, b) { + return b - a; + } - var array = createRandomArray(); - sort(array, comparator); + var array = createRandomArray(); + sort(array, comparator); - for (var i = 0; i < array.length - 1; i += 1) { - expect(array[i] >= array[i + 1]).toBeTruthy(); - } - }); + for (var i = 0; i < array.length - 1; i += 1) { + expect(array[i] >= array[i + 1]).toBeTruthy(); + } + }); + } }); }; \ No newline at end of file From e0d1281becf77b9f15ef26567213e8552e5c2e48 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 12 Mar 2014 10:06:44 +0200 Subject: [PATCH 107/613] Update divide and conquer --- .../maximum-subarray-divide-and-conquer.js | 56 +++++++++---------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/src/searching/subarray/maximum-subarray-divide-and-conquer.js b/src/searching/subarray/maximum-subarray-divide-and-conquer.js index 108e9130..78c1f5d4 100644 --- a/src/searching/subarray/maximum-subarray-divide-and-conquer.js +++ b/src/searching/subarray/maximum-subarray-divide-and-conquer.js @@ -2,7 +2,6 @@ * Finds the maximum subarray using the divide and conquer algorithm * by Bentley, Jon (1984) (complexity O(n(logn))); */ -var array = [4,5,-4,6,-34,-2,-34,-5,3,4,-1,2,3,2,8,-32,-45]; /** * Accepts an array and range. Finds the maximum sum of elements @@ -15,25 +14,25 @@ var array = [4,5,-4,6,-34,-2,-34,-5,3,4,-1,2,3,2,8,-32,-45]; * @return {number} the maximum sum including the middle element */ function crossSubarray(array, left, middle, right) { - var leftSum = -Infinity, - rightSum = -Infinity, - sum = 0, - i; + var leftSum = -Infinity, + rightSum = -Infinity, + sum = 0, + i; - for (i = middle; i >= left; i -= 1) { - if (sum + array[i] >= leftSum) { - leftSum = sum + array[i]; - } - sum += array[i]; + for (i = middle; i >= left; i -= 1) { + if (sum + array[i] >= leftSum) { + leftSum = sum + array[i]; } - sum = 0; - for (i = middle + 1; i < right; i += 1) { - if (sum + array[i] >= rightSum) { - rightSum = sum + array[i]; - } - sum += array[i]; + sum += array[i]; + } + sum = 0; + for (i = middle + 1; i < right; i += 1) { + if (sum + array[i] >= rightSum) { + rightSum = sum + array[i]; } - return leftSum + rightSum; + sum += array[i]; + } + return leftSum + rightSum; } /** @@ -42,18 +41,19 @@ function crossSubarray(array, left, middle, right) { * @param {array} array * @param {number} left side of the range * @param {number} the right side of the range - * @return {number} the maximum sum of the elements of subarray whithin the given range + * @return {number} the maximum sum of the elements of + * subarray whithin the given range */ function maxSubarrayPartitioner(array, left, right) { - if (right - left <= 1) { - return array[left]; - } - var middle = Math.floor((left + right) / 2), - leftSum = maxSubarrayPartitioner(array, left, middle), - rightSum = maxSubarrayPartitioner(array, middle, right), - crossSum = crossSubarray(array, left, middle, right); + if (right - left <= 1) { + return array[left]; + } + var middle = Math.floor((left + right) / 2), + leftSum = maxSubarrayPartitioner(array, left, middle), + rightSum = maxSubarrayPartitioner(array, middle, right), + crossSum = crossSubarray(array, left, middle, right); - return Math.max(crossSum, leftSum, rightSum); + return Math.max(crossSum, leftSum, rightSum); } /** @@ -63,7 +63,5 @@ function maxSubarrayPartitioner(array, left, right) { * @return the maximum sum */ function maxSubarray(array) { - return maxSubarrayPartitioner(array, 0, array.length); + return maxSubarrayPartitioner(array, 0, array.length); } - -console.log(maxSubarray(array)); From fc1efaeb02769f342d93d674cd5fab9372b3944b Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 12 Mar 2014 10:08:01 +0200 Subject: [PATCH 108/613] Export the max subarray algorithm --- .../maximum-subarray-divide-and-conquer.js | 116 ++++++++++-------- 1 file changed, 62 insertions(+), 54 deletions(-) diff --git a/src/searching/subarray/maximum-subarray-divide-and-conquer.js b/src/searching/subarray/maximum-subarray-divide-and-conquer.js index 78c1f5d4..1e815a44 100644 --- a/src/searching/subarray/maximum-subarray-divide-and-conquer.js +++ b/src/searching/subarray/maximum-subarray-divide-and-conquer.js @@ -1,67 +1,75 @@ /** - * Finds the maximum subarray using the divide and conquer algorithm + * Finds the maximum subarray using the divide and conquer algorithm * by Bentley, Jon (1984) (complexity O(n(logn))); */ -/** - * Accepts an array and range. Finds the maximum sum of elements - * around the middle of the range. - * - * @param {array} array - * @param {number} left - the left interval of the range - * @param {number} middle - the middle of the range - * @param {number} right - the right side of the range - * @return {number} the maximum sum including the middle element - */ -function crossSubarray(array, left, middle, right) { - var leftSum = -Infinity, - rightSum = -Infinity, - sum = 0, - i; +(function (exports) { + + 'use strict'; - for (i = middle; i >= left; i -= 1) { - if (sum + array[i] >= leftSum) { - leftSum = sum + array[i]; + /** + * Accepts an array and range. Finds the maximum sum of elements + * around the middle of the range. + * + * @param {array} array + * @param {number} left - the left interval of the range + * @param {number} middle - the middle of the range + * @param {number} right - the right side of the range + * @return {number} the maximum sum including the middle element + */ + function crossSubarray(array, left, middle, right) { + var leftSum = -Infinity, + rightSum = -Infinity, + sum = 0, + i; + + for (i = middle; i >= left; i -= 1) { + if (sum + array[i] >= leftSum) { + leftSum = sum + array[i]; + } + sum += array[i]; + } + sum = 0; + for (i = middle + 1; i < right; i += 1) { + if (sum + array[i] >= rightSum) { + rightSum = sum + array[i]; + } + sum += array[i]; } - sum += array[i]; + return leftSum + rightSum; } - sum = 0; - for (i = middle + 1; i < right; i += 1) { - if (sum + array[i] >= rightSum) { - rightSum = sum + array[i]; + + /** + * Using divide and conquer finds the maximum sum of subarray of the given + * + * @param {array} array + * @param {number} left side of the range + * @param {number} the right side of the range + * @return {number} the maximum sum of the elements of + * subarray whithin the given range + */ + function maxSubarrayPartitioner(array, left, right) { + if (right - left <= 1) { + return array[left]; } - sum += array[i]; + var middle = Math.floor((left + right) / 2), + leftSum = maxSubarrayPartitioner(array, left, middle), + rightSum = maxSubarrayPartitioner(array, middle, right), + crossSum = crossSubarray(array, left, middle, right); + + return Math.max(crossSum, leftSum, rightSum); } - return leftSum + rightSum; -} -/** - * Using divide and conquer finds the maximum sum of subarray of the given - * - * @param {array} array - * @param {number} left side of the range - * @param {number} the right side of the range - * @return {number} the maximum sum of the elements of - * subarray whithin the given range - */ -function maxSubarrayPartitioner(array, left, right) { - if (right - left <= 1) { - return array[left]; + /** + * Returns the maximum sum of the elements of a subarray of the given array + * + * @param {array} the array + * @return the maximum sum + */ + function maxSubarray(array) { + return maxSubarrayPartitioner(array, 0, array.length); } - var middle = Math.floor((left + right) / 2), - leftSum = maxSubarrayPartitioner(array, left, middle), - rightSum = maxSubarrayPartitioner(array, middle, right), - crossSum = crossSubarray(array, left, middle, right); - return Math.max(crossSum, leftSum, rightSum); -} + exports.maxSubarray = maxSubarray; -/** - * Returns the maximum sum of the elements of a subarray of the given array - * - * @param {array} the array - * @return the maximum sum - */ -function maxSubarray(array) { - return maxSubarrayPartitioner(array, 0, array.length); -} +}(typeof exports === 'undefined' ? window : exports)); From 85bdf71e6d69e3e5d2c440550173ad820962a7a8 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 12 Mar 2014 10:17:12 +0200 Subject: [PATCH 109/613] Add tests for the max sum of subarray --- ...aximum-subarray-divide-and-conquer.spec.js | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/searching/subarray/maximum-subarray-divide-and-conquer.spec.js diff --git a/test/searching/subarray/maximum-subarray-divide-and-conquer.spec.js b/test/searching/subarray/maximum-subarray-divide-and-conquer.spec.js new file mode 100644 index 00000000..40deb2e9 --- /dev/null +++ b/test/searching/subarray/maximum-subarray-divide-and-conquer.spec.js @@ -0,0 +1,37 @@ +'use strict'; + +var maxSubArray = + require('../../../src/searching/subarray/maximum-subarray-divide-and-conquer') + .maxSubarray; + +describe('Maximum subarray implemented with divide and conquer', function () { + + it('should work with empty arrays', function () { + expect(isNaN(maxSubArray([]))).toBeTruthy(); + }); + + it('should return the only element when an array with' + + 'single element is passed', function () { + expect(maxSubArray([42])).toBe(42); + }); + + it('should return the only negative element when an array with' + + 'single element is passed', function () { + expect(maxSubArray([-42])).toBe(-42); + }); + + it('should return the zero when an array with' + + 'single element, which is zero is passed', function () { + expect(maxSubArray([0])).toBe(0); + }); + + it('should return the max sum of a subarray', function () { + expect(maxSubArray([1, -1, 2, 3, -1])).toBe(5); + }); + + it('should return the max nevative number when array' + + 'with nevative numbers is provided', function () { + expect(maxSubArray([-10, -1, -2, -3, -1])).toBe(-1); + }); + +}); \ No newline at end of file From 7688607d62d2496deddfa36c6e12904122508d13 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 14 Mar 2014 09:49:26 +0200 Subject: [PATCH 110/613] Validate according to jshintrc --- test/searching/binarysearch/binarysearch.spec.js | 15 +++++++++------ .../longest-increasing-subsequence.spec.js | 13 ++++++++++--- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/test/searching/binarysearch/binarysearch.spec.js b/test/searching/binarysearch/binarysearch.spec.js index 881b1c39..606c8729 100644 --- a/test/searching/binarysearch/binarysearch.spec.js +++ b/test/searching/binarysearch/binarysearch.spec.js @@ -1,22 +1,25 @@ -var binarySearch = require('../../../src/searching/binarysearch/binarysearch').binarySearch; +'use strict'; + +var binarySearch = + require('../../../src/searching/binarysearch/binarysearch').binarySearch; describe('Binary search', function () { it('should find the element at position 0 ', function () { - expect(binarySearch([1,2,3,4,6,8], 1)).toBe(0); + expect(binarySearch([1, 2, 3, 4, 6, 8], 1)).toBe(0); }); it('should find the eleent in position arr.length', function () { - expect(binarySearch([1,2,3,4,6,8], 1)).toBe(0); + expect(binarySearch([1, 2, 3, 4, 6, 8], 1)).toBe(0); }); it('should work with arrays with 2 elements', function () { - expect(binarySearch([1,8], 1)).toBe(0); - expect(binarySearch([1,8], 8)).toBe(1); + expect(binarySearch([1, 8], 1)).toBe(0); + expect(binarySearch([1, 8], 8)).toBe(1); }); it('should return -1 for missing elements', function () { - expect(binarySearch([1,2,3], 4)).toBe(-1); + expect(binarySearch([1, 2, 3], 4)).toBe(-1); }); it('should work with empty arrays', function () { diff --git a/test/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js b/test/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js index 4cb6c4f8..78c48bb9 100644 --- a/test/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js +++ b/test/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js @@ -1,9 +1,15 @@ -var longestSubsequence = require('../../../src/searching/longest-increasing-subsequence/longest-increasing-subsequence').longestSubsequence; +'use strict'; + +var longestSubsequence = + require('../../../src/searching/' + + 'longest-increasing-subsequence/longest-increasing-subsequence') + .longestSubsequence; describe('longest subsequence', function () { + var sequence; beforeEach(function () { - global.sequence = [5, 2, 8, 6, 3, 6, 9, 7, 11]; + sequence = [5, 2, 8, 6, 3, 6, 9, 7, 11]; }); it('should give the right length', function () { @@ -15,7 +21,8 @@ describe('longest subsequence', function () { }); it('should return the correct path', function () { - expect(longestSubsequence(sequence).toString()).toBe([2,3,6,9,11].toString()); + expect(longestSubsequence(sequence).toString()) + .toBe([2, 3, 6, 9, 11].toString()); }); }); \ No newline at end of file From babff99b9c4fb866a34d643c55934207dd4029b7 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 14 Mar 2014 09:54:48 +0200 Subject: [PATCH 111/613] Update bfs according to jshintrc --- src/graphs/searching/bfs.js | 106 ++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 48 deletions(-) diff --git a/src/graphs/searching/bfs.js b/src/graphs/searching/bfs.js index 0ce987b8..1211ef92 100644 --- a/src/graphs/searching/bfs.js +++ b/src/graphs/searching/bfs.js @@ -10,59 +10,69 @@ var graph = [[1,0,1,0,0,0], [0,0,0,0,1,1]]; * * * * * * * * * * * * * * * * * */ +'use strict'; + /** * Breadth-first search algorithm for matrix representation of graph. * The algorithm finds whether there's a path between two given nodes. */ -var breadthFirstSearch = function () { +var breadthFirstSearch = (function () { + + var visited = [], + queue = [], + target, + graph; - var visted = [], - queue = [], - target, - graph; + /** + * Initializes the algorithm + * + * @private + * @param {array} inputGraph The input matrix of the graph + * @param {number} destination The destination + */ + function init(inputGraph, destination) { + graph = inputGraph; + target = destination; + visited = []; + queue = []; + for (var i = 0; i < graph.length; i += 1) { + visited[i] = false; + } + } - /** - * Initializes the algorithm - * - * @private - * @param {array} inputGraph The input matrix of the graph - * @param {number} destination The destination - */ - function init(inputGraph, destination) { - graph = inputGraph; - target = destination; - visited = []; - queue = []; - for (var i = 0; i < graph.length; i += 1) - visited[i] = false; + function processNode(destination, current, node) { + if (graph[current][node]) { + if (node === destination) { + return true; + } + if (!visited[node]) { + queue.push(node); + } } + } - /** - * Finds whether there's a path between a given start node - * to given destination - * - * @public - * @param {array} graph A matrix representation of the graph - * @param {number} source The source node - * @param {number} destination The destination node - * @returns {boolean} true/false depending whether there's a path between the nodes - */ - return function (graph, source, destination) { - init(graph, destination); - var current; - queue.push(source); - while (queue.length > 0) { - current = queue.shift(); - visited[current] = true; - for (var i = 0; i < graph.length; i += 1) { - if (graph[current][i]) { - if (i === destination) - return true; - if (!visited[i]) - queue.push(i); - } - } - } - return false; - }; -}(); + /** + * Finds whether there's a path between a given start node + * to given destination + * + * @public + * @param {array} graph A matrix representation of the graph + * @param {number} source The source node + * @param {number} destination The destination node + * @returns {boolean} true/false depending whether there's + * a path between the nodes + */ + return function (graph, source, destination) { + init(graph, destination); + var current; + queue.push(source); + while (queue.length > 0) { + current = queue.shift(); + visited[current] = true; + for (var i = 0; i < graph.length; i += 1) { + processNode(destination, current, i); + } + } + return false; + }; +}()); From a1a239d45c5e8cbcc5107c6448d1601deb766642 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 14 Mar 2014 09:56:29 +0200 Subject: [PATCH 112/613] Add comments and fixes issue --- src/graphs/searching/bfs.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/graphs/searching/bfs.js b/src/graphs/searching/bfs.js index 1211ef92..7024ef4d 100644 --- a/src/graphs/searching/bfs.js +++ b/src/graphs/searching/bfs.js @@ -40,6 +40,13 @@ var breadthFirstSearch = (function () { } } + /** + * Process given node + * + * @param {number} destination The destionation, which should be reached + * @param {number} current The current node + * @param {number} node Neighbour node + */ function processNode(destination, current, node) { if (graph[current][node]) { if (node === destination) { @@ -70,7 +77,10 @@ var breadthFirstSearch = (function () { current = queue.shift(); visited[current] = true; for (var i = 0; i < graph.length; i += 1) { - processNode(destination, current, i); + var result = processNode(destination, current, i); + if (result) { + return true; + } } } return false; From 6b2f00f180aab894709bfbbda66af6376f69e157 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 14 Mar 2014 09:57:18 +0200 Subject: [PATCH 113/613] Export the bfs algorithm --- src/graphs/searching/bfs.js | 134 +++++++++++++++++++----------------- 1 file changed, 70 insertions(+), 64 deletions(-) diff --git a/src/graphs/searching/bfs.js b/src/graphs/searching/bfs.js index 7024ef4d..5ae2ce67 100644 --- a/src/graphs/searching/bfs.js +++ b/src/graphs/searching/bfs.js @@ -10,79 +10,85 @@ var graph = [[1,0,1,0,0,0], [0,0,0,0,1,1]]; * * * * * * * * * * * * * * * * * */ -'use strict'; +(function (exports) { -/** - * Breadth-first search algorithm for matrix representation of graph. - * The algorithm finds whether there's a path between two given nodes. - */ -var breadthFirstSearch = (function () { - - var visited = [], - queue = [], - target, - graph; + 'use strict'; /** - * Initializes the algorithm - * - * @private - * @param {array} inputGraph The input matrix of the graph - * @param {number} destination The destination + * Breadth-first search algorithm for matrix representation of graph. + * The algorithm finds whether there's a path between two given nodes. */ - function init(inputGraph, destination) { - graph = inputGraph; - target = destination; - visited = []; - queue = []; - for (var i = 0; i < graph.length; i += 1) { - visited[i] = false; - } - } + var breadthFirstSearch = (function () { - /** - * Process given node - * - * @param {number} destination The destionation, which should be reached - * @param {number} current The current node - * @param {number} node Neighbour node - */ - function processNode(destination, current, node) { - if (graph[current][node]) { - if (node === destination) { - return true; - } - if (!visited[node]) { - queue.push(node); + var visited = [], + queue = [], + target, + graph; + + /** + * Initializes the algorithm + * + * @private + * @param {array} inputGraph The input matrix of the graph + * @param {number} destination The destination + */ + function init(inputGraph, destination) { + graph = inputGraph; + target = destination; + visited = []; + queue = []; + for (var i = 0; i < graph.length; i += 1) { + visited[i] = false; } } - } - /** - * Finds whether there's a path between a given start node - * to given destination - * - * @public - * @param {array} graph A matrix representation of the graph - * @param {number} source The source node - * @param {number} destination The destination node - * @returns {boolean} true/false depending whether there's - * a path between the nodes - */ - return function (graph, source, destination) { - init(graph, destination); - var current; - queue.push(source); - while (queue.length > 0) { - current = queue.shift(); - visited[current] = true; - for (var i = 0; i < graph.length; i += 1) { - var result = processNode(destination, current, i); - if (result) { + /** + * Process given node + * + * @param {number} destination The destionation, which should be reached + * @param {number} current The current node + * @param {number} node Neighbour node + */ + function processNode(destination, current, node) { + if (graph[current][node]) { + if (node === destination) { return true; } + if (!visited[node]) { + queue.push(node); + } } } - return false; - }; -}()); + + /** + * Finds whether there's a path between a given start node + * to given destination + * + * @public + * @param {array} graph A matrix representation of the graph + * @param {number} source The source node + * @param {number} destination The destination node + * @returns {boolean} true/false depending whether there's + * a path between the nodes + */ + return function (graph, source, destination) { + init(graph, destination); + var current; + queue.push(source); + while (queue.length > 0) { + current = queue.shift(); + visited[current] = true; + for (var i = 0; i < graph.length; i += 1) { + var result = processNode(destination, current, i); + if (result) { + return true; + } + } + } + return false; + }; + }()); + + exports.breadthFirstSearch = breadthFirstSearch; + +}(typeof exports === 'undefined' ? window : exports)); From 7ec48981d106934609f0404d57f81b4150d17e7b Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 15 Mar 2014 09:33:01 +0200 Subject: [PATCH 114/613] Minor changes in bfs --- src/graphs/searching/bfs.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/graphs/searching/bfs.js b/src/graphs/searching/bfs.js index 5ae2ce67..8d509ac9 100644 --- a/src/graphs/searching/bfs.js +++ b/src/graphs/searching/bfs.js @@ -1,15 +1,3 @@ -/* * * * * * * * * * * * * * * * * * - - Sample graph - -var graph = [[1,0,1,0,0,0], - [0,1,0,1,0,0], - [1,0,1,0,1,0], - [0,1,0,1,1,0], - [0,0,1,1,1,1], - [0,0,0,0,1,1]]; -* * * * * * * * * * * * * * * * * */ - (function (exports) { 'use strict'; From 53845f1a43009cbcc4276fcc4ee13a13dc2153f3 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 15 Mar 2014 09:33:23 +0200 Subject: [PATCH 115/613] Add spec file for bfs --- test/graphs/searching/bfs.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/graphs/searching/bfs.js diff --git a/test/graphs/searching/bfs.js b/test/graphs/searching/bfs.js new file mode 100644 index 00000000..8685bb10 --- /dev/null +++ b/test/graphs/searching/bfs.js @@ -0,0 +1,11 @@ +/* * * * * * * * * * * * * * * * * * + + Sample graph + +var graph = [[1,0,1,0,0,0], + [0,1,0,1,0,0], + [1,0,1,0,1,0], + [0,1,0,1,1,0], + [0,0,1,1,1,1], + [0,0,0,0,1,1]]; +* * * * * * * * * * * * * * * * * */ From 639192e44c39889f359f43edee4a64ff8173c5f6 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 15 Mar 2014 13:15:56 +0200 Subject: [PATCH 116/613] Rename bfs spec file --- test/graphs/searching/{bfs.js => bfs.spec.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/graphs/searching/{bfs.js => bfs.spec.js} (100%) diff --git a/test/graphs/searching/bfs.js b/test/graphs/searching/bfs.spec.js similarity index 100% rename from test/graphs/searching/bfs.js rename to test/graphs/searching/bfs.spec.js From 1c94e5e93371c296c4c210663c4270cb0e5aabc0 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 15 Mar 2014 13:27:51 +0200 Subject: [PATCH 117/613] Validates the parameters --- src/graphs/searching/bfs.js | 36 ++++++++++++++++++++++++++ test/graphs/searching/bfs.spec.js | 42 ++++++++++++++++++++++++------- 2 files changed, 69 insertions(+), 9 deletions(-) diff --git a/src/graphs/searching/bfs.js b/src/graphs/searching/bfs.js index 8d509ac9..03499591 100644 --- a/src/graphs/searching/bfs.js +++ b/src/graphs/searching/bfs.js @@ -48,6 +48,39 @@ } } + /** + * Validates the graph + * + * @param {array} graph A matrix representation of the graph + * @param {number} source The source node + * @param {number} destination The destination node + * @returns {boolean} true/false depending whether the params are valid + */ + function invalidParams(graph, source, destination) { + if (!graph) { + return true; + } + var invalidCoordinates = + source.concat(destination).filter(function (c, i) { + if (c < 0) { + return true; + } + if (i % 2 === 0) { + if (c >= graph.length) { + return true; + } + } else { + if (c >= graph[0].length) { + return true; + } + } + }); + if (invalidCoordinates.length) { + return true; + } + return false; + } + /** * Finds whether there's a path between a given start node * to given destination @@ -60,6 +93,9 @@ * a path between the nodes */ return function (graph, source, destination) { + if (invalidParams(graph, source, destination)) { + return false; + } init(graph, destination); var current; queue.push(source); diff --git a/test/graphs/searching/bfs.spec.js b/test/graphs/searching/bfs.spec.js index 8685bb10..ae619247 100644 --- a/test/graphs/searching/bfs.spec.js +++ b/test/graphs/searching/bfs.spec.js @@ -1,11 +1,35 @@ -/* * * * * * * * * * * * * * * * * * +'use strict'; - Sample graph +var sampleGraph = [[1, 0, 1, 0, 0, 0], + [0, 1, 0, 1, 0, 0], + [1, 0, 1, 0, 1, 0], + [0, 1, 0, 1, 1, 0], + [0, 1, 0, 1, 1, 0], + [0, 1, 0, 1, 1, 0], + [0, 0, 1, 1, 1, 1], + [0, 0, 0, 0, 1, 1]]; -var graph = [[1,0,1,0,0,0], - [0,1,0,1,0,0], - [1,0,1,0,1,0], - [0,1,0,1,1,0], - [0,0,1,1,1,1], - [0,0,0,0,1,1]]; -* * * * * * * * * * * * * * * * * */ +var bfs = require('../../../src/graphs/searching/bfs').breadthFirstSearch; + +describe('BFS', function () { + + var graph; + + it('should work with incorrect input', function () { + expect(bfs(null, 1, 1)).toBe(false); + expect(bfs(sampleGraph, [-1, -1], [0, 0])).toBe(false); + expect(bfs(sampleGraph, [0, -1], [-1, 0])).toBe(false); + expect(bfs(sampleGraph, [0, 0], [-1, 0])).toBe(false); + expect(bfs(sampleGraph, [0, 1000], [-1, 0])).toBe(false); + expect(bfs(sampleGraph, [100000, 1000], [-1, 0])).toBe(false); + expect(bfs(sampleGraph, [0, 0], [100, 100])).toBe(false); + expect(bfs(sampleGraph, [0, 0], [6, 6])).toBe(false); + }); + + it('should work with 1x1 matrix', function () { + graph = [[1]]; + //expec(graph) + }); + + +}); \ No newline at end of file From 4311f9da0766f0026f85147f4460196a1af1e165 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 16 Mar 2014 13:18:00 +0200 Subject: [PATCH 118/613] Fix dfs implementation --- src/graphs/searching/bfs.js | 38 +++++++++++++++++++------------ test/graphs/searching/bfs.spec.js | 5 ++-- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/graphs/searching/bfs.js b/src/graphs/searching/bfs.js index 03499591..b1bf1f5a 100644 --- a/src/graphs/searching/bfs.js +++ b/src/graphs/searching/bfs.js @@ -23,11 +23,18 @@ function init(inputGraph, destination) { graph = inputGraph; target = destination; - visited = []; queue = []; - for (var i = 0; i < graph.length; i += 1) { - visited[i] = false; + visited = {}; + } + + function addNode(node) { + if (visited[node] || + node[0] < 0 || node[1] < 0 || + node[0] > graph.length || node[1] > graph[0].length || + !graph[node[0]] || !graph[node[0]]) { + return; } + queue.push(node); } /** @@ -37,14 +44,15 @@ * @param {number} current The current node * @param {number} node Neighbour node */ - function processNode(destination, current, node) { - if (graph[current][node]) { - if (node === destination) { - return true; - } - if (!visited[node]) { - queue.push(node); - } + function processNode(destination, current) { + if (destination.toString() === current.toString()) { + return true; + } else { + addNode([current[0], current[1] + 1]); + addNode([current[0], current[1] - 1]); + addNode([current[0] + 1, current[1]]); + addNode([current[0] - 1, current[1]]); + return false; } } @@ -87,8 +95,8 @@ * * @public * @param {array} graph A matrix representation of the graph - * @param {number} source The source node - * @param {number} destination The destination node + * @param {array} source The source node + * @param {array} destination The destination node * @returns {boolean} true/false depending whether there's * a path between the nodes */ @@ -102,8 +110,8 @@ while (queue.length > 0) { current = queue.shift(); visited[current] = true; - for (var i = 0; i < graph.length; i += 1) { - var result = processNode(destination, current, i); + if (graph[current[0]][current[1]]) { + var result = processNode(destination, current); if (result) { return true; } diff --git a/test/graphs/searching/bfs.spec.js b/test/graphs/searching/bfs.spec.js index ae619247..50898901 100644 --- a/test/graphs/searching/bfs.spec.js +++ b/test/graphs/searching/bfs.spec.js @@ -28,8 +28,9 @@ describe('BFS', function () { it('should work with 1x1 matrix', function () { graph = [[1]]; - //expec(graph) + expect(bfs(graph, [0, 0], [0, 0])).toBeTruthy(); + graph = [[0]]; + expect(bfs(graph, [0, 0], [0, 0])).toBeFalsy(); }); - }); \ No newline at end of file From c972cdcc8c03cfd93c9fd6e354b03e0a6870ee20 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 16 Mar 2014 13:23:47 +0200 Subject: [PATCH 119/613] Fix dfs implementation --- src/graphs/searching/bfs.js | 34 ++++++++++++++++++------------- test/graphs/searching/bfs.spec.js | 18 ++++++++-------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/graphs/searching/bfs.js b/src/graphs/searching/bfs.js index b1bf1f5a..08ab2dec 100644 --- a/src/graphs/searching/bfs.js +++ b/src/graphs/searching/bfs.js @@ -64,29 +64,37 @@ * @param {number} destination The destination node * @returns {boolean} true/false depending whether the params are valid */ - function invalidParams(graph, source, destination) { + function validateParams(graph, source, destination) { if (!graph) { - return true; + throw 'The graph should be represented as a matrix'; + } + if (!graph[0]) { + throw 'The graph should be represented as ' + + 'a matrix, with size at least 1x1'; + } + var width = graph[0].length; + for (var i = 0; i < graph.length; i += 1) { + if (graph[i] !== width) { + throw 'The graph should be represented as a matrix'; + } } - var invalidCoordinates = - source.concat(destination).filter(function (c, i) { + source.concat(destination).filter(function (c, i) { if (c < 0) { - return true; + throw 'The source and destination coordinates should be above zero'; } if (i % 2 === 0) { if (c >= graph.length) { - return true; + throw 'The source and destination coordinates ' + + 'should not be above graph\'s size'; } } else { if (c >= graph[0].length) { - return true; + throw 'The source and destination coordinates ' + + 'should not be above graph\'s size'; } } }); - if (invalidCoordinates.length) { - return true; - } - return false; + return true; } /** @@ -101,9 +109,7 @@ * a path between the nodes */ return function (graph, source, destination) { - if (invalidParams(graph, source, destination)) { - return false; - } + validateParams(graph, source, destination); init(graph, destination); var current; queue.push(source); diff --git a/test/graphs/searching/bfs.spec.js b/test/graphs/searching/bfs.spec.js index 50898901..308e3b04 100644 --- a/test/graphs/searching/bfs.spec.js +++ b/test/graphs/searching/bfs.spec.js @@ -16,14 +16,16 @@ describe('BFS', function () { var graph; it('should work with incorrect input', function () { - expect(bfs(null, 1, 1)).toBe(false); - expect(bfs(sampleGraph, [-1, -1], [0, 0])).toBe(false); - expect(bfs(sampleGraph, [0, -1], [-1, 0])).toBe(false); - expect(bfs(sampleGraph, [0, 0], [-1, 0])).toBe(false); - expect(bfs(sampleGraph, [0, 1000], [-1, 0])).toBe(false); - expect(bfs(sampleGraph, [100000, 1000], [-1, 0])).toBe(false); - expect(bfs(sampleGraph, [0, 0], [100, 100])).toBe(false); - expect(bfs(sampleGraph, [0, 0], [6, 6])).toBe(false); + expect(function () { + bfs(null, [1, 1], [1, 1]); + }).toThrow(); + // expect(bfs(sampleGraph, [-1, -1], [0, 0])).toBe(false); + // expect(bfs(sampleGraph, [0, -1], [-1, 0])).toBe(false); + // expect(bfs(sampleGraph, [0, 0], [-1, 0])).toBe(false); + // expect(bfs(sampleGraph, [0, 1000], [-1, 0])).toBe(false); + // expect(bfs(sampleGraph, [100000, 1000], [-1, 0])).toBe(false); + // expect(bfs(sampleGraph, [0, 0], [100, 100])).toBe(false); + // expect(bfs(sampleGraph, [0, 0], [6, 6])).toBe(false); }); it('should work with 1x1 matrix', function () { From 8fe14d3d3568baeed8fef71b91e70faf3a52dbbc Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 16 Mar 2014 13:38:34 +0200 Subject: [PATCH 120/613] Updates the tests of bfs --- src/graphs/searching/bfs.js | 43 +++++++++++++++++-------------- test/graphs/searching/bfs.spec.js | 32 ++++++++++++++++------- 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/src/graphs/searching/bfs.js b/src/graphs/searching/bfs.js index 08ab2dec..40be1ba9 100644 --- a/src/graphs/searching/bfs.js +++ b/src/graphs/searching/bfs.js @@ -18,7 +18,7 @@ * * @private * @param {array} inputGraph The input matrix of the graph - * @param {number} destination The destination + * @param {array} destination The destination */ function init(inputGraph, destination) { graph = inputGraph; @@ -27,6 +27,10 @@ visited = {}; } + /** + * Adds a valid node to the queue + * @param {array} node Node to be added to the queue + */ function addNode(node) { if (visited[node] || node[0] < 0 || node[1] < 0 || @@ -40,9 +44,8 @@ /** * Process given node * - * @param {number} destination The destionation, which should be reached - * @param {number} current The current node - * @param {number} node Neighbour node + * @param {array} destination The destionation, which should be reached + * @param {array} current The current node */ function processNode(destination, current) { if (destination.toString() === current.toString()) { @@ -57,40 +60,40 @@ } /** - * Validates the graph + * Validates the params * * @param {array} graph A matrix representation of the graph - * @param {number} source The source node - * @param {number} destination The destination node - * @returns {boolean} true/false depending whether the params are valid + * @param {array} source The source node + * @param {array} destination The destination node */ function validateParams(graph, source, destination) { if (!graph) { - throw 'The graph should be represented as a matrix'; + throw new Error('The graph should be represented as a matrix'); } - if (!graph[0]) { - throw 'The graph should be represented as ' + - 'a matrix, with size at least 1x1'; + if (graph[0] === undefined) { + throw new Error('The graph should be represented as ' + + 'a matrix, with size at least 1x1'); } var width = graph[0].length; - for (var i = 0; i < graph.length; i += 1) { - if (graph[i] !== width) { - throw 'The graph should be represented as a matrix'; + for (var i = 1; i < graph.length; i += 1) { + if (graph[i].length !== width) { + throw new Error('The graph should be represented as a matrix'); } } source.concat(destination).filter(function (c, i) { if (c < 0) { - throw 'The source and destination coordinates should be above zero'; + throw new Error('The source and destination coordinates ' + + 'should be above zero'); } if (i % 2 === 0) { if (c >= graph.length) { - throw 'The source and destination coordinates ' + - 'should not be above graph\'s size'; + throw new Error('The source and destination coordinates ' + + 'should not be above graph\'s size'); } } else { if (c >= graph[0].length) { - throw 'The source and destination coordinates ' + - 'should not be above graph\'s size'; + throw new Error('The source and destination coordinates ' + + 'should not be above graph\'s size'); } } }); diff --git a/test/graphs/searching/bfs.spec.js b/test/graphs/searching/bfs.spec.js index 308e3b04..05c2f6ce 100644 --- a/test/graphs/searching/bfs.spec.js +++ b/test/graphs/searching/bfs.spec.js @@ -13,23 +13,35 @@ var bfs = require('../../../src/graphs/searching/bfs').breadthFirstSearch; describe('BFS', function () { - var graph; - it('should work with incorrect input', function () { expect(function () { bfs(null, [1, 1], [1, 1]); }).toThrow(); - // expect(bfs(sampleGraph, [-1, -1], [0, 0])).toBe(false); - // expect(bfs(sampleGraph, [0, -1], [-1, 0])).toBe(false); - // expect(bfs(sampleGraph, [0, 0], [-1, 0])).toBe(false); - // expect(bfs(sampleGraph, [0, 1000], [-1, 0])).toBe(false); - // expect(bfs(sampleGraph, [100000, 1000], [-1, 0])).toBe(false); - // expect(bfs(sampleGraph, [0, 0], [100, 100])).toBe(false); - // expect(bfs(sampleGraph, [0, 0], [6, 6])).toBe(false); + expect(function () { + bfs(sampleGraph, [-1, -1], [0, 0]); + }).toThrow(); + expect(function () { + bfs(sampleGraph, [0, -1], [-1, 0]); + }).toThrow(); + expect(function () { + bfs(sampleGraph, [0, 0], [-1, 0]); + }).toThrow(); + expect(function () { + bfs(sampleGraph, [0, 1000], [-1, 0]); + }).toThrow(); + expect(function () { + bfs(sampleGraph, [100000, 1000], [-1, 0]); + }).toThrow(); + expect(function () { + bfs(sampleGraph, [0, 0], [100, 100]); + }).toThrow(); + expect(function () { + bfs(sampleGraph, [0, 0], [5, 5]); + }).not.toThrow(); }); it('should work with 1x1 matrix', function () { - graph = [[1]]; + var graph = [[1]]; expect(bfs(graph, [0, 0], [0, 0])).toBeTruthy(); graph = [[0]]; expect(bfs(graph, [0, 0], [0, 0])).toBeFalsy(); From 21268fd84d6057461f50de5ffd8aee511320594a Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 16 Mar 2014 14:37:45 +0200 Subject: [PATCH 121/613] Fix issue in bfs... --- src/graphs/searching/bfs.js | 4 ++-- test/graphs/searching/bfs.spec.js | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/graphs/searching/bfs.js b/src/graphs/searching/bfs.js index 40be1ba9..6b40f3e0 100644 --- a/src/graphs/searching/bfs.js +++ b/src/graphs/searching/bfs.js @@ -34,8 +34,8 @@ function addNode(node) { if (visited[node] || node[0] < 0 || node[1] < 0 || - node[0] > graph.length || node[1] > graph[0].length || - !graph[node[0]] || !graph[node[0]]) { + node[0] >= graph.length || node[1] >= graph[0].length || + !graph[node[0]][node[1]]) { return; } queue.push(node); diff --git a/test/graphs/searching/bfs.spec.js b/test/graphs/searching/bfs.spec.js index 05c2f6ce..010c2d52 100644 --- a/test/graphs/searching/bfs.spec.js +++ b/test/graphs/searching/bfs.spec.js @@ -1,8 +1,8 @@ 'use strict'; -var sampleGraph = [[1, 0, 1, 0, 0, 0], - [0, 1, 0, 1, 0, 0], - [1, 0, 1, 0, 1, 0], +var sampleGraph = [[1, 1, 1, 0, 0, 0], + [0, 1, 1, 1, 0, 0], + [1, 0, 1, 1, 1, 0], [0, 1, 0, 1, 1, 0], [0, 1, 0, 1, 1, 0], [0, 1, 0, 1, 1, 0], @@ -47,4 +47,9 @@ describe('BFS', function () { expect(bfs(graph, [0, 0], [0, 0])).toBeFalsy(); }); + it('should work in the general case', function () { + expect(bfs(sampleGraph, [0, 0], [1, 1])).toBeTruthy(); + expect(bfs(sampleGraph, [0, 0], [6, 5])).toBeTruthy(); + }); + }); \ No newline at end of file From c392297d622a01f976bc147c54f0709876672c7d Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 19 Mar 2014 15:40:48 +0200 Subject: [PATCH 122/613] Add few more assertions for bfs --- test/graphs/searching/bfs.spec.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/graphs/searching/bfs.spec.js b/test/graphs/searching/bfs.spec.js index 010c2d52..c8133574 100644 --- a/test/graphs/searching/bfs.spec.js +++ b/test/graphs/searching/bfs.spec.js @@ -50,6 +50,9 @@ describe('BFS', function () { it('should work in the general case', function () { expect(bfs(sampleGraph, [0, 0], [1, 1])).toBeTruthy(); expect(bfs(sampleGraph, [0, 0], [6, 5])).toBeTruthy(); + expect(bfs(sampleGraph, [0, 0], [0, 5])).toBeFalsy(); + expect(bfs(sampleGraph, [1, 1], [6, 5])).toBeTruthy(); + expect(bfs(sampleGraph, [1, 1], [0, 5])).toBeFalsy(); }); }); \ No newline at end of file From b1f46ecd1ab4580170722651daa2a01bc7003371 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 19 Mar 2014 15:43:15 +0200 Subject: [PATCH 123/613] Fix the indentation in dfs --- src/graphs/searching/dfs.js | 116 ++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 53 deletions(-) diff --git a/src/graphs/searching/dfs.js b/src/graphs/searching/dfs.js index b758384b..9483ab7b 100644 --- a/src/graphs/searching/dfs.js +++ b/src/graphs/searching/dfs.js @@ -1,7 +1,12 @@ +'use strict'; +/** + * BUGGY DON'T USE + */ + /* * * * * * * * * * * * * * * * * * - Sample graph - + Sample graph + var graph = [[1,0,1,0,0,0], [0,1,0,1,0,0], [1,0,1,0,1,0], @@ -14,60 +19,65 @@ var graph = [[1,0,1,0,0,0], * Depth-first search algorithm for matrix representation of graph. * The algorithm finds whether there's a path between two given nodes. */ -var depthFirstSearch = function () { +var depthFirstSearch = (function () { - var visted = [], - target, - graph; + var visited = [], + target, + graph; - /** - * Returns whether the destination could be reached - * from given node - * - * @private - * @param {number} current Current node - * @returns {boolean} True/false depending whether - * the destination can be reached from the current node - */ - function dfs(current) { - if (current === target) return true; - visited[current] = true; - for (var i = 0; i < graph.length; i += 1) { - if (graph[current][i] === 1 && - !visited[i]) { - return depthFirstSearch(i); - } - } - return false; + /** + * Returns whether the destination could be reached + * from given node + * + * @private + * @param {number} current Current node + * @returns {boolean} True/false depending whether + * the destination can be reached from the current node + */ + function dfs(current) { + if (current === target) { + return true; + } + visited[current] = true; + for (var i = 0; i < graph.length; i += 1) { + if (graph[current][i] === 1 && + !visited[i]) { + return depthFirstSearch(i); + } } + return false; + } - /** - * Initializes the algorithm - * - * @private - * @param {array} inputGraph The input matrix of the graph - * @param {number} destination The destination - */ - function init(inputGraph, destination) { - graph = inputGraph; - target = destination; - visited = []; - for (var i = 0; i < graph.length; i += 1) - visited[i] = false; + /** + * Initializes the algorithm + * + * @private + * @param {array} inputGraph The input matrix of the graph + * @param {number} destination The destination + */ + function init(inputGraph, destination) { + graph = inputGraph; + target = destination; + visited = []; + for (var i = 0; i < graph.length; i += 1) { + visited[i] = false; } + } + + /** + * Finds whether there's a path between a given start node + * to given destination + * + * @public + * @param {array} graph A matrix representation of the graph + * @param {number} source The source node + * @param {number} destination The destination node + * @returns {boolean} true/false depending + * whether there's a path between the nodes + */ + return function (graph, source, destination) { + init(graph, destination); + return dfs(source); + }; - /** - * Finds whether there's a path between a given start node - * to given destination - * - * @public - * @param {array} graph A matrix representation of the graph - * @param {number} source The source node - * @param {number} destination The destination node - * @returns {boolean} true/false depending whether there's a path between the nodes - */ - return function (graph, source, destination) { - init(graph, destination); - return dfs(source); - }; -}(); +}()); From fd065891ec9c16e4e8efda540ea51bc0f365473b Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 19 Mar 2014 15:44:06 +0200 Subject: [PATCH 124/613] Validate the parameters in dfs --- src/graphs/searching/dfs.js | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/graphs/searching/dfs.js b/src/graphs/searching/dfs.js index 9483ab7b..5564911c 100644 --- a/src/graphs/searching/dfs.js +++ b/src/graphs/searching/dfs.js @@ -64,6 +64,47 @@ var depthFirstSearch = (function () { } } + /** + * Validates the params + * + * @param {array} graph A matrix representation of the graph + * @param {array} source The source node + * @param {array} destination The destination node + */ + function validateParams(graph, source, destination) { + if (!graph) { + throw new Error('The graph should be represented as a matrix'); + } + if (graph[0] === undefined) { + throw new Error('The graph should be represented as ' + + 'a matrix, with size at least 1x1'); + } + var width = graph[0].length; + for (var i = 1; i < graph.length; i += 1) { + if (graph[i].length !== width) { + throw new Error('The graph should be represented as a matrix'); + } + } + source.concat(destination).filter(function (c, i) { + if (c < 0) { + throw new Error('The source and destination coordinates ' + + 'should be above zero'); + } + if (i % 2 === 0) { + if (c >= graph.length) { + throw new Error('The source and destination coordinates ' + + 'should not be above graph\'s size'); + } + } else { + if (c >= graph[0].length) { + throw new Error('The source and destination coordinates ' + + 'should not be above graph\'s size'); + } + } + }); + return true; + } + /** * Finds whether there's a path between a given start node * to given destination @@ -76,6 +117,7 @@ var depthFirstSearch = (function () { * whether there's a path between the nodes */ return function (graph, source, destination) { + validateParams(graph, source, destination); init(graph, destination); return dfs(source); }; From 6b58ab37d06c16baa50de5a6a82bdfc40d92ff9c Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 19 Mar 2014 15:48:01 +0200 Subject: [PATCH 125/613] Fix dfs --- src/graphs/searching/dfs.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/graphs/searching/dfs.js b/src/graphs/searching/dfs.js index 5564911c..9e2f4a00 100644 --- a/src/graphs/searching/dfs.js +++ b/src/graphs/searching/dfs.js @@ -1,7 +1,4 @@ 'use strict'; -/** - * BUGGY DON'T USE - */ /* * * * * * * * * * * * * * * * * * @@ -35,16 +32,21 @@ var depthFirstSearch = (function () { * the destination can be reached from the current node */ function dfs(current) { - if (current === target) { + if (visited[current] || + current[0] < 0 || current[1] < 0 || + current[0] >= graph.length || current[1] >= graph[0].length || + !graph[current[0]][current[1]]) { + return; + } + if (current[0] === target[0] && + current[1] === target[1]) { return true; } visited[current] = true; - for (var i = 0; i < graph.length; i += 1) { - if (graph[current][i] === 1 && - !visited[i]) { - return depthFirstSearch(i); - } - } + dfs([current[0] + 1, current[1]]); + dfs([current[0] - 1, current[1]]); + dfs([current[0], current[1] + 1]); + dfs([current[0], current[1] - 1]); return false; } @@ -58,10 +60,7 @@ var depthFirstSearch = (function () { function init(inputGraph, destination) { graph = inputGraph; target = destination; - visited = []; - for (var i = 0; i < graph.length; i += 1) { - visited[i] = false; - } + visited = {}; } /** From f850a5d17f7e9832e94a4ad5f6f8e3e10e8aa95b Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 19 Mar 2014 15:50:51 +0200 Subject: [PATCH 126/613] Export dfs --- src/graphs/searching/dfs.js | 197 ++++++++++++++++++------------------ 1 file changed, 101 insertions(+), 96 deletions(-) diff --git a/src/graphs/searching/dfs.js b/src/graphs/searching/dfs.js index 9e2f4a00..ce3a37f9 100644 --- a/src/graphs/searching/dfs.js +++ b/src/graphs/searching/dfs.js @@ -12,113 +12,118 @@ var graph = [[1,0,1,0,0,0], [0,0,0,0,1,1]]; * * * * * * * * * * * * * * * * * */ -/** - * Depth-first search algorithm for matrix representation of graph. - * The algorithm finds whether there's a path between two given nodes. - */ -var depthFirstSearch = (function () { - - var visited = [], - target, - graph; - +(function (exports) { /** - * Returns whether the destination could be reached - * from given node - * - * @private - * @param {number} current Current node - * @returns {boolean} True/false depending whether - * the destination can be reached from the current node + * Depth-first search algorithm for matrix representation of graph. + * The algorithm finds whether there's a path between two given nodes. */ - function dfs(current) { - if (visited[current] || - current[0] < 0 || current[1] < 0 || - current[0] >= graph.length || current[1] >= graph[0].length || - !graph[current[0]][current[1]]) { - return; - } - if (current[0] === target[0] && - current[1] === target[1]) { - return true; - } - visited[current] = true; - dfs([current[0] + 1, current[1]]); - dfs([current[0] - 1, current[1]]); - dfs([current[0], current[1] + 1]); - dfs([current[0], current[1] - 1]); - return false; - } + var depthFirstSearch = (function () { - /** - * Initializes the algorithm - * - * @private - * @param {array} inputGraph The input matrix of the graph - * @param {number} destination The destination - */ - function init(inputGraph, destination) { - graph = inputGraph; - target = destination; - visited = {}; - } + var visited = [], + target, + graph; - /** - * Validates the params - * - * @param {array} graph A matrix representation of the graph - * @param {array} source The source node - * @param {array} destination The destination node - */ - function validateParams(graph, source, destination) { - if (!graph) { - throw new Error('The graph should be represented as a matrix'); + /** + * Returns whether the destination could be reached + * from given node + * + * @private + * @param {number} current Current node + * @returns {boolean} True/false depending whether + * the destination can be reached from the current node + */ + function dfs(current) { + if (visited[current] || + current[0] < 0 || current[1] < 0 || + current[0] >= graph.length || current[1] >= graph[0].length || + !graph[current[0]][current[1]]) { + return false; + } + if (current[0] === target[0] && + current[1] === target[1]) { + return true; + } + visited[current] = true; + return dfs([current[0] + 1, current[1]]) || + dfs([current[0] - 1, current[1]]) || + dfs([current[0], current[1] + 1]) || + dfs([current[0], current[1] - 1]); } - if (graph[0] === undefined) { - throw new Error('The graph should be represented as ' + - 'a matrix, with size at least 1x1'); + + /** + * Initializes the algorithm + * + * @private + * @param {array} inputGraph The input matrix of the graph + * @param {number} destination The destination + */ + function init(inputGraph, destination) { + graph = inputGraph; + target = destination; + visited = {}; } - var width = graph[0].length; - for (var i = 1; i < graph.length; i += 1) { - if (graph[i].length !== width) { + + /** + * Validates the params + * + * @param {array} graph A matrix representation of the graph + * @param {array} source The source node + * @param {array} destination The destination node + */ + function validateParams(graph, source, destination) { + if (!graph) { throw new Error('The graph should be represented as a matrix'); } - } - source.concat(destination).filter(function (c, i) { - if (c < 0) { - throw new Error('The source and destination coordinates ' + - 'should be above zero'); + if (graph[0] === undefined) { + throw new Error('The graph should be represented as ' + + 'a matrix, with size at least 1x1'); } - if (i % 2 === 0) { - if (c >= graph.length) { - throw new Error('The source and destination coordinates ' + - 'should not be above graph\'s size'); + var width = graph[0].length; + for (var i = 1; i < graph.length; i += 1) { + if (graph[i].length !== width) { + throw new Error('The graph should be represented as a matrix'); } - } else { - if (c >= graph[0].length) { + } + source.concat(destination).filter(function (c, i) { + if (c < 0) { throw new Error('The source and destination coordinates ' + - 'should not be above graph\'s size'); + 'should be above zero'); } - } - }); - return true; - } + if (i % 2 === 0) { + if (c >= graph.length) { + throw new Error('The source and destination coordinates ' + + 'should not be above graph\'s size'); + } + } else { + if (c >= graph[0].length) { + throw new Error('The source and destination coordinates ' + + 'should not be above graph\'s size'); + } + } + }); + return true; + } - /** - * Finds whether there's a path between a given start node - * to given destination - * - * @public - * @param {array} graph A matrix representation of the graph - * @param {number} source The source node - * @param {number} destination The destination node - * @returns {boolean} true/false depending - * whether there's a path between the nodes - */ - return function (graph, source, destination) { - validateParams(graph, source, destination); - init(graph, destination); - return dfs(source); - }; + /** + * Finds whether there's a path between a given start node + * to given destination + * + * @public + * @param {array} graph A matrix representation of the graph + * @param {number} source The source node + * @param {number} destination The destination node + * @returns {boolean} true/false depending + * whether there's a path between the nodes + */ + return function (graph, source, destination) { + validateParams(graph, source, destination); + init(graph, destination); + return dfs(source); + }; + + + }()); + + exports.depthFirstSearch = depthFirstSearch; -}()); +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file From 67bddfc17c2465934ccbc814f59ca8d3f934097f Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 20 Mar 2014 15:36:39 +0200 Subject: [PATCH 127/613] Add tests for dfs --- test/graphs/searching/dfs.spec.js | 58 +++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 test/graphs/searching/dfs.spec.js diff --git a/test/graphs/searching/dfs.spec.js b/test/graphs/searching/dfs.spec.js new file mode 100644 index 00000000..84dd9708 --- /dev/null +++ b/test/graphs/searching/dfs.spec.js @@ -0,0 +1,58 @@ +'use strict'; + +var sampleGraph = [[1, 1, 1, 0, 0, 0], + [0, 1, 1, 1, 0, 0], + [1, 0, 1, 1, 1, 0], + [0, 1, 0, 1, 1, 0], + [0, 1, 0, 1, 1, 0], + [0, 1, 0, 1, 1, 0], + [0, 0, 1, 1, 1, 1], + [0, 0, 0, 0, 1, 1]]; + +var dfs = require('../../../src/graphs/searching/dfs').depthFirstSearch; + +describe('dfs', function () { + + it('should work with incorrect input', function () { + expect(function () { + dfs(null, [1, 1], [1, 1]); + }).toThrow(); + expect(function () { + dfs(sampleGraph, [-1, -1], [0, 0]); + }).toThrow(); + expect(function () { + dfs(sampleGraph, [0, -1], [-1, 0]); + }).toThrow(); + expect(function () { + dfs(sampleGraph, [0, 0], [-1, 0]); + }).toThrow(); + expect(function () { + dfs(sampleGraph, [0, 1000], [-1, 0]); + }).toThrow(); + expect(function () { + dfs(sampleGraph, [100000, 1000], [-1, 0]); + }).toThrow(); + expect(function () { + dfs(sampleGraph, [0, 0], [100, 100]); + }).toThrow(); + expect(function () { + dfs(sampleGraph, [0, 0], [5, 5]); + }).not.toThrow(); + }); + + it('should work with 1x1 matrix', function () { + var graph = [[1]]; + expect(dfs(graph, [0, 0], [0, 0])).toBeTruthy(); + graph = [[0]]; + expect(dfs(graph, [0, 0], [0, 0])).toBeFalsy(); + }); + + it('should work in the general case', function () { + expect(dfs(sampleGraph, [0, 0], [1, 1])).toBeTruthy(); + expect(dfs(sampleGraph, [0, 0], [6, 5])).toBeTruthy(); + expect(dfs(sampleGraph, [0, 0], [0, 5])).toBeFalsy(); + expect(dfs(sampleGraph, [1, 1], [6, 5])).toBeTruthy(); + expect(dfs(sampleGraph, [1, 1], [0, 5])).toBeFalsy(); + }); + +}); \ No newline at end of file From 637536eb7279876b1df16770d49ecbb6a8dbf651 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 2 May 2014 15:06:34 -0700 Subject: [PATCH 128/613] Remove trending --- readme.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/readme.md b/readme.md index cd9bd4ee..2f06c36e 100644 --- a/readme.md +++ b/readme.md @@ -18,5 +18,3 @@ Initiate the PR. ## License The code in this repository is distributed under the terms of the MIT license. - -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/mgechev/javascript-algorithms/trend.png)](https://bitdeli.com/free "Bitdeli Badge") From e9b9aa99cb5c57f710bd59d935109836c1dcd867 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 15 May 2014 05:07:45 -0700 Subject: [PATCH 129/613] Add red black tree --- src/data-structures/red-black-tree.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/data-structures/red-black-tree.js diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js new file mode 100644 index 00000000..5da6b1be --- /dev/null +++ b/src/data-structures/red-black-tree.js @@ -0,0 +1,25 @@ +(function (global) { + + 'use strict'; + + function Node(key, value, isRed) { + this._key = key; + this._value = value; + this._isRed = isRed; + } + + Node.prototype.isRed = function () { + return !!this._isRed; + }; + + Node.prototype.getKey = function () { + return this._key; + }; + + Node.prototype.getValue = function () { + return this._value; + }; + + global.Node = Node; + +}(typeof window === 'undefined' ? module.exports : window)); From 8631cf5fdc2b0b27907bdfd787d707d0a0dbe570 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 15 May 2014 05:08:27 -0700 Subject: [PATCH 130/613] Add basic tests for Node --- test/data-structures/red-black-tree.spec.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 test/data-structures/red-black-tree.spec.js diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js new file mode 100644 index 00000000..a0ba6a44 --- /dev/null +++ b/test/data-structures/red-black-tree.spec.js @@ -0,0 +1,10 @@ +'use strict'; + +var mod = require('../../src/data-structures/red-black-tree.js'), + Node = mod.Node; + +describe('Node', function () { + it('should be a constructor function', function () { + expect(typeof Node).toBe('function'); + }); +}); From c0eb3515933335eeffdc4a781ae353bfb3489255 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 15 May 2014 05:10:39 -0700 Subject: [PATCH 131/613] Add tests for Node --- test/data-structures/red-black-tree.spec.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index a0ba6a44..3247f05e 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -7,4 +7,10 @@ describe('Node', function () { it('should be a constructor function', function () { expect(typeof Node).toBe('function'); }); + it('should set all properties via the constructor', function () { + var node = new Node('key', 'value', true); + expect(node.getKey()).toBe('key'); + expect(node.getValue()).toBe('value'); + expect(node.isRed()).toBeTruthy(); + }); }); From 62e78c512d54c980fa2b76e62c37f14bf052be70 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 15 May 2014 05:16:28 -0700 Subject: [PATCH 132/613] Add RBTree function --- src/data-structures/red-black-tree.js | 7 +++++++ test/data-structures/red-black-tree.spec.js | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index 5da6b1be..c566ccc1 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -22,4 +22,11 @@ global.Node = Node; + + function RBTree() { + this._root = null; + } + + global.RBTree = RBTree; + }(typeof window === 'undefined' ? module.exports : window)); diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index 3247f05e..6ea0f224 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -1,7 +1,8 @@ 'use strict'; var mod = require('../../src/data-structures/red-black-tree.js'), - Node = mod.Node; + Node = mod.Node, + RBTree = mod.RBTree; describe('Node', function () { it('should be a constructor function', function () { @@ -12,5 +13,17 @@ describe('Node', function () { expect(node.getKey()).toBe('key'); expect(node.getValue()).toBe('value'); expect(node.isRed()).toBeTruthy(); + node = new Node('key', 'value', undefined); + //if we set isRed to falcy it should be turned to red + expect(node.isRed()).toBe(false); + }); +}); + +describe('RBTree', function () { + it('should be a constructor function', function () { + expect(typeof RBTree).toBe('function'); + }); + it('should initialize root to null by default', function () { + expect(new RBTree()._root).toBeNull(); }); }); From 493c8c38dc46e012cfc07138c3c257f3a7791384 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 15 May 2014 05:21:40 -0700 Subject: [PATCH 133/613] Add logic basic insertion case --- src/data-structures/red-black-tree.js | 10 ++++++++++ test/data-structures/red-black-tree.spec.js | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index c566ccc1..681f703b 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -27,6 +27,16 @@ this._root = null; } + RBTree.prototype.put = function (key, value) { + return this._put(key, value, this._root); + }; + + RBTree.prototype._put = function (key, value, node) { + if (this._root === null) { + return (this._root = new Node(key, value, false)); + } + }; + global.RBTree = RBTree; }(typeof window === 'undefined' ? module.exports : window)); diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index 6ea0f224..b8d94003 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -26,4 +26,13 @@ describe('RBTree', function () { it('should initialize root to null by default', function () { expect(new RBTree()._root).toBeNull(); }); + + describe('RBTree node insertion', function () { + it('should be able to insert a node in empty tree', function () { + var tree = new RBTree(); + tree.put('foo', 'bar'); + expect(tree._root.getKey()).toBe('foo'); + expect(tree._root.getValue()).toBe('bar'); + }); + }); }); From 18d5b6ec8d23d864ec3e54137df6a0e4bd856645 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 16 May 2014 13:49:12 -0700 Subject: [PATCH 134/613] Add left and right properties of the node --- src/data-structures/red-black-tree.js | 19 +++++++++++++++++-- test/data-structures/red-black-tree.spec.js | 4 +++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index 681f703b..379062df 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -2,8 +2,10 @@ 'use strict'; - function Node(key, value, isRed) { + function Node(key, left, right, value, isRed) { this._key = key; + this._left = left; + this._right = right; this._value = value; this._isRed = isRed; } @@ -20,6 +22,14 @@ return this._value; }; + Node.prototype.getLeft = function () { + return this._left; + }; + + Node.prototype.getRight = function () { + return this._right; + }; + global.Node = Node; @@ -33,10 +43,15 @@ RBTree.prototype._put = function (key, value, node) { if (this._root === null) { - return (this._root = new Node(key, value, false)); + return (this._root = new Node(key, null, null, value, false)); } }; + RBTree.prototype._rotateLeft = function (node) { + var x = node.getRight(); + + }; + global.RBTree = RBTree; }(typeof window === 'undefined' ? module.exports : window)); diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index b8d94003..50009587 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -9,8 +9,10 @@ describe('Node', function () { expect(typeof Node).toBe('function'); }); it('should set all properties via the constructor', function () { - var node = new Node('key', 'value', true); + var node = new Node('key', 1, 2, 'value', true); expect(node.getKey()).toBe('key'); + expect(node.getLeft()).toBe(1); + expect(node.getRight()).toBe(2); expect(node.getValue()).toBe('value'); expect(node.isRed()).toBeTruthy(); node = new Node('key', 'value', undefined); From bcf14c3159b5a1bad4ede815c2cc2b721dd67662 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 16 May 2014 13:56:43 -0700 Subject: [PATCH 135/613] Add smarter getters and setters --- src/data-structures/red-black-tree.js | 31 ++++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index 379062df..86eb3029 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -14,21 +14,21 @@ return !!this._isRed; }; - Node.prototype.getKey = function () { - return this._key; - }; + 'key value left right' + .split(' ') + .forEach(function (key) { - Node.prototype.getValue = function () { - return this._value; - }; + var valueName = key.substr(0, 1).toUpperCase() + key.substr(1, key.length); - Node.prototype.getLeft = function () { - return this._left; - }; + Node.prototype['get' + valueName] = function () { + return this['_' + key]; + }; - Node.prototype.getRight = function () { - return this._right; - }; + Node.prototype['set' + valueName] = function (val) { + this['_' + key] = val; + }; + + }); global.Node = Node; @@ -49,7 +49,12 @@ RBTree.prototype._rotateLeft = function (node) { var x = node.getRight(); - + if (x !== null) { + var temp = x.left; + node.right = temp; + x.left = node; + } + return x; }; global.RBTree = RBTree; From eca6d26af28cd359d79b92ad19552466f346ff33 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 16 May 2014 14:05:12 -0700 Subject: [PATCH 136/613] Add left and right rotations --- src/data-structures/red-black-tree.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index 86eb3029..e2407b1f 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -50,9 +50,19 @@ RBTree.prototype._rotateLeft = function (node) { var x = node.getRight(); if (x !== null) { - var temp = x.left; - node.right = temp; - x.left = node; + var temp = x.getLeft(); + node.setRight(temp); + x.setLeft(node); + } + return x; + }; + + RBTree.prototype._rotateRight = function (node) { + var x = node.getLeft(); + if (x !== null) { + var temp = x.getRight(); + node.setLeft(temp); + x.setRight(node); } return x; }; From fc6c8041fccedc15b9e7bb81a59afd0c147facbb Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 16 May 2014 16:08:29 -0700 Subject: [PATCH 137/613] Changes in the insertion algorithm --- src/data-structures/red-black-tree.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index e2407b1f..fe0d2a7f 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -14,6 +14,10 @@ return !!this._isRed; }; + Node.prototype.flipColor = function () { + this._isRed = !this._isRed; + }; + 'key value left right' .split(' ') .forEach(function (key) { @@ -42,9 +46,30 @@ }; RBTree.prototype._put = function (key, value, node) { + var newRoot = node; if (this._root === null) { - return (this._root = new Node(key, null, null, value, false)); + return new Node(key, null, null, value, false); + } + if (node.getValue() > value) { + this._put(key, value, node.getLeft()); + } else if (node.getValue() < value) { + this._put(key, value, node.getRight()); + } + if (this._isRed(node.getRight())) { + newRoot = this._rotateLeft(node); } + if (this._isRed(node.getLeft()) && this._isRed(node.getLeft().getLeft())) { + newRoot = this._rotateRight(node); + } + if (this._isRed(node.getLeft()) && this._isRed(node.getRight())) { + this._flipColors(); + } + return newRoot; + }; + + RBTree.prototype._flipColors = function (node) { + node.getLeft().flipColor(); + node.getRight().flipColor(); }; RBTree.prototype._rotateLeft = function (node) { From e2619955b99d4d3cf7fbeb5fed8212057d892f49 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 16 May 2014 16:10:17 -0700 Subject: [PATCH 138/613] Changes in the API --- src/data-structures/red-black-tree.js | 6 +++--- test/data-structures/red-black-tree.spec.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index fe0d2a7f..4ffb79f4 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -2,7 +2,7 @@ 'use strict'; - function Node(key, left, right, value, isRed) { + function Node(key, value, left, right, isRed) { this._key = key; this._left = left; this._right = right; @@ -42,13 +42,13 @@ } RBTree.prototype.put = function (key, value) { - return this._put(key, value, this._root); + return (this._root = this._put(key, value, this._root)); }; RBTree.prototype._put = function (key, value, node) { var newRoot = node; if (this._root === null) { - return new Node(key, null, null, value, false); + return new Node(key, value, null, null, false); } if (node.getValue() > value) { this._put(key, value, node.getLeft()); diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index 50009587..5679c469 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -9,13 +9,13 @@ describe('Node', function () { expect(typeof Node).toBe('function'); }); it('should set all properties via the constructor', function () { - var node = new Node('key', 1, 2, 'value', true); + var node = new Node('key', 'value', 1, 2, true); expect(node.getKey()).toBe('key'); expect(node.getLeft()).toBe(1); expect(node.getRight()).toBe(2); expect(node.getValue()).toBe('value'); expect(node.isRed()).toBeTruthy(); - node = new Node('key', 'value', undefined); + node = new Node('key', 'value', null, null, undefined); //if we set isRed to falcy it should be turned to red expect(node.isRed()).toBe(false); }); From 9f0cff1728bc7a09b4667d5b44e75613983d0cee Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 16 May 2014 16:12:01 -0700 Subject: [PATCH 139/613] Changes in the API --- test/data-structures/red-black-tree.spec.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index 5679c469..159cb008 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -19,6 +19,10 @@ describe('Node', function () { //if we set isRed to falcy it should be turned to red expect(node.isRed()).toBe(false); }); + it('should has method flipColor', function () { + var node = new Node(); + expect(typeof node.flipColor).toBe('function'); + }); }); describe('RBTree', function () { From 9a4588a73a5412d012f927ed7ea3993d45bf0b18 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 16 May 2014 16:13:39 -0700 Subject: [PATCH 140/613] Add tests --- test/data-structures/red-black-tree.spec.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index 159cb008..bc3b96e4 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -5,9 +5,11 @@ var mod = require('../../src/data-structures/red-black-tree.js'), RBTree = mod.RBTree; describe('Node', function () { + it('should be a constructor function', function () { expect(typeof Node).toBe('function'); }); + it('should set all properties via the constructor', function () { var node = new Node('key', 'value', 1, 2, true); expect(node.getKey()).toBe('key'); @@ -19,9 +21,20 @@ describe('Node', function () { //if we set isRed to falcy it should be turned to red expect(node.isRed()).toBe(false); }); - it('should has method flipColor', function () { - var node = new Node(); - expect(typeof node.flipColor).toBe('function'); + + describe('Node flipColor', function () { + it('should has method flipColor', function () { + var node = new Node(); + expect(typeof node.flipColor).toBe('function'); + }); + it('should work properly', function () { + var node = new Node(); + expect(node.isRed()).toBe(false); + node.flipColor(); + expect(node.isRed()).toBe(true); + node.flipColor(); + expect(node.isRed()).toBe(false); + }); }); }); From 4466fb4c7b40e8408be545332e5dff7a921ec831 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 16 May 2014 16:18:37 -0700 Subject: [PATCH 141/613] Update insert --- src/data-structures/red-black-tree.js | 13 +++++++------ test/data-structures/red-black-tree.spec.js | 8 ++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index 4ffb79f4..d776ca77 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -42,21 +42,22 @@ } RBTree.prototype.put = function (key, value) { - return (this._root = this._put(key, value, this._root)); + this._root = this._put(key, value, this._root); + this._root.flipColor(); }; RBTree.prototype._put = function (key, value, node) { var newRoot = node; if (this._root === null) { - return new Node(key, value, null, null, false); + return new Node(key, value, null, null, true); } - if (node.getValue() > value) { + if (node.getKey() > key) { this._put(key, value, node.getLeft()); - } else if (node.getValue() < value) { - this._put(key, value, node.getRight()); + } else if (node.getKey() < key) { + node.setLeft(this._put(key, value, node.getRight())); } if (this._isRed(node.getRight())) { - newRoot = this._rotateLeft(node); + node.setRight(this._rotateLeft(node)); } if (this._isRed(node.getLeft()) && this._isRed(node.getLeft().getLeft())) { newRoot = this._rotateRight(node); diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index bc3b96e4..8632ca6c 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -53,5 +53,13 @@ describe('RBTree', function () { expect(tree._root.getKey()).toBe('foo'); expect(tree._root.getValue()).toBe('bar'); }); + + it('should be able to insert a node in 1 level tree', function () { + var tree = new RBTree(); + tree.put(1, 'bar'); + + }); + }); + }); From c87a94a0b9a46aa728f6998300a9b105c26cece0 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 16 May 2014 16:22:01 -0700 Subject: [PATCH 142/613] Update tests --- src/data-structures/red-black-tree.js | 9 +++++---- test/data-structures/red-black-tree.spec.js | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index d776ca77..a0b1e860 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -42,13 +42,14 @@ } RBTree.prototype.put = function (key, value) { + console.log(this._root); this._root = this._put(key, value, this._root); this._root.flipColor(); }; RBTree.prototype._put = function (key, value, node) { var newRoot = node; - if (this._root === null) { + if (node === null) { return new Node(key, value, null, null, true); } if (node.getKey() > key) { @@ -56,13 +57,13 @@ } else if (node.getKey() < key) { node.setLeft(this._put(key, value, node.getRight())); } - if (this._isRed(node.getRight())) { + if (this.isRed(node.getRight())) { node.setRight(this._rotateLeft(node)); } - if (this._isRed(node.getLeft()) && this._isRed(node.getLeft().getLeft())) { + if (this.isRed(node.getLeft()) && this.isRed(node.getLeft().getLeft())) { newRoot = this._rotateRight(node); } - if (this._isRed(node.getLeft()) && this._isRed(node.getRight())) { + if (this.isRed(node.getLeft()) && this.isRed(node.getRight())) { this._flipColors(); } return newRoot; diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index 8632ca6c..0cac6820 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -46,7 +46,7 @@ describe('RBTree', function () { expect(new RBTree()._root).toBeNull(); }); - describe('RBTree node insertion', function () { + describe('node insertion', function () { it('should be able to insert a node in empty tree', function () { var tree = new RBTree(); tree.put('foo', 'bar'); @@ -57,7 +57,7 @@ describe('RBTree', function () { it('should be able to insert a node in 1 level tree', function () { var tree = new RBTree(); tree.put(1, 'bar'); - + tree.put(0, 'baz'); }); }); From 74eaa79d5b73067e1ad474d4cac24e87b5ed7ab1 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 16 May 2014 22:42:26 -0700 Subject: [PATCH 143/613] Bugfixes --- src/data-structures/red-black-tree.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index a0b1e860..8bb40031 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -42,11 +42,17 @@ } RBTree.prototype.put = function (key, value) { - console.log(this._root); this._root = this._put(key, value, this._root); this._root.flipColor(); }; + RBTree.prototype.isRed = function (node) { + if (!node) { + return false; + } + return node.isRed(); + }; + RBTree.prototype._put = function (key, value, node) { var newRoot = node; if (node === null) { From ae1746a32f92eb6c8115606ff86bfb2c1898a825 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 16 May 2014 22:46:24 -0700 Subject: [PATCH 144/613] Fix bugs --- src/data-structures/red-black-tree.js | 6 +++--- test/data-structures/red-black-tree.spec.js | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index 8bb40031..d046d37c 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -59,12 +59,12 @@ return new Node(key, value, null, null, true); } if (node.getKey() > key) { - this._put(key, value, node.getLeft()); + node.setLeft(this._put(key, value, node.getLeft())); } else if (node.getKey() < key) { - node.setLeft(this._put(key, value, node.getRight())); + node.setRight(this._put(key, value, node.getRight())); } if (this.isRed(node.getRight())) { - node.setRight(this._rotateLeft(node)); + newRoot = this._rotateLeft(node); } if (this.isRed(node.getLeft()) && this.isRed(node.getLeft().getLeft())) { newRoot = this._rotateRight(node); diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index 0cac6820..ee44b8bb 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -58,6 +58,7 @@ describe('RBTree', function () { var tree = new RBTree(); tree.put(1, 'bar'); tree.put(0, 'baz'); + expect(tree._root._left).not.toBeNull(); }); }); From b7133eb4c9e335ae1e6cc49785e06eceea18c15c Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 16 May 2014 22:47:19 -0700 Subject: [PATCH 145/613] Fix bugs --- test/data-structures/red-black-tree.spec.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index ee44b8bb..e534b040 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -59,6 +59,9 @@ describe('RBTree', function () { tree.put(1, 'bar'); tree.put(0, 'baz'); expect(tree._root._left).not.toBeNull(); + expect(tree._root._left.isRed()).toBeTruthy(); + tree.put(2, 'baz'); + expect(tree._root._left).not.toBeNull(); }); }); From f32eea583cc6c8e638d084fc5c88acec55b30f7e Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 16 May 2014 23:26:00 -0700 Subject: [PATCH 146/613] Update insertion --- src/data-structures/red-black-tree.js | 4 ++-- test/data-structures/red-black-tree.spec.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index d046d37c..d1707ee1 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -63,14 +63,14 @@ } else if (node.getKey() < key) { node.setRight(this._put(key, value, node.getRight())); } - if (this.isRed(node.getRight())) { + if (this.isRed(node.getRight()) && !this.isRed(node.getLeft())) { newRoot = this._rotateLeft(node); } if (this.isRed(node.getLeft()) && this.isRed(node.getLeft().getLeft())) { newRoot = this._rotateRight(node); } if (this.isRed(node.getLeft()) && this.isRed(node.getRight())) { - this._flipColors(); + this._flipColors(node); } return newRoot; }; diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index e534b040..b7e6a0c5 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -61,7 +61,7 @@ describe('RBTree', function () { expect(tree._root._left).not.toBeNull(); expect(tree._root._left.isRed()).toBeTruthy(); tree.put(2, 'baz'); - expect(tree._root._left).not.toBeNull(); + expect(tree._root._right).not.toBeNull(); }); }); From 3f4407c7e0606b71382f837842517f6428647d25 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 16 May 2014 23:26:22 -0700 Subject: [PATCH 147/613] Update insertion --- test/data-structures/red-black-tree.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index b7e6a0c5..4320327a 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -62,6 +62,7 @@ describe('RBTree', function () { expect(tree._root._left.isRed()).toBeTruthy(); tree.put(2, 'baz'); expect(tree._root._right).not.toBeNull(); + expect(tree._root._right._isRed).toBeFalsy(); }); }); From ad7984b5030b923caf47304ef105d649eb2dede2 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 16 May 2014 23:34:28 -0700 Subject: [PATCH 148/613] Change direct property access instead of set/get methods --- src/data-structures/red-black-tree.js | 38 +++++++++++++-------- test/data-structures/red-black-tree.spec.js | 2 -- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index d1707ee1..54914ea3 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -59,47 +59,57 @@ return new Node(key, value, null, null, true); } if (node.getKey() > key) { - node.setLeft(this._put(key, value, node.getLeft())); + node._left = this._put(key, value, node._left); } else if (node.getKey() < key) { - node.setRight(this._put(key, value, node.getRight())); + node._right = this._put(key, value, node._right); } - if (this.isRed(node.getRight()) && !this.isRed(node.getLeft())) { + if (this.isRed(node._right) && !this.isRed(node._left)) { newRoot = this._rotateLeft(node); } - if (this.isRed(node.getLeft()) && this.isRed(node.getLeft().getLeft())) { + if (this.isRed(node._left) && this.isRed(node._left._left)) { newRoot = this._rotateRight(node); } - if (this.isRed(node.getLeft()) && this.isRed(node.getRight())) { + if (this.isRed(node._left) && this.isRed(node._right)) { this._flipColors(node); } return newRoot; }; RBTree.prototype._flipColors = function (node) { - node.getLeft().flipColor(); - node.getRight().flipColor(); + node._left.flipColor(); + node._right.flipColor(); }; RBTree.prototype._rotateLeft = function (node) { - var x = node.getRight(); + var x = node._right; if (x !== null) { - var temp = x.getLeft(); + var temp = x._left; node.setRight(temp); - x.setLeft(node); + x._left = node; } return x; }; RBTree.prototype._rotateRight = function (node) { - var x = node.getLeft(); + var x = node._left; if (x !== null) { - var temp = x.getRight(); - node.setLeft(temp); - x.setRight(node); + var temp = x._right; + node._left = temp; + x._right = node; } return x; }; + RBTree.prototype.getIterator = function () { + return new RBTIterator(this); + }; + + function RBTIterator(tree) { + this._tree = tree; + } + global.RBTree = RBTree; + + }(typeof window === 'undefined' ? module.exports : window)); diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index 4320327a..b9cba3ba 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -53,7 +53,6 @@ describe('RBTree', function () { expect(tree._root.getKey()).toBe('foo'); expect(tree._root.getValue()).toBe('bar'); }); - it('should be able to insert a node in 1 level tree', function () { var tree = new RBTree(); tree.put(1, 'bar'); @@ -64,7 +63,6 @@ describe('RBTree', function () { expect(tree._root._right).not.toBeNull(); expect(tree._root._right._isRed).toBeFalsy(); }); - }); }); From ffca1b562610a781cbcf0f6a14ea88b35192d218 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 16 May 2014 23:38:35 -0700 Subject: [PATCH 149/613] Improve formatting --- src/data-structures/red-black-tree.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index 54914ea3..9c3a1202 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -21,17 +21,13 @@ 'key value left right' .split(' ') .forEach(function (key) { - var valueName = key.substr(0, 1).toUpperCase() + key.substr(1, key.length); - Node.prototype['get' + valueName] = function () { return this['_' + key]; }; - Node.prototype['set' + valueName] = function (val) { this['_' + key] = val; }; - }); global.Node = Node; From d861d433b2d3e87ff314cbe801fb71f3e77d73b4 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 16 May 2014 23:38:54 -0700 Subject: [PATCH 150/613] Improve formatting --- src/data-structures/red-black-tree.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index 9c3a1202..c540086d 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -107,5 +107,5 @@ global.RBTree = RBTree; - }(typeof window === 'undefined' ? module.exports : window)); + From 41f5d65a370e197f95f0b9c68b28baeabfa1a151 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 17 May 2014 16:52:02 -0700 Subject: [PATCH 151/613] Fixes in the rotations --- src/data-structures/red-black-tree.js | 30 ++++++++++++++++----- test/data-structures/red-black-tree.spec.js | 18 +++++++++---- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index c540086d..c73518e3 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -2,23 +2,35 @@ 'use strict'; - function Node(key, value, left, right, isRed) { + var Colors = { + RED: 0, + BLACK: 1 + }; + + global.Colors = Colors; + + + function Node(key, value, left, right, color) { this._key = key; this._left = left; this._right = right; this._value = value; - this._isRed = isRed; + this._color = color; } Node.prototype.isRed = function () { - return !!this._isRed; + return this._color === Colors.RED; }; Node.prototype.flipColor = function () { - this._isRed = !this._isRed; + if (this._color === Colors.RED) { + this._color = Colors.BLACK; + } else { + this._color = Colors.RED; + } }; - 'key value left right' + 'key value left right color' .split(' ') .forEach(function (key) { var valueName = key.substr(0, 1).toUpperCase() + key.substr(1, key.length); @@ -39,7 +51,7 @@ RBTree.prototype.put = function (key, value) { this._root = this._put(key, value, this._root); - this._root.flipColor(); + this._root.setColor(Colors.BLACK); }; RBTree.prototype.isRed = function (node) { @@ -52,7 +64,7 @@ RBTree.prototype._put = function (key, value, node) { var newRoot = node; if (node === null) { - return new Node(key, value, null, null, true); + return new Node(key, value, null, null, Colors.RED); } if (node.getKey() > key) { node._left = this._put(key, value, node._left); @@ -82,6 +94,8 @@ var temp = x._left; node.setRight(temp); x._left = node; + x.setColor(node.getColor()); + node.setColor(Colors.RED); } return x; }; @@ -92,6 +106,8 @@ var temp = x._right; node._left = temp; x._right = node; + x.setColor(node.getColor()); + node.setColor(Colors.RED); } return x; }; diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index b9cba3ba..75f40cfd 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -2,7 +2,8 @@ var mod = require('../../src/data-structures/red-black-tree.js'), Node = mod.Node, - RBTree = mod.RBTree; + RBTree = mod.RBTree, + Colors = mod.Colors; describe('Node', function () { @@ -11,15 +12,12 @@ describe('Node', function () { }); it('should set all properties via the constructor', function () { - var node = new Node('key', 'value', 1, 2, true); + var node = new Node('key', 'value', 1, 2, Colors.RED); expect(node.getKey()).toBe('key'); expect(node.getLeft()).toBe(1); expect(node.getRight()).toBe(2); expect(node.getValue()).toBe('value'); expect(node.isRed()).toBeTruthy(); - node = new Node('key', 'value', null, null, undefined); - //if we set isRed to falcy it should be turned to red - expect(node.isRed()).toBe(false); }); describe('Node flipColor', function () { @@ -53,6 +51,7 @@ describe('RBTree', function () { expect(tree._root.getKey()).toBe('foo'); expect(tree._root.getValue()).toBe('bar'); }); + it('should be able to insert a node in 1 level tree', function () { var tree = new RBTree(); tree.put(1, 'bar'); @@ -62,7 +61,16 @@ describe('RBTree', function () { tree.put(2, 'baz'); expect(tree._root._right).not.toBeNull(); expect(tree._root._right._isRed).toBeFalsy(); + + tree = new RBTree(); + tree.put(1, 'bar'); + tree.put(2, 'bar'); + tree.put(3, 'bar'); + tree.put(4, 'bar'); + console.log(tree._root); +// expect(tree._root._right._isRed).toBeFalsy(); }); + }); }); From e46e12d34e5e2f9c76afbcf57d0a6173abbba996 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 17 May 2014 16:56:08 -0700 Subject: [PATCH 152/613] Add tests --- test/data-structures/red-black-tree.spec.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index 75f40cfd..3ce2bd79 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -64,11 +64,13 @@ describe('RBTree', function () { tree = new RBTree(); tree.put(1, 'bar'); - tree.put(2, 'bar'); - tree.put(3, 'bar'); - tree.put(4, 'bar'); - console.log(tree._root); -// expect(tree._root._right._isRed).toBeFalsy(); + tree.put(2, 'foo'); + tree.put(3, 'baz'); + expect(tree._root._right).not.toBeNull(); + expect(tree._root._left).not.toBeNull(); + expect(tree._root._isRed).toBeFalsy(); + expect(tree._root._right._isRed).toBeFalsy(); + expect(tree._root._left._isRed).toBeFalsy(); }); }); From 29d08cb222f8953ca6110021506557c95938f923 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 17 May 2014 16:59:11 -0700 Subject: [PATCH 153/613] Add find method --- src/data-structures/red-black-tree.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index c73518e3..a65ae14d 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -112,6 +112,24 @@ return x; }; + RBTree.prototype.get = function (key) { + return this._get(this._root, key); + }; + + RBTree.prototype._get = function (node, key) { + if (node === null) { + return undefined; + } + if (node.getKey() === key) { + return node.getValue(); + } + if (node.getKey() > key) { + return this._get(node.getLeft(), key); + } else { + return this._get(node.getRight(), key); + } + }; + RBTree.prototype.getIterator = function () { return new RBTIterator(this); }; @@ -120,6 +138,9 @@ this._tree = tree; } + RBTIterator.prototype.next = function () { + }; + global.RBTree = RBTree; From 2544fba24cd46f633ea5542e1620e647c5db4bd7 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 17 May 2014 16:59:56 -0700 Subject: [PATCH 154/613] Add find method --- test/data-structures/red-black-tree.spec.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index 3ce2bd79..74bd026b 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -75,4 +75,9 @@ describe('RBTree', function () { }); + describe('get method', function () { + var tree = new RBTree(); + expect(tree.get(1)).toBeUndefined(); + }); + }); From 0dfa288e681343277dee40272665e68ad606c048 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 17 May 2014 17:01:49 -0700 Subject: [PATCH 155/613] Add tests for get --- test/data-structures/red-black-tree.spec.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index 74bd026b..c542cc36 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -78,6 +78,15 @@ describe('RBTree', function () { describe('get method', function () { var tree = new RBTree(); expect(tree.get(1)).toBeUndefined(); + tree.put(1, 'baz'); + expect(tree.get(1)).toBe('baz'); + tree.put(2, 'foo'); + expect(tree.get(2)).toBe('foo'); + tree.put(3, 'bar'); + expect(tree.get(3)).toBe('bar'); + expect(tree.get(4)).toBeUndefined(); + tree.put(5, 'foobar'); + expect(tree.get(5)).toBe('foobar'); }); }); From d3215c05cf074cf7a344744a46ef5f92d92f9bd2 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 17 May 2014 17:04:16 -0700 Subject: [PATCH 156/613] Remove iterator --- src/data-structures/red-black-tree.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index a65ae14d..f9bd49cf 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -130,17 +130,6 @@ } }; - RBTree.prototype.getIterator = function () { - return new RBTIterator(this); - }; - - function RBTIterator(tree) { - this._tree = tree; - } - - RBTIterator.prototype.next = function () { - }; - global.RBTree = RBTree; From 0fb9ad7928691198c8eab419edff5f5cbffeaf0c Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 17 May 2014 17:05:34 -0700 Subject: [PATCH 157/613] Bugfix --- src/data-structures/red-black-tree.js | 2 ++ test/data-structures/red-black-tree.spec.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index f9bd49cf..79eea7c8 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -70,6 +70,8 @@ node._left = this._put(key, value, node._left); } else if (node.getKey() < key) { node._right = this._put(key, value, node._right); + } else { + node.setValue(value); } if (this.isRed(node._right) && !this.isRed(node._left)) { newRoot = this._rotateLeft(node); diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index c542cc36..f4a04fb4 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -87,6 +87,8 @@ describe('RBTree', function () { expect(tree.get(4)).toBeUndefined(); tree.put(5, 'foobar'); expect(tree.get(5)).toBe('foobar'); + tree.put(5, 'foobar1'); + expect(tree.get(5)).toBe('foobar1'); }); }); From b6dc8942697a399821151496f0c43fe847820201 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 17 May 2014 17:11:10 -0700 Subject: [PATCH 158/613] Add tests for insertion --- test/data-structures/red-black-tree.spec.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index f4a04fb4..e5d6fe65 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -71,6 +71,10 @@ describe('RBTree', function () { expect(tree._root._isRed).toBeFalsy(); expect(tree._root._right._isRed).toBeFalsy(); expect(tree._root._left._isRed).toBeFalsy(); + tree.put(4, 'foobar'); + tree.put(5, 'foobar'); + expect(tree._root._right._right).not.toBeNull(); + expect(tree._root._right._right._isRed).toBeFalsy(); }); }); From 8925628f8d0ea8722bf80875c628b4d1fbff376f Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 17 May 2014 17:12:09 -0700 Subject: [PATCH 159/613] Using the API instead of private props --- test/data-structures/red-black-tree.spec.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index e5d6fe65..3bc3091d 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -60,7 +60,7 @@ describe('RBTree', function () { expect(tree._root._left.isRed()).toBeTruthy(); tree.put(2, 'baz'); expect(tree._root._right).not.toBeNull(); - expect(tree._root._right._isRed).toBeFalsy(); + expect(tree._root._right.isRed()).toBeFalsy(); tree = new RBTree(); tree.put(1, 'bar'); @@ -68,13 +68,13 @@ describe('RBTree', function () { tree.put(3, 'baz'); expect(tree._root._right).not.toBeNull(); expect(tree._root._left).not.toBeNull(); - expect(tree._root._isRed).toBeFalsy(); - expect(tree._root._right._isRed).toBeFalsy(); - expect(tree._root._left._isRed).toBeFalsy(); + expect(tree._root.isRed()).toBeFalsy(); + expect(tree._root._right.isRed()).toBeFalsy(); + expect(tree._root._left.isRed()).toBeFalsy(); tree.put(4, 'foobar'); tree.put(5, 'foobar'); expect(tree._root._right._right).not.toBeNull(); - expect(tree._root._right._right._isRed).toBeFalsy(); + expect(tree._root._right._right.isRed()).toBeFalsy(); }); }); From 15cbe485a95b28310993c8ab315dfd3fe5c66a1f Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 17 May 2014 17:15:13 -0700 Subject: [PATCH 160/613] Using public API instead of private properties --- src/data-structures/red-black-tree.js | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index 79eea7c8..48256b56 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -67,35 +67,35 @@ return new Node(key, value, null, null, Colors.RED); } if (node.getKey() > key) { - node._left = this._put(key, value, node._left); + node.setLeft(this._put(key, value, node.getLeft())); } else if (node.getKey() < key) { - node._right = this._put(key, value, node._right); + node.setRight(this._put(key, value, node.getRight())); } else { node.setValue(value); } - if (this.isRed(node._right) && !this.isRed(node._left)) { + if (this.isRed(node.getRight()) && !this.isRed(node.getLeft())) { newRoot = this._rotateLeft(node); } - if (this.isRed(node._left) && this.isRed(node._left._left)) { + if (this.isRed(node.getLeft()) && this.isRed(node.getLeft().getLeft())) { newRoot = this._rotateRight(node); } - if (this.isRed(node._left) && this.isRed(node._right)) { + if (this.isRed(node.getLeft()) && this.isRed(node.getRight())) { this._flipColors(node); } return newRoot; }; RBTree.prototype._flipColors = function (node) { - node._left.flipColor(); - node._right.flipColor(); + node.getLeft().flipColor(); + node.getRight().flipColor(); }; RBTree.prototype._rotateLeft = function (node) { - var x = node._right; + var x = node.getRight(); if (x !== null) { - var temp = x._left; + var temp = x.getLeft(); node.setRight(temp); - x._left = node; + x.setLeft(node); x.setColor(node.getColor()); node.setColor(Colors.RED); } @@ -103,11 +103,11 @@ }; RBTree.prototype._rotateRight = function (node) { - var x = node._left; + var x = node.getLeft(); if (x !== null) { - var temp = x._right; - node._left = temp; - x._right = node; + var temp = x.getRight(); + node.setLeft(temp); + x.setRight(node); x.setColor(node.getColor()); node.setColor(Colors.RED); } From eaa1d587670c571cdd27ffbacebece97a5af04a0 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 17 May 2014 17:16:01 -0700 Subject: [PATCH 161/613] Using public API instead of private properties --- test/data-structures/red-black-tree.spec.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index 3bc3091d..a631d0cc 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -59,22 +59,22 @@ describe('RBTree', function () { expect(tree._root._left).not.toBeNull(); expect(tree._root._left.isRed()).toBeTruthy(); tree.put(2, 'baz'); - expect(tree._root._right).not.toBeNull(); - expect(tree._root._right.isRed()).toBeFalsy(); + expect(tree._root.getRight()).not.toBeNull(); + expect(tree._root.getRight().isRed()).toBeFalsy(); tree = new RBTree(); tree.put(1, 'bar'); tree.put(2, 'foo'); tree.put(3, 'baz'); - expect(tree._root._right).not.toBeNull(); + expect(tree._root.getRight()).not.toBeNull(); expect(tree._root._left).not.toBeNull(); expect(tree._root.isRed()).toBeFalsy(); - expect(tree._root._right.isRed()).toBeFalsy(); + expect(tree._root.getRight().isRed()).toBeFalsy(); expect(tree._root._left.isRed()).toBeFalsy(); tree.put(4, 'foobar'); tree.put(5, 'foobar'); - expect(tree._root._right._right).not.toBeNull(); - expect(tree._root._right._right.isRed()).toBeFalsy(); + expect(tree._root.getRight().getRight()).not.toBeNull(); + expect(tree._root.getRight().getRight().isRed()).toBeFalsy(); }); }); From 79b865e0942faf4c0c92360a2de745179d9f1b84 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 17 May 2014 17:16:16 -0700 Subject: [PATCH 162/613] Using public API instead of private properties --- test/data-structures/red-black-tree.spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index a631d0cc..54801e8a 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -56,8 +56,8 @@ describe('RBTree', function () { var tree = new RBTree(); tree.put(1, 'bar'); tree.put(0, 'baz'); - expect(tree._root._left).not.toBeNull(); - expect(tree._root._left.isRed()).toBeTruthy(); + expect(tree._root.getLeft()).not.toBeNull(); + expect(tree._root.getLeft().isRed()).toBeTruthy(); tree.put(2, 'baz'); expect(tree._root.getRight()).not.toBeNull(); expect(tree._root.getRight().isRed()).toBeFalsy(); @@ -67,10 +67,10 @@ describe('RBTree', function () { tree.put(2, 'foo'); tree.put(3, 'baz'); expect(tree._root.getRight()).not.toBeNull(); - expect(tree._root._left).not.toBeNull(); + expect(tree._root.getLeft()).not.toBeNull(); expect(tree._root.isRed()).toBeFalsy(); expect(tree._root.getRight().isRed()).toBeFalsy(); - expect(tree._root._left.isRed()).toBeFalsy(); + expect(tree._root.getLeft().isRed()).toBeFalsy(); tree.put(4, 'foobar'); tree.put(5, 'foobar'); expect(tree._root.getRight().getRight()).not.toBeNull(); From 13eadd2841bbe1a6f10d1ad643295fdce81b8672 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 17 May 2014 17:18:03 -0700 Subject: [PATCH 163/613] Refactoring in the RBT tests --- test/data-structures/red-black-tree.spec.js | 28 +++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index 54801e8a..219bf5eb 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -80,19 +80,21 @@ describe('RBTree', function () { }); describe('get method', function () { - var tree = new RBTree(); - expect(tree.get(1)).toBeUndefined(); - tree.put(1, 'baz'); - expect(tree.get(1)).toBe('baz'); - tree.put(2, 'foo'); - expect(tree.get(2)).toBe('foo'); - tree.put(3, 'bar'); - expect(tree.get(3)).toBe('bar'); - expect(tree.get(4)).toBeUndefined(); - tree.put(5, 'foobar'); - expect(tree.get(5)).toBe('foobar'); - tree.put(5, 'foobar1'); - expect(tree.get(5)).toBe('foobar1'); + it('should be able to find value by given key', function () { + var tree = new RBTree(); + expect(tree.get(1)).toBeUndefined(); + tree.put(1, 'baz'); + expect(tree.get(1)).toBe('baz'); + tree.put(2, 'foo'); + expect(tree.get(2)).toBe('foo'); + tree.put(3, 'bar'); + expect(tree.get(3)).toBe('bar'); + expect(tree.get(4)).toBeUndefined(); + tree.put(5, 'foobar'); + expect(tree.get(5)).toBe('foobar'); + tree.put(5, 'foobar1'); + expect(tree.get(5)).toBe('foobar1'); + }); }); }); From 9a8c73adff16e0b76b874497b962e2ecd6b312a7 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 19 May 2014 19:29:08 -0700 Subject: [PATCH 164/613] Add comments --- src/data-structures/red-black-tree.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index 48256b56..88e5e7b1 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -2,6 +2,9 @@ 'use strict'; + /** + * Enum for the different colors + */ var Colors = { RED: 0, BLACK: 1 @@ -10,6 +13,11 @@ global.Colors = Colors; + /** + * Represents given node in the tree. + * + * @constructor + */ function Node(key, value, left, right, color) { this._key = key; this._left = left; @@ -30,6 +38,10 @@ } }; + /** + * Creates getters and setters for the properties: + * key, value, left, right and color. + */ 'key value left right color' .split(' ') .forEach(function (key) { @@ -45,6 +57,11 @@ global.Node = Node; + /** + * Represents a Red-Black Tree + * + * @constructor + */ function RBTree() { this._root = null; } From f5427c75d7b867c5136ff08ea7796d92ddfde3cc Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 19 May 2014 19:32:15 -0700 Subject: [PATCH 165/613] Add comments --- src/data-structures/red-black-tree.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index 88e5e7b1..f7cc2bdb 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -66,11 +66,19 @@ this._root = null; } + /** + * Adds value associated with given key. + * Complexity O(log n) + */ RBTree.prototype.put = function (key, value) { this._root = this._put(key, value, this._root); this._root.setColor(Colors.BLACK); }; + /** + * Returns true or false depending on whether + * given node is red. + */ RBTree.prototype.isRed = function (node) { if (!node) { return false; @@ -78,6 +86,10 @@ return node.isRed(); }; + /** + * Helper function for insertion of given key, value pair + * into the red-black tree. + */ RBTree.prototype._put = function (key, value, node) { var newRoot = node; if (node === null) { From 3a1971f4cf7bd0fb2d50e5c7565147b6708ac3f2 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 19 May 2014 19:38:19 -0700 Subject: [PATCH 166/613] Add comments --- src/data-structures/red-black-tree.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index f7cc2bdb..58dd7017 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -114,11 +114,19 @@ return newRoot; }; + /** + * Flip the colors of the both neighbours of given node. + * Complexity O(1). + */ RBTree.prototype._flipColors = function (node) { node.getLeft().flipColor(); node.getRight().flipColor(); }; + /* + * Rotates given node to left. + * Complexity O(1). + */ RBTree.prototype._rotateLeft = function (node) { var x = node.getRight(); if (x !== null) { @@ -131,6 +139,10 @@ return x; }; + /* + * Rotates given node to right. + * Complexity O(1). + */ RBTree.prototype._rotateRight = function (node) { var x = node.getLeft(); if (x !== null) { @@ -143,6 +155,13 @@ return x; }; + /** + * Gets value by given key. + * Complexity O(log n). + * + * @param {*} key A key to be searched for + * @return {*} A value which will be returned based on the passed key + */ RBTree.prototype.get = function (key) { return this._get(this._root, key); }; From 0c66c4ed9464c64f45635f19513074cdcf74f626 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 23 Sep 2014 16:28:42 +0300 Subject: [PATCH 167/613] Recursive binary search to 2 spaces --- .../binarysearch/recursive-binarysearch.js | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/searching/binarysearch/recursive-binarysearch.js b/src/searching/binarysearch/recursive-binarysearch.js index 7e1c3c61..0e5480a6 100644 --- a/src/searching/binarysearch/recursive-binarysearch.js +++ b/src/searching/binarysearch/recursive-binarysearch.js @@ -5,38 +5,38 @@ */ var binarySearch = (function () { - /** - * Binary search. - * - * @pivate - * @param {array} array Given array where we should find the index of the element - * @param {number} key Key of the element which index should be found - * @param {number} left Left index - * @param {number} right Right index - * @returns {number} index The index of the element or -1 if not found - * - */ - function recursiveBinarySearch(array, key, left, right) { - if (left > right) - return -1; - var middle = Math.floor((right + left) / 2); - if (array[middle] === key) - return middle; - else if (array[middle] > key) - return recursiveBinarySearch(array, key, left, middle - 1); - else - return recursiveBinarySearch(array, key, middle + 1, right); - } + /** + * Binary search. + * + * @pivate + * @param {array} array Given array where we should find the index of the element + * @param {number} key Key of the element which index should be found + * @param {number} left Left index + * @param {number} right Right index + * @returns {number} index The index of the element or -1 if not found + * + */ + function recursiveBinarySearch(array, key, left, right) { + if (left > right) + return -1; + var middle = Math.floor((right + left) / 2); + if (array[middle] === key) + return middle; + else if (array[middle] > key) + return recursiveBinarySearch(array, key, left, middle - 1); + else + return recursiveBinarySearch(array, key, middle + 1, right); + } - /** - * Calls the binary search function with it's initial values. - * - * @param {array} array The input array - * @param {number} key The key of the element which index should be found - * @returns {number} index The index of the element or -1 if not found - */ - return function (array, key) { - return recursiveBinarySearch(array, key, 0, array.length); - }; + /** + * Calls the binary search function with it's initial values. + * + * @param {array} array The input array + * @param {number} key The key of the element which index should be found + * @returns {number} index The index of the element or -1 if not found + */ + return function (array, key) { + return recursiveBinarySearch(array, key, 0, array.length); + }; }()); From 3587a78ad0ae3b399b50422bd80a7b9ac9dcc979 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 23 Sep 2014 16:31:12 +0300 Subject: [PATCH 168/613] Validates according to jshintrc --- .../binarysearch/recursive-binarysearch.js | 81 ++++++++++--------- 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/src/searching/binarysearch/recursive-binarysearch.js b/src/searching/binarysearch/recursive-binarysearch.js index 0e5480a6..b042e069 100644 --- a/src/searching/binarysearch/recursive-binarysearch.js +++ b/src/searching/binarysearch/recursive-binarysearch.js @@ -1,42 +1,49 @@ -/** - * Recursive version of binary search. It's complexity is O(log n). - * - * @public - */ -var binarySearch = (function () { - +(function (exports) { + 'use strict'; /** - * Binary search. - * - * @pivate - * @param {array} array Given array where we should find the index of the element - * @param {number} key Key of the element which index should be found - * @param {number} left Left index - * @param {number} right Right index - * @returns {number} index The index of the element or -1 if not found + * Recursive version of binary search. It's complexity is O(log n). * + * @public */ - function recursiveBinarySearch(array, key, left, right) { - if (left > right) - return -1; - var middle = Math.floor((right + left) / 2); - if (array[middle] === key) - return middle; - else if (array[middle] > key) - return recursiveBinarySearch(array, key, left, middle - 1); - else - return recursiveBinarySearch(array, key, middle + 1, right); - } + var binarySearch = (function () { + /** + * Binary search. + * + * @pivate + * @param {array} array Array where we should find the index of the element + * @param {number} key Key of the element which index should be found + * @param {number} left Left index + * @param {number} right Right index + * @returns {number} index The index of the element or -1 if not found + * + */ + function recursiveBinarySearch(array, key, left, right) { + if (left > right) { + return -1; + } + var middle = Math.floor((right + left) / 2); + if (array[middle] === key) { + return middle; + } else if (array[middle] > key) { + return recursiveBinarySearch(array, key, left, middle - 1); + } else { + return recursiveBinarySearch(array, key, middle + 1, right); + } + } - /** - * Calls the binary search function with it's initial values. - * - * @param {array} array The input array - * @param {number} key The key of the element which index should be found - * @returns {number} index The index of the element or -1 if not found - */ - return function (array, key) { - return recursiveBinarySearch(array, key, 0, array.length); - }; + /** + * Calls the binary search function with it's initial values. + * + * @param {array} array The input array + * @param {number} key The key of the element which index should be found + * @returns {number} index The index of the element or -1 if not found + */ + return function (array, key) { + return recursiveBinarySearch(array, key, 0, array.length); + }; + + }()); + + exports.binarySearch = binarySearch; -}()); +}(typeof exports === 'undefined' ? window : exports)); From 27d1ce22530ab01af12c6944aa0d7e5c1181a222 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 23 Sep 2014 20:55:05 +0300 Subject: [PATCH 169/613] Fix issue in the heap --- src/data-structures/heap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index 231794e5..0572baab 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -108,7 +108,7 @@ }; Heap.prototype.isEmpty = function () { - return !this._heapify.length; + return !this._heap.length; }; exports.Heap = Heap; From 64aba7cadae17a14013a77d57c1fd016a3f7530d Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 23 Sep 2014 22:13:31 +0300 Subject: [PATCH 170/613] Add lsd --- src/sorting/least-significant-digit/lsd.js | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/sorting/least-significant-digit/lsd.js diff --git a/src/sorting/least-significant-digit/lsd.js b/src/sorting/least-significant-digit/lsd.js new file mode 100644 index 00000000..b22af8d2 --- /dev/null +++ b/src/sorting/least-significant-digit/lsd.js @@ -0,0 +1,34 @@ +function lsd(arr, letterIdx) { + 'use strict'; + var temp, count, max; + letterIdx = letterIdx || 1; + for (var i = letterIdx - 1; i >= 0; i -= 1) { + count = []; + max = -Infinity; + temp = []; + for (var j = 0; j < arr.length; j += 1) { + var charCode = arr[j].charCodeAt(i); + if (max < charCode) { + max = charCode; + } + var old = count[charCode + 1] || 0; + count[charCode + 1] = old + 1; + } + for (var c = 0; c < max; c += 1) { + count[c] = count[c] || 0; + count[c + 1] = count[c + 1] || 0; + count[c + 1] += count[c]; + } + for (j = 0; j < arr.length; j += 1) { + var code = arr[j].charCodeAt(i); + temp[count[code]] = arr[j]; + count[code] += 1; + } + for (j = 0; j < arr.length; j += 1) { + arr[j] = temp[j]; + } + } + return arr; +} + +//module.exports.lsd = lsd; From b96fb337711eedf11a59945911aa1248c65af6f3 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 23 Sep 2014 22:16:13 +0300 Subject: [PATCH 171/613] Update lsd --- src/sorting/least-significant-digit/lsd.js | 71 +++++++++++++--------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/src/sorting/least-significant-digit/lsd.js b/src/sorting/least-significant-digit/lsd.js index b22af8d2..6259444b 100644 --- a/src/sorting/least-significant-digit/lsd.js +++ b/src/sorting/least-significant-digit/lsd.js @@ -1,34 +1,47 @@ -function lsd(arr, letterIdx) { +(function (exports) { 'use strict'; - var temp, count, max; - letterIdx = letterIdx || 1; - for (var i = letterIdx - 1; i >= 0; i -= 1) { - count = []; - max = -Infinity; - temp = []; - for (var j = 0; j < arr.length; j += 1) { - var charCode = arr[j].charCodeAt(i); - if (max < charCode) { - max = charCode; + + /** + * Sorts strings lexicographically. + * Complexity O(n*m) + * + * @public + * @param {Array} arr Input array + * @param {Number} letterIdx Index to start sorting from + * @returns {Array} Sorted array + */ + function lsd(arr, letterIdx) { + var temp, count, max; + letterIdx = letterIdx || 1; + for (var i = letterIdx - 1; i >= 0; i -= 1) { + count = []; + max = -Infinity; + temp = []; + for (var j = 0; j < arr.length; j += 1) { + var charCode = arr[j].charCodeAt(i); + if (max < charCode) { + max = charCode; + } + var old = count[charCode + 1] || 0; + count[charCode + 1] = old + 1; + } + for (var c = 0; c < max; c += 1) { + count[c] = count[c] || 0; + count[c + 1] = count[c + 1] || 0; + count[c + 1] += count[c]; + } + for (j = 0; j < arr.length; j += 1) { + var code = arr[j].charCodeAt(i); + temp[count[code]] = arr[j]; + count[code] += 1; + } + for (j = 0; j < arr.length; j += 1) { + arr[j] = temp[j]; } - var old = count[charCode + 1] || 0; - count[charCode + 1] = old + 1; - } - for (var c = 0; c < max; c += 1) { - count[c] = count[c] || 0; - count[c + 1] = count[c + 1] || 0; - count[c + 1] += count[c]; - } - for (j = 0; j < arr.length; j += 1) { - var code = arr[j].charCodeAt(i); - temp[count[code]] = arr[j]; - count[code] += 1; - } - for (j = 0; j < arr.length; j += 1) { - arr[j] = temp[j]; } + return arr; } - return arr; -} -//module.exports.lsd = lsd; + exports.lsd = lsd; + +}(typeof exports === 'undefined' ? window : exports)); From de3e7274527b72256bdf4c2f4be93c40c1c2d735 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 24 Sep 2014 11:29:15 +0300 Subject: [PATCH 172/613] Update lsd --- src/sorting/least-significant-digit/lsd.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/sorting/least-significant-digit/lsd.js b/src/sorting/least-significant-digit/lsd.js index 6259444b..77aef9b0 100644 --- a/src/sorting/least-significant-digit/lsd.js +++ b/src/sorting/least-significant-digit/lsd.js @@ -11,21 +11,17 @@ * @returns {Array} Sorted array */ function lsd(arr, letterIdx) { - var temp, count, max; + var temp, count; letterIdx = letterIdx || 1; for (var i = letterIdx - 1; i >= 0; i -= 1) { count = []; - max = -Infinity; temp = []; for (var j = 0; j < arr.length; j += 1) { var charCode = arr[j].charCodeAt(i); - if (max < charCode) { - max = charCode; - } var old = count[charCode + 1] || 0; count[charCode + 1] = old + 1; } - for (var c = 0; c < max; c += 1) { + for (var c = 0; c < count.length; c += 1) { count[c] = count[c] || 0; count[c + 1] = count[c + 1] || 0; count[c + 1] += count[c]; @@ -45,3 +41,4 @@ exports.lsd = lsd; }(typeof exports === 'undefined' ? window : exports)); + From f0cee86561b9ce7aba6f7d748891acf079bc5383 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 24 Sep 2014 11:39:50 +0300 Subject: [PATCH 173/613] Add msd string sorting --- src/sorting/most-significant-digit/msd.js | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/sorting/most-significant-digit/msd.js diff --git a/src/sorting/most-significant-digit/msd.js b/src/sorting/most-significant-digit/msd.js new file mode 100644 index 00000000..60a63da4 --- /dev/null +++ b/src/sorting/most-significant-digit/msd.js @@ -0,0 +1,43 @@ + +var msd = (function () { + 'use strict'; + + function charCodeAt(str, i) { + return (i < str.length) ? str.charCodeAt(i) : -1; + } + + function sort(arr, lo, hi, d) { + var temp = [], + count = [], + j, idx; + // Use Insertion sort when the + // array is smaller than given threshold + for (j = lo; j <= hi; j += 1) { + idx = charCodeAt(arr[j], d) + 2; + count[idx] = count[idx] || 0; + count[idx] += 1; + } + for (j = 0; j < count.length - 1; j += 1) { + count[j] = count[j] || 0; + count[j + 1] = count[j + 1] || 0; + count[j + 1] += count[j]; + } + for (j = lo; j <= hi; j += 1) { + idx = charCodeAt(arr[j], d) + 1; + temp[count[idx]] = arr[j]; + count[idx] += 1; + } + for (j = lo; j <= hi; j += 1) { + arr[j] = temp[j - lo]; + } + for (j = 0; j < count.length - 2; j += 1) { + sort(arr, lo + count[j], lo + count[j + 1] - 1, d + 1); + } + } + + return function msd(arr, d) { + d = d || 0; + sort(arr, 0, arr.length - 1, d); + return arr; + }; +}()); From 49e965d7456bdae76042cfb24e98002c1e8b600f Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 24 Sep 2014 11:41:38 +0300 Subject: [PATCH 174/613] Exports msd --- src/sorting/most-significant-digit/msd.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/sorting/most-significant-digit/msd.js b/src/sorting/most-significant-digit/msd.js index 60a63da4..b22716ee 100644 --- a/src/sorting/most-significant-digit/msd.js +++ b/src/sorting/most-significant-digit/msd.js @@ -1,5 +1,5 @@ +(function (exports) { -var msd = (function () { 'use strict'; function charCodeAt(str, i) { @@ -35,9 +35,11 @@ var msd = (function () { } } - return function msd(arr, d) { + function msd(arr, d) { d = d || 0; sort(arr, 0, arr.length - 1, d); return arr; - }; -}()); + } + + exports.msd = msd; +}(typeof exports === 'undefined' ? window : exports)); From 5542ae3f37ba3930b65a0c1499565c7681ed5291 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 25 Sep 2014 10:17:00 +0300 Subject: [PATCH 175/613] Add msd spec --- .../most-significant-digit/msd.spec.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/sorting/most-significant-digit/msd.spec.js diff --git a/test/sorting/most-significant-digit/msd.spec.js b/test/sorting/most-significant-digit/msd.spec.js new file mode 100644 index 00000000..721d40af --- /dev/null +++ b/test/sorting/most-significant-digit/msd.spec.js @@ -0,0 +1,23 @@ +var msd = require('../../../src/sorting/most-significant-digit/msd.js').msd; + +describe('Most-Significant Digit', function () { + 'use strict'; + + it('should work with empty arrays', function () { + expect(msd([]).length).toBe(0); + }); + + it('should work with arrays with a single element', function () { + var arr = ['a']; + expect(msd(arr).length).toBe(1); + expect(msd(arr)[0]).toBe('a'); + }); + + it('should work with arrays with equally length strings', function () { + var arr = ['a']; + expect(msd(arr).length).toBe(1); + expect(msd(arr)[0]).toBe('a'); + }); + + +}); From c59a0d05c9e7f8ffb3525f64a6fcf906d396d97c Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 25 Sep 2014 10:20:18 +0300 Subject: [PATCH 176/613] Update msd spec --- .../most-significant-digit/msd.spec.js | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/test/sorting/most-significant-digit/msd.spec.js b/test/sorting/most-significant-digit/msd.spec.js index 721d40af..eb10b765 100644 --- a/test/sorting/most-significant-digit/msd.spec.js +++ b/test/sorting/most-significant-digit/msd.spec.js @@ -9,15 +9,26 @@ describe('Most-Significant Digit', function () { it('should work with arrays with a single element', function () { var arr = ['a']; - expect(msd(arr).length).toBe(1); - expect(msd(arr)[0]).toBe('a'); + msd(arr); + expect(arr.length).toBe(1); + expect(arr[0]).toBe('a'); }); it('should work with arrays with equally length strings', function () { - var arr = ['a']; - expect(msd(arr).length).toBe(1); - expect(msd(arr)[0]).toBe('a'); + var arr = ['bb', 'aa', 'cc']; + msd(arr); + expect(arr.length).toBe(3); + expect(arr[0]).toBe('aa'); + expect(arr[1]).toBe('bb'); + expect(arr[2]).toBe('cc'); }); - + it('should work with arrays with equally length strings', function () { + var arr = ['bb', 'aa', 'cc']; + msd(arr); + expect(arr.length).toBe(3); + expect(arr[0]).toBe('aa'); + expect(arr[1]).toBe('bb'); + expect(arr[2]).toBe('cc'); + }); }); From ebb6a56da65a28b219d76721477593d3d1312c44 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 25 Sep 2014 10:21:15 +0300 Subject: [PATCH 177/613] Add test case --- test/sorting/most-significant-digit/msd.spec.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/sorting/most-significant-digit/msd.spec.js b/test/sorting/most-significant-digit/msd.spec.js index eb10b765..b1f4bc74 100644 --- a/test/sorting/most-significant-digit/msd.spec.js +++ b/test/sorting/most-significant-digit/msd.spec.js @@ -23,12 +23,13 @@ describe('Most-Significant Digit', function () { expect(arr[2]).toBe('cc'); }); - it('should work with arrays with equally length strings', function () { - var arr = ['bb', 'aa', 'cc']; + it('should work with arrays with differently length strings', function () { + var arr = ['bb', 'aaa', 'a', 'aa']; msd(arr); - expect(arr.length).toBe(3); - expect(arr[0]).toBe('aa'); - expect(arr[1]).toBe('bb'); - expect(arr[2]).toBe('cc'); + expect(arr.length).toBe(4); + expect(arr[0]).toBe('a'); + expect(arr[1]).toBe('aa'); + expect(arr[2]).toBe('aaa'); + expect(arr[3]).toBe('bb'); }); }); From 4dccd2481861db42ad327ea3178acc433e9350aa Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 25 Sep 2014 10:23:48 +0300 Subject: [PATCH 178/613] Update msd --- src/sorting/most-significant-digit/msd.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/sorting/most-significant-digit/msd.js b/src/sorting/most-significant-digit/msd.js index b22716ee..2e4ab4f4 100644 --- a/src/sorting/most-significant-digit/msd.js +++ b/src/sorting/most-significant-digit/msd.js @@ -35,6 +35,20 @@ } } + /** + * Sorts given array lexicographically. + * The algorithms knows how to treat + * differently length strings. + * The algorithm is stable. + * + * Complexity O(n*m) + * + * @public + * @param {Array} arr The array, which needs to be sorted + * @param {Number} d The digit from which the sorting should start + * @return {Array} The sorted array + */ + function msd(arr, d) { d = d || 0; sort(arr, 0, arr.length - 1, d); From 5a4fbfa2d3910d02753317b461d7a4c4d1999063 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 29 Sep 2014 14:42:53 +0300 Subject: [PATCH 179/613] Tests for lsd --- .../least-significant-digit/lsd.spec.js | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/sorting/least-significant-digit/lsd.spec.js diff --git a/test/sorting/least-significant-digit/lsd.spec.js b/test/sorting/least-significant-digit/lsd.spec.js new file mode 100644 index 00000000..bb660ef0 --- /dev/null +++ b/test/sorting/least-significant-digit/lsd.spec.js @@ -0,0 +1,35 @@ +var lsd = require('../../../src/sorting/least-significant-digit/lsd.js').lsd; + +describe('Least-Significant Digit', function () { + 'use strict'; + + it('should work with empty arrays', function () { + expect(lsd([]).length).toBe(0); + }); + + it('should work with arrays with a single element', function () { + var arr = ['a']; + lsd(arr); + expect(arr.length).toBe(1); + expect(arr[0]).toBe('a'); + }); + + it('should work with arrays with equally length strings', function () { + var arr = ['bb', 'aa', 'cc']; + lsd(arr); + expect(arr.length).toBe(3); + expect(arr[0]).toBe('aa'); + expect(arr[1]).toBe('bb'); + expect(arr[2]).toBe('cc'); + }); + + it('should work with arrays with differently length strings', function () { + var arr = ['bb', 'aaa', 'a', 'aa']; + lsd(arr); + expect(arr.length).toBe(4); + expect(arr[0]).toBe('a'); + expect(arr[1]).toBe('aa'); + expect(arr[2]).toBe('aaa'); + expect(arr[3]).toBe('bb'); + }); +}); From 3038569103a64869733655540708937f3ac64535 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 29 Sep 2014 14:45:44 +0300 Subject: [PATCH 180/613] Fix lsd --- src/sorting/least-significant-digit/lsd.js | 2 +- .../least-significant-digit/lsd.spec.js | 36 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/sorting/least-significant-digit/lsd.js b/src/sorting/least-significant-digit/lsd.js index 77aef9b0..a1c3169f 100644 --- a/src/sorting/least-significant-digit/lsd.js +++ b/src/sorting/least-significant-digit/lsd.js @@ -21,7 +21,7 @@ var old = count[charCode + 1] || 0; count[charCode + 1] = old + 1; } - for (var c = 0; c < count.length; c += 1) { + for (var c = 0; c < count.length - 1; c += 1) { count[c] = count[c] || 0; count[c + 1] = count[c + 1] || 0; count[c + 1] += count[c]; diff --git a/test/sorting/least-significant-digit/lsd.spec.js b/test/sorting/least-significant-digit/lsd.spec.js index bb660ef0..1bfdafa4 100644 --- a/test/sorting/least-significant-digit/lsd.spec.js +++ b/test/sorting/least-significant-digit/lsd.spec.js @@ -14,22 +14,22 @@ describe('Least-Significant Digit', function () { expect(arr[0]).toBe('a'); }); - it('should work with arrays with equally length strings', function () { - var arr = ['bb', 'aa', 'cc']; - lsd(arr); - expect(arr.length).toBe(3); - expect(arr[0]).toBe('aa'); - expect(arr[1]).toBe('bb'); - expect(arr[2]).toBe('cc'); - }); - - it('should work with arrays with differently length strings', function () { - var arr = ['bb', 'aaa', 'a', 'aa']; - lsd(arr); - expect(arr.length).toBe(4); - expect(arr[0]).toBe('a'); - expect(arr[1]).toBe('aa'); - expect(arr[2]).toBe('aaa'); - expect(arr[3]).toBe('bb'); - }); +// it('should work with arrays with equally length strings', function () { +// var arr = ['bb', 'aa', 'cc']; +// lsd(arr); +// expect(arr.length).toBe(3); +// expect(arr[0]).toBe('aa'); +// expect(arr[1]).toBe('bb'); +// expect(arr[2]).toBe('cc'); +// }); +// +// it('should work with arrays with differently length strings', function () { +// var arr = ['bb', 'aaa', 'a', 'aa']; +// lsd(arr); +// expect(arr.length).toBe(4); +// expect(arr[0]).toBe('a'); +// expect(arr[1]).toBe('aa'); +// expect(arr[2]).toBe('aaa'); +// expect(arr[3]).toBe('bb'); +// }); }); From f605a53c338e11c4bbe21ae34359ca144cdebc6e Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 29 Sep 2014 14:47:32 +0300 Subject: [PATCH 181/613] Add tests for lsd --- .../least-significant-digit/lsd.spec.js | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/test/sorting/least-significant-digit/lsd.spec.js b/test/sorting/least-significant-digit/lsd.spec.js index 1bfdafa4..6115998d 100644 --- a/test/sorting/least-significant-digit/lsd.spec.js +++ b/test/sorting/least-significant-digit/lsd.spec.js @@ -14,22 +14,21 @@ describe('Least-Significant Digit', function () { expect(arr[0]).toBe('a'); }); -// it('should work with arrays with equally length strings', function () { -// var arr = ['bb', 'aa', 'cc']; -// lsd(arr); -// expect(arr.length).toBe(3); -// expect(arr[0]).toBe('aa'); -// expect(arr[1]).toBe('bb'); -// expect(arr[2]).toBe('cc'); -// }); -// -// it('should work with arrays with differently length strings', function () { -// var arr = ['bb', 'aaa', 'a', 'aa']; -// lsd(arr); -// expect(arr.length).toBe(4); -// expect(arr[0]).toBe('a'); -// expect(arr[1]).toBe('aa'); -// expect(arr[2]).toBe('aaa'); -// expect(arr[3]).toBe('bb'); -// }); + it('should work with arrays with equally length strings', function () { + var arr = ['bb', 'aa', 'cc']; + lsd(arr); + expect(arr.length).toBe(3); + expect(arr[0]).toBe('aa'); + expect(arr[1]).toBe('bb'); + expect(arr[2]).toBe('cc'); + }); + + it('should work with arrays with equally length strings', function () { + var arr = ['bbb', 'aac', 'aaa']; + lsd(arr, 3); + expect(arr.length).toBe(3); + expect(arr[0]).toBe('aaa'); + expect(arr[1]).toBe('aac'); + expect(arr[2]).toBe('bbb'); + }); }); From ff1cec82d6fc68034f29ece9471d3833a616db16 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 30 Sep 2014 13:47:18 +0300 Subject: [PATCH 182/613] Add three way string quicksort --- .../3-way-string-quicksort/quicksort.js | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/sorting/3-way-string-quicksort/quicksort.js diff --git a/src/sorting/3-way-string-quicksort/quicksort.js b/src/sorting/3-way-string-quicksort/quicksort.js new file mode 100644 index 00000000..8aee1c6b --- /dev/null +++ b/src/sorting/3-way-string-quicksort/quicksort.js @@ -0,0 +1,49 @@ +var quicksort = (function () { + 'use strict'; + + function charAt(str, i) { + return (i < str.length) ? str.charCodeAt(i) : -1; + } + + function swap(arr, i, j) { + var temp = arr[j]; + arr[j] = arr[i]; + arr[i] = temp; + } + + function quicksort(arr, lo, hi, d) { + if (lo >= hi) { + return; + } + var lowPointer = lo, + highPointer = hi, + p = charAt(arr[lo], d), + i = lo + 1, + current; + + while (i <= highPointer) { + current = charAt(arr[i], d); + if (current < p) { + swap(arr, i, lowPointer); + lowPointer += 1; + } else if (current > p) { + highPointer -= 1; + i += 1; + } else { + i += 1; + } + } + + quicksort(arr, lo, lowPointer - 1, d); + if (p >= 0) { + quicksort(arr, lowPointer, highPointer, d + 1); + } + quicksort(arr, highPointer + 1, hi, d); + } + + return function sort(arr) { + quicksort(arr, 0, arr.length - 1, 0); + return arr; + }; +}()); + From b609a7c4733f39ac8987e40599472aad8b3443d7 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 30 Sep 2014 13:49:14 +0300 Subject: [PATCH 183/613] Exports quicksort --- .../3-way-string-quicksort/quicksort.js | 83 ++++++++++--------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/src/sorting/3-way-string-quicksort/quicksort.js b/src/sorting/3-way-string-quicksort/quicksort.js index 8aee1c6b..cc1833a1 100644 --- a/src/sorting/3-way-string-quicksort/quicksort.js +++ b/src/sorting/3-way-string-quicksort/quicksort.js @@ -1,49 +1,54 @@ -var quicksort = (function () { +(function (exports) { 'use strict'; - function charAt(str, i) { - return (i < str.length) ? str.charCodeAt(i) : -1; - } + var quicksort = (function () { - function swap(arr, i, j) { - var temp = arr[j]; - arr[j] = arr[i]; - arr[i] = temp; - } + function charAt(str, i) { + return (i < str.length) ? str.charCodeAt(i) : -1; + } - function quicksort(arr, lo, hi, d) { - if (lo >= hi) { - return; + function swap(arr, i, j) { + var temp = arr[j]; + arr[j] = arr[i]; + arr[i] = temp; } - var lowPointer = lo, - highPointer = hi, - p = charAt(arr[lo], d), - i = lo + 1, - current; - - while (i <= highPointer) { - current = charAt(arr[i], d); - if (current < p) { - swap(arr, i, lowPointer); - lowPointer += 1; - } else if (current > p) { - highPointer -= 1; - i += 1; - } else { - i += 1; + + function quicksort(arr, lo, hi, d) { + if (lo >= hi) { + return; } - } + var lowPointer = lo, + highPointer = hi, + p = charAt(arr[lo], d), + i = lo + 1, + current; - quicksort(arr, lo, lowPointer - 1, d); - if (p >= 0) { - quicksort(arr, lowPointer, highPointer, d + 1); + while (i <= highPointer) { + current = charAt(arr[i], d); + if (current < p) { + swap(arr, i, lowPointer); + lowPointer += 1; + } else if (current > p) { + highPointer -= 1; + i += 1; + } else { + i += 1; + } + } + + quicksort(arr, lo, lowPointer - 1, d); + if (p >= 0) { + quicksort(arr, lowPointer, highPointer, d + 1); + } + quicksort(arr, highPointer + 1, hi, d); } - quicksort(arr, highPointer + 1, hi, d); - } - return function sort(arr) { - quicksort(arr, 0, arr.length - 1, 0); - return arr; - }; -}()); + return function sort(arr) { + quicksort(arr, 0, arr.length - 1, 0); + return arr; + }; + }()); + + exports.quicksort = quicksort; +}(typeof exports === 'undefined' ? window : exports)); From e480819d7cce58e6bef02ca6c0f1dbb9b28abc68 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 30 Sep 2014 13:52:29 +0300 Subject: [PATCH 184/613] Add comment about 3 way string quicksort --- src/sorting/3-way-string-quicksort/quicksort.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sorting/3-way-string-quicksort/quicksort.js b/src/sorting/3-way-string-quicksort/quicksort.js index cc1833a1..71417f35 100644 --- a/src/sorting/3-way-string-quicksort/quicksort.js +++ b/src/sorting/3-way-string-quicksort/quicksort.js @@ -1,6 +1,10 @@ (function (exports) { 'use strict'; + /** + * Effective inplace string sorting algorithm. + * The algorithm is NOT stable. + */ var quicksort = (function () { function charAt(str, i) { From 4aeddcf2b96817995e1d53a7b53bd4173b53d8c2 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 1 Oct 2014 14:37:30 +0300 Subject: [PATCH 185/613] Add tests for 3 way string quicksort --- .../3-way-string-quicksort/quicksort.spec.js | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/sorting/3-way-string-quicksort/quicksort.spec.js diff --git a/test/sorting/3-way-string-quicksort/quicksort.spec.js b/test/sorting/3-way-string-quicksort/quicksort.spec.js new file mode 100644 index 00000000..0fcf13e5 --- /dev/null +++ b/test/sorting/3-way-string-quicksort/quicksort.spec.js @@ -0,0 +1,36 @@ +var quicksort = + require('../../../src/sorting/3-way-string-quicksort/quicksort.js').quicksort; + +describe('Most-Significant Digit', function () { + 'use strict'; + + it('should work with empty arrays', function () { + expect(quicksort([]).length).toBe(0); + }); + + it('should work with arrays with a single element', function () { + var arr = ['a']; + quicksort(arr); + expect(arr.length).toBe(1); + expect(arr[0]).toBe('a'); + }); + + it('should work with arrays with equally length strings', function () { + var arr = ['bb', 'aa', 'cc']; + quicksort(arr); + expect(arr.length).toBe(3); + expect(arr[0]).toBe('aa'); + expect(arr[1]).toBe('bb'); + expect(arr[2]).toBe('cc'); + }); + + it('should work with arrays with differently length strings', function () { + var arr = ['bb', 'aaa', 'a', 'aa']; + quicksort(arr); + expect(arr.length).toBe(4); + expect(arr[0]).toBe('a'); + expect(arr[1]).toBe('aa'); + expect(arr[2]).toBe('aaa'); + expect(arr[3]).toBe('bb'); + }); +}); From 1dab02e94a2e289bf51ae2e67ed57a61319fd908 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 2 Oct 2014 17:13:42 +0300 Subject: [PATCH 186/613] Fix 3 way quick sort --- src/sorting/3-way-string-quicksort/quicksort.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sorting/3-way-string-quicksort/quicksort.js b/src/sorting/3-way-string-quicksort/quicksort.js index 71417f35..bf6b6a79 100644 --- a/src/sorting/3-way-string-quicksort/quicksort.js +++ b/src/sorting/3-way-string-quicksort/quicksort.js @@ -33,6 +33,7 @@ swap(arr, i, lowPointer); lowPointer += 1; } else if (current > p) { + swap(arr, i, highPointer); highPointer -= 1; i += 1; } else { From 94b706a95cc8c32925e0cdf62ca1e6f97557a45b Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 7 Oct 2014 11:02:49 +0300 Subject: [PATCH 187/613] Update bresenham --- src/graphics/bresenham-line-drawing.js | 77 ++++++++++++++------------ 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/src/graphics/bresenham-line-drawing.js b/src/graphics/bresenham-line-drawing.js index 3e4fa39a..cd050ac0 100644 --- a/src/graphics/bresenham-line-drawing.js +++ b/src/graphics/bresenham-line-drawing.js @@ -1,38 +1,45 @@ -/** - * Bresenham's line drawing algorithm. - * It has complexity O(n) - * @param {number} x1 The first coordinate of the beginning of the line - * @param {number} y1 The second coordinate of the beginning of the line - * @param {number} x2 The first coordinate of the end of the line - * @param {number} y2 The second coordinate of the end of the line - */ -function drawLine(x1, y1, x2, y2) { - var dx = Math.abs(x2 - x1), - dy = Math.abs(y2 - y1), - cx = (x1 < x2) ? 1 : -1, - cy = (y1 < y2) ? 1 : -1, - error = dx - dy, - doubledError; - - while (x1 !== x2 || y1 !== y2) { - drawPoint(x1, y1); - doubledError = error + error; - if (doubledError > -dy) { - error -= dy; - x1 += cx; - } - if (doubledError < dx) { - error += dx; - y1 += cy; +(function (exports) { + 'use strict'; + + /** + * Bresenham's line drawing algorithm. + * It has complexity O(n) + * @param {number} x1 The first coordinate of the beginning of the line + * @param {number} y1 The second coordinate of the beginning of the line + * @param {number} x2 The first coordinate of the end of the line + * @param {number} y2 The second coordinate of the end of the line + */ + function drawLine(x1, y1, x2, y2) { + var dx = Math.abs(x2 - x1), + dy = Math.abs(y2 - y1), + cx = (x1 < x2) ? 1 : -1, + cy = (y1 < y2) ? 1 : -1, + error = dx - dy, + doubledError; + + while (x1 !== x2 || y1 !== y2) { + drawPoint(x1, y1); + doubledError = error + error; + if (doubledError > -dy) { + error -= dy; + x1 += cx; + } + if (doubledError < dx) { + error += dx; + y1 += cy; + } } } -} -/** - * Draws (prints) the given coordinates - * @param {number} x The first coordinate of the point - * @param {number} y The second coordinate of the point - */ -function drawPoint(x, y) { - console.log(x, y); -} \ No newline at end of file + /** + * Draws (prints) the given coordinates + * @param {number} x The first coordinate of the point + * @param {number} y The second coordinate of the point + */ + function drawPoint(x, y) { + console.log(x, y); + } + + exports.drawLine = drawLine; + +}(typeof exports === 'undefined' ? window : exports)); From 7ce1c36a20dc6577d835a6159fadcb47a9d6c658 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 7 Oct 2014 11:28:12 +0300 Subject: [PATCH 188/613] Update dijkstra --- src/graphs/searching/quickfind.js | 10 +- src/graphs/searching/quickunion.js | 2 +- src/graphs/shortest-path/dijkstra.js | 166 ++++++++++++++------------- 3 files changed, 91 insertions(+), 87 deletions(-) diff --git a/src/graphs/searching/quickfind.js b/src/graphs/searching/quickfind.js index 373c62f2..307ed4e8 100644 --- a/src/graphs/searching/quickfind.js +++ b/src/graphs/searching/quickfind.js @@ -7,8 +7,9 @@ */ function QuickFind(size) { this._ids = []; - for (var i = 0; i < size; i += 1) + for (var i = 0; i < size; i += 1) { this._ids[i] = i; + } } /** @@ -20,11 +21,12 @@ function QuickFind(size) { */ QuickFind.prototype.union = function (p, q) { var size = this._ids.length, - pval = this._ids[p], - qval = this._ids[q]; + pval = this._ids[p], + qval = this._ids[q]; for (var i = 0; i < size; i += 1) { - if (this._ids[i] === qval) + if (this._ids[i] === qval) { this._ids[i] = pval; + } } }; diff --git a/src/graphs/searching/quickunion.js b/src/graphs/searching/quickunion.js index 6e63e5f4..bcab5a33 100644 --- a/src/graphs/searching/quickunion.js +++ b/src/graphs/searching/quickunion.js @@ -34,7 +34,7 @@ QuickUnion.prototype._root = function (i) { */ QuickUnion.prototype.union = function (p, q) { var pRoot = this._root(p), - qRoot = this._root(q); + qRoot = this._root(q); this._ids[pRoot] = qRoot; }; diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index 2a83d404..638237e8 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -12,99 +12,101 @@ var graph = [[NaN, 7, 9, NaN, NaN, 16], /** * Dijstra's shortest path algorithm. - * For the implementation is not used the most suitable data structure (Fibonacci heap) + * For the implementation is not used the most + * suitable data structure (Fibonacci heap) * but the binary heap gives also good results. The implementation bellow finds * the minimum distance between two given nodes using a distance matrix. */ var dijstra = function () { + 'use strict'; - var Heap = require('../../data-structures/heap.js').Heap, - current, - visited, - distance, - unvisited; + var Heap = require('../../data-structures/heap.js').Heap, + current, + visited, + distance, + unvisited; - /** - * Creates a new node instance - * - * @constructor - * @private - * @param {number} id The id of the node - * @param {number} distance The distance from the beginning - */ - function Node(id, distance) { - this.node = id; - this.distance = distance; - } + /** + * Creates a new node instance + * + * @constructor + * @private + * @param {number} id The id of the node + * @param {number} distance The distance from the beginning + */ + function Node(id, distance) { + this.node = id; + this.distance = distance; + } - /** - * Compares the distances between two nodes. - * - * @private - * @param {object} a A node - * @param {object} b A graph node - * @returns {number} The - */ - function compareNodesDistance(a, b) { - return b.distance - a.distance; - } + /** + * Compares the distances between two nodes. + * + * @private + * @param {object} a A node + * @param {object} b A graph node + * @returns {number} The + */ + function compareNodesDistance(a, b) { + return b.distance - a.distance; + } - /** - * Initialize all variables used for the algorithm - * - * @private - * @param {number} src A start node - */ - function init(src) { - var currentTemp; - current = {}; - visited = []; - distance = []; - unvisited = new Heap(compareNodesDistance); - for (var i = 0; i < graph.length; i += 1) { - currentTemp = new Node(); - if (src === i) { - currentTemp.distance = 0; - } else { - currentTemp.distance = Infinity; - } - currentTemp.node = i; - visited[i] = false; - distance[i] = currentTemp; - unvisited.add(currentTemp); - } - current.node = src; - current.distance = 0; + /** + * Initialize all variables used for the algorithm + * + * @private + * @param {number} src A start node + */ + function init(src, graph) { + var currentTemp; + current = {}; + visited = []; + distance = []; + unvisited = new Heap(compareNodesDistance); + for (var i = 0; i < graph.length; i += 1) { + currentTemp = new Node(); + if (src === i) { + currentTemp.distance = 0; + } else { + currentTemp.distance = Infinity; + } + currentTemp.node = i; + visited[i] = false; + distance[i] = currentTemp; + unvisited.add(currentTemp); } + current.node = src; + current.distance = 0; + } - /** - * Dijkstra's shortest path algorithm - * - * @public - * @param {number} src Source node - * @param {number} dest Destination node - * @param {array} graph A distance matrix of the graph - * @returns {number} The shortest distance between the nodes - */ - return function (src, dest, graph) { - var tempDistance = 0; - init(src); - while (current.node != dest && current.distance != Infinity) { - for (var i = 0; i < graph.length; i += 1) { - if (current.node !== i && //if it's not the current node - !visited[i] && //and if we haven't visited this node - !isNaN(graph[i][current.node])) { //and this node is sibling of the current... + /** + * Dijkstra's shortest path algorithm + * + * @public + * @param {number} src Source node + * @param {number} dest Destination node + * @param {array} graph A distance matrix of the graph + * @returns {number} The shortest distance between the nodes + */ + return function (src, dest, graph) { + var tempDistance = 0; + init(src, graph); + while (current.node != dest && current.distance != Infinity) { + for (var i = 0; i < graph.length; i += 1) { + if (current.node !== i && //if it's not the current node + !visited[i] && //and if we haven't visited this node + !isNaN(graph[i][current.node])) { //and this node is sibling of the current... - tempDistance = current.distance + graph[i][current.node]; - if (tempDistance < distance[i].distance) { - distance[i].distance = tempDistance; - } - } - } - visited[current.node] = true; - current = unvisited.extract(); + tempDistance = current.distance + graph[i][current.node]; + if (tempDistance < distance[i].distance) { + distance[i].distance = tempDistance; + } } - return distance[dest].distance; - }; + } + visited[current.node] = true; + current = unvisited.extract(); + } + return distance[dest].distance; + }; }(); From c2c8203bf09a0c6c7f8c774b5bb0142971775cf7 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 7 Oct 2014 11:32:37 +0300 Subject: [PATCH 189/613] Update indentation in floyd --- src/graphs/shortest-path/floyd.js | 94 +++++++++++++++---------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/src/graphs/shortest-path/floyd.js b/src/graphs/shortest-path/floyd.js index c723aeb4..41ff368e 100644 --- a/src/graphs/shortest-path/floyd.js +++ b/src/graphs/shortest-path/floyd.js @@ -19,56 +19,56 @@ var graph = [[NaN, 7, 9, NaN, NaN, 16], */ var floydWarshall = (function () { - /** - * Matrix used for the algorithm. - */ - var dist; + /** + * Matrix used for the algorithm. + */ + var dist; - /** - * Initialize the distance matrix - * - * @private - * @param {array} graph Distance matrix of the array - * @return {array} Distance matrix used for the algorithm - */ - function init(graph) { - var dist = []; - var size = graph.length; - for (var i = 0; i < size; i += 1) { - dist[i] = []; - for (var j = 0; j < size; j += 1) { - if (i === j) { - dist[i][j] = 0; - } else if (isNaN(graph[i][j])) { - dist[i][j] = Infinity; - } else { - dist[i][j] = graph[i][j]; - } - } + /** + * Initialize the distance matrix + * + * @private + * @param {array} graph Distance matrix of the array + * @return {array} Distance matrix used for the algorithm + */ + function init(graph) { + var dist = []; + var size = graph.length; + for (var i = 0; i < size; i += 1) { + dist[i] = []; + for (var j = 0; j < size; j += 1) { + if (i === j) { + dist[i][j] = 0; + } else if (isNaN(graph[i][j])) { + dist[i][j] = Infinity; + } else { + dist[i][j] = graph[i][j]; } - return dist; + } } + return dist; + } - /** - * Finds the shortest path between each two vertices - * Complexity O(n^3) - * - * @public - * @param {array} graph The graph which should be processed - * @return {array} The array which contains the shortest distance between each two vertices - */ - return function (graph) { - dist = init(graph); - var size = graph.length; - for (var k = 0; k < size; k += 1) { - for (var i = 0; i < size; i += 1) { - for (var j = 0; j < size; j += 1) { - if (dist[i][j] > dist[i][k] + dist[k][j]) { - dist[i][j] = dist[i][k] + dist[k][j]; - } - } - } + /** + * Finds the shortest path between each two vertices + * Complexity O(n^3) + * + * @public + * @param {array} graph The graph which should be processed + * @return {array} The array which contains the shortest distance between each two vertices + */ + return function (graph) { + dist = init(graph); + var size = graph.length; + for (var k = 0; k < size; k += 1) { + for (var i = 0; i < size; i += 1) { + for (var j = 0; j < size; j += 1) { + if (dist[i][j] > dist[i][k] + dist[k][j]) { + dist[i][j] = dist[i][k] + dist[k][j]; + } } - return dist; - }; + } + } + return dist; + }; }()); From 76383bd5e66b6dfea2b5a5309dd86674bfb64b8b Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 8 Oct 2014 11:45:46 +0300 Subject: [PATCH 190/613] Basic linked list --- src/data-structures/linked-list.js | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/data-structures/linked-list.js diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js new file mode 100644 index 00000000..a74113fe --- /dev/null +++ b/src/data-structures/linked-list.js @@ -0,0 +1,52 @@ +function Node(data) { + this.data = data; + this.next = null; + this.prev = null; +} + +function LinkedList() { + this.first = null; + this.last = null; +} + +LinkedList.prototype.push = function (data) { + var node = new Node(data); + if (this.first === null) { + this.first = this.last = node; + } else { + var temp = this.last; + this.last = node; + node.prev = temp; + temp.next = node; + } +}; + +LinkedList.prototype.unshift = function (data) { + var node = new Node(data); + if (this.first === null) { + this.first = this.last = node; + } else { + var temp = this.first; + this.first = node; + node.next = temp; + temp.prev = node; + } +}; + +LinkedList.prototype.inorder = function (cb) { + var temp = this.first; + while (temp) { + cb(temp); + temp = temp.next; + } +}; + +//var list = new LinkedList(); +//list.push(1); +//list.push(2); +//list.unshift(3); +//list.unshift(4); +//list.push(-1); +//list.inorder(function (node) { +// console.log(node.data); +//}); \ No newline at end of file From 95e70bc935db34f4a753ad50870767efce5f1e24 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 8 Oct 2014 11:49:03 +0300 Subject: [PATCH 191/613] Basic linked list --- src/data-structures/linked-list.js | 41 +++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index a74113fe..6ae01a93 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -41,12 +41,35 @@ LinkedList.prototype.inorder = function (cb) { } }; -//var list = new LinkedList(); -//list.push(1); -//list.push(2); -//list.unshift(3); -//list.unshift(4); -//list.push(-1); -//list.inorder(function (node) { -// console.log(node.data); -//}); \ No newline at end of file +LinkedList.prototype.remove = function (data) { + if (this.first === null) { + return false; + } + var temp = this.first, + next, prev; + while (temp) { + if (temp.data === data) { + next = temp.next; + prev = temp.prev; + if (next) { + next.prev = prev; + } + if (prev) { + prev.next = next; + } + return true; + } + } + return false; +}; + +var list = new LinkedList(); +list.push(1); +list.push(2); +list.unshift(3); +list.unshift(4); +list.push(-1); +list.remove(-1); +list.inorder(function (node) { + console.log(node.data); +}); \ No newline at end of file From 76ce76882dafefd2fcddbcc9baa1b254b1a79516 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 8 Oct 2014 11:51:03 +0300 Subject: [PATCH 192/613] Add remove method --- src/data-structures/linked-list.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index 6ae01a93..9415f72b 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -57,19 +57,26 @@ LinkedList.prototype.remove = function (data) { if (prev) { prev.next = next; } + if (temp === this.first) { + this.first = next; + } + if (temp === this.last) { + this.last = prev; + } return true; } + temp = temp.next; } return false; }; var list = new LinkedList(); -list.push(1); -list.push(2); -list.unshift(3); -list.unshift(4); -list.push(-1); -list.remove(-1); -list.inorder(function (node) { - console.log(node.data); -}); \ No newline at end of file +//list.push(1); +//list.push(2); +//list.unshift(3); +//list.unshift(4); +//list.push(-1); +//list.remove(-1); +//list.inorder(function (node) { +// console.log(node.data); +//}); \ No newline at end of file From 0834aae381f98de08c3311e979de03be9f9258a8 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 8 Oct 2014 11:52:51 +0300 Subject: [PATCH 193/613] Add remove method --- src/data-structures/linked-list.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index 9415f72b..75b7668f 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -70,6 +70,25 @@ LinkedList.prototype.remove = function (data) { return false; }; +LinkedList.prototype.hasCycle = function () { + var fast = this.first, + slow = this.first; + while (true) { + if (fast === null) { + return false; + } + fast = fast.next; + if (fast === null) { + return false; + } + fast = fast.next; + slow = slow.next; + if (fast === slow) { + return true; + } + } +}; + var list = new LinkedList(); //list.push(1); //list.push(2); From 56b6b0188a25d3a2f83afcfd0976fff81e4b8c35 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 8 Oct 2014 11:54:27 +0300 Subject: [PATCH 194/613] Add linked list --- src/data-structures/linked-list.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index 75b7668f..7bdd355d 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -88,14 +88,3 @@ LinkedList.prototype.hasCycle = function () { } } }; - -var list = new LinkedList(); -//list.push(1); -//list.push(2); -//list.unshift(3); -//list.unshift(4); -//list.push(-1); -//list.remove(-1); -//list.inorder(function (node) { -// console.log(node.data); -//}); \ No newline at end of file From 9d976de093319284d8abeba49b6d14f8cd71776d Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 8 Oct 2014 15:04:03 +0300 Subject: [PATCH 195/613] Update the linked list --- src/data-structures/linked-list.js | 163 +++++++++++++++-------------- 1 file changed, 86 insertions(+), 77 deletions(-) diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index 7bdd355d..b2d79108 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -1,90 +1,99 @@ -function Node(data) { - this.data = data; - this.next = null; - this.prev = null; -} +(function (exports) { -function LinkedList() { - this.first = null; - this.last = null; -} + 'use strict'; -LinkedList.prototype.push = function (data) { - var node = new Node(data); - if (this.first === null) { - this.first = this.last = node; - } else { - var temp = this.last; - this.last = node; - node.prev = temp; - temp.next = node; + function Node(data) { + this.data = data; + this.next = null; + this.prev = null; } -}; -LinkedList.prototype.unshift = function (data) { - var node = new Node(data); - if (this.first === null) { - this.first = this.last = node; - } else { - var temp = this.first; - this.first = node; - node.next = temp; - temp.prev = node; + function LinkedList() { + this.first = null; + this.last = null; } -}; -LinkedList.prototype.inorder = function (cb) { - var temp = this.first; - while (temp) { - cb(temp); - temp = temp.next; - } -}; + LinkedList.prototype.push = function (data) { + var node = new Node(data); + if (this.first === null) { + this.first = this.last = node; + } else { + var temp = this.last; + this.last = node; + node.prev = temp; + temp.next = node; + } + }; -LinkedList.prototype.remove = function (data) { - if (this.first === null) { - return false; - } - var temp = this.first, - next, prev; - while (temp) { - if (temp.data === data) { - next = temp.next; - prev = temp.prev; - if (next) { - next.prev = prev; - } - if (prev) { - prev.next = next; - } - if (temp === this.first) { - this.first = next; - } - if (temp === this.last) { - this.last = prev; - } - return true; + LinkedList.prototype.unshift = function (data) { + var node = new Node(data); + if (this.first === null) { + this.first = this.last = node; + } else { + var temp = this.first; + this.first = node; + node.next = temp; + temp.prev = node; } - temp = temp.next; - } - return false; -}; + }; -LinkedList.prototype.hasCycle = function () { - var fast = this.first, - slow = this.first; - while (true) { - if (fast === null) { - return false; + LinkedList.prototype.inorder = function (cb) { + var temp = this.first; + while (temp) { + cb(temp); + temp = temp.next; } - fast = fast.next; - if (fast === null) { + }; + + LinkedList.prototype.remove = function (data) { + if (this.first === null) { return false; } - fast = fast.next; - slow = slow.next; - if (fast === slow) { - return true; + var temp = this.first, + next, prev; + while (temp) { + if (temp.data === data) { + next = temp.next; + prev = temp.prev; + if (next) { + next.prev = prev; + } + if (prev) { + prev.next = next; + } + if (temp === this.first) { + this.first = next; + } + if (temp === this.last) { + this.last = prev; + } + return true; + } + temp = temp.next; } - } -}; + return false; + }; + + LinkedList.prototype.hasCycle = function () { + var fast = this.first, + slow = this.first; + while (true) { + if (fast === null) { + return false; + } + fast = fast.next; + if (fast === null) { + return false; + } + fast = fast.next; + slow = slow.next; + if (fast === slow) { + return true; + } + } + }; + + exports.LinkedList = LinkedList; + exports.Node = Node; + +}(typeof exports === 'undefined' ? window : exports)); From 322d47236f979ddf831338acc612cbfe7e2504df Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 8 Oct 2014 15:15:03 +0300 Subject: [PATCH 196/613] Add shift and pop operations --- src/data-structures/linked-list.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index b2d79108..ed854d93 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -93,7 +93,26 @@ } }; + LinkedList.prototype.pop = function () { + if (this.last === null) { + return null; + } + var temp = this.last; + this.last = this.last.prev; + return temp; + }; + + LinkedList.prototype.shift = function () { + if (this.first === null) { + return null; + } + var temp = this.first; + this.first = this.first.next; + return temp; + }; + exports.LinkedList = LinkedList; exports.Node = Node; }(typeof exports === 'undefined' ? window : exports)); + From 46e8cf206a229e9b2161e28089e65e11ecb3765e Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 8 Oct 2014 15:15:32 +0300 Subject: [PATCH 197/613] Update linked list --- src/data-structures/linked-list.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index ed854d93..701c3f44 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -1,5 +1,4 @@ (function (exports) { - 'use strict'; function Node(data) { From a4209ab012a5e25717a243f3b63c6db77917cff0 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 13 Oct 2014 12:46:12 +0300 Subject: [PATCH 198/613] Add quickselect --- src/searching/quickselect/quickselect.js | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/searching/quickselect/quickselect.js diff --git a/src/searching/quickselect/quickselect.js b/src/searching/quickselect/quickselect.js new file mode 100644 index 00000000..a04ad7e4 --- /dev/null +++ b/src/searching/quickselect/quickselect.js @@ -0,0 +1,44 @@ +// O(n) +function findNthNumber(arr, n, lo, hi) { + 'use strict'; + + function partition(arr, lo, hi, pivotIdx) { + function swap(arr, i, j) { + var temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + var pivot = arr[pivotIdx]; + swap(arr, pivotIdx, hi); + for (var i = lo; i < hi; i += 1) { + if (arr[i] < pivot) { + swap(arr, i, lo); + lo += 1; + } + } + swap(arr, hi, lo); + return lo; + } + + if (arr.length <= n) { + return NaN; + } + lo = lo || 0; + hi = hi || arr.length - 1; + if (lo === hi) { + return arr[lo]; + } + while (hi >= lo) { + var pivotIdx = + partition(arr, lo, hi, lo + Math.floor(Math.random() * (hi - lo + 1))); + if (n === pivotIdx) { + return arr[pivotIdx]; + } + if (n < pivotIdx) { + hi = pivotIdx - 1; + } else { + lo = pivotIdx + 1; + } + } + return null; +} From edfbab4b29640367ad7012ce5e3ba19cf64ba373 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 13 Oct 2014 12:47:32 +0300 Subject: [PATCH 199/613] Update quickselect --- src/searching/quickselect/quickselect.js | 76 +++++++++++++----------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/src/searching/quickselect/quickselect.js b/src/searching/quickselect/quickselect.js index a04ad7e4..97fd1276 100644 --- a/src/searching/quickselect/quickselect.js +++ b/src/searching/quickselect/quickselect.js @@ -1,44 +1,48 @@ -// O(n) -function findNthNumber(arr, n, lo, hi) { +(function (exports) { 'use strict'; - function partition(arr, lo, hi, pivotIdx) { - function swap(arr, i, j) { - var temp = arr[i]; - arr[i] = arr[j]; - arr[j] = temp; - } - var pivot = arr[pivotIdx]; - swap(arr, pivotIdx, hi); - for (var i = lo; i < hi; i += 1) { - if (arr[i] < pivot) { - swap(arr, i, lo); - lo += 1; + // O(n) + function quickselect(arr, n, lo, hi) { + function partition(arr, lo, hi, pivotIdx) { + function swap(arr, i, j) { + var temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + var pivot = arr[pivotIdx]; + swap(arr, pivotIdx, hi); + for (var i = lo; i < hi; i += 1) { + if (arr[i] < pivot) { + swap(arr, i, lo); + lo += 1; + } } + swap(arr, hi, lo); + return lo; } - swap(arr, hi, lo); - return lo; - } - if (arr.length <= n) { - return NaN; - } - lo = lo || 0; - hi = hi || arr.length - 1; - if (lo === hi) { - return arr[lo]; - } - while (hi >= lo) { - var pivotIdx = - partition(arr, lo, hi, lo + Math.floor(Math.random() * (hi - lo + 1))); - if (n === pivotIdx) { - return arr[pivotIdx]; + if (arr.length <= n) { + return NaN; } - if (n < pivotIdx) { - hi = pivotIdx - 1; - } else { - lo = pivotIdx + 1; + lo = lo || 0; + hi = hi || arr.length - 1; + if (lo === hi) { + return arr[lo]; } + while (hi >= lo) { + var pivotIdx = + partition(arr, lo, hi, lo + Math.floor(Math.random() * (hi - lo + 1))); + if (n === pivotIdx) { + return arr[pivotIdx]; + } + if (n < pivotIdx) { + hi = pivotIdx - 1; + } else { + lo = pivotIdx + 1; + } + } + return null; } - return null; -} + exports.quickselect = quickselect; + +}(typeof exports === 'undefined' ? window : exports)); From d86b7443df7bd60235fc51fd76c03c90c5d3453b Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 20 Oct 2014 13:22:34 +0300 Subject: [PATCH 200/613] Update binary search tree --- src/data-structures/binary-search-tree.js | 40 ++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 3677c604..060cef52 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -42,7 +42,6 @@ BinaryTree.prototype.insert = function (value, current) { this._root = new Node(value, null, null, null); return; } - var insertKey; current = current || this._root; if (current.value > value) @@ -273,3 +272,42 @@ BinaryTree.prototype.findMin = function () { BinaryTree.prototype.findMax = function () { return this._findMax(this._root); }; + +BinaryTree.prototype._height = function (current) { + if (!current) { + return 0; + } + return 1 + Math.max(this._height(current._left), + this._height(current._right)); +}; + +/** + * Returns the height of the tree + * + * @public + * @returns {Number} The height of the tree + */ +BinaryTree.prototype.height = function () { + return this._height(this._root); +}; + +BinaryTree.prototype._isBalanced = function (current) { + if (!current) { + return true; + } + return this._isBalanced(current._left) && + this._isBalanced(current._right) && + Math.abs(this._height(current._left) - + this._height(current._right)) <= 1; +}; + +/** + * Returns whether the BST is balanced + * + * @public + * @returns {Boolean} Whether the tree is balanced or not + */ +BinaryTree.prototype.isBalanced = function () { + return this._isBalanced(this._root); +}; + From d1323c1d91d7962104d0d595a54c09b1ca1ee121 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 21 Oct 2014 15:27:22 +0300 Subject: [PATCH 201/613] Add diameter to bst --- src/data-structures/binary-search-tree.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 060cef52..8fe38e39 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -311,3 +311,25 @@ BinaryTree.prototype.isBalanced = function () { return this._isBalanced(this._root); }; +/** + * Finds the diameter of the binary tree + * + * @public + * @returns {Number} The longest path in the BST + */ +BinaryTree.prototype.diameter = function () { + return this._diameter(this._root); +}; + +BinaryTree.prototype._diameter = function (current) { + if (!current) { + return 0; + } + var heightLeft = this._height(current._left), + heightRight = this._height(current._right), + diameterLeft = this._diameter(current._left), + diameterRight = this._diameter(current._right); + return Math.max(heightLeft + diameterRight, + Math.max(heightLeft + diameterLeft, heightLeft + heightRight + 1)); +}; + From 801ee8707c8fea0d42229548e662cb821f3f2dd8 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 21 Oct 2014 15:56:33 +0300 Subject: [PATCH 202/613] Add lowest common ancestor --- src/data-structures/binary-search-tree.js | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 8fe38e39..33a41518 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -333,3 +333,41 @@ BinaryTree.prototype._diameter = function (current) { Math.max(heightLeft + diameterLeft, heightLeft + heightRight + 1)); }; +/** + * Finds the lowest common ancestor of two nodes. + * + * @public + * @returns {Node} The lowest common ancestor of the two nodes or null + */ +BinaryTree.prototype.lowestCommonAncestor = function (firstNode, secondNode, current) { + return this._lowestCommonAncestor(firstNode, secondNode, this._root); +}; + +BinaryTree.prototype._lowestCommonAncestor = function (firstNode, secondNode, current) { + var firstNodeInLeft = this._existsInSubtree(firstNode, current._left), + secondNodeInLeft = this._existsInSubtree(secondNode, current._left), + firstNodeInRight = this._existsInSubtree(firstNode, current._right), + secondNodeInRight = this._existsInSubtree(secondNode, current._right); + if ((firstNodeInLeft && secondNodeInRight) || + (firstNodeInRight && secondNodeInLeft)) { + return current; + } + if (secondNodeInLeft && firstNodeInLeft) { + return this._lowestCommonAncestor(firstNode, secondNode, current._left); + } + if (secondNodeInRight && secondNodeInLeft) { + return this._lowestCommonAncestor(firstNode, secondNode, current._right); + } + return null; +}; + +BinaryTree.prototype._existsInSubtree = function (node, root) { + if (!root) { + return false; + } + if (node === root.value) { + return true; + } + return this._existsInSubtree(node, root._left) || this._existsInSubtree(node, root._right); +}; + From c180579770460f374f35c963ed508a20409e6ba8 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 30 Oct 2014 11:41:15 +0200 Subject: [PATCH 203/613] Add inverse method to the linked list --- src/data-structures/linked-list.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index 701c3f44..1bb8d06f 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -110,6 +110,26 @@ return temp; }; + LinkedList.prototype.inverse = function () { + + function inverse(current, next) { + if (!next) { + return; + } + inverse(next, next.next); + next.next = current; + } + + if (!this.first) { + return; + } + inverse(this.first, this.first.next); + this.first.next = null; + var temp = this.first; + this.first = this.last; + this.last = temp; + }; + exports.LinkedList = LinkedList; exports.Node = Node; From 9e04b42ddcc2e757bfd093b8e6c959ff20133552 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 5 Nov 2014 16:09:31 +0200 Subject: [PATCH 204/613] Add permutations --- src/combinatorics/permutations.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/combinatorics/permutations.js diff --git a/src/combinatorics/permutations.js b/src/combinatorics/permutations.js new file mode 100644 index 00000000..64f415c6 --- /dev/null +++ b/src/combinatorics/permutations.js @@ -0,0 +1,28 @@ +var permutations = (function () { + 'use strict'; + + var res; + + function swap(arr, i, j) { + var temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + + function permutations(arr, current) { + if (current >= arr.length) { + return res.push(arr.slice()); + } + for (var i = current; i < arr.length; i += 1) { + swap(arr, i, current); + permutations(arr, current + 1); + swap(arr, i, current); + } + } + + return function (arr) { + res = []; + permutations(arr, 0); + return res; + }; +}()); From 55050a8095558841b6a0914cb5c0783a1654e1be Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 5 Nov 2014 16:11:08 +0200 Subject: [PATCH 205/613] Exports the function --- src/combinatorics/permutations.js | 49 +++++++++++++++++-------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/combinatorics/permutations.js b/src/combinatorics/permutations.js index 64f415c6..02946959 100644 --- a/src/combinatorics/permutations.js +++ b/src/combinatorics/permutations.js @@ -1,28 +1,33 @@ -var permutations = (function () { +(function (exports) { 'use strict'; + var permutations = (function () { - var res; + var res; - function swap(arr, i, j) { - var temp = arr[i]; - arr[i] = arr[j]; - arr[j] = temp; - } - - function permutations(arr, current) { - if (current >= arr.length) { - return res.push(arr.slice()); + function swap(arr, i, j) { + var temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; } - for (var i = current; i < arr.length; i += 1) { - swap(arr, i, current); - permutations(arr, current + 1); - swap(arr, i, current); + + function permutations(arr, current) { + if (current >= arr.length) { + return res.push(arr.slice()); + } + for (var i = current; i < arr.length; i += 1) { + swap(arr, i, current); + permutations(arr, current + 1); + swap(arr, i, current); + } } - } - return function (arr) { - res = []; - permutations(arr, 0); - return res; - }; -}()); + return function (arr) { + res = []; + permutations(arr, 0); + return res; + }; + }()); + + exports.permutations = permutations; + +}(typeof exports === 'undefined' ? window : exports)); From 13530bc0900a947b71b326ca9c8881374c39ceda Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 5 Nov 2014 16:15:39 +0200 Subject: [PATCH 206/613] Add comments for the permutations method --- src/combinatorics/permutations.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/combinatorics/permutations.js b/src/combinatorics/permutations.js index 02946959..e6d9742b 100644 --- a/src/combinatorics/permutations.js +++ b/src/combinatorics/permutations.js @@ -10,6 +10,14 @@ arr[j] = temp; } + /** + * Finds all the permutations of given array. + * Complexity O(n*n!). + * + * @param {Array} arr Array to find the permutations of + * @param {Number} current Current element + * @returns {Array} Array containing all the permutations + */ function permutations(arr, current) { if (current >= arr.length) { return res.push(arr.slice()); From 8ef12365943f0ce444b126ace2b8f1a01759f353 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 5 Nov 2014 16:43:54 +0200 Subject: [PATCH 207/613] Add combinations of k elements --- src/combinatorics/combinations.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/combinatorics/combinations.js diff --git a/src/combinatorics/combinations.js b/src/combinatorics/combinations.js new file mode 100644 index 00000000..472159a8 --- /dev/null +++ b/src/combinatorics/combinations.js @@ -0,0 +1,22 @@ +var combinations = (function () { + 'use strict'; + + var res = []; + + function combinations(arr, k, start, idx, current) { + if (idx === k) { + res.push(current.slice()); + return; + } + for (var i = start; i < arr.length; i += 1) { + current[idx] = arr[i]; + combinations(arr, k, i + 1, idx + 1, current); + } + } + + return function (arr, k) { + res = []; + combinations(arr, k, 0, 0, []); + return res; + }; +}()); From 2a7a662e710cdbebd96bc6bf69b53112c0c4f9c1 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 5 Nov 2014 16:45:23 +0200 Subject: [PATCH 208/613] Wrap combinations in IIFE --- src/combinatorics/combinations.js | 40 +++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/combinatorics/combinations.js b/src/combinatorics/combinations.js index 472159a8..72e352a1 100644 --- a/src/combinatorics/combinations.js +++ b/src/combinatorics/combinations.js @@ -1,22 +1,26 @@ -var combinations = (function () { +(function (exports) { 'use strict'; + var combinations = (function () { + var res = []; - var res = []; - - function combinations(arr, k, start, idx, current) { - if (idx === k) { - res.push(current.slice()); - return; - } - for (var i = start; i < arr.length; i += 1) { - current[idx] = arr[i]; - combinations(arr, k, i + 1, idx + 1, current); + function combinations(arr, k, start, idx, current) { + if (idx === k) { + res.push(current.slice()); + return; + } + for (var i = start; i < arr.length; i += 1) { + current[idx] = arr[i]; + combinations(arr, k, i + 1, idx + 1, current); + } } - } - return function (arr, k) { - res = []; - combinations(arr, k, 0, 0, []); - return res; - }; -}()); + return function (arr, k) { + res = []; + combinations(arr, k, 0, 0, []); + return res; + }; + }()); + + exports.combinations = combinations; + +}(typeof exports === 'undefined' ? window : exports)); From 2c62501b145b0427fbcbef810ab15daede41057e Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 6 Nov 2014 22:26:46 +0200 Subject: [PATCH 209/613] Update linked list --- src/data-structures/linked-list.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index 1bb8d06f..315e715d 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -110,7 +110,7 @@ return temp; }; - LinkedList.prototype.inverse = function () { + LinkedList.prototype.recursiveReverse = function () { function inverse(current, next) { if (!next) { @@ -130,6 +130,22 @@ this.last = temp; }; + LinkedList.prototype.reverse = function () { + if (!this.first || !this.first.next) { + return; + } + var current = this.first.next, + prev = this.first; + while (current) { + var temp = current.next; + current.next = prev; + prev = current; + current = temp; + } + this.first.next = null; + this.first = prev; + }; + exports.LinkedList = LinkedList; exports.Node = Node; From f84bada743824202872656862180191f70b32de6 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 6 Nov 2014 23:32:37 +0200 Subject: [PATCH 210/613] Update the end pointer in the linked list --- src/data-structures/linked-list.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index 315e715d..fdf208ba 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -135,15 +135,18 @@ return; } var current = this.first.next, - prev = this.first; + prev = this.first, + temp; while (current) { - var temp = current.next; + temp = current.next; current.next = prev; prev = current; current = temp; } this.first.next = null; + temp = this.first; this.first = prev; + this.last = temp; }; exports.LinkedList = LinkedList; From ccd9ee4e92c5db92139f9ec717f0e27523bacaf6 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 7 Nov 2014 12:34:33 +0200 Subject: [PATCH 211/613] Update bst --- src/data-structures/binary-search-tree.js | 56 +++++++++++------------ 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 33a41518..5e2df746 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -273,23 +273,6 @@ BinaryTree.prototype.findMax = function () { return this._findMax(this._root); }; -BinaryTree.prototype._height = function (current) { - if (!current) { - return 0; - } - return 1 + Math.max(this._height(current._left), - this._height(current._right)); -}; - -/** - * Returns the height of the tree - * - * @public - * @returns {Number} The height of the tree - */ -BinaryTree.prototype.height = function () { - return this._height(this._root); -}; BinaryTree.prototype._isBalanced = function (current) { if (!current) { @@ -297,8 +280,8 @@ BinaryTree.prototype._isBalanced = function (current) { } return this._isBalanced(current._left) && this._isBalanced(current._right) && - Math.abs(this._height(current._left) - - this._height(current._right)) <= 1; + Math.abs(this._getHeight(current._left) - + this._getHeight(current._right)) <= 1; }; /** @@ -317,20 +300,35 @@ BinaryTree.prototype.isBalanced = function () { * @public * @returns {Number} The longest path in the BST */ -BinaryTree.prototype.diameter = function () { - return this._diameter(this._root); +BinaryTree.prototype.getDiameter = function () { + function getDiameter(root) { + if (!root) { + return 0; + } + var leftHeight = this._getHeight(root._left), + rightHeight = this._getHeight(root._right), + path = leftHeight + rightHeight + 1; + return Math.max(path, Math.max(getDiameter(root._left), getDiameter(root._right))); + } + getDiameter = getDiameter.bind(this); + return getDiameter(this._root); }; -BinaryTree.prototype._diameter = function (current) { - if (!current) { +/** + * Returns the height of the tree + * + * @public + * @returns {Number} The height of the tree + */ +BinaryTree.prototype.getHeight = function () { + return this._getHeight(this._root); +}; + +BinaryTree.prototype._getHeight = function (node) { + if (!node) { return 0; } - var heightLeft = this._height(current._left), - heightRight = this._height(current._right), - diameterLeft = this._diameter(current._left), - diameterRight = this._diameter(current._right); - return Math.max(heightLeft + diameterRight, - Math.max(heightLeft + diameterLeft, heightLeft + heightRight + 1)); + return 1 + Math.max(this._getHeight(node._left), this._getHeight(node._right)); }; /** From a1fd6f3af6556315f96e9fde192f5eb0ab15884b Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 8 Nov 2014 03:45:53 +0200 Subject: [PATCH 212/613] Fix return at quickselect --- src/searching/quickselect/quickselect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/searching/quickselect/quickselect.js b/src/searching/quickselect/quickselect.js index 97fd1276..d49ca2e6 100644 --- a/src/searching/quickselect/quickselect.js +++ b/src/searching/quickselect/quickselect.js @@ -41,7 +41,7 @@ lo = pivotIdx + 1; } } - return null; + return NaN; } exports.quickselect = quickselect; From c1dd51e64ae868b1306d4e25c4567929606e4e54 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 9 Nov 2014 17:36:51 +0200 Subject: [PATCH 213/613] Fix diameter --- src/data-structures/binary-search-tree.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 5e2df746..718f96f8 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -301,7 +301,7 @@ BinaryTree.prototype.isBalanced = function () { * @returns {Number} The longest path in the BST */ BinaryTree.prototype.getDiameter = function () { - function getDiameter(root) { + var getDiameter = function (root) { if (!root) { return 0; } @@ -309,8 +309,7 @@ BinaryTree.prototype.getDiameter = function () { rightHeight = this._getHeight(root._right), path = leftHeight + rightHeight + 1; return Math.max(path, Math.max(getDiameter(root._left), getDiameter(root._right))); - } - getDiameter = getDiameter.bind(this); + }.bind(this); return getDiameter(this._root); }; From d722f9d7a6f767d735cf65351cd6c3bfc1c7089b Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 10 Nov 2014 16:32:23 +0200 Subject: [PATCH 214/613] Minor change in lss --- .../longest-increasing-subsequence.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js index 5a1084bb..b71111bc 100644 --- a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js +++ b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js @@ -103,4 +103,4 @@ }; })(); -}(typeof exports === 'undefined' ? exports : this)); \ No newline at end of file +}(typeof exports === 'undefined' ? exports : this)); From 8860d200cc8de8fac38d1c68cfb67b758f8e6b9f Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 10 Nov 2014 17:47:11 +0200 Subject: [PATCH 215/613] Add newline --- src/combinatorics/combinations.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/combinatorics/combinations.js b/src/combinatorics/combinations.js index 72e352a1..69595629 100644 --- a/src/combinatorics/combinations.js +++ b/src/combinatorics/combinations.js @@ -1,5 +1,6 @@ (function (exports) { 'use strict'; + var combinations = (function () { var res = []; From e4a7e2d93b0eadac96a5f48d705ff78118a5b526 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 11 Nov 2014 22:51:35 +0200 Subject: [PATCH 216/613] Update permutations & combinations --- src/combinatorics/combinations.js | 5 ++++- src/combinatorics/permutations.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/combinatorics/combinations.js b/src/combinatorics/combinations.js index 69595629..fbd5fa3f 100644 --- a/src/combinatorics/combinations.js +++ b/src/combinatorics/combinations.js @@ -18,7 +18,10 @@ return function (arr, k) { res = []; combinations(arr, k, 0, 0, []); - return res; + var temp = res; + // Free the extra memory + res = null; + return temp; }; }()); diff --git a/src/combinatorics/permutations.js b/src/combinatorics/permutations.js index e6d9742b..4430e33a 100644 --- a/src/combinatorics/permutations.js +++ b/src/combinatorics/permutations.js @@ -32,7 +32,10 @@ return function (arr) { res = []; permutations(arr, 0); - return res; + var temp = res; + // Free the extra memory + res = null; + return temp; }; }()); From 861829549d597cb4ab4500fc5f029da0594b51ff Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 12 Nov 2014 18:35:20 +0200 Subject: [PATCH 217/613] Update Dijkstra's algorithm --- src/graphs/shortest-path/dijkstra.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index 638237e8..d0075990 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -1,12 +1,12 @@ /*********************************************** A sample distance matrix -var graph = [[NaN, 7, 9, NaN, NaN, 16], - [7, NaN, 10, 15, NaN, NaN], - [9, 10, NaN, 11, NaN, 2], - [NaN, 15, 11, NaN, 6, NaN], - [NaN, NaN, NaN, 6, NaN, 9], - [16, NaN, 2, NaN, 9, NaN]]; +var graph = [[Infinity, 7, 9, Infinity, Infinity, 16], + [7, Infinity, 10, 15, Infinity, Infinity], + [9, 10, Infinity, 11, Infinity, 2], + [Infinity, 15, 11, Infinity, 6, Infinity], + [Infinity, Infinity, Infinity, 6, Infinity, 9], + [16, Infinity, 2, Infinity, 9, Infinity]]; ***********************************************/ @@ -96,7 +96,7 @@ var dijstra = function () { for (var i = 0; i < graph.length; i += 1) { if (current.node !== i && //if it's not the current node !visited[i] && //and if we haven't visited this node - !isNaN(graph[i][current.node])) { //and this node is sibling of the current... + Number.isFinite(graph[i][current.node])) { //and this node is sibling of the current... tempDistance = current.distance + graph[i][current.node]; if (tempDistance < distance[i].distance) { From 3ff7445955c4742110adcb836ddb5ddf297f78b6 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 13 Nov 2014 13:12:04 +0200 Subject: [PATCH 218/613] Update bfs --- src/graphs/searching/bfs.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/graphs/searching/bfs.js b/src/graphs/searching/bfs.js index 6b40f3e0..3e87b591 100644 --- a/src/graphs/searching/bfs.js +++ b/src/graphs/searching/bfs.js @@ -126,6 +126,10 @@ } } } + visited = null; + queue = null; + target = -1; + graph = null; return false; }; }()); From 69defd78f8196bb722ec9c0f2eea9da4a32b5b4a Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 14 Nov 2014 10:26:06 +0200 Subject: [PATCH 219/613] Add cartesian product --- src/combinatorics/cartesianproduct.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/combinatorics/cartesianproduct.js diff --git a/src/combinatorics/cartesianproduct.js b/src/combinatorics/cartesianproduct.js new file mode 100644 index 00000000..adc1d4d6 --- /dev/null +++ b/src/combinatorics/cartesianproduct.js @@ -0,0 +1,23 @@ +var cartesianProduct = (function () { + 'use strict'; + var result; + + function cartesianProduct(sets, index, current) { + if (index === sets.length) { + return result.push(current.slice()); + } + for (var i = 0; i < sets[index].length; i += 1) { + current[index] = sets[index][i]; + cartesianProduct(sets, index + 1, current); + } + } + + return function (sets) { + result = []; + cartesianProduct(sets, 0, []); + return result; + }; +}()); + +// console.log([[1, 2],[3, 4],[5, 6],[7, 8]]); +// console.log(cartesianProduct([[1, 2],[3, 4],[5, 6],[7, 8]])); From 9639809d4bfa0b4f53b9678051399cec9c3235ea Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 15 Nov 2014 18:59:56 +0200 Subject: [PATCH 220/613] Add Knuth-Morris-Pratt algorithm --- .../knuth-morris-pratt/knuth-morris-pratt.js | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/searching/knuth-morris-pratt/knuth-morris-pratt.js diff --git a/src/searching/knuth-morris-pratt/knuth-morris-pratt.js b/src/searching/knuth-morris-pratt/knuth-morris-pratt.js new file mode 100644 index 00000000..cae4b4a4 --- /dev/null +++ b/src/searching/knuth-morris-pratt/knuth-morris-pratt.js @@ -0,0 +1,47 @@ +var kmp = (function () { + 'use strict'; + function builtKMPTable(str) { + var res = [], + len, front, end, found; + for (var i = 1; i <= str.length; i += 1) { + front = Math.max(1, i - ((res[i - 2] || 0) + 1)); + end = Math.min(i - 1, (res[i - 2] || 0) + 1); + found = false; + len = 0; + while (end >= 1 && front <= i && !found) { + if (str.substring(0, end) === str.substring(front, i)) { + found = true; + len = end; + } else { + end -= 1; + front += 1; + } + } + res[i - 1] = len; + } + return res; + } + + function indexOf(str, substr) { + var table = builtKMPTable(substr), + i = 0, j = 0; + while (i < str.length) { + if (str[i] === substr[j]) { + i += 1; + j += 1; + } + if (j === substr.length) { + return i - j; + } + if (i < str.length && str[i] !== substr[j]) { + if (table[j - 1] !== 0) { + j = table[j - 1]; + } else { + i += 1; + } + } + } + return -1; + } + return indexOf; +}()); \ No newline at end of file From aa667f1c6205dcc16a213d743e3a1657b69ee453 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 15 Nov 2014 19:01:31 +0200 Subject: [PATCH 221/613] Update Knuth-Morris-Pratt --- .../knuth-morris-pratt/knuth-morris-pratt.js | 82 ++++++++++--------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/src/searching/knuth-morris-pratt/knuth-morris-pratt.js b/src/searching/knuth-morris-pratt/knuth-morris-pratt.js index cae4b4a4..83d02abb 100644 --- a/src/searching/knuth-morris-pratt/knuth-morris-pratt.js +++ b/src/searching/knuth-morris-pratt/knuth-morris-pratt.js @@ -1,47 +1,53 @@ -var kmp = (function () { +(function (exports) { 'use strict'; - function builtKMPTable(str) { - var res = [], - len, front, end, found; - for (var i = 1; i <= str.length; i += 1) { - front = Math.max(1, i - ((res[i - 2] || 0) + 1)); - end = Math.min(i - 1, (res[i - 2] || 0) + 1); - found = false; - len = 0; - while (end >= 1 && front <= i && !found) { - if (str.substring(0, end) === str.substring(front, i)) { - found = true; - len = end; - } else { - end -= 1; - front += 1; + + var kmp = (function () { + function builtKMPTable(str) { + var res = [], + len, front, end, found; + for (var i = 1; i <= str.length; i += 1) { + front = Math.max(1, i - ((res[i - 2] || 0) + 1)); + end = Math.min(i - 1, (res[i - 2] || 0) + 1); + found = false; + len = 0; + while (end >= 1 && front <= i && !found) { + if (str.substring(0, end) === str.substring(front, i)) { + found = true; + len = end; + } else { + end -= 1; + front += 1; + } } + res[i - 1] = len; } - res[i - 1] = len; + return res; } - return res; - } - function indexOf(str, substr) { - var table = builtKMPTable(substr), - i = 0, j = 0; - while (i < str.length) { - if (str[i] === substr[j]) { - i += 1; - j += 1; - } - if (j === substr.length) { - return i - j; - } - if (i < str.length && str[i] !== substr[j]) { - if (table[j - 1] !== 0) { - j = table[j - 1]; - } else { + function indexOf(str, substr) { + var table = builtKMPTable(substr), + i = 0, j = 0; + while (i < str.length) { + if (str[i] === substr[j]) { i += 1; + j += 1; + } + if (j === substr.length) { + return i - j; + } + if (i < str.length && str[i] !== substr[j]) { + if (table[j - 1] !== 0) { + j = table[j - 1]; + } else { + i += 1; + } } } + return -1; } - return -1; - } - return indexOf; -}()); \ No newline at end of file + return indexOf; + }()); + + exports.kmp = kmp; + +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file From 011d0e4d2065273cbc8acd460f11c7f05bc05243 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 16 Nov 2014 16:37:50 +0200 Subject: [PATCH 222/613] Add basic suffix tree --- src/data-structures/suffix-tree.js | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/data-structures/suffix-tree.js diff --git a/src/data-structures/suffix-tree.js b/src/data-structures/suffix-tree.js new file mode 100644 index 00000000..ec896e1f --- /dev/null +++ b/src/data-structures/suffix-tree.js @@ -0,0 +1,52 @@ +function Node(value) { + this.value = value; + this.nodes = []; + this.leaves = []; +} + +function SuffixTree() { + this.root = new Node(''); +} + +SuffixTree.prototype.addNode = (function () { + + function addNode(suffix, current) { + var n, l; + for (var i = 0; i < current.nodes.length; i += 1) { + n = current.nodes[i]; + if (n.value === suffix[0]) { + addNode(suffix.substr(1, suffix.length), n); + return; + } + } + for (i = 0; i < current.leaves.length; i += 1) { + l = current.leaves[i]; + if (l[0] === suffix[0]) { + var prefix = l[0]; + n = new Node(prefix); + current.nodes.push(n); + current.leaves.splice(current.leaves.indexOf(l), 1); + l = l.substr(1, l.length); + suffix = suffix.substr(1, suffix.length); + addNode(l, n); + addNode(suffix, n); + return; + } + } + current.leaves.push(suffix); + } + + return function (suffix) { + addNode(suffix, this.root); + }; +}()); + +SuffixTree.prototype.build = function (string) { + for (var i = 0; i < string.length; i += 1) { + this.addNode(string.substr(i, string.length)); + } +}; + +// var suffix = new SuffixTree(); +// suffix.build('banana'); +// console.log(suffix); \ No newline at end of file From fec295f7cae244b3cd6bd8eaa791cd54c4d8dba2 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 16 Nov 2014 16:39:44 +0200 Subject: [PATCH 223/613] Add todos for the suffix tree --- src/data-structures/suffix-tree.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/data-structures/suffix-tree.js b/src/data-structures/suffix-tree.js index ec896e1f..bd104456 100644 --- a/src/data-structures/suffix-tree.js +++ b/src/data-structures/suffix-tree.js @@ -1,3 +1,10 @@ +// TODO +// 1) The algorithm is quite ineffective, better use +// Ukkomen's algorithm to build it in O(n) complexity. +// 2) Refactor the code in order to make addNode more readable. +// 3) Add methods `addLeaf`, `addNode` to the suffix tree node, +// it should be responsible for knowing it's internal representation. +// 4) etc... function Node(value) { this.value = value; this.nodes = []; From 763941141e95bb19b1b38772e8f0aef21d0becae Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 17 Nov 2014 14:30:30 +0200 Subject: [PATCH 224/613] Update the suffix tree representation --- src/data-structures/suffix-tree.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/data-structures/suffix-tree.js b/src/data-structures/suffix-tree.js index bd104456..6f7b3d47 100644 --- a/src/data-structures/suffix-tree.js +++ b/src/data-structures/suffix-tree.js @@ -7,7 +7,7 @@ // 4) etc... function Node(value) { this.value = value; - this.nodes = []; + this.nodes = {}; this.leaves = []; } @@ -19,8 +19,9 @@ SuffixTree.prototype.addNode = (function () { function addNode(suffix, current) { var n, l; - for (var i = 0; i < current.nodes.length; i += 1) { - n = current.nodes[i]; + var nodes = Object.keys(current.nodes); + for (var i = 0; i < nodes.length; i += 1) { + n = nodes[i]; if (n.value === suffix[0]) { addNode(suffix.substr(1, suffix.length), n); return; @@ -31,7 +32,7 @@ SuffixTree.prototype.addNode = (function () { if (l[0] === suffix[0]) { var prefix = l[0]; n = new Node(prefix); - current.nodes.push(n); + current.nodes[l[0]] = n; current.leaves.splice(current.leaves.indexOf(l), 1); l = l.substr(1, l.length); suffix = suffix.substr(1, suffix.length); @@ -54,6 +55,21 @@ SuffixTree.prototype.build = function (string) { } }; + +// function isSubstr(tree, str) { +// if (str.length === 0) { +// return true; +// } +// var l = tree.leaves.filter(function (l) { +// return l.indexOf(str) >= 0; +// }); +// if (l.length > 0) return true; +// if (!tree.nodes[str[0]]) { +// return false; +// } +// return isSubstr(tree.nodes[str[0]], str.substr(1, str.length)); +// } +// // var suffix = new SuffixTree(); // suffix.build('banana'); // console.log(suffix); \ No newline at end of file From 0dd195ce93c2b590a61ecca161f56428e4c351df Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 17 Nov 2014 15:46:43 +0200 Subject: [PATCH 225/613] Fix the suffix tree implementation --- src/data-structures/suffix-tree.js | 102 +++++++++++++++++------------ 1 file changed, 60 insertions(+), 42 deletions(-) diff --git a/src/data-structures/suffix-tree.js b/src/data-structures/suffix-tree.js index 6f7b3d47..66f9f690 100644 --- a/src/data-structures/suffix-tree.js +++ b/src/data-structures/suffix-tree.js @@ -5,71 +5,89 @@ // 3) Add methods `addLeaf`, `addNode` to the suffix tree node, // it should be responsible for knowing it's internal representation. // 4) etc... -function Node(value) { - this.value = value; +function Node(val) { + this.value = val; this.nodes = {}; - this.leaves = []; } function SuffixTree() { - this.root = new Node(''); + this.root = new Node(); } SuffixTree.prototype.addNode = (function () { - function addNode(suffix, current) { - var n, l; - var nodes = Object.keys(current.nodes); - for (var i = 0; i < nodes.length; i += 1) { - n = nodes[i]; - if (n.value === suffix[0]) { - addNode(suffix.substr(1, suffix.length), n); - return; + function maxPrefix(a, b) { + var res = []; + for (var i = 0; i < Math.min(a.length, b.length); i += 1) { + if (a[i] === b[i]) { + res.push(a[i]); + } else { + return ''; } } - for (i = 0; i < current.leaves.length; i += 1) { - l = current.leaves[i]; - if (l[0] === suffix[0]) { - var prefix = l[0]; - n = new Node(prefix); - current.nodes[l[0]] = n; - current.leaves.splice(current.leaves.indexOf(l), 1); - l = l.substr(1, l.length); - suffix = suffix.substr(1, suffix.length); - addNode(l, n); - addNode(suffix, n); - return; - } + return res.join(''); + } + + function addNode(suffix, current) { + if (!suffix) { + return; + } + if (current.value === suffix) { + return; + } + if (current.nodes[suffix[0]]) { + return addNode(suffix.substr(1, suffix.length), current.nodes[suffix[0]]); + } + var prefix = maxPrefix(current.value, suffix); + console.log(prefix, current.value, suffix); + if (prefix.length) { + console.log('recursive, prefix:', prefix, current.value, suffix); + var temp = current.value; + var suffixSuffix = suffix.substr(prefix.length, suffix.length); + var currentSuffix = temp.substr(prefix.length, temp.length); + current.value = prefix; + addNode(currentSuffix, current); + addNode(suffixSuffix, current); + } else { + current.nodes[suffix[0]] = new Node(suffix); } - current.leaves.push(suffix); } - + return function (suffix) { addNode(suffix, this.root); }; }()); SuffixTree.prototype.build = function (string) { - for (var i = 0; i < string.length; i += 1) { + this.root.value = string; + for (var i = 1; i < string.length; i += 1) { this.addNode(string.substr(i, string.length)); + console.log(JSON.stringify(this.root)); } }; -// function isSubstr(tree, str) { -// if (str.length === 0) { -// return true; -// } -// var l = tree.leaves.filter(function (l) { -// return l.indexOf(str) >= 0; -// }); -// if (l.length > 0) return true; -// if (!tree.nodes[str[0]]) { -// return false; -// } -// return isSubstr(tree.nodes[str[0]], str.substr(1, str.length)); -// } -// +function isSubstr(tree, str) { + if (!tree) { + return false; + } + if (tree.nodes[str[0]]) { + return isSubstr(tree, str.substr(1, str.length)); + } + var match = ''; + for (var i = 0; i < Math.min(tree.value.length, str.length); i += 1) { + if (tree.value[i] === str[i]) { + match += str[i]; + } else { + break; + } + } + if (match.length === str.length) { + return true; + } + return false; +} + // var suffix = new SuffixTree(); // suffix.build('banana'); // console.log(suffix); \ No newline at end of file From eab77eeb50ef3ff252adff7d1070858f4607de9a Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 17 Nov 2014 15:47:11 +0200 Subject: [PATCH 226/613] Remove useless logs --- src/data-structures/suffix-tree.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/data-structures/suffix-tree.js b/src/data-structures/suffix-tree.js index 66f9f690..b9588fb4 100644 --- a/src/data-structures/suffix-tree.js +++ b/src/data-structures/suffix-tree.js @@ -39,9 +39,7 @@ SuffixTree.prototype.addNode = (function () { return addNode(suffix.substr(1, suffix.length), current.nodes[suffix[0]]); } var prefix = maxPrefix(current.value, suffix); - console.log(prefix, current.value, suffix); if (prefix.length) { - console.log('recursive, prefix:', prefix, current.value, suffix); var temp = current.value; var suffixSuffix = suffix.substr(prefix.length, suffix.length); var currentSuffix = temp.substr(prefix.length, temp.length); @@ -62,7 +60,6 @@ SuffixTree.prototype.build = function (string) { this.root.value = string; for (var i = 1; i < string.length; i += 1) { this.addNode(string.substr(i, string.length)); - console.log(JSON.stringify(this.root)); } }; From 4010a698d89a2c5aae54fa391d138786c44b56bc Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 17 Nov 2014 15:49:22 +0200 Subject: [PATCH 227/613] Add comment about the complexity of the build method --- src/data-structures/suffix-tree.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/data-structures/suffix-tree.js b/src/data-structures/suffix-tree.js index b9588fb4..661b1c48 100644 --- a/src/data-structures/suffix-tree.js +++ b/src/data-structures/suffix-tree.js @@ -56,6 +56,7 @@ SuffixTree.prototype.addNode = (function () { }; }()); +// O(n^2) or even O(n^3) because of maxPrefix SuffixTree.prototype.build = function (string) { this.root.value = string; for (var i = 1; i < string.length; i += 1) { From 7d2d21cb211f040add25380de876715e65db7126 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 17 Nov 2014 15:52:43 +0200 Subject: [PATCH 228/613] Add additional comments --- src/data-structures/suffix-tree.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/data-structures/suffix-tree.js b/src/data-structures/suffix-tree.js index 661b1c48..7c01c68f 100644 --- a/src/data-structures/suffix-tree.js +++ b/src/data-structures/suffix-tree.js @@ -1,10 +1,6 @@ // TODO // 1) The algorithm is quite ineffective, better use // Ukkomen's algorithm to build it in O(n) complexity. -// 2) Refactor the code in order to make addNode more readable. -// 3) Add methods `addLeaf`, `addNode` to the suffix tree node, -// it should be responsible for knowing it's internal representation. -// 4) etc... function Node(val) { this.value = val; this.nodes = {}; @@ -29,23 +25,28 @@ SuffixTree.prototype.addNode = (function () { } function addNode(suffix, current) { + // Empty string already exists in the suffix tree if (!suffix) { return; } + // The suffix is already inside the tree if (current.value === suffix) { return; } + // Insert recursively if (current.nodes[suffix[0]]) { return addNode(suffix.substr(1, suffix.length), current.nodes[suffix[0]]); } + // Find the maximum prefix and split the current node if prefix exists var prefix = maxPrefix(current.value, suffix); if (prefix.length) { - var temp = current.value; - var suffixSuffix = suffix.substr(prefix.length, suffix.length); - var currentSuffix = temp.substr(prefix.length, temp.length); + var temp = current.value, + suffixSuffix = suffix.substr(prefix.length, suffix.length), + currentSuffix = temp.substr(prefix.length, temp.length); current.value = prefix; addNode(currentSuffix, current); addNode(suffixSuffix, current); + // If prefix doesn't exists add new child node } else { current.nodes[suffix[0]] = new Node(suffix); } From d33ee89dcd59d6e254561a9a3e9c847580037c39 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 18 Nov 2014 17:16:28 +0200 Subject: [PATCH 229/613] Update suffix tree --- src/data-structures/suffix-tree.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/data-structures/suffix-tree.js b/src/data-structures/suffix-tree.js index 7c01c68f..b769fb27 100644 --- a/src/data-structures/suffix-tree.js +++ b/src/data-structures/suffix-tree.js @@ -89,4 +89,8 @@ function isSubstr(tree, str) { // var suffix = new SuffixTree(); // suffix.build('banana'); -// console.log(suffix); \ No newline at end of file +// console.log(suffix); + +var st = new SuffixTree(); +st.build('Since these cases are very common use cases, the problem was easily solved by choosing either a random index for the pivot, choosing the middle index of the partition or (especially for longer partitions) choosing the median of the first, middle and last element of the partition for the pivot. With these modifications, the worst case of Quick sort has less chances to occur, but worst case can still occur if the input array is such that the maximum (or minimum) element is always chosen as pivot.'); +console.log(JSON.stringify(st)); \ No newline at end of file From b1a892f8a573e65dece9eabbc23b40c7ec390e2d Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 18 Nov 2014 17:20:43 +0200 Subject: [PATCH 230/613] Add variations with repetions --- src/combinatorics/variations-repetion.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/combinatorics/variations-repetion.js diff --git a/src/combinatorics/variations-repetion.js b/src/combinatorics/variations-repetion.js new file mode 100644 index 00000000..a545038d --- /dev/null +++ b/src/combinatorics/variations-repetion.js @@ -0,0 +1,24 @@ +var variationsWithRepetion = (function () { + 'use strict'; + + var res; + + function variations(arr, k, index, current) { + if (k === index) { + return res.push(current.slice()); + } + for (var i = 0; i < arr.length; i += 1) { + current[index] = arr[i]; + variations(arr, k, index + 1, current); + } + } + + return function (arr, k) { + res = []; + variations(arr, k, 0, []); + var temp = res; + res = undefined; + return temp; + }; +}()); + From 21987d59c3f3156396eb6bc1309530494f9663a8 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 19 Nov 2014 15:30:49 +0200 Subject: [PATCH 231/613] Add Bellman-Ford --- src/graphs/shortest-path/bellman-ford.js | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/graphs/shortest-path/bellman-ford.js diff --git a/src/graphs/shortest-path/bellman-ford.js b/src/graphs/shortest-path/bellman-ford.js new file mode 100644 index 00000000..b5d80939 --- /dev/null +++ b/src/graphs/shortest-path/bellman-ford.js @@ -0,0 +1,57 @@ +(function (global) { + 'use strict'; + + function Edge(u, v, weight) { + this.from = u; + this.to = v; + this.weight = weight; + } + + // Complexity O(|V||E|) + function bellmanFord(vertexes, edges, source) { + var distances = {}, parents = {}, c; + for (var i = 0; i < vertexes.length; i += 1) { + distances[vertexes[i]] = Infinity; + parents[vertexes[i]] = null; + } + distances[source] = 0; + for (i = 0; i < vertexes.length - 1; i += 1) { + for (var j = 0; j < edges.length; j += 1) { + c = edges[j]; + if (distances[c.from] + c.weight < distances[c.to]) { + distances[c.to] = distances[c.from] + c.weight; + parents[c.to] = c.from; + } + } + } + + for (i = 0; i < edges.length; i += 1) { + c = edges[i]; + if (distances[c.from] + c.weight < distances[c.to]) { + return undefined; + } + } + + return { parents: parents, distances: distances }; + } + + global.Edge = Edge; + global.bellmanFord = bellmanFord; + +}((typeof window === 'undefined') ? global : window)); + +// var glob = (typeof window === 'undefined') ? global : window; +// var Edge = glob.Edge; +// var bellmanFord = glob.bellmanFord; +// var edges = []; +// var vertexes = [0, 1, 2, 3, 4]; +// edges.push(new Edge(0, 1, -1)); +// edges.push(new Edge(0, 2, 4)); +// edges.push(new Edge(1, 2, 3)); +// edges.push(new Edge(1, 3, 2)); +// edges.push(new Edge(3, 1, 1)); +// edges.push(new Edge(4, 3, -3)); +// edges.push(new Edge(1, 4, 2)); +// edges.push(new Edge(3, 2, 5)); +// +// console.log(bellmanFord(vertexes, edges, 0)); From 89c992b74a72635bb8bf900ed7a846162b0b6a69 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 20 Nov 2014 17:05:07 +0200 Subject: [PATCH 232/613] Update shuffling --- src/shuffle/richarddurstenfeld.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/shuffle/richarddurstenfeld.js b/src/shuffle/richarddurstenfeld.js index 26d507e3..f9b83f0f 100644 --- a/src/shuffle/richarddurstenfeld.js +++ b/src/shuffle/richarddurstenfeld.js @@ -4,8 +4,6 @@ * algorithm and is introduced by Richard Durstenfeld. */ -var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - /** * Shuffles an array. Complexity O(n). * @@ -13,15 +11,14 @@ var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; * @returns {array} Shuffled array */ function shuffle(array) { - var arraySize = array.length - 1, - rand, temp; - for (var i = arraySize; i >= 0; i -= 1) { - rand = Math.round(Math.random() * arraySize); - temp = array[i]; - array[i] = array[rand]; - array[rand] = temp; - } - return array; + 'use strict'; + var arraySize = array.length - 1, + rand, temp; + for (var i = arraySize; i >= 0; i -= 1) { + rand = Math.round(Math.random() * arraySize); + temp = array[i]; + array[i] = array[rand]; + array[rand] = temp; + } + return array; } - -console.log(shuffle(array)); From 3575bb486cbf7fe42dd969eb6954f29ee3086248 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 20 Nov 2014 17:06:02 +0200 Subject: [PATCH 233/613] Add use strict to fisher yates algorithm --- src/shuffle/fisheryates.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/shuffle/fisheryates.js b/src/shuffle/fisheryates.js index 54032dc4..d51e6b7f 100644 --- a/src/shuffle/fisheryates.js +++ b/src/shuffle/fisheryates.js @@ -6,6 +6,7 @@ * @return {array} The shuffled array. */ function shuffle(array) { + 'use strict'; var size = array.length, rand, temp; for (var i = 1; i < size; i += 1) { @@ -17,6 +18,3 @@ function shuffle(array) { return array; } -//var array = [1,2,3,4,5,6,7,8,9]; -//console.log(array); -//console.log(shuffle(array)); From b5915b6450ff2fd867f02ed3bb3cee6b2bef2f9c Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 24 Nov 2014 12:26:23 +0200 Subject: [PATCH 234/613] Fix the indentation of Prim's algorithm --- src/graphs/spanning-trees/prim.js | 115 +++++++++++++++--------------- 1 file changed, 59 insertions(+), 56 deletions(-) diff --git a/src/graphs/spanning-trees/prim.js b/src/graphs/spanning-trees/prim.js index ea5e8b85..901761db 100644 --- a/src/graphs/spanning-trees/prim.js +++ b/src/graphs/spanning-trees/prim.js @@ -8,7 +8,8 @@ var Heap = require('../../data-structures/heap').Heap; * @param {number} id The id of the vertex */ function Vertex(id) { - this.id = id; + 'use strict'; + this.id = id; } /** @@ -21,9 +22,10 @@ function Vertex(id) { * @param {number} distance Weight of the node */ function Edge(e, v, distance) { - this.e = e; - this.v = v; - this.distance = distance; + 'use strict'; + this.e = e; + this.v = v; + this.distance = distance; } /** @@ -33,8 +35,8 @@ function Edge(e, v, distance) { * @public */ function Graph(edges) { - console.log(edges); - this.edges = edges || []; + 'use strict'; + this.edges = edges || []; } /** @@ -44,58 +46,59 @@ function Graph(edges) { * @return {Graph} Graph which is the minimum spanning tree */ Graph.prototype.prim = (function () { - - var queue; - - /** - * Initialize the algorithm. - * - * @private - */ - function init() { - queue = new Heap(compareEdges); - this.edges.forEach(function (e) { - queue.add(e); - }); - } - - /** - * Used for comparitions in the heap - * - * @private - * @param {Vertex} a First operand of the comparition - * @param {Vertex} b Second operand of the comparition - * @return {number} Number which which is equal, greater or less then zero and - * indicates whether the first vertex is "greater" than the second. - */ - function compareEdges(a, b) { - return b.distance - a.distance; - } - - /** - * Prim's algorithm implementation - * - * @public - * @return {Graph} Minimum spanning tree. - */ - return function () { - init.call(this); - var inTheTree = {}, - current = queue.extract(), - spannigTree = []; + 'use strict'; + + var queue; + + /** + * Initialize the algorithm. + * + * @private + */ + function init() { + queue = new Heap(compareEdges); + this.edges.forEach(function (e) { + queue.add(e); + }); + } + + /** + * Used for comparitions in the heap + * + * @private + * @param {Vertex} a First operand of the comparition + * @param {Vertex} b Second operand of the comparition + * @return {number} Number which which is equal, greater or less then zero and + * indicates whether the first vertex is "greater" than the second. + */ + function compareEdges(a, b) { + return b.distance - a.distance; + } + + /** + * Prim's algorithm implementation + * + * @public + * @return {Graph} Minimum spanning tree. + */ + return function () { + init.call(this); + var inTheTree = {}, + current = queue.extract(), + spannigTree = []; + spannigTree.push(current); + inTheTree[current.e.id] = true; + while (queue.isEmpty()) { + current = queue.extract(); + if (!inTheTree[current.v.id] || + !inTheTree[current.e.id]) { spannigTree.push(current); inTheTree[current.e.id] = true; - while (queue.isEmpty()) { - current = queue.extract(); - if (!inTheTree[current.v.id] || - !inTheTree[current.e.id]) { - spannigTree.push(current); - inTheTree[current.e.id] = true; - inTheTree[current.v.id] = true; - } - } - return new Graph(spannigTree); - }; + inTheTree[current.v.id] = true; + } + } + return new Graph(spannigTree); + }; }()); From 9a53c98884d2bf2f3288a9203201aa86c7e74805 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 24 Nov 2014 13:05:26 +0200 Subject: [PATCH 235/613] Fix the liniting of the Heap --- src/data-structures/heap.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index 0572baab..c7a4c89e 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -1,4 +1,5 @@ (function (exports) { + 'use strict'; /** * Constructor function of minimum heap @@ -20,7 +21,8 @@ /** * Exchange indexes with start index given as argument * to turn the tree into a valid heap. On a single call - * this method maintains only a single "branch" of the heap. Complexity O(log n) + * this method maintains only a single "branch" of the heap. + * Complexity O(log n) * * @private * @param {number} index The parent @@ -31,11 +33,15 @@ right = 2 * index + 2, temp; - if (left < this._heap.length && this._cmp(this._heap[left], this._heap[index]) > 0) + if (left < this._heap.length && + this._cmp(this._heap[left], this._heap[index]) > 0) { extr = left; + } - if (right < this._heap.length && this._cmp(this._heap[right], this._heap[index]) > 0) + if (right < this._heap.length && + this._cmp(this._heap[right], this._heap[index]) > 0) { extr = right; + } if (index !== extr) { temp = this._heap[index]; @@ -54,6 +60,7 @@ * @returns {number} parent The new position of the element */ Heap.prototype.changeKey = function (index, value) { + this._heap[index] = value; var elem = this._heap[index], parent = Math.floor(index / 2), temp; @@ -92,21 +99,27 @@ }; /** - * Removes and returns the current extremum value which is on the top of the heap. + * Removes and returns the current extremum value + * which is on the top of the heap. * Complexity O(log n). * * @public * @returns {number} The extremum value */ Heap.prototype.extract = function () { - if (!this._heap.length) + if (!this._heap.length) { throw 'The heap is already empty!'; + } var extr = this._heap.shift(); this._heapify(0); return extr; }; + Heap.prototype.getCollection = function () { + return this._heap; + }; + Heap.prototype.isEmpty = function () { return !this._heap.length; }; From 9d899933023bc229f799cb0e27cdf9d68b06acc8 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 24 Nov 2014 13:47:18 +0200 Subject: [PATCH 236/613] Fix the Prim's MST algorithm --- src/graphs/spanning-trees/prim.js | 153 +++++++++++++++--------------- 1 file changed, 74 insertions(+), 79 deletions(-) diff --git a/src/graphs/spanning-trees/prim.js b/src/graphs/spanning-trees/prim.js index 901761db..6e088852 100644 --- a/src/graphs/spanning-trees/prim.js +++ b/src/graphs/spanning-trees/prim.js @@ -34,9 +34,10 @@ function Edge(e, v, distance) { * @constructor * @public */ -function Graph(edges) { +function Graph(edges, nodesCount) { 'use strict'; this.edges = edges || []; + this.nodesCount = nodesCount || 0; } /** @@ -57,9 +58,6 @@ Graph.prototype.prim = (function () { */ function init() { queue = new Heap(compareEdges); - this.edges.forEach(function (e) { - queue.add(e); - }); } /** @@ -84,18 +82,57 @@ Graph.prototype.prim = (function () { return function () { init.call(this); var inTheTree = {}, - current = queue.extract(), - spannigTree = []; - spannigTree.push(current); - inTheTree[current.e.id] = true; - while (queue.isEmpty()) { - current = queue.extract(); - if (!inTheTree[current.v.id] || - !inTheTree[current.e.id]) { - spannigTree.push(current); - inTheTree[current.e.id] = true; - inTheTree[current.v.id] = true; - } + startVertex = this.edges[0].e.id, + spannigTree = [], + parents = {}, + distances = {}, + current; + inTheTree[startVertex] = true; + queue.add({ + node: startVertex, + distance: 0 + }); + for (var i = 0; i < this.nodesCount - 1; i += 1) { + current = queue.extract().node; + inTheTree[current] = true; + this.edges.forEach(function (e) { + if (inTheTree[e.v.id] && inTheTree[e.e.id]) { + return; + } + var collection = queue.getCollection(), + node; + if (e.e.id === current) { + node = e.v.id; + } else if (e.v.id === current) { + node = e.e.id; + } else { + return; + } + for (var i = 0; i < collection.length; i += 1) { + if (collection[i].node === node) { + if (collection[i].distance > e.distance) { + queue.changeKey(i, { + node: node, + distance: e.distance + }); + parents[node] = current; + distances[node] = e.distance; + } + return; + } + } + queue.add({ + node: node, + distance: e.distance + }); + parents[node] = current; + distances[node] = e.distance; + }); + console.log(queue._heap); + console.log(); + } + for (var node in parents) { + spannigTree.push(new Edge(node, parents[node], distances[node])); } return new Graph(spannigTree); }; @@ -104,71 +141,29 @@ Graph.prototype.prim = (function () { /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Sample graph * * * * * * * * * * * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -var graph; - (function () { - var edges = []; - - edges.push(new Edge( - new Vertex(0), - new Vertex(1), - 7 - )); - - edges.push(new Edge( - new Vertex(0), - new Vertex(2), - 9 - )); - - edges.push(new Edge( - new Vertex(0), - new Vertex(5), - 16 - )); - - edges.push(new Edge( - new Vertex(1), - new Vertex(2), - 10 - )); - - edges.push(new Edge( - new Vertex(1), - new Vertex(3), - 15 - )); - - edges.push(new Edge( - new Vertex(2), - new Vertex(3), - 11 - )); - - edges.push(new Edge( - new Vertex(2), - new Vertex(5), - 2 - )); - - edges.push(new Edge( - new Vertex(3), - new Vertex(4), - 6 - )); - - edges.push(new Edge( - new Vertex(4), - new Vertex(5), - 9 - )); - - graph = new Graph(edges); - + 'use strict'; + var graph, edges = []; + edges.push(new Edge(new Vertex(0), new Vertex(1), 4)); + edges.push(new Edge(new Vertex(0), new Vertex(7), 8)); + edges.push(new Edge(new Vertex(1), new Vertex(7), 11)); + edges.push(new Edge(new Vertex(1), new Vertex(2), 8)); + edges.push(new Edge(new Vertex(2), new Vertex(8), 2)); + edges.push(new Edge(new Vertex(2), new Vertex(3), 7)); + edges.push(new Edge(new Vertex(2), new Vertex(5), 4)); + edges.push(new Edge(new Vertex(2), new Vertex(3), 7)); + edges.push(new Edge(new Vertex(3), new Vertex(4), 9)); + edges.push(new Edge(new Vertex(3), new Vertex(5), 14)); + edges.push(new Edge(new Vertex(4), new Vertex(5), 10)); + edges.push(new Edge(new Vertex(5), new Vertex(6), 2)); + edges.push(new Edge(new Vertex(6), new Vertex(8), 6)); + edges.push(new Edge(new Vertex(8), new Vertex(7), 7)); + graph = new Graph(edges, 9); + + console.log(graph.prim()); }()); -console.log(graph.prim()); -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ From 006377531678f138209a3b88cfa117661bf1260f Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 24 Nov 2014 14:53:40 +0200 Subject: [PATCH 237/613] Fix in quick union --- src/graphs/searching/weightquickunion.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphs/searching/weightquickunion.js b/src/graphs/searching/weightquickunion.js index 22142ff9..2e19067c 100644 --- a/src/graphs/searching/weightquickunion.js +++ b/src/graphs/searching/weightquickunion.js @@ -23,7 +23,7 @@ function QuickUnion(n) { */ QuickUnion.prototype._root = function (i) { while (i !== this._ids[i]) { -// this._ids = this._ids[this._ids[i]]; //enables the path compression +// this._ids[i] = this._ids[this._ids[i]]; //enables the path compression i = this._ids[i]; } return i; From 863a507891cb9a124abe9d477a3bc95086dc7b3b Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 24 Nov 2014 15:46:16 +0200 Subject: [PATCH 238/613] Move quick find & quick union to a sets folder --- src/{graphs/searching => sets}/quickfind.js | 0 src/{graphs/searching => sets}/quickunion.js | 0 src/{graphs/searching => sets}/weightquickunion.js | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename src/{graphs/searching => sets}/quickfind.js (100%) rename src/{graphs/searching => sets}/quickunion.js (100%) rename src/{graphs/searching => sets}/weightquickunion.js (100%) diff --git a/src/graphs/searching/quickfind.js b/src/sets/quickfind.js similarity index 100% rename from src/graphs/searching/quickfind.js rename to src/sets/quickfind.js diff --git a/src/graphs/searching/quickunion.js b/src/sets/quickunion.js similarity index 100% rename from src/graphs/searching/quickunion.js rename to src/sets/quickunion.js diff --git a/src/graphs/searching/weightquickunion.js b/src/sets/weightquickunion.js similarity index 100% rename from src/graphs/searching/weightquickunion.js rename to src/sets/weightquickunion.js From 6e0da7f847b3f63873a725d918d0a2184a756569 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 25 Nov 2014 22:48:13 +0200 Subject: [PATCH 239/613] Update quick find --- src/sets/quickfind.js | 100 ++++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 48 deletions(-) diff --git a/src/sets/quickfind.js b/src/sets/quickfind.js index 307ed4e8..0b048b1c 100644 --- a/src/sets/quickfind.js +++ b/src/sets/quickfind.js @@ -1,53 +1,57 @@ -/** - * Checks whether there is a path between two nodes. - * The initialization is O(n). - * - * @constructor - * @param {numner} size The count of the nodes - */ -function QuickFind(size) { - this._ids = []; - for (var i = 0; i < size; i += 1) { - this._ids[i] = i; +(function (exports) { + /** + * Checks whether there is a path between two nodes. + * The initialization is O(n). + * + * @constructor + * @param {numner} size The count of the nodes + */ + function QuickFind(size) { + this._ids = []; + for (var i = 0; i < size; i += 1) { + this._ids[i] = i; + } } -} -/** - * Connects two nodes - p and q. - * Complexity O(n). - * - * @param {number} p The first node - * @param {number} q The second node - */ -QuickFind.prototype.union = function (p, q) { - var size = this._ids.length, - pval = this._ids[p], - qval = this._ids[q]; - for (var i = 0; i < size; i += 1) { - if (this._ids[i] === qval) { - this._ids[i] = pval; + /** + * Connects two nodes - p and q. + * Complexity O(n). + * + * @param {number} p The first node + * @param {number} q The second node + */ + QuickFind.prototype.union = function (p, q) { + var size = this._ids.length, + pval = this._ids[p], + qval = this._ids[q]; + for (var i = 0; i < size; i += 1) { + if (this._ids[i] === qval) { + this._ids[i] = pval; + } } - } -}; + }; + + /** + * Checks whether two nodes are connected. + * Complexity O(1). + * + * @param {number} p The first node + * @param {number} q The second node + * + */ + QuickFind.prototype.connected = function (p, q) { + return this._ids[p] === this._ids[q]; + }; -/** - * Checks whether two nodes are connected. - * Complexity O(1). - * - * @param {number} p The first node - * @param {number} q The second node - * - */ -QuickFind.prototype.connected = function (p, q) { - return this._ids[p] === this._ids[q]; -}; + exports.QuickFind = QuickFind; -//var find = new QuickFind(10); -//find.union(0, 1); -//find.union(2, 1); -//find.union(3, 4); -//find.union(8, 9); -//find.union(4, 8); -// -//console.log(find.connected(0, 9)); //expected false -//console.log(find.connected(3, 9)); //expected true + //var find = new QuickFind(10); + //find.union(0, 1); + //find.union(2, 1); + //find.union(3, 4); + //find.union(8, 9); + //find.union(4, 8); + // + //console.log(find.connected(0, 9)); //expected false + //console.log(find.connected(3, 9)); //expected true +}(typeof exports === 'undefined' ? window : exports)); From 3f0494e7e29bdf4576d1a0a45b61cd17c34fc95b Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 25 Nov 2014 22:49:16 +0200 Subject: [PATCH 240/613] Update quickunion --- src/sets/quickunion.js | 115 +++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 56 deletions(-) diff --git a/src/sets/quickunion.js b/src/sets/quickunion.js index bcab5a33..4ff3908a 100644 --- a/src/sets/quickunion.js +++ b/src/sets/quickunion.js @@ -1,61 +1,64 @@ -/** - * Checks whether path between two nodes exists. - * The initialization has O(n) complexity. - * - * @constructor - * @param {number} n Nodes count - * - */ -function QuickUnion(n) { - this._ids = []; - for (var i = 0; i < n; i += 1) { - this._ids[i] = i; +(function (exports) { + /** + * Checks whether path between two nodes exists. + * The initialization has O(n) complexity. + * + * @constructor + * @param {number} n Nodes count + * + */ + function QuickUnion(n) { + this._ids = []; + for (var i = 0; i < n; i += 1) { + this._ids[i] = i; + } } -} -/** - * Finds the root of given node. - * Complexity O(n). - * - * @param {number} i The given node - * @return {number} The root of the given node - */ -QuickUnion.prototype._root = function (i) { - while (i !== this._ids[i]) i = this._ids[i]; - return i; -}; + /** + * Finds the root of given node. + * Complexity O(n). + * + * @param {number} i The given node + * @return {number} The root of the given node + */ + QuickUnion.prototype._root = function (i) { + while (i !== this._ids[i]) i = this._ids[i]; + return i; + }; -/** - * Unions two nodes. - * Complexity O(n). - * - * @param {number} p The first node - * @param {number} q The second node - */ -QuickUnion.prototype.union = function (p, q) { - var pRoot = this._root(p), - qRoot = this._root(q); - this._ids[pRoot] = qRoot; -}; + /** + * Unions two nodes. + * Complexity O(n). + * + * @param {number} p The first node + * @param {number} q The second node + */ + QuickUnion.prototype.union = function (p, q) { + var pRoot = this._root(p), + qRoot = this._root(q); + this._ids[pRoot] = qRoot; + }; -/** - * Checks whether two nodes are connected. - * Complexity O(n). - * - * @param {number} p The first node. - * @param {number} q The second node. - * @return {boolean} True/false depending on whether the nodes are connected. - */ -QuickUnion.prototype.connected = function (p, q) { - return this._root(p) === this._root(q); -}; + /** + * Checks whether two nodes are connected. + * Complexity O(n). + * + * @param {number} p The first node. + * @param {number} q The second node. + * @return {boolean} True/false depending on whether the nodes are connected. + */ + QuickUnion.prototype.connected = function (p, q) { + return this._root(p) === this._root(q); + }; -//var union = new QuickUnion(10); -//union.union(0, 1); -//union.union(2, 1); -//union.union(3, 4); -//union.union(8, 9); -//union.union(4, 8); -// -//console.log(union.connected(0, 9)); //expected false -//console.log(union.connected(3, 9)); //expected true + //var union = new QuickUnion(10); + //union.union(0, 1); + //union.union(2, 1); + //union.union(3, 4); + //union.union(8, 9); + //union.union(4, 8); + // + //console.log(union.connected(0, 9)); //expected false + //console.log(union.connected(3, 9)); //expected true + exports.QuickUnion = QuickUnion; +}(typeof exports === 'undefined' ? window : exports)); From 1020f448b09dd2f7bbf756215ee6eab0b8c3910c Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 25 Nov 2014 22:50:11 +0200 Subject: [PATCH 241/613] Update weight quickunion --- src/sets/weightquickunion.js | 141 ++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 69 deletions(-) diff --git a/src/sets/weightquickunion.js b/src/sets/weightquickunion.js index 2e19067c..cb88c289 100644 --- a/src/sets/weightquickunion.js +++ b/src/sets/weightquickunion.js @@ -1,74 +1,77 @@ -/** - * Checks whether there is a path between two nodes - * Complexity of the initialization O(n). - * - * @constructor - * @param {number} n The nodes count - */ -function QuickUnion(n) { - this._ids = []; - this._size = []; - for (var i = 0; i < n; i += 1) { - this._ids[i] = i; - this._size[i] = 1; +(function (exports) { + /** + * Checks whether there is a path between two nodes + * Complexity of the initialization O(n). + * + * @constructor + * @param {number} n The nodes count + */ + function QuickUnion(n) { + this._ids = []; + this._size = []; + for (var i = 0; i < n; i += 1) { + this._ids[i] = i; + this._size[i] = 1; + } } -} -/** - * Finds the root of given node. - * The complexity is around O(logn) - * - * @param {number} i The given node - * @return {number} The root of the node - */ -QuickUnion.prototype._root = function (i) { - while (i !== this._ids[i]) { -// this._ids[i] = this._ids[this._ids[i]]; //enables the path compression - i = this._ids[i]; - } - return i; -}; + /** + * Finds the root of given node. + * The complexity is around O(logn) + * + * @param {number} i The given node + * @return {number} The root of the node + */ + QuickUnion.prototype._root = function (i) { + while (i !== this._ids[i]) { + // this._ids[i] = this._ids[this._ids[i]]; //enables the path compression + i = this._ids[i]; + } + return i; + }; -/** - * Checks whether two nodes are connected. - * Complexity O(logn) - * - * @param {number} p The first node - * @param {number} q The second node - * @return {boolean} True/false depending on whether the nodes are connected - */ -QuickUnion.prototype.connected = function (p, q) { - return this._root(p) === this._root(q); -}; + /** + * Checks whether two nodes are connected. + * Complexity O(logn) + * + * @param {number} p The first node + * @param {number} q The second node + * @return {boolean} True/false depending on whether the nodes are connected + */ + QuickUnion.prototype.connected = function (p, q) { + return this._root(p) === this._root(q); + }; -/** - * Unions two nodes. - * Complexity O(logn) - * - * @param {number} p The first node - * @param {number} q The second node - */ -QuickUnion.prototype.union = function (p, q) { - var pf = this._root(p); - var qf = this._root(q); - if (pf == qf) return; // already linked - var psz = this._size[qf]; - var qsz = this._size[pf]; - if (psz < qsz) { - this._ids[pf] = qf; - this._size[qf] += psz; - } else { - this._ids[qf] = pf; - this._size[pf] += qsz; - } -}; + /** + * Unions two nodes. + * Complexity O(logn) + * + * @param {number} p The first node + * @param {number} q The second node + */ + QuickUnion.prototype.union = function (p, q) { + var pf = this._root(p); + var qf = this._root(q); + if (pf == qf) return; // already linked + var psz = this._size[qf]; + var qsz = this._size[pf]; + if (psz < qsz) { + this._ids[pf] = qf; + this._size[qf] += psz; + } else { + this._ids[qf] = pf; + this._size[pf] += qsz; + } + }; -//var union = new QuickUnion(10); -//union.union(0, 1); -//union.union(2, 1); -//union.union(3, 4); -//union.union(8, 9); -//union.union(4, 8); -// -//console.log(union.connected(0, 9)); //expected false -//console.log(union.connected(3, 9)); //expected true + //var union = new QuickUnion(10); + //union.union(0, 1); + //union.union(2, 1); + //union.union(3, 4); + //union.union(8, 9); + //union.union(4, 8); + // + //console.log(union.connected(0, 9)); //expected false + //console.log(union.connected(3, 9)); //expected true + exports.QuickUnion = QuickUnion; +}(typeof exports === 'undefined' ? window : exports)); From adb8c011f4b5da9d909cfda0d680e62da18429e7 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 27 Nov 2014 14:35:57 +0200 Subject: [PATCH 242/613] Add towers of Hanoi --- src/others/hanoi.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/others/hanoi.js diff --git a/src/others/hanoi.js b/src/others/hanoi.js new file mode 100644 index 00000000..95ec58ea --- /dev/null +++ b/src/others/hanoi.js @@ -0,0 +1,15 @@ +/* + * Hanoi towers + */ +function hanoi(count, source, intermediate, goal, result) { + 'use strict'; + result = result || []; + if (count === 1) { + result.push([source, goal]); + } else { + hanoi(count - 1, source, goal, intermediate, result); + result.push([source, goal]); + hanoi(count - 1, intermediate, source, goal, result); + } + return result; +} From 1834f40c86d881433ffe5ddc67f27aa1aca4ff86 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 29 Nov 2014 13:31:54 +0200 Subject: [PATCH 243/613] Exports suffix tree --- src/data-structures/suffix-tree.js | 167 +++++++++++++++-------------- 1 file changed, 88 insertions(+), 79 deletions(-) diff --git a/src/data-structures/suffix-tree.js b/src/data-structures/suffix-tree.js index b769fb27..663234d0 100644 --- a/src/data-structures/suffix-tree.js +++ b/src/data-structures/suffix-tree.js @@ -1,96 +1,105 @@ // TODO // 1) The algorithm is quite ineffective, better use // Ukkomen's algorithm to build it in O(n) complexity. -function Node(val) { - this.value = val; - this.nodes = {}; -} +(function (exports) { + 'use strict'; -function SuffixTree() { - this.root = new Node(); -} + function Node(val) { + this.value = val; + this.nodes = {}; + } -SuffixTree.prototype.addNode = (function () { + function SuffixTree() { + this.root = new Node(); + } - function maxPrefix(a, b) { - var res = []; - for (var i = 0; i < Math.min(a.length, b.length); i += 1) { - if (a[i] === b[i]) { - res.push(a[i]); - } else { - return ''; + SuffixTree.prototype.addNode = (function () { + + function maxPrefix(a, b) { + var res = []; + for (var i = 0; i < Math.min(a.length, b.length); i += 1) { + if (a[i] === b[i]) { + res.push(a[i]); + } else { + return ''; + } } + return res.join(''); } - return res.join(''); - } - function addNode(suffix, current) { - // Empty string already exists in the suffix tree - if (!suffix) { - return; - } - // The suffix is already inside the tree - if (current.value === suffix) { - return; - } - // Insert recursively - if (current.nodes[suffix[0]]) { - return addNode(suffix.substr(1, suffix.length), current.nodes[suffix[0]]); - } - // Find the maximum prefix and split the current node if prefix exists - var prefix = maxPrefix(current.value, suffix); - if (prefix.length) { - var temp = current.value, - suffixSuffix = suffix.substr(prefix.length, suffix.length), - currentSuffix = temp.substr(prefix.length, temp.length); - current.value = prefix; - addNode(currentSuffix, current); - addNode(suffixSuffix, current); - // If prefix doesn't exists add new child node - } else { - current.nodes[suffix[0]] = new Node(suffix); + function addNode(suffix, current) { + // Empty string already exists in the suffix tree + if (!suffix) { + return; + } + // The suffix is already inside the tree + if (current.value === suffix) { + return; + } + // Insert recursively + if (current.nodes[suffix[0]]) { + return addNode(suffix.substr(1, suffix.length), + current.nodes[suffix[0]]); + } + // Find the maximum prefix and split the current node if prefix exists + var prefix = maxPrefix(current.value, suffix); + if (prefix.length) { + var temp = current.value, + suffixSuffix = suffix.substr(prefix.length, suffix.length), + currentSuffix = temp.substr(prefix.length, temp.length); + current.value = prefix; + addNode(currentSuffix, current); + addNode(suffixSuffix, current); + // If prefix doesn't exists add new child node + } else { + current.nodes[suffix[0]] = new Node(suffix); + } } - } - return function (suffix) { - addNode(suffix, this.root); + return function (suffix) { + addNode(suffix, this.root); + }; + }()); + + // O(n^2) or even O(n^3) because of maxPrefix + SuffixTree.prototype.build = function (string) { + this.root.value = string; + for (var i = 1; i < string.length; i += 1) { + this.addNode(string.substr(i, string.length)); + } }; -}()); -// O(n^2) or even O(n^3) because of maxPrefix -SuffixTree.prototype.build = function (string) { - this.root.value = string; - for (var i = 1; i < string.length; i += 1) { - this.addNode(string.substr(i, string.length)); - } -}; +// function isSubstr(tree, str) { +// if (!tree) { +// return false; +// } +// if (tree.nodes[str[0]]) { +// return isSubstr(tree, str.substr(1, str.length)); +// } +// var match = ''; +// for (var i = 0; i < Math.min(tree.value.length, str.length); i += 1) { +// if (tree.value[i] === str[i]) { +// match += str[i]; +// } else { +// break; +// } +// } +// if (match.length === str.length) { +// return true; +// } +// return false; +// } -function isSubstr(tree, str) { - if (!tree) { - return false; - } - if (tree.nodes[str[0]]) { - return isSubstr(tree, str.substr(1, str.length)); - } - var match = ''; - for (var i = 0; i < Math.min(tree.value.length, str.length); i += 1) { - if (tree.value[i] === str[i]) { - match += str[i]; - } else { - break; - } - } - if (match.length === str.length) { - return true; - } - return false; -} + // var suffix = new SuffixTree(); + // suffix.build('banana'); + // console.log(suffix); + // + // var st = new SuffixTree(); + // st.build('Since these cases are very common use cases, the problem was easily solved by choosing either a random index for the pivot, choosing the middle index of the partition or (especially for longer partitions) choosing the median of the first, middle and last element of the partition for the pivot. With these modifications, the worst case of Quick sort has less chances to occur, but worst case can still occur if the input array is such that the maximum (or minimum) element is always chosen as pivot.'); + // console.log(JSON.stringify(st)); -// var suffix = new SuffixTree(); -// suffix.build('banana'); -// console.log(suffix); + exports.Node = Node; + exports.SuffixTree = SuffixTree; -var st = new SuffixTree(); -st.build('Since these cases are very common use cases, the problem was easily solved by choosing either a random index for the pivot, choosing the middle index of the partition or (especially for longer partitions) choosing the median of the first, middle and last element of the partition for the pivot. With these modifications, the worst case of Quick sort has less chances to occur, but worst case can still occur if the input array is such that the maximum (or minimum) element is always chosen as pivot.'); -console.log(JSON.stringify(st)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file From 719d6a0c63c2fcd5e02e4a472f329aea49ace0bb Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 1 Dec 2014 10:41:15 +0200 Subject: [PATCH 244/613] Interval tree initial commit --- src/data-structures/interval-tree.js | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/data-structures/interval-tree.js diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js new file mode 100644 index 00000000..be0f6c0b --- /dev/null +++ b/src/data-structures/interval-tree.js @@ -0,0 +1,47 @@ +function Node(start, end, left, right) { + this.interval = [start, end]; + this.maxRight = -Infinity; + this.parentNode = null; + this.left = left; + this.right = right; +} + +function IntervalTree() { + this.root = null; +} + +function addNode(node, side, interval) { + var child = new Node(interval[0], interval[1]); + child.parentNode = node; + node[side] = child; + if (side === 'right' && node.maxRight < interval[1]) { + while (child) { + child.maxRight = interval[1]; + child = child.parentNode; + } + } +} + +function addHelper(node, interval) { + if (node.interval[0] > interval[0]) { + if (node.left) { + addHelper(node.left, interval); + } else { + addNode(node, 'left', interval); + } + } else { + if (node.right) { + addHelper(node.right, interval); + } else { + addNode(node, 'right', interval); + } + } +} + +IntervalTree.prototype.add = function (interval) { + if (!this.root) { + this.root = new Node(interval[0], interval[1]); + return; + } + addHelper(this.root, interval); +}; \ No newline at end of file From ef7e5a6b71324cf04f6a8bb1c3cf3ff4a90ff9bf Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 1 Dec 2014 11:33:22 +0200 Subject: [PATCH 245/613] Add contains operation --- src/data-structures/interval-tree.js | 87 ++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 4 deletions(-) diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index be0f6c0b..742e2f2e 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -1,6 +1,6 @@ function Node(start, end, left, right) { this.interval = [start, end]; - this.maxRight = -Infinity; + this.max = -Infinity; this.parentNode = null; this.left = left; this.right = right; @@ -14,9 +14,11 @@ function addNode(node, side, interval) { var child = new Node(interval[0], interval[1]); child.parentNode = node; node[side] = child; - if (side === 'right' && node.maxRight < interval[1]) { + if (side === 'right' && node.max < interval[1]) { while (child) { - child.maxRight = interval[1]; + if (child.max < interval[1]) { + child.max = interval[1]; + } child = child.parentNode; } } @@ -44,4 +46,81 @@ IntervalTree.prototype.add = function (interval) { return; } addHelper(this.root, interval); -}; \ No newline at end of file +}; + +function contains(point, node) { + if (!node) { + return false; + } + if (node.interval[0] <= point && node.interval[1] >= point) { + return true; + } + var result = false, temp; + ['left', 'right'].forEach(function (key) { + temp = node[key]; + if (temp) { + if (temp.max > point) { + result = result || contains(point, temp); + } + } + }); + return result; +} + +IntervalTree.prototype.contains = function (point) { + return contains(point, this.root); +}; + +function intersectsHelper(interval, node) { + if (!node) { + return false; + } + if (intersects(node.interval, interval)) { + return true; + } + var result = false, temp; + ['left', 'right'].forEach(function (side) { + temp = node[side]; + if (temp) { + if (intersects(interval, [temp.interval[0], temp.max]) || + temp.interval[0] <= interval[0]) { + result = result || intersectsHelper(interval, temp); + } + } + }); + return result; +} + +function intersects(a, b) { + return (a[0] <= b[0] && a[1] >= b[0]) || (a[0] <= b[1] && a[1] >= b[1]) || + (b[0] <= a[0] && b[1] >= a[0]) || (b[0] <= a[1] && b[1] >= a[1]); +} + +IntervalTree.prototype.intersects = function (interval) { + return intersectsHelper(intersects, this.root); +}; + +function heightHelper(node) { + if (!node) { + return 0; + } + return 1 + Math.max(heightHelper(node.left), heightHelper(node.right)); +} + +IntervalTree.prototype.height = function () { + return heightHelper(this.root); +}; + + +var t = new IntervalTree(); + +t.add([1, 2]); +t.add([-1, 8]); +t.add([-1, 18]); +t.add([2, 4]); +t.add([8, 13]); +t.add([2, 10]); + +console.log(t.intersects([1, 2])); +console.log(t.contains(16)); +console.log(t.height()); \ No newline at end of file From ede1819c12ac10099c4c42c6391ee3d45cb4dfbf Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 1 Dec 2014 11:41:19 +0200 Subject: [PATCH 246/613] Add intersects operation --- src/data-structures/interval-tree.js | 35 +++++++++++++--------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index 742e2f2e..74982398 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -81,11 +81,8 @@ function intersectsHelper(interval, node) { var result = false, temp; ['left', 'right'].forEach(function (side) { temp = node[side]; - if (temp) { - if (intersects(interval, [temp.interval[0], temp.max]) || - temp.interval[0] <= interval[0]) { - result = result || intersectsHelper(interval, temp); - } + if (temp && temp.max >= interval[0]) { + result = result || intersectsHelper(interval, temp); } }); return result; @@ -97,7 +94,7 @@ function intersects(a, b) { } IntervalTree.prototype.intersects = function (interval) { - return intersectsHelper(intersects, this.root); + return intersectsHelper(interval, this.root); }; function heightHelper(node) { @@ -111,16 +108,16 @@ IntervalTree.prototype.height = function () { return heightHelper(this.root); }; - -var t = new IntervalTree(); - -t.add([1, 2]); -t.add([-1, 8]); -t.add([-1, 18]); -t.add([2, 4]); -t.add([8, 13]); -t.add([2, 10]); - -console.log(t.intersects([1, 2])); -console.log(t.contains(16)); -console.log(t.height()); \ No newline at end of file +// +// var t = new IntervalTree(); +// +// t.add([1, 2]); +// t.add([-1, 8]); +// t.add([-1, 18]); +// t.add([2, 4]); +// t.add([8, 13]); +// t.add([2, 10]); +// +// console.log(t.intersects([19, 29])); +// console.log(t.contains(16)); +// console.log(t.height()); \ No newline at end of file From fe35792b91a059bf9fc732e6cbee143e0d09aa4f Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 1 Dec 2014 11:43:03 +0200 Subject: [PATCH 247/613] Linting of the interval tree --- src/data-structures/interval-tree.js | 186 ++++++++++++++------------- 1 file changed, 97 insertions(+), 89 deletions(-) diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index 74982398..1a3336e5 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -1,112 +1,120 @@ -function Node(start, end, left, right) { - this.interval = [start, end]; - this.max = -Infinity; - this.parentNode = null; - this.left = left; - this.right = right; -} +(function (exports) { + 'use strict'; -function IntervalTree() { - this.root = null; -} + function Node(start, end, left, right) { + this.interval = [start, end]; + this.max = -Infinity; + this.parentNode = null; + this.left = left; + this.right = right; + } + + function IntervalTree() { + this.root = null; + } -function addNode(node, side, interval) { - var child = new Node(interval[0], interval[1]); - child.parentNode = node; - node[side] = child; - if (side === 'right' && node.max < interval[1]) { - while (child) { - if (child.max < interval[1]) { - child.max = interval[1]; + function addNode(node, side, interval) { + var child = new Node(interval[0], interval[1]); + child.parentNode = node; + node[side] = child; + if (side === 'right' && node.max < interval[1]) { + while (child) { + if (child.max < interval[1]) { + child.max = interval[1]; + } + child = child.parentNode; } - child = child.parentNode; } } -} -function addHelper(node, interval) { - if (node.interval[0] > interval[0]) { - if (node.left) { - addHelper(node.left, interval); - } else { - addNode(node, 'left', interval); - } - } else { - if (node.right) { - addHelper(node.right, interval); + function addHelper(node, interval) { + if (node.interval[0] > interval[0]) { + if (node.left) { + addHelper(node.left, interval); + } else { + addNode(node, 'left', interval); + } } else { - addNode(node, 'right', interval); + if (node.right) { + addHelper(node.right, interval); + } else { + addNode(node, 'right', interval); + } } } -} -IntervalTree.prototype.add = function (interval) { - if (!this.root) { - this.root = new Node(interval[0], interval[1]); - return; - } - addHelper(this.root, interval); -}; + IntervalTree.prototype.add = function (interval) { + if (!this.root) { + this.root = new Node(interval[0], interval[1]); + return; + } + addHelper(this.root, interval); + }; -function contains(point, node) { - if (!node) { - return false; - } - if (node.interval[0] <= point && node.interval[1] >= point) { - return true; - } - var result = false, temp; - ['left', 'right'].forEach(function (key) { - temp = node[key]; - if (temp) { - if (temp.max > point) { - result = result || contains(point, temp); - } + function contains(point, node) { + if (!node) { + return false; } - }); - return result; -} + if (node.interval[0] <= point && node.interval[1] >= point) { + return true; + } + var result = false, temp; + ['left', 'right'].forEach(function (key) { + temp = node[key]; + if (temp) { + if (temp.max > point) { + result = result || contains(point, temp); + } + } + }); + return result; + } -IntervalTree.prototype.contains = function (point) { - return contains(point, this.root); -}; + IntervalTree.prototype.contains = function (point) { + return contains(point, this.root); + }; -function intersectsHelper(interval, node) { - if (!node) { - return false; - } - if (intersects(node.interval, interval)) { - return true; - } - var result = false, temp; - ['left', 'right'].forEach(function (side) { - temp = node[side]; - if (temp && temp.max >= interval[0]) { - result = result || intersectsHelper(interval, temp); + function intersectsHelper(interval, node) { + if (!node) { + return false; + } + if (intersects(node.interval, interval)) { + return true; } - }); - return result; -} + var result = false, temp; + ['left', 'right'].forEach(function (side) { + temp = node[side]; + if (temp && temp.max >= interval[0]) { + result = result || intersectsHelper(interval, temp); + } + }); + return result; + } -function intersects(a, b) { - return (a[0] <= b[0] && a[1] >= b[0]) || (a[0] <= b[1] && a[1] >= b[1]) || - (b[0] <= a[0] && b[1] >= a[0]) || (b[0] <= a[1] && b[1] >= a[1]); -} + function intersects(a, b) { + return (a[0] <= b[0] && a[1] >= b[0]) || (a[0] <= b[1] && a[1] >= b[1]) || + (b[0] <= a[0] && b[1] >= a[0]) || (b[0] <= a[1] && b[1] >= a[1]); + } -IntervalTree.prototype.intersects = function (interval) { - return intersectsHelper(interval, this.root); -}; + IntervalTree.prototype.intersects = function (interval) { + return intersectsHelper(interval, this.root); + }; -function heightHelper(node) { - if (!node) { - return 0; + function heightHelper(node) { + if (!node) { + return 0; + } + return 1 + Math.max(heightHelper(node.left), heightHelper(node.right)); } - return 1 + Math.max(heightHelper(node.left), heightHelper(node.right)); -} -IntervalTree.prototype.height = function () { - return heightHelper(this.root); -}; + IntervalTree.prototype.height = function () { + return heightHelper(this.root); + }; + + exports.Node = Node; + exports.IntervalTree = IntervalTree; + +}(typeof exports === 'undefined' ? window : exports)); // // var t = new IntervalTree(); From 02d4a7582b4879dc5b1e4bcb5f30e9da2e74ee43 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 2 Dec 2014 11:27:27 +0200 Subject: [PATCH 248/613] Add incomplete deletion --- src/data-structures/interval-tree.js | 72 +++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 13 deletions(-) diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index 1a3336e5..46d68811 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -111,21 +111,67 @@ return heightHelper(this.root); }; + // adjust the max value + IntervalTree.prototype.removeHelper = function (interval, node) { + if (!node) { + return; + } + if (node.interval[0] === interval[0] && + node.interval[1] === interval[1]) { + if (node.left && node.right) { + var replacement = node.left; + while (replacement.left) { + replacement = replacement.left; + } + var temp = replacement.interval; + replacement.interval = node.interval; + node.interval = temp; + this._removeHelper(replacement.interval, node); + } else { + var side = 'left'; + if (node.right) { + side = 'right'; + } + var parentNode = node.parentNode; + if (parentNode) { + if (parentNode.left === node) { + parentNode.left = node[side]; + } else { + parentNode.right = node[side]; + } + node[side].parentNode = parentNode; + } else { + this.root = node[side]; + this.root.parentNode = null; + } + } + } else { + // could be optimized + this._removeHelper(interval, node.left); + this._removeHelper(interval, node.right); + } + }; + + IntervalTree.prototype.remove = function (interval) { + return this._removeHelper(interval, this.root); + }; + exports.Node = Node; exports.IntervalTree = IntervalTree; }(typeof exports === 'undefined' ? window : exports)); -// -// var t = new IntervalTree(); -// -// t.add([1, 2]); -// t.add([-1, 8]); -// t.add([-1, 18]); -// t.add([2, 4]); -// t.add([8, 13]); -// t.add([2, 10]); -// -// console.log(t.intersects([19, 29])); -// console.log(t.contains(16)); -// console.log(t.height()); \ No newline at end of file +var IntervalTree = exports.IntervalTree; + +var t = new IntervalTree(); + +t.add([1, 2]); +t.add([-1, 8]); +t.add([-1, 18]); +t.add([2, 4]); +t.add([8, 13]); +t.add([2, 10]); + +console.log(t.intersects([19, 29])); +console.log(t.contains(16)); +console.log(t.height()); \ No newline at end of file From 01dc2d553205e11f6808a28b5a8bc45652615471 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 2 Dec 2014 11:55:22 +0200 Subject: [PATCH 249/613] Buggy remove implementation --- src/data-structures/interval-tree.js | 67 +++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index 46d68811..0c9a5832 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -111,13 +111,33 @@ return heightHelper(this.root); }; + IntervalTree.prototype.findMax = function (node) { + var stack = [node], + current, max = -Infinity, maxNode; + while (stack.length) { + current = stack.pop(); + if (current.left) { + stack.push(current.left); + } + if (current.right) { + stack.push(current.right); + } + if (current.interval[1] > max) { + max = current.interval[1]; + maxNode = current; + } + } + return maxNode; + }; + // adjust the max value - IntervalTree.prototype.removeHelper = function (interval, node) { + IntervalTree.prototype._removeHelper = function (interval, node) { if (!node) { return; } if (node.interval[0] === interval[0] && node.interval[1] === interval[1]) { + // When left and right children exists if (node.left && node.right) { var replacement = node.left; while (replacement.left) { @@ -128,6 +148,7 @@ node.interval = temp; this._removeHelper(replacement.interval, node); } else { + // When only left or right child exists var side = 'left'; if (node.right) { side = 'right'; @@ -139,12 +160,30 @@ } else { parentNode.right = node[side]; } - node[side].parentNode = parentNode; + if (node[side]) { + node[side].parentNode = parentNode; + } } else { this.root = node[side]; this.root.parentNode = null; } } + // Adjust the max value + var p = node.parentNode; + if (p) { + var maxNode = this.findMax(p); + if (maxNode.interval[1] > p.max) { + var max = maxNode.interval[1]; + while (maxNode) { + if (max > maxNode.max && maxNode.max === node.interval[1]) { + maxNode.max = max; + maxNode = maxNode.parentNode; + } else { + maxNode = false; + } + } + } + } } else { // could be optimized this._removeHelper(interval, node.left); @@ -171,7 +210,23 @@ t.add([-1, 18]); t.add([2, 4]); t.add([8, 13]); t.add([2, 10]); - -console.log(t.intersects([19, 29])); -console.log(t.contains(16)); -console.log(t.height()); \ No newline at end of file +t.add([-2, 10]); +t.add([-4, 15]); +t.add([-6, 15]); + +t.remove([1, 2]); +t.remove([-1, 8]); +t.remove([-1, 18]); +t.remove([2, 4]); +t.remove([8, 13]); +t.remove([2, 10]); +t.remove([-2, 10]); +t.remove([-4, 15]); + +console.log(t.root); +console.log(t.intersects([17, 29])); + +//console.log(t.intersects([19, 29])); +//console.log(t.contains(16)); + +console.log('Height:', t.height()); \ No newline at end of file From 05ca413c33371173c1a826993120b5ed0405dcad Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 2 Dec 2014 11:55:56 +0200 Subject: [PATCH 250/613] Add comments --- src/data-structures/interval-tree.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index 0c9a5832..8635defc 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -1,3 +1,5 @@ +// The implementation doesn't work properly! +// Most of the operations are still buggy, not properly implemented. (function (exports) { 'use strict'; From 8530563577508e2b57161bb77b968bca0db1d052 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 2 Dec 2014 11:59:50 +0200 Subject: [PATCH 251/613] Fix the insert operation --- src/data-structures/interval-tree.js | 44 +++++++++++++++------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index 8635defc..8082b42b 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -19,7 +19,7 @@ var child = new Node(interval[0], interval[1]); child.parentNode = node; node[side] = child; - if (side === 'right' && node.max < interval[1]) { + if (node.max < interval[1]) { while (child) { if (child.max < interval[1]) { child.max = interval[1]; @@ -167,7 +167,10 @@ } } else { this.root = node[side]; - this.root.parentNode = null; + // last node removed + if (this.root) { + this.root.parentNode = null; + } } } // Adjust the max value @@ -208,25 +211,26 @@ var t = new IntervalTree(); t.add([1, 2]); t.add([-1, 8]); -t.add([-1, 18]); -t.add([2, 4]); -t.add([8, 13]); -t.add([2, 10]); -t.add([-2, 10]); -t.add([-4, 15]); -t.add([-6, 15]); - -t.remove([1, 2]); -t.remove([-1, 8]); -t.remove([-1, 18]); -t.remove([2, 4]); -t.remove([8, 13]); -t.remove([2, 10]); -t.remove([-2, 10]); -t.remove([-4, 15]); - +// t.add([-1, 18]); +// t.add([2, 4]); +// t.add([8, 13]); +// t.add([2, 10]); +// t.add([-2, 10]); +// t.add([-4, 15]); +// t.add([-6, 15]); + +// t.remove([1, 2]); +// t.remove([-1, 8]); +// t.remove([-1, 18]); +// t.remove([2, 4]); +// t.remove([8, 13]); +// t.remove([2, 10]); +// t.remove([-2, 10]); +// t.remove([-4, 15]); +// t.remove([-6, 15]); + +console.log(t.height()); console.log(t.root); -console.log(t.intersects([17, 29])); //console.log(t.intersects([19, 29])); //console.log(t.contains(16)); From 687492f98e6e708b96aa6f3c3e6d91b3b7b1b44e Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 2 Dec 2014 12:02:45 +0200 Subject: [PATCH 252/613] Fix the remove operation --- src/data-structures/interval-tree.js | 52 +++++----------------------- 1 file changed, 8 insertions(+), 44 deletions(-) diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index 8082b42b..249daff9 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -1,5 +1,3 @@ -// The implementation doesn't work properly! -// Most of the operations are still buggy, not properly implemented. (function (exports) { 'use strict'; @@ -176,16 +174,14 @@ // Adjust the max value var p = node.parentNode; if (p) { - var maxNode = this.findMax(p); - if (maxNode.interval[1] > p.max) { - var max = maxNode.interval[1]; - while (maxNode) { - if (max > maxNode.max && maxNode.max === node.interval[1]) { - maxNode.max = max; - maxNode = maxNode.parentNode; - } else { - maxNode = false; - } + var maxNode = this.findMax(p), + max = maxNode.interval[1]; + while (maxNode) { + if (maxNode.max === node.interval[1]) { + maxNode.max = max; + maxNode = maxNode.parentNode; + } else { + maxNode = false; } } } @@ -204,35 +200,3 @@ exports.IntervalTree = IntervalTree; }(typeof exports === 'undefined' ? window : exports)); - -var IntervalTree = exports.IntervalTree; - -var t = new IntervalTree(); - -t.add([1, 2]); -t.add([-1, 8]); -// t.add([-1, 18]); -// t.add([2, 4]); -// t.add([8, 13]); -// t.add([2, 10]); -// t.add([-2, 10]); -// t.add([-4, 15]); -// t.add([-6, 15]); - -// t.remove([1, 2]); -// t.remove([-1, 8]); -// t.remove([-1, 18]); -// t.remove([2, 4]); -// t.remove([8, 13]); -// t.remove([2, 10]); -// t.remove([-2, 10]); -// t.remove([-4, 15]); -// t.remove([-6, 15]); - -console.log(t.height()); -console.log(t.root); - -//console.log(t.intersects([19, 29])); -//console.log(t.contains(16)); - -console.log('Height:', t.height()); \ No newline at end of file From ddb89f00f30b0e9496e4fdc6c3869d85a2e127fb Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 3 Dec 2014 10:50:59 +0200 Subject: [PATCH 253/613] Remove useless function call --- src/data-structures/binary-search-tree.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 718f96f8..6c4705ba 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -308,7 +308,7 @@ BinaryTree.prototype.getDiameter = function () { var leftHeight = this._getHeight(root._left), rightHeight = this._getHeight(root._right), path = leftHeight + rightHeight + 1; - return Math.max(path, Math.max(getDiameter(root._left), getDiameter(root._right))); + return Math.max(path, getDiameter(root._left), getDiameter(root._right)); }.bind(this); return getDiameter(this._root); }; From 4fee2547e856c6cf3cc5aa97869564bc65e31663 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 4 Dec 2014 16:05:32 +0200 Subject: [PATCH 254/613] Exports runlength --- src/combinatorics/cartesianproduct.js | 2 - src/compression/runlength/runlength.js | 106 +++++++++++++------------ 2 files changed, 56 insertions(+), 52 deletions(-) diff --git a/src/combinatorics/cartesianproduct.js b/src/combinatorics/cartesianproduct.js index adc1d4d6..0be43dd8 100644 --- a/src/combinatorics/cartesianproduct.js +++ b/src/combinatorics/cartesianproduct.js @@ -19,5 +19,3 @@ var cartesianProduct = (function () { }; }()); -// console.log([[1, 2],[3, 4],[5, 6],[7, 8]]); -// console.log(cartesianProduct([[1, 2],[3, 4],[5, 6],[7, 8]])); diff --git a/src/compression/runlength/runlength.js b/src/compression/runlength/runlength.js index 1040d456..fa9e7532 100644 --- a/src/compression/runlength/runlength.js +++ b/src/compression/runlength/runlength.js @@ -4,64 +4,70 @@ * give us representation of string in binary which in which the * zeros will be stripped and replaced with their count. */ -var runLengthEncoding = (function () { - +(function (exports) { 'use strict'; - /** - * Convers a given string to sequence of numbers - * This takes O(n). - */ - function convertToAscii(str) { - var result = '', - currentChar = '', - i = 0; - for (; i < str.length; i += 1) { - currentChar = str[i].charCodeAt(0).toString(2); - if (currentChar.length < 8) { - while (8 - currentChar.length) { - currentChar = '0' + currentChar; + var runLengthEncoding = (function () { + + /** + * Convers a given string to sequence of numbers + * This takes O(n). + */ + function convertToAscii(str) { + var result = '', + currentChar = '', + i = 0; + for (; i < str.length; i += 1) { + currentChar = str[i].charCodeAt(0).toString(2); + if (currentChar.length < 8) { + while (8 - currentChar.length) { + currentChar = '0' + currentChar; + } } + result += currentChar; } - result += currentChar; + return result; } - return result; - } - /** - * Encodes the binary string to run-length encoding. - * Takes O(n^2). - */ - function runLength(vector) { - var result = '', - zeros = 0, - zerosTemp = '', - wordLength = 0, - i = 0; - for (; i < vector.length; i += 1) { - if (vector[i] === '0') { - zeros += 1; - } else { - zerosTemp = zeros.toString(2); - wordLength = zerosTemp.length - 1; - while (wordLength) { - result = result + '1'; - wordLength -= 1; + /** + * Encodes the binary string to run-length encoding. + * Takes O(n^2). + */ + function runLength(vector) { + var result = '', + zeros = 0, + zerosTemp = '', + wordLength = 0, + i = 0; + for (; i < vector.length; i += 1) { + if (vector[i] === '0') { + zeros += 1; + } else { + zerosTemp = zeros.toString(2); + wordLength = zerosTemp.length - 1; + while (wordLength) { + result = result + '1'; + wordLength -= 1; + } + result += '0' + zerosTemp; + zeros = 0; } - result += '0' + zerosTemp; - zeros = 0; } + return result; } - return result; - } - /** - * Accepts a string and returns it's run-length encoded binary representation. - * Takes O(n^2). - */ - return function (str) { - var asciiString = convertToAscii(str); - return runLength(asciiString); - }; + /** + * Accepts a string and returns it's run-length + * encoded binary representation. + * Takes O(n^2). + */ + return function (str) { + var asciiString = convertToAscii(str); + return runLength(asciiString); + }; + + }()); + + exports.runLength = runLengthEncoding; -}()); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file From 432efa1f22fad10eca85e5365e287d364e55f26a Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 4 Dec 2014 18:26:47 +0200 Subject: [PATCH 255/613] Add topological sort --- src/graphs/others/topological-sort.js | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/graphs/others/topological-sort.js diff --git a/src/graphs/others/topological-sort.js b/src/graphs/others/topological-sort.js new file mode 100644 index 00000000..fa155134 --- /dev/null +++ b/src/graphs/others/topological-sort.js @@ -0,0 +1,44 @@ +var topologicalSort = (function () { + 'use strict'; + + function topologicalSortHelper(node, visited, temp, graph, result) { + temp[node] = true; + var neighbors = graph[node]; + for (var i = 0; i < neighbors.length; i += 1) { + var n = neighbors[i]; + if (temp[n]) { + throw new Error('The graph is not a DAG'); + } + if (!visited[n]) { + topologicalSortHelper(n, visited, temp, graph, result); + } + } + temp[node] = false; + visited[node] = true; + result.push(node); + } + + return function (graph) { + var result = [], + visited = [], + temp = []; + for (var node in graph) { + if (!visited[node] && !temp[node]) { + topologicalSortHelper(node, visited, temp, graph, result); + } + } + return result.reverse(); + }; +}()); + +var graph = { + '0': ['1', '2'], + '1': ['2', '4'], + '2': ['3'], + '3': [], + '4': ['5', '6'], + '5': [], + '6': ['3'] +}; + +console.log(topologicalSort(graph)); From 0a677cd647016a19c01d2f99802fe7391a4248e4 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 4 Dec 2014 20:01:39 +0200 Subject: [PATCH 256/613] Add todo for dijkstra --- src/graphs/shortest-path/dijkstra.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index d0075990..71a66ee2 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -93,6 +93,7 @@ var dijstra = function () { var tempDistance = 0; init(src, graph); while (current.node != dest && current.distance != Infinity) { + var changed = false; for (var i = 0; i < graph.length; i += 1) { if (current.node !== i && //if it's not the current node !visited[i] && //and if we haven't visited this node @@ -100,10 +101,14 @@ var dijstra = function () { tempDistance = current.distance + graph[i][current.node]; if (tempDistance < distance[i].distance) { + changed = true; distance[i].distance = tempDistance; } } } + if (changed) { + // TODO the heap should update the order of the elements! + } visited[current.node] = true; current = unvisited.extract(); } From 778787ac039923fd2f8b16db3b42e8dc54481740 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 5 Dec 2014 08:44:50 +0200 Subject: [PATCH 257/613] Add warning message --- readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/readme.md b/readme.md index 2f06c36e..d2d76109 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,7 @@ +## Note + +Note that not all algorithms are well tested so bugs are quite possible. + ## About This repository contains different famous Computer Science algorithms implemented in JavaScript From 424099235bc84c8b8f0fb4a9739ab73695a02cb0 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 6 Dec 2014 19:44:57 +0200 Subject: [PATCH 258/613] Add update method to the heap --- src/data-structures/heap.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index c7a4c89e..44146d5a 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -76,6 +76,18 @@ return parent; }; + /** + * Updates given node. This operation is useful + * in algorithms like Dijkstra, A* where we need + * to decrease/increase the value of givne node. + */ + Heap.prototype.update = function (node) { + var idx = this._heap.indexOf(node); + if (idx >= 0) { + this.changeKey(idx, node); + } + }; + /** * Adds new element to the heap. Complexity O(log n). * From 626374c2619a1afd693da99fad960dd310c57ce7 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 6 Dec 2014 19:45:14 +0200 Subject: [PATCH 259/613] Fix Dijkstra --- src/graphs/shortest-path/dijkstra.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index 71a66ee2..5b30c1bb 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -93,22 +93,19 @@ var dijstra = function () { var tempDistance = 0; init(src, graph); while (current.node != dest && current.distance != Infinity) { - var changed = false; for (var i = 0; i < graph.length; i += 1) { if (current.node !== i && //if it's not the current node !visited[i] && //and if we haven't visited this node Number.isFinite(graph[i][current.node])) { //and this node is sibling of the current... - tempDistance = current.distance + graph[i][current.node]; + tempDistance = current.distance + graph[i][current.node]; if (tempDistance < distance[i].distance) { - changed = true; distance[i].distance = tempDistance; + current.distance = tempDistance; + unvisited.update(current); } } } - if (changed) { - // TODO the heap should update the order of the elements! - } visited[current.node] = true; current = unvisited.extract(); } From 4f497dd9d775e97051c569d4360dc5d5aece3873 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 6 Dec 2014 19:46:45 +0200 Subject: [PATCH 260/613] Update isFinite check --- src/graphs/shortest-path/dijkstra.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index 5b30c1bb..37de6669 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -92,7 +92,7 @@ var dijstra = function () { return function (src, dest, graph) { var tempDistance = 0; init(src, graph); - while (current.node != dest && current.distance != Infinity) { + while (current.node !== dest && isFinite(current.distance)) { for (var i = 0; i < graph.length; i += 1) { if (current.node !== i && //if it's not the current node !visited[i] && //and if we haven't visited this node From b4bf7490f3d144771e5e9436367d6f87f6357c5a Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 10 Dec 2014 22:02:18 +0200 Subject: [PATCH 261/613] Exports cartesian product --- src/combinatorics/cartesianproduct.js | 36 +++++++++++++++------------ 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/combinatorics/cartesianproduct.js b/src/combinatorics/cartesianproduct.js index 0be43dd8..a344a03b 100644 --- a/src/combinatorics/cartesianproduct.js +++ b/src/combinatorics/cartesianproduct.js @@ -1,21 +1,25 @@ -var cartesianProduct = (function () { +(function (exports) { 'use strict'; - var result; + var cartesianProduct = (function () { + var result; - function cartesianProduct(sets, index, current) { - if (index === sets.length) { - return result.push(current.slice()); + function cartesianProduct(sets, index, current) { + if (index === sets.length) { + return result.push(current.slice()); + } + for (var i = 0; i < sets[index].length; i += 1) { + current[index] = sets[index][i]; + cartesianProduct(sets, index + 1, current); + } } - for (var i = 0; i < sets[index].length; i += 1) { - current[index] = sets[index][i]; - cartesianProduct(sets, index + 1, current); - } - } - return function (sets) { - result = []; - cartesianProduct(sets, 0, []); - return result; - }; -}()); + return function (sets) { + result = []; + cartesianProduct(sets, 0, []); + return result; + }; + }()); + + exports.cartesianProduct = cartesianProduct; +}(typeof exports === 'undefined' ? window : exports)); From a3984f54c82d0110271b96ab80790dd483cc6365 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 10 Dec 2014 22:03:25 +0200 Subject: [PATCH 262/613] Exports variations with repetions --- src/combinatorics/cartesianproduct.js | 1 + src/combinatorics/variations-repetion.js | 40 +++++++++++++----------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/combinatorics/cartesianproduct.js b/src/combinatorics/cartesianproduct.js index a344a03b..74024f41 100644 --- a/src/combinatorics/cartesianproduct.js +++ b/src/combinatorics/cartesianproduct.js @@ -1,5 +1,6 @@ (function (exports) { 'use strict'; + var cartesianProduct = (function () { var result; diff --git a/src/combinatorics/variations-repetion.js b/src/combinatorics/variations-repetion.js index a545038d..d9eb4984 100644 --- a/src/combinatorics/variations-repetion.js +++ b/src/combinatorics/variations-repetion.js @@ -1,24 +1,28 @@ -var variationsWithRepetion = (function () { +(function (exports) { 'use strict'; - var res; + var variationsWithRepetion = (function () { + var res; - function variations(arr, k, index, current) { - if (k === index) { - return res.push(current.slice()); + function variations(arr, k, index, current) { + if (k === index) { + return res.push(current.slice()); + } + for (var i = 0; i < arr.length; i += 1) { + current[index] = arr[i]; + variations(arr, k, index + 1, current); + } } - for (var i = 0; i < arr.length; i += 1) { - current[index] = arr[i]; - variations(arr, k, index + 1, current); - } - } - return function (arr, k) { - res = []; - variations(arr, k, 0, []); - var temp = res; - res = undefined; - return temp; - }; -}()); + return function (arr, k) { + res = []; + variations(arr, k, 0, []); + var temp = res; + res = undefined; + return temp; + }; + }()); + + exports.variationsWithRepetion = variationsWithRepetion; +}(typeof exports === 'undefined' ? window : exports)); From db0c1c049a0620314f1dfde4c364ed7d027e68d4 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 11 Dec 2014 09:56:16 +0000 Subject: [PATCH 263/613] Add Levenshtein distance --- src/others/levenshtein-distance.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/others/levenshtein-distance.js diff --git a/src/others/levenshtein-distance.js b/src/others/levenshtein-distance.js new file mode 100644 index 00000000..fe2c4d25 --- /dev/null +++ b/src/others/levenshtein-distance.js @@ -0,0 +1,27 @@ +var levenshteinDistance = (function () { + 'use strict'; + + function levenshteinDistance(s, ls, t, lt) { + if (ls === 0) { + return lt; + } + if (lt === 0) { + return ls; + } + var cost; + if (s[ls - 1] === t[lt - 1]) { + cost = 0; + } else { + cost = 1; + } + return Math.min(levenshteinDistance(s, ls - 1, t, lt) + 1, + levenshteinDistance(s, ls, t, lt - 1) + 1, + levenshteinDistance(s, ls - 1, t, lt - 1) + cost); + } + + return function (s, t) { + return levenshteinDistance(s, s.length, t, t.length); + }; +}()); + +//console.log(levenshteinDistance('kitten', 'sitting')); \ No newline at end of file From 924c77d8bbd4a7e57e0c5d48e917ca55864e8765 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 12 Dec 2014 11:02:14 +0000 Subject: [PATCH 264/613] Export Levenshtein's distance algorithm --- src/others/levenshtein-distance.js | 48 ++++++++++++++++-------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/others/levenshtein-distance.js b/src/others/levenshtein-distance.js index fe2c4d25..07edbeef 100644 --- a/src/others/levenshtein-distance.js +++ b/src/others/levenshtein-distance.js @@ -1,27 +1,31 @@ -var levenshteinDistance = (function () { +(function (exports) { 'use strict'; - function levenshteinDistance(s, ls, t, lt) { - if (ls === 0) { - return lt; - } - if (lt === 0) { - return ls; - } - var cost; - if (s[ls - 1] === t[lt - 1]) { - cost = 0; - } else { - cost = 1; + var levenshteinDistance = (function () { + + function levenshteinDistance(s, ls, t, lt) { + if (ls === 0) { + return lt; + } + if (lt === 0) { + return ls; + } + var cost; + if (s[ls - 1] === t[lt - 1]) { + cost = 0; + } else { + cost = 1; + } + return Math.min(levenshteinDistance(s, ls - 1, t, lt) + 1, + levenshteinDistance(s, ls, t, lt - 1) + 1, + levenshteinDistance(s, ls - 1, t, lt - 1) + cost); } - return Math.min(levenshteinDistance(s, ls - 1, t, lt) + 1, - levenshteinDistance(s, ls, t, lt - 1) + 1, - levenshteinDistance(s, ls - 1, t, lt - 1) + cost); - } - return function (s, t) { - return levenshteinDistance(s, s.length, t, t.length); - }; -}()); + return function (s, t) { + return levenshteinDistance(s, s.length, t, t.length); + }; + }()); + + exports.levenshteinDistance = levenshteinDistance; -//console.log(levenshteinDistance('kitten', 'sitting')); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file From 8a3c0a0f22caf0c87ca70277cfd09b774bfeacaf Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 12 Dec 2014 15:20:08 +0000 Subject: [PATCH 265/613] Export Fisher Yates shuffling algorithm --- src/shuffle/fisheryates.js | 40 ++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/shuffle/fisheryates.js b/src/shuffle/fisheryates.js index d51e6b7f..1eaa460b 100644 --- a/src/shuffle/fisheryates.js +++ b/src/shuffle/fisheryates.js @@ -1,20 +1,26 @@ -/** - * The shuffling algorithm of - * Fisher-Yates. Complexity O(n) - * - * @param {array} array The array which should be shuffled - * @return {array} The shuffled array. - */ -function shuffle(array) { +(function (exports) { 'use strict'; - var size = array.length, - rand, temp; - for (var i = 1; i < size; i += 1) { - rand = Math.round(Math.random() * i); - temp = array[rand]; - array[rand] = array[i]; - array[i] = temp; + + /** + * The shuffling algorithm of + * Fisher-Yates. Complexity O(n) + * + * @param {array} array The array which should be shuffled + * @return {array} The shuffled array. + */ + function shuffle(array) { + var size = array.length, + rand, temp; + for (var i = 1; i < size; i += 1) { + rand = Math.round(Math.random() * i); + temp = array[rand]; + array[rand] = array[i]; + array[i] = temp; + } + return array; } - return array; -} + + exports.shuffle = shuffle; + +}(typeof exports === 'undefined' ? window : exports)); From 4a15260d25bbd5b1cda7093c1d2bad2e7e47ac05 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 13 Dec 2014 12:36:40 +0000 Subject: [PATCH 266/613] Export topological sort --- src/graphs/others/topological-sort.js | 67 +++++++++++++-------------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/src/graphs/others/topological-sort.js b/src/graphs/others/topological-sort.js index fa155134..a8729d76 100644 --- a/src/graphs/others/topological-sort.js +++ b/src/graphs/others/topological-sort.js @@ -1,44 +1,39 @@ -var topologicalSort = (function () { +(function (exports) { 'use strict'; - function topologicalSortHelper(node, visited, temp, graph, result) { - temp[node] = true; - var neighbors = graph[node]; - for (var i = 0; i < neighbors.length; i += 1) { - var n = neighbors[i]; - if (temp[n]) { - throw new Error('The graph is not a DAG'); - } - if (!visited[n]) { - topologicalSortHelper(n, visited, temp, graph, result); + var topologicalSort = (function () { + + function topologicalSortHelper(node, visited, temp, graph, result) { + temp[node] = true; + var neighbors = graph[node]; + for (var i = 0; i < neighbors.length; i += 1) { + var n = neighbors[i]; + if (temp[n]) { + throw new Error('The graph is not a DAG'); + } + if (!visited[n]) { + topologicalSortHelper(n, visited, temp, graph, result); + } } + temp[node] = false; + visited[node] = true; + result.push(node); } - temp[node] = false; - visited[node] = true; - result.push(node); - } - return function (graph) { - var result = [], - visited = [], - temp = []; - for (var node in graph) { - if (!visited[node] && !temp[node]) { - topologicalSortHelper(node, visited, temp, graph, result); + return function (graph) { + var result = [], + visited = [], + temp = []; + for (var node in graph) { + if (!visited[node] && !temp[node]) { + topologicalSortHelper(node, visited, temp, graph, result); + } } - } - return result.reverse(); - }; -}()); + return result.reverse(); + }; + }()); + + exports.topologicalSort = topologicalSort; -var graph = { - '0': ['1', '2'], - '1': ['2', '4'], - '2': ['3'], - '3': [], - '4': ['5', '6'], - '5': [], - '6': ['3'] -}; +}(typeof exports === 'undefined' ? window : exports)); -console.log(topologicalSort(graph)); From eb4c6ebdd4ca7ac9459f96b01033616472c430d6 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 14 Dec 2014 18:04:11 +0200 Subject: [PATCH 267/613] Export the binary tree and the node functions --- src/data-structures/binary-search-tree.js | 731 +++++++++++----------- 1 file changed, 369 insertions(+), 362 deletions(-) diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 6c4705ba..b15f3b46 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -1,370 +1,377 @@ -/** - * Implementation of binary search tree. - */ - -/** - * A node of the tree - * - * @public - * @constructor - * @param {number|string} Value of the node - * @param {Node} Left subling - * @param {Node} Right sibling - * @param {Node} Parent of the node - */ -function Node(value, left, right, parent) { - this.value = value; - this._left = left; - this._right = right; - this._parent = parent; -} - -/** - * Defines the binary tree - * - * @public - * @constructor - */ -function BinaryTree() { - this._root = null; -} - -/** - * Inserts a node into the binary tree. The method's complexity is O(log n) in the average case and - * O(n) in the worst case. - * - * @public - * @param {number|string} Value - * @param {[Node]} Current node - */ -BinaryTree.prototype.insert = function (value, current) { - if (this._root === null) { - this._root = new Node(value, null, null, null); - return; +(function (exports) { + 'use strict'; + + /** + * Implementation of binary search tree. + */ + + /** + * A node of the tree + * + * @public + * @constructor + * @param {number|string} Value of the node + * @param {Node} Left subling + * @param {Node} Right sibling + * @param {Node} Parent of the node + */ + function Node(value, left, right, parent) { + this.value = value; + this._left = left; + this._right = right; + this._parent = parent; } - var insertKey; - current = current || this._root; - if (current.value > value) - insertKey = '_left'; - else - insertKey = '_right'; - if (!current[insertKey]) - current[insertKey] = new Node(value, null, null, current); - else - this.insert(value, current[insertKey]); -}; - -/** - * Prints the nodes of the tree in order. It starts the tree traversal from a given node. - * - * @private - * @param {Node} Node from which to start the traversal - * @param {Function} Callback which will be called for each traversed node - */ -BinaryTree.prototype._inorder = function (current, callback) { - if (!current) - return; - this._inorder(current._left, callback); - if (typeof callback === 'function') - callback(current); - this._inorder(current._right, callback); -}; - -/** - * Inorder traversal of the whole binary search tree - * - * @public - * @param {Function} Callback which will be called for each traversed node - */ -BinaryTree.prototype.inorder = function (callback) { - return this._inorder(this._root, callback); -}; - -/** - * Post-order traversal from given node - * - * @private - * @param {Node} Node from which to start the traversal - * @param {Function} Callback which will be called for each traversed node - */ -BinaryTree.prototype._postorder = function (current, callback) { - if (!current) - return; - if (typeof callback === 'function') - callback(current); - this._postorder(current._left, callback); - this._postorder(current._right, callback); -}; - -/** - * Post-order traversal of the whole tree - * - * @public - * @param {Function} Callback which will be called for each traversed node - */ -BinaryTree.prototype.postorder = function (callback) { - return this._postorder(this._root, callback); -}; - -/** - * Pre-order traversal of the tree from given node - * - * @private - * @param {Node} Node from which to start the traversal - * @param {Function} Callback which will be called for each traversed node - */ -BinaryTree.prototype._preorder = function (current, callback) { - if (!current) - return; - if (typeof callback === 'function') - callback(current); - this._preorder(current._left, callback); - this._preorder(current._right, callback); -}; - -/** - * Pre-order preorder traversal of the whole tree - * - * @public - * @param {Function} Callback which will be called for each traversed node - */ -BinaryTree.prototype.preorder = function (callback) { - return this._preorder(this._root, callback); -}; - -/** - * Finds a node by it's value. Average runtime complexity O(log n) - * - * @public - * @param {number|string} Value of the node which should be found - */ -BinaryTree.prototype.find = function (value) { - return this._find(value, this._root); -}; - -/** - * Finds a node by it's value in given sub-tree. Average runtime complexity: O(log n). - * - * @private - * @param {number|string} Value of the node which should be found - * @param {Node} Current node to be checked - */ -BinaryTree.prototype._find = function (value, current) { - if (!current) - return null; - - if (current.value === value) - return current; - - if (current.value > value) - return this._find(value, current._left); - - if (current.value < value) - return this._find(value, current._right); - -}; - -/** - * Replaces given child with new one, for given parent - * - * @private - * @param {Node} Parent node - * @param {Node} Child to be replaced - * @param {Node} Child replacement - */ -BinaryTree.prototype._replaceChild = function (parent, oldChild, newChild) { - if (!parent) { - this._root = newChild; - this._root._parent = null; - } else { - - if (parent._left === oldChild) - parent._left = newChild; - else - parent._right = newChild; - if (newChild) { - newChild._parent = parent; - } + /** + * Defines the binary tree + * + * @public + * @constructor + */ + function BinaryTree() { + this._root = null; } -}; - -/** - * Removes node from the tree. Average runtime complexity: O(log n). - * - * @public - * @param {Node} Node to be removed - * @returns {boolean} True/false depending on whether the given node is removed - */ -BinaryTree.prototype.remove = function (node) { - if (!node) - return false; - - if (node._left && node._right) { - var min = this._findMin(node._right), - temp = node.value; - - node.value = min.value; - min.value = temp; - return this.remove(min); - } else { - if (node._left) - this._replaceChild(node._parent, node, node._left); - else if (node._right) - this._replaceChild(node._parent, node, node._right); + + /** + * Inserts a node into the binary tree. The method's complexity is O(log n) in the average case and + * O(n) in the worst case. + * + * @public + * @param {number|string} Value + * @param {[Node]} Current node + */ + BinaryTree.prototype.insert = function (value, current) { + if (this._root === null) { + this._root = new Node(value, null, null, null); + return; + } + var insertKey; + current = current || this._root; + if (current.value > value) + insertKey = '_left'; else - this._replaceChild(node._parent, node, null); - return true; - } -}; - -/** - * Finds the node with minimum value in given sub-tree - * - * @private - * @param {Node} Root of the sub-tree - * @param {[number|string]} Current minimum value of the sub-tree - * @returns {Node} The node with minimum value in the sub-tree - */ -BinaryTree.prototype._findMin = function (node, current) { - current = current || { value: Infinity }; - if (!node) - return current; - if (current.value > node.value) - current = node; - return this._findMin(node._left, current); -}; - -/** - * Finds the node with maximum value in given sub-tree - * - * @private - * @param {Node} Root of the sub-tree - * @param {[number|string]} Current maximum value of the sub-tree - * @returns {Node} The node with maximum value in the sub-tree - */ -BinaryTree.prototype._findMax = function (node, current) { - current = current || { value: -Infinity }; - if (!node) - return current; - if (current.value < node.value) - current = node; - return this._findMax(node._right, current); -}; - -/** - * Finds the node with minimum value in the whole tree - * - * @public - * @returns {Node} The minimum node of the tree - */ -BinaryTree.prototype.findMin = function () { - return this._findMin(this._root); -}; - -/** - * Finds the maximum node of the tree - * - * @public - * @returns {Node} The maximum node of the tree - * - */ -BinaryTree.prototype.findMax = function () { - return this._findMax(this._root); -}; - - -BinaryTree.prototype._isBalanced = function (current) { - if (!current) { - return true; - } - return this._isBalanced(current._left) && - this._isBalanced(current._right) && - Math.abs(this._getHeight(current._left) - - this._getHeight(current._right)) <= 1; -}; - -/** - * Returns whether the BST is balanced - * - * @public - * @returns {Boolean} Whether the tree is balanced or not - */ -BinaryTree.prototype.isBalanced = function () { - return this._isBalanced(this._root); -}; - -/** - * Finds the diameter of the binary tree - * - * @public - * @returns {Number} The longest path in the BST - */ -BinaryTree.prototype.getDiameter = function () { - var getDiameter = function (root) { - if (!root) { + insertKey = '_right'; + if (!current[insertKey]) + current[insertKey] = new Node(value, null, null, current); + else + this.insert(value, current[insertKey]); + }; + + /** + * Prints the nodes of the tree in order. It starts the tree traversal from a given node. + * + * @private + * @param {Node} Node from which to start the traversal + * @param {Function} Callback which will be called for each traversed node + */ + BinaryTree.prototype._inorder = function (current, callback) { + if (!current) + return; + this._inorder(current._left, callback); + if (typeof callback === 'function') + callback(current); + this._inorder(current._right, callback); + }; + + /** + * Inorder traversal of the whole binary search tree + * + * @public + * @param {Function} Callback which will be called for each traversed node + */ + BinaryTree.prototype.inorder = function (callback) { + return this._inorder(this._root, callback); + }; + + /** + * Post-order traversal from given node + * + * @private + * @param {Node} Node from which to start the traversal + * @param {Function} Callback which will be called for each traversed node + */ + BinaryTree.prototype._postorder = function (current, callback) { + if (!current) + return; + if (typeof callback === 'function') + callback(current); + this._postorder(current._left, callback); + this._postorder(current._right, callback); + }; + + /** + * Post-order traversal of the whole tree + * + * @public + * @param {Function} Callback which will be called for each traversed node + */ + BinaryTree.prototype.postorder = function (callback) { + return this._postorder(this._root, callback); + }; + + /** + * Pre-order traversal of the tree from given node + * + * @private + * @param {Node} Node from which to start the traversal + * @param {Function} Callback which will be called for each traversed node + */ + BinaryTree.prototype._preorder = function (current, callback) { + if (!current) + return; + if (typeof callback === 'function') + callback(current); + this._preorder(current._left, callback); + this._preorder(current._right, callback); + }; + + /** + * Pre-order preorder traversal of the whole tree + * + * @public + * @param {Function} Callback which will be called for each traversed node + */ + BinaryTree.prototype.preorder = function (callback) { + return this._preorder(this._root, callback); + }; + + /** + * Finds a node by it's value. Average runtime complexity O(log n) + * + * @public + * @param {number|string} Value of the node which should be found + */ + BinaryTree.prototype.find = function (value) { + return this._find(value, this._root); + }; + + /** + * Finds a node by it's value in given sub-tree. Average runtime complexity: O(log n). + * + * @private + * @param {number|string} Value of the node which should be found + * @param {Node} Current node to be checked + */ + BinaryTree.prototype._find = function (value, current) { + if (!current) + return null; + + if (current.value === value) + return current; + + if (current.value > value) + return this._find(value, current._left); + + if (current.value < value) + return this._find(value, current._right); + + }; + + /** + * Replaces given child with new one, for given parent + * + * @private + * @param {Node} Parent node + * @param {Node} Child to be replaced + * @param {Node} Child replacement + */ + BinaryTree.prototype._replaceChild = function (parent, oldChild, newChild) { + if (!parent) { + this._root = newChild; + this._root._parent = null; + } else { + + if (parent._left === oldChild) + parent._left = newChild; + else + parent._right = newChild; + + if (newChild) { + newChild._parent = parent; + } + } + }; + + /** + * Removes node from the tree. Average runtime complexity: O(log n). + * + * @public + * @param {Node} Node to be removed + * @returns {boolean} True/false depending on whether the given node is removed + */ + BinaryTree.prototype.remove = function (node) { + if (!node) + return false; + + if (node._left && node._right) { + var min = this._findMin(node._right), + temp = node.value; + + node.value = min.value; + min.value = temp; + return this.remove(min); + } else { + if (node._left) + this._replaceChild(node._parent, node, node._left); + else if (node._right) + this._replaceChild(node._parent, node, node._right); + else + this._replaceChild(node._parent, node, null); + return true; + } + }; + + /** + * Finds the node with minimum value in given sub-tree + * + * @private + * @param {Node} Root of the sub-tree + * @param {[number|string]} Current minimum value of the sub-tree + * @returns {Node} The node with minimum value in the sub-tree + */ + BinaryTree.prototype._findMin = function (node, current) { + current = current || { value: Infinity }; + if (!node) + return current; + if (current.value > node.value) + current = node; + return this._findMin(node._left, current); + }; + + /** + * Finds the node with maximum value in given sub-tree + * + * @private + * @param {Node} Root of the sub-tree + * @param {[number|string]} Current maximum value of the sub-tree + * @returns {Node} The node with maximum value in the sub-tree + */ + BinaryTree.prototype._findMax = function (node, current) { + current = current || { value: -Infinity }; + if (!node) + return current; + if (current.value < node.value) + current = node; + return this._findMax(node._right, current); + }; + + /** + * Finds the node with minimum value in the whole tree + * + * @public + * @returns {Node} The minimum node of the tree + */ + BinaryTree.prototype.findMin = function () { + return this._findMin(this._root); + }; + + /** + * Finds the maximum node of the tree + * + * @public + * @returns {Node} The maximum node of the tree + * + */ + BinaryTree.prototype.findMax = function () { + return this._findMax(this._root); + }; + + + BinaryTree.prototype._isBalanced = function (current) { + if (!current) { + return true; + } + return this._isBalanced(current._left) && + this._isBalanced(current._right) && + Math.abs(this._getHeight(current._left) - + this._getHeight(current._right)) <= 1; + }; + + /** + * Returns whether the BST is balanced + * + * @public + * @returns {Boolean} Whether the tree is balanced or not + */ + BinaryTree.prototype.isBalanced = function () { + return this._isBalanced(this._root); + }; + + /** + * Finds the diameter of the binary tree + * + * @public + * @returns {Number} The longest path in the BST + */ + BinaryTree.prototype.getDiameter = function () { + var getDiameter = function (root) { + if (!root) { + return 0; + } + var leftHeight = this._getHeight(root._left), + rightHeight = this._getHeight(root._right), + path = leftHeight + rightHeight + 1; + return Math.max(path, getDiameter(root._left), getDiameter(root._right)); + }.bind(this); + return getDiameter(this._root); + }; + + /** + * Returns the height of the tree + * + * @public + * @returns {Number} The height of the tree + */ + BinaryTree.prototype.getHeight = function () { + return this._getHeight(this._root); + }; + + BinaryTree.prototype._getHeight = function (node) { + if (!node) { return 0; } - var leftHeight = this._getHeight(root._left), - rightHeight = this._getHeight(root._right), - path = leftHeight + rightHeight + 1; - return Math.max(path, getDiameter(root._left), getDiameter(root._right)); - }.bind(this); - return getDiameter(this._root); -}; - -/** - * Returns the height of the tree - * - * @public - * @returns {Number} The height of the tree - */ -BinaryTree.prototype.getHeight = function () { - return this._getHeight(this._root); -}; - -BinaryTree.prototype._getHeight = function (node) { - if (!node) { - return 0; - } - return 1 + Math.max(this._getHeight(node._left), this._getHeight(node._right)); -}; - -/** - * Finds the lowest common ancestor of two nodes. - * - * @public - * @returns {Node} The lowest common ancestor of the two nodes or null - */ -BinaryTree.prototype.lowestCommonAncestor = function (firstNode, secondNode, current) { - return this._lowestCommonAncestor(firstNode, secondNode, this._root); -}; - -BinaryTree.prototype._lowestCommonAncestor = function (firstNode, secondNode, current) { - var firstNodeInLeft = this._existsInSubtree(firstNode, current._left), - secondNodeInLeft = this._existsInSubtree(secondNode, current._left), - firstNodeInRight = this._existsInSubtree(firstNode, current._right), - secondNodeInRight = this._existsInSubtree(secondNode, current._right); - if ((firstNodeInLeft && secondNodeInRight) || - (firstNodeInRight && secondNodeInLeft)) { - return current; - } - if (secondNodeInLeft && firstNodeInLeft) { - return this._lowestCommonAncestor(firstNode, secondNode, current._left); - } - if (secondNodeInRight && secondNodeInLeft) { - return this._lowestCommonAncestor(firstNode, secondNode, current._right); - } - return null; -}; + return 1 + Math.max(this._getHeight(node._left), this._getHeight(node._right)); + }; -BinaryTree.prototype._existsInSubtree = function (node, root) { - if (!root) { - return false; - } - if (node === root.value) { - return true; - } - return this._existsInSubtree(node, root._left) || this._existsInSubtree(node, root._right); -}; + /** + * Finds the lowest common ancestor of two nodes. + * + * @public + * @returns {Node} The lowest common ancestor of the two nodes or null + */ + BinaryTree.prototype.lowestCommonAncestor = function (firstNode, secondNode, current) { + return this._lowestCommonAncestor(firstNode, secondNode, this._root); + }; + + BinaryTree.prototype._lowestCommonAncestor = function (firstNode, secondNode, current) { + var firstNodeInLeft = this._existsInSubtree(firstNode, current._left), + secondNodeInLeft = this._existsInSubtree(secondNode, current._left), + firstNodeInRight = this._existsInSubtree(firstNode, current._right), + secondNodeInRight = this._existsInSubtree(secondNode, current._right); + if ((firstNodeInLeft && secondNodeInRight) || + (firstNodeInRight && secondNodeInLeft)) { + return current; + } + if (secondNodeInLeft && firstNodeInLeft) { + return this._lowestCommonAncestor(firstNode, secondNode, current._left); + } + if (secondNodeInRight && secondNodeInLeft) { + return this._lowestCommonAncestor(firstNode, secondNode, current._right); + } + return null; + }; + + BinaryTree.prototype._existsInSubtree = function (node, root) { + if (!root) { + return false; + } + if (node === root.value) { + return true; + } + return this._existsInSubtree(node, root._left) || this._existsInSubtree(node, root._right); + }; + + exports.BinaryTree = BinaryTree; + exports.Node = Node; +}(typeof exports === 'undefined' ? window : exports)); From 4f0d011886711728a93a8881b886ced62fbcd178 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 14 Dec 2014 18:05:48 +0200 Subject: [PATCH 268/613] Add comments in the topological sort --- src/graphs/others/topological-sort.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/graphs/others/topological-sort.js b/src/graphs/others/topological-sort.js index a8729d76..f0db1a36 100644 --- a/src/graphs/others/topological-sort.js +++ b/src/graphs/others/topological-sort.js @@ -1,6 +1,10 @@ (function (exports) { 'use strict'; + /** + * Complexity O(|E|), where E is the set + * which contains all edges and |E| is their count. + */ var topologicalSort = (function () { function topologicalSortHelper(node, visited, temp, graph, result) { From c4608a4502e397b69bd5b1563bf9d1f6dd570a5b Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 15 Dec 2014 17:49:20 +0200 Subject: [PATCH 269/613] Wrap shuffle and export it --- src/shuffle/richarddurstenfeld.js | 50 +++++++++++++++++-------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/shuffle/richarddurstenfeld.js b/src/shuffle/richarddurstenfeld.js index f9b83f0f..a409d8b2 100644 --- a/src/shuffle/richarddurstenfeld.js +++ b/src/shuffle/richarddurstenfeld.js @@ -1,24 +1,30 @@ -/** - * Shuffle of an array elements. - * This algorithm is modified version of Fisher-Yates shuffle - * algorithm and is introduced by Richard Durstenfeld. - */ - -/** - * Shuffles an array. Complexity O(n). - * - * @param {array} array An array which should be shuffled - * @returns {array} Shuffled array - */ -function shuffle(array) { +(function (exports) { 'use strict'; - var arraySize = array.length - 1, - rand, temp; - for (var i = arraySize; i >= 0; i -= 1) { - rand = Math.round(Math.random() * arraySize); - temp = array[i]; - array[i] = array[rand]; - array[rand] = temp; + /** + * Shuffle of an array elements. + * This algorithm is modified version of Fisher-Yates shuffle + * algorithm and is introduced by Richard Durstenfeld. + */ + + /** + * Shuffles an array. Complexity O(n). + * + * @param {array} array An array which should be shuffled + * @returns {array} Shuffled array + */ + function shuffle(array) { + var arraySize = array.length - 1, + rand, temp; + for (var i = arraySize; i >= 0; i -= 1) { + rand = Math.round(Math.random() * arraySize); + temp = array[i]; + array[i] = array[rand]; + array[rand] = temp; + } + return array; } - return array; -} + + exports.shuffle = shuffle; + +}(typeof exports === 'undefined' ? window : exports)); + From a03e327c0eaf2d08308b8d1b0623c2282c7748f9 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 6 Jan 2015 10:05:23 +0200 Subject: [PATCH 270/613] Update bfs --- src/graphs/searching/bfs.js | 162 +++++++++--------------------------- 1 file changed, 41 insertions(+), 121 deletions(-) diff --git a/src/graphs/searching/bfs.js b/src/graphs/searching/bfs.js index 3e87b591..e29ec767 100644 --- a/src/graphs/searching/bfs.js +++ b/src/graphs/searching/bfs.js @@ -1,139 +1,59 @@ (function (exports) { - 'use strict'; - /** - * Breadth-first search algorithm for matrix representation of graph. - * The algorithm finds whether there's a path between two given nodes. - */ - var breadthFirstSearch = (function () { - - var visited = [], - queue = [], - target, - graph; - - /** - * Initializes the algorithm - * - * @private - * @param {array} inputGraph The input matrix of the graph - * @param {array} destination The destination - */ - function init(inputGraph, destination) { - graph = inputGraph; - target = destination; - queue = []; - visited = {}; - } - - /** - * Adds a valid node to the queue - * @param {array} node Node to be added to the queue - */ - function addNode(node) { - if (visited[node] || - node[0] < 0 || node[1] < 0 || - node[0] >= graph.length || node[1] >= graph[0].length || - !graph[node[0]][node[1]]) { - return; - } - queue.push(node); - } - - /** - * Process given node - * - * @param {array} destination The destionation, which should be reached - * @param {array} current The current node - */ - function processNode(destination, current) { - if (destination.toString() === current.toString()) { - return true; - } else { - addNode([current[0], current[1] + 1]); - addNode([current[0], current[1] - 1]); - addNode([current[0] + 1, current[1]]); - addNode([current[0] - 1, current[1]]); - return false; - } - } + var bfs = (function () { - /** - * Validates the params - * - * @param {array} graph A matrix representation of the graph - * @param {array} source The source node - * @param {array} destination The destination node - */ - function validateParams(graph, source, destination) { - if (!graph) { - throw new Error('The graph should be represented as a matrix'); + function buildPath(parents, targetNode) { + var result = [targetNode]; + while (parents[targetNode] !== null) { + targetNode = parents[targetNode]; + result.push(targetNode); } - if (graph[0] === undefined) { - throw new Error('The graph should be represented as ' + - 'a matrix, with size at least 1x1'); - } - var width = graph[0].length; - for (var i = 1; i < graph.length; i += 1) { - if (graph[i].length !== width) { - throw new Error('The graph should be represented as a matrix'); - } - } - source.concat(destination).filter(function (c, i) { - if (c < 0) { - throw new Error('The source and destination coordinates ' + - 'should be above zero'); - } - if (i % 2 === 0) { - if (c >= graph.length) { - throw new Error('The source and destination coordinates ' + - 'should not be above graph\'s size'); - } - } else { - if (c >= graph[0].length) { - throw new Error('The source and destination coordinates ' + - 'should not be above graph\'s size'); - } - } - }); - return true; + return result.reverse(); } /** - * Finds whether there's a path between a given start node - * to given destination + * Returns the shortest path between + * startNode and targetNode. + * Time complexity O(|V|*|V|), because we use adjust matrix. * - * @public - * @param {array} graph A matrix representation of the graph - * @param {array} source The source node - * @param {array} destination The destination node - * @returns {boolean} true/false depending whether there's - * a path between the nodes + * @param {array} graph The adjust matrix, which represents the graph + * @param {number} startNode The start node + * @param {number} targetNode The target, which should be reached + * @returns {array} The shortest path from startNode to targetNode */ - return function (graph, source, destination) { - validateParams(graph, source, destination); - init(graph, destination); - var current; - queue.push(source); - while (queue.length > 0) { + return function (graph, startNode, targetNode) { + var parents = [], + queue = [], + visited = [], + current; + queue.push(startNode); + parents[startNode] = null; + visited[startNode] = true; + while (queue.length) { current = queue.shift(); - visited[current] = true; - if (graph[current[0]][current[1]]) { - var result = processNode(destination, current); - if (result) { - return true; + if (current === targetNode) { + return buildPath(parents, targetNode); + } + for (var i = 0; i < graph.length; i += 1) { + if (i !== current && graph[current][i] && !visited[i]) { + parents[i] = current; + visited[i] = true; + queue.push(i); } } } - visited = null; - queue = null; - target = -1; - graph = null; - return false; + return null; }; }()); - exports.breadthFirstSearch = breadthFirstSearch; + exports.bfs = bfs; + +}((typeof window === 'undefined') ? module.exports : window)); -}(typeof exports === 'undefined' ? window : exports)); +console.log(exports.bfs( +[[0, 0, 0, 0, 1], + [0, 0, 0, 1, 0], + [0, 0, 0, 0, 0], + [1, 0, 1, 0, 0], + [0, 1, 0, 1, 0]], 0, 2)); \ No newline at end of file From 4a07417a1ddf1c8e09c7bd2d255125b30379ca3b Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 6 Jan 2015 10:09:45 +0200 Subject: [PATCH 271/613] Update bfs test case --- test/graphs/searching/bfs.spec.js | 44 +++---------------------------- 1 file changed, 3 insertions(+), 41 deletions(-) diff --git a/test/graphs/searching/bfs.spec.js b/test/graphs/searching/bfs.spec.js index c8133574..a74db39f 100644 --- a/test/graphs/searching/bfs.spec.js +++ b/test/graphs/searching/bfs.spec.js @@ -9,50 +9,12 @@ var sampleGraph = [[1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1]]; -var bfs = require('../../../src/graphs/searching/bfs').breadthFirstSearch; +var bfs = require('../../../src/graphs/searching/bfs').bfs; describe('BFS', function () { - it('should work with incorrect input', function () { - expect(function () { - bfs(null, [1, 1], [1, 1]); - }).toThrow(); - expect(function () { - bfs(sampleGraph, [-1, -1], [0, 0]); - }).toThrow(); - expect(function () { - bfs(sampleGraph, [0, -1], [-1, 0]); - }).toThrow(); - expect(function () { - bfs(sampleGraph, [0, 0], [-1, 0]); - }).toThrow(); - expect(function () { - bfs(sampleGraph, [0, 1000], [-1, 0]); - }).toThrow(); - expect(function () { - bfs(sampleGraph, [100000, 1000], [-1, 0]); - }).toThrow(); - expect(function () { - bfs(sampleGraph, [0, 0], [100, 100]); - }).toThrow(); - expect(function () { - bfs(sampleGraph, [0, 0], [5, 5]); - }).not.toThrow(); - }); - - it('should work with 1x1 matrix', function () { - var graph = [[1]]; - expect(bfs(graph, [0, 0], [0, 0])).toBeTruthy(); - graph = [[0]]; - expect(bfs(graph, [0, 0], [0, 0])).toBeFalsy(); - }); - - it('should work in the general case', function () { - expect(bfs(sampleGraph, [0, 0], [1, 1])).toBeTruthy(); - expect(bfs(sampleGraph, [0, 0], [6, 5])).toBeTruthy(); - expect(bfs(sampleGraph, [0, 0], [0, 5])).toBeFalsy(); - expect(bfs(sampleGraph, [1, 1], [6, 5])).toBeTruthy(); - expect(bfs(sampleGraph, [1, 1], [0, 5])).toBeFalsy(); + it('should work with empty graph', function () { + expect(bfs([], 0, 0)).toEqual([0]); }); }); \ No newline at end of file From 4da2e8e624b9fa4ad90aef4a5d43dcbd09717661 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 6 Jan 2015 10:10:33 +0200 Subject: [PATCH 272/613] Update bfs test case --- test/graphs/searching/bfs.spec.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/graphs/searching/bfs.spec.js b/test/graphs/searching/bfs.spec.js index a74db39f..f2891be6 100644 --- a/test/graphs/searching/bfs.spec.js +++ b/test/graphs/searching/bfs.spec.js @@ -17,4 +17,9 @@ describe('BFS', function () { expect(bfs([], 0, 0)).toEqual([0]); }); + it('should return the correct output when used with\ + source node equals target node', function () { + + }); + }); \ No newline at end of file From 346fc0696a83f5569d4d66de1b122ecbae273774 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 6 Jan 2015 10:13:49 +0200 Subject: [PATCH 273/613] Add cycle test case --- src/graphs/searching/bfs.js | 7 ------- test/graphs/searching/bfs.spec.js | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/graphs/searching/bfs.js b/src/graphs/searching/bfs.js index e29ec767..8f037681 100644 --- a/src/graphs/searching/bfs.js +++ b/src/graphs/searching/bfs.js @@ -50,10 +50,3 @@ exports.bfs = bfs; }((typeof window === 'undefined') ? module.exports : window)); - -console.log(exports.bfs( -[[0, 0, 0, 0, 1], - [0, 0, 0, 1, 0], - [0, 0, 0, 0, 0], - [1, 0, 1, 0, 0], - [0, 1, 0, 1, 0]], 0, 2)); \ No newline at end of file diff --git a/test/graphs/searching/bfs.spec.js b/test/graphs/searching/bfs.spec.js index f2891be6..244641ca 100644 --- a/test/graphs/searching/bfs.spec.js +++ b/test/graphs/searching/bfs.spec.js @@ -1,13 +1,12 @@ +/* jshint multistr: true */ + 'use strict'; -var sampleGraph = [[1, 1, 1, 0, 0, 0], - [0, 1, 1, 1, 0, 0], - [1, 0, 1, 1, 1, 0], - [0, 1, 0, 1, 1, 0], - [0, 1, 0, 1, 1, 0], - [0, 1, 0, 1, 1, 0], - [0, 0, 1, 1, 1, 1], - [0, 0, 0, 0, 1, 1]]; +var graph = [[0, 0, 0, 0, 1], + [0, 0, 0, 1, 0], + [0, 0, 0, 0, 0], + [1, 0, 1, 0, 0], + [0, 1, 0, 1, 0]]; var bfs = require('../../../src/graphs/searching/bfs').bfs; @@ -19,7 +18,11 @@ describe('BFS', function () { it('should return the correct output when used with\ source node equals target node', function () { + expect(bfs(graph, 2, 2)).toEqual([2]); + }); + it('should return work with cycles', function () { + expect(bfs(graph, 0, 2)).toEqual([0, 4, 3, 2]); }); }); \ No newline at end of file From 68238972351e0c02fedb8f61bdae309e9487b667 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 6 Jan 2015 10:15:21 +0200 Subject: [PATCH 274/613] Add test case for no path --- test/graphs/searching/bfs.spec.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/graphs/searching/bfs.spec.js b/test/graphs/searching/bfs.spec.js index 244641ca..3707d6ac 100644 --- a/test/graphs/searching/bfs.spec.js +++ b/test/graphs/searching/bfs.spec.js @@ -25,4 +25,13 @@ describe('BFS', function () { expect(bfs(graph, 0, 2)).toEqual([0, 4, 3, 2]); }); + it('should return falsy value when there\'s no path', function () { + var graph = [[0, 0, 0, 0, 1], + [0, 0, 0, 1, 0], + [0, 0, 0, 0, 0], + [1, 0, 0, 0, 0], + [0, 1, 0, 1, 0]]; + expect(bfs(graph, 0, 2)).toBeFalsy(); + }); + }); \ No newline at end of file From af6de19ca9c085368aec1eb3b8b1cb3a6b5deca8 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 6 Jan 2015 10:22:56 +0200 Subject: [PATCH 275/613] Add test case for parent update --- test/graphs/searching/bfs.spec.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/graphs/searching/bfs.spec.js b/test/graphs/searching/bfs.spec.js index 3707d6ac..eae3cf80 100644 --- a/test/graphs/searching/bfs.spec.js +++ b/test/graphs/searching/bfs.spec.js @@ -34,4 +34,11 @@ describe('BFS', function () { expect(bfs(graph, 0, 2)).toBeFalsy(); }); + it('should not update the parent node once set', function () { + var graph = [[0, 1, 1], + [0, 0, 1], + [0, 0, 0]]; + expect(bfs(graph, 0, 2)).toEqual([0, 2]); + }); + }); \ No newline at end of file From f5645bb26a2ccfbf821707b13f0509db0f307c78 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 6 Jan 2015 10:26:50 +0200 Subject: [PATCH 276/613] Add extra information for the test case --- test/graphs/searching/bfs.spec.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/graphs/searching/bfs.spec.js b/test/graphs/searching/bfs.spec.js index eae3cf80..4ffa6e1c 100644 --- a/test/graphs/searching/bfs.spec.js +++ b/test/graphs/searching/bfs.spec.js @@ -34,6 +34,16 @@ describe('BFS', function () { expect(bfs(graph, 0, 2)).toBeFalsy(); }); + /** + * In this case the graph should not + * update the parent of 2, in case it was called + * with source 0 and target 2, after the first iteration. + * + * 0 ---> 1 + * \ | + * \ v + * -> 2 + */ it('should not update the parent node once set', function () { var graph = [[0, 1, 1], [0, 0, 1], From 862dd926b0d8de9798a81d702434e1583efe4e66 Mon Sep 17 00:00:00 2001 From: Microfed Date: Thu, 8 Jan 2015 12:41:57 +0300 Subject: [PATCH 277/613] Fix reversing double linked list --- src/data-structures/linked-list.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index fdf208ba..8b6522a8 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -140,10 +140,12 @@ while (current) { temp = current.next; current.next = prev; + prev.prev = current; prev = current; current = temp; } this.first.next = null; + this.last.prev = null; temp = this.first; this.first = prev; this.last = temp; From 4f76422d6455031d57186838ef218771614fed4d Mon Sep 17 00:00:00 2001 From: Microfed Date: Thu, 8 Jan 2015 12:50:13 +0300 Subject: [PATCH 278/613] Fix formatting --- src/data-structures/linked-list.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index 8b6522a8..74456600 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -140,12 +140,12 @@ while (current) { temp = current.next; current.next = prev; - prev.prev = current; + prev.prev = current; prev = current; current = temp; } this.first.next = null; - this.last.prev = null; + this.last.prev = null; temp = this.first; this.first = prev; this.last = temp; From a0e9034e6215b660468f896e93d1de03c142dcfa Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 8 Jan 2015 14:12:36 +0200 Subject: [PATCH 279/613] New dfs implementation --- src/graphs/searching/dfs.js | 143 +++++++++--------------------------- 1 file changed, 34 insertions(+), 109 deletions(-) diff --git a/src/graphs/searching/dfs.js b/src/graphs/searching/dfs.js index ce3a37f9..e6df5d97 100644 --- a/src/graphs/searching/dfs.js +++ b/src/graphs/searching/dfs.js @@ -1,129 +1,54 @@ -'use strict'; - -/* * * * * * * * * * * * * * * * * * - - Sample graph - -var graph = [[1,0,1,0,0,0], - [0,1,0,1,0,0], - [1,0,1,0,1,0], - [0,1,0,1,1,0], - [0,0,1,1,1,1], - [0,0,0,0,1,1]]; -* * * * * * * * * * * * * * * * * */ +/** + * Depth-First Search graph searching algorithm. + * Finds out whether there's a path between + * two nodes - start node and a target. + */ (function (exports) { - /** - * Depth-first search algorithm for matrix representation of graph. - * The algorithm finds whether there's a path between two given nodes. - */ - var depthFirstSearch = (function () { + 'use strict'; - var visited = [], - target, - graph; + var dfs = (function () { /** - * Returns whether the destination could be reached - * from given node - * - * @private - * @param {number} current Current node - * @returns {boolean} True/false depending whether - * the destination can be reached from the current node + * Implements an iterative DFS. + * Complexity O(|V|^2), since it uses adjust matrix. */ - function dfs(current) { - if (visited[current] || - current[0] < 0 || current[1] < 0 || - current[0] >= graph.length || current[1] >= graph[0].length || - !graph[current[0]][current[1]]) { - return false; - } - if (current[0] === target[0] && - current[1] === target[1]) { - return true; - } + function hasPath(graph, current, goal) { + var stack = [], + visited = [], + node; + stack.push(current); visited[current] = true; - return dfs([current[0] + 1, current[1]]) || - dfs([current[0] - 1, current[1]]) || - dfs([current[0], current[1] + 1]) || - dfs([current[0], current[1] - 1]); - } - - /** - * Initializes the algorithm - * - * @private - * @param {array} inputGraph The input matrix of the graph - * @param {number} destination The destination - */ - function init(inputGraph, destination) { - graph = inputGraph; - target = destination; - visited = {}; - } - - /** - * Validates the params - * - * @param {array} graph A matrix representation of the graph - * @param {array} source The source node - * @param {array} destination The destination node - */ - function validateParams(graph, source, destination) { - if (!graph) { - throw new Error('The graph should be represented as a matrix'); - } - if (graph[0] === undefined) { - throw new Error('The graph should be represented as ' + - 'a matrix, with size at least 1x1'); - } - var width = graph[0].length; - for (var i = 1; i < graph.length; i += 1) { - if (graph[i].length !== width) { - throw new Error('The graph should be represented as a matrix'); + while (stack.length) { + node = stack.pop(); + if (node === goal) { + return true; } - } - source.concat(destination).filter(function (c, i) { - if (c < 0) { - throw new Error('The source and destination coordinates ' + - 'should be above zero'); - } - if (i % 2 === 0) { - if (c >= graph.length) { - throw new Error('The source and destination coordinates ' + - 'should not be above graph\'s size'); - } - } else { - if (c >= graph[0].length) { - throw new Error('The source and destination coordinates ' + - 'should not be above graph\'s size'); + for (var i = 0; i < graph[node].length; i += 1) { + if (graph[node][i] && !visited[i]) { + stack.push(i); + visited[i] = true; } } - }); - return true; + } + return false; } /** - * Finds whether there's a path between a given start node - * to given destination + * Returns whether there's a path between two nodes + * in a graph represented with adjust matrix. * * @public - * @param {array} graph A matrix representation of the graph - * @param {number} source The source node - * @param {number} destination The destination node - * @returns {boolean} true/false depending - * whether there's a path between the nodes + * @param {array} graph Adjust matrix representation of a graph + * @param {number} start A start node + * @param {number} goal The target node + * @return {boolean} Returns whether there's a path between start and goal */ - return function (graph, source, destination) { - validateParams(graph, source, destination); - init(graph, destination); - return dfs(source); + return function (graph, start, goal) { + return hasPath(graph, start, goal); }; - - }()); - exports.depthFirstSearch = depthFirstSearch; + exports.dfs = dfs; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); From 942504f793fcd9cb970ea666d64ef6965f880acb Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 8 Jan 2015 14:20:11 +0200 Subject: [PATCH 280/613] Update dfs tests --- test/graphs/searching/dfs.spec.js | 71 +++++++++++-------------------- 1 file changed, 25 insertions(+), 46 deletions(-) diff --git a/test/graphs/searching/dfs.spec.js b/test/graphs/searching/dfs.spec.js index 84dd9708..ad901350 100644 --- a/test/graphs/searching/dfs.spec.js +++ b/test/graphs/searching/dfs.spec.js @@ -1,58 +1,37 @@ 'use strict'; -var sampleGraph = [[1, 1, 1, 0, 0, 0], - [0, 1, 1, 1, 0, 0], - [1, 0, 1, 1, 1, 0], - [0, 1, 0, 1, 1, 0], - [0, 1, 0, 1, 1, 0], - [0, 1, 0, 1, 1, 0], - [0, 0, 1, 1, 1, 1], - [0, 0, 0, 0, 1, 1]]; - -var dfs = require('../../../src/graphs/searching/dfs').depthFirstSearch; +var dfs = require('../../../src/graphs/searching/dfs').dfs; describe('dfs', function () { - it('should work with incorrect input', function () { - expect(function () { - dfs(null, [1, 1], [1, 1]); - }).toThrow(); - expect(function () { - dfs(sampleGraph, [-1, -1], [0, 0]); - }).toThrow(); - expect(function () { - dfs(sampleGraph, [0, -1], [-1, 0]); - }).toThrow(); - expect(function () { - dfs(sampleGraph, [0, 0], [-1, 0]); - }).toThrow(); - expect(function () { - dfs(sampleGraph, [0, 1000], [-1, 0]); - }).toThrow(); - expect(function () { - dfs(sampleGraph, [100000, 1000], [-1, 0]); - }).toThrow(); - expect(function () { - dfs(sampleGraph, [0, 0], [100, 100]); - }).toThrow(); - expect(function () { - dfs(sampleGraph, [0, 0], [5, 5]); - }).not.toThrow(); + it('should work with empty graph', function () { + expect(dfs([[]])).toBeTruthy(); }); - it('should work with 1x1 matrix', function () { - var graph = [[1]]; - expect(dfs(graph, [0, 0], [0, 0])).toBeTruthy(); - graph = [[0]]; - expect(dfs(graph, [0, 0], [0, 0])).toBeFalsy(); + it('should always find a path between node and itself', function () { + expect(dfs([[0]]), 0, 0).toBeTruthy(); }); - it('should work in the general case', function () { - expect(dfs(sampleGraph, [0, 0], [1, 1])).toBeTruthy(); - expect(dfs(sampleGraph, [0, 0], [6, 5])).toBeTruthy(); - expect(dfs(sampleGraph, [0, 0], [0, 5])).toBeFalsy(); - expect(dfs(sampleGraph, [1, 1], [6, 5])).toBeTruthy(); - expect(dfs(sampleGraph, [1, 1], [0, 5])).toBeFalsy(); + it('should always find a path between two directly connected nodes', + function () { + expect(dfs([[0, 1], [1, 0]], 0, 1)).toBeTruthy(); + expect(dfs([[0, 1], [1, 0]], 1, 0)).toBeTruthy(); + }); + + it('should always find a path between two directly connected' + + 'connected nodes in a directed graph', function () { + expect(dfs([[0, 0], [1, 0]], 1, 0)).toBeTruthy(); }); + it('should always find a path between two indirectly connected nodes', + function () { + expect(dfs([[0, 1, 0], [0, 0, 1], [0, 0, 0]], 0, 2)).toBeTruthy(); + }); + + it('should not find a path between two nodes, which are not connected', + function () { + expect(dfs([[0, 0], [1, 0]], 0, 1)).toBeFalsy(); + expect(dfs([[0, 0, 0], [0, 0, 1], [0, 0, 0]], 0, 2)).toBeFalsy(); + }); + }); \ No newline at end of file From 0dff9e96e106a99b03849261477140911ea5212f Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 8 Jan 2015 14:33:13 +0200 Subject: [PATCH 281/613] Update Bresenham line drawing algorithm --- src/graphics/bresenham-line-drawing.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/graphics/bresenham-line-drawing.js b/src/graphics/bresenham-line-drawing.js index cd050ac0..cc0f3112 100644 --- a/src/graphics/bresenham-line-drawing.js +++ b/src/graphics/bresenham-line-drawing.js @@ -9,13 +9,14 @@ * @param {number} x2 The first coordinate of the end of the line * @param {number} y2 The second coordinate of the end of the line */ - function drawLine(x1, y1, x2, y2) { + function drawLine(x1, y1, x2, y2, draw) { + drawPoint = draw || drawPoint; var dx = Math.abs(x2 - x1), - dy = Math.abs(y2 - y1), - cx = (x1 < x2) ? 1 : -1, - cy = (y1 < y2) ? 1 : -1, - error = dx - dy, - doubledError; + dy = Math.abs(y2 - y1), + cx = (x1 < x2) ? 1 : -1, + cy = (y1 < y2) ? 1 : -1, + error = dx - dy, + doubledError; while (x1 !== x2 || y1 !== y2) { drawPoint(x1, y1); From 30882e04471c9e777478282e1d87f8608ec82845 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 8 Jan 2015 18:33:33 +0200 Subject: [PATCH 282/613] Add contributors list --- readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/readme.md b/readme.md index d2d76109..cdcdb9c2 100644 --- a/readme.md +++ b/readme.md @@ -19,6 +19,10 @@ and all `*.spec.js` files will be executed. Fork the repo and make requred changes. After that push your changes in branch, which is named according to the changes you did. Initiate the PR. +## Contributors + +[![mgechev](https://avatars.githubusercontent.com/u/455023?v=3&s=117)](https://github.com/mgechev)[![Microfed](https://avatars.githubusercontent.com/u/613179?v=3&s=117)](https://github.com/Microfed)[![contra](https://avatars.githubusercontent.com/u/425716?v=3&s=117)](https://github.com/contra) + ## License The code in this repository is distributed under the terms of the MIT license. From 0c2eaf89fdb74bdf106ff17ffce45cfe2a19ec74 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 9 Jan 2015 08:11:17 +0200 Subject: [PATCH 283/613] Update topological sort docs --- src/graphs/others/topological-sort.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/graphs/others/topological-sort.js b/src/graphs/others/topological-sort.js index f0db1a36..3272c75b 100644 --- a/src/graphs/others/topological-sort.js +++ b/src/graphs/others/topological-sort.js @@ -24,6 +24,13 @@ result.push(node); } + /** + * Implements the topological sort algorithm. + * + * @public + * @param {object} graph A graph represented with list of neighbors + * @return {array} The list containing all nodes in topological sorted order + */ return function (graph) { var result = [], visited = [], From d969f4d3bbe559bf553b4a903bcb1842a0f2b10f Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 9 Jan 2015 18:49:39 +0200 Subject: [PATCH 284/613] Add gulp config --- gulpfile.js | 8 ++++++++ package.json | 29 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 gulpfile.js create mode 100644 package.json diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..02de0e94 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,8 @@ +'use strict'; +var jsdoc = require('gulp-jsdoc'), + gulp = require('gulp'); + +gulp.task('jsdoc', function () { + gulp.src('./src/**/*.js') + .pipe(jsdoc('./documentation')); +}); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 00000000..16215507 --- /dev/null +++ b/package.json @@ -0,0 +1,29 @@ +{ + "name": "javascript-algorithms", + "version": "0.0.0", + "description": "Implementations of different computer science algorithms", + "main": "index.js", + "directories": { + "test": "test" + }, + "dependencies": { + "jsdoc": "^3.3.0-alpha13" + }, + "devDependencies": { + "gulp": "^3.8.10", + "gulp-jsdoc": "^0.1.4" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git://github.com/mgechev/javascript-algorithms" + }, + "author": "@mgechev", + "license": "MIT", + "bugs": { + "url": "https://github.com/mgechev/javascript-algorithms/issues" + }, + "homepage": "https://github.com/mgechev/javascript-algorithms" +} From b52ecef4da87555de5e2471d89c19deac6638dfa Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 9 Jan 2015 18:54:34 +0200 Subject: [PATCH 285/613] Fix data types in binary tree --- src/data-structures/binary-search-tree.js | 21 +++++++++++---------- src/data-structures/heap.js | 16 ++++++++-------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index b15f3b46..92c3981a 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -8,9 +8,10 @@ /** * A node of the tree * + * @class * @public * @constructor - * @param {number|string} Value of the node + * @param {Number|String} Value of the node * @param {Node} Left subling * @param {Node} Right sibling * @param {Node} Parent of the node @@ -37,7 +38,7 @@ * O(n) in the worst case. * * @public - * @param {number|string} Value + * @param {Number|String} Value * @param {[Node]} Current node */ BinaryTree.prototype.insert = function (value, current) { @@ -139,7 +140,7 @@ * Finds a node by it's value. Average runtime complexity O(log n) * * @public - * @param {number|string} Value of the node which should be found + * @param {Number|String} Value of the node which should be found */ BinaryTree.prototype.find = function (value) { return this._find(value, this._root); @@ -149,22 +150,22 @@ * Finds a node by it's value in given sub-tree. Average runtime complexity: O(log n). * * @private - * @param {number|string} Value of the node which should be found + * @param {Number|String} Value of the node which should be found * @param {Node} Current node to be checked */ BinaryTree.prototype._find = function (value, current) { if (!current) return null; - + if (current.value === value) return current; - + if (current.value > value) return this._find(value, current._left); - + if (current.value < value) return this._find(value, current._right); - + }; /** @@ -226,7 +227,7 @@ * * @private * @param {Node} Root of the sub-tree - * @param {[number|string]} Current minimum value of the sub-tree + * @param {[Number|String]} Current minimum value of the sub-tree * @returns {Node} The node with minimum value in the sub-tree */ BinaryTree.prototype._findMin = function (node, current) { @@ -243,7 +244,7 @@ * * @private * @param {Node} Root of the sub-tree - * @param {[number|string]} Current maximum value of the sub-tree + * @param {[Number|String]} Current maximum value of the sub-tree * @returns {Node} The node with maximum value in the sub-tree */ BinaryTree.prototype._findMax = function (node, current) { diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index 44146d5a..d702d69b 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -25,7 +25,7 @@ * Complexity O(log n) * * @private - * @param {number} index The parent + * @param {Number} index The parent */ Heap.prototype._heapify = function (index) { var extr = index, @@ -55,9 +55,9 @@ * Changes the key for give index. Complexity O(log n). * * @public - * @param {number} index Index which key should be changed - * @param {number} value New value of the key - * @returns {number} parent The new position of the element + * @param {Number} index Index which key should be changed + * @param {Number} value New value of the key + * @returns {Number} parent The new position of the element */ Heap.prototype.changeKey = function (index, value) { this._heap[index] = value; @@ -92,8 +92,8 @@ * Adds new element to the heap. Complexity O(log n). * * @public - * @param {number} value The new value which will be inserted - * @returns {number} The index of the inserted value + * @param {Number} value The new value which will be inserted + * @returns {Number} The index of the inserted value */ Heap.prototype.add = function (value) { this._heap.push(value); @@ -104,7 +104,7 @@ * Gets the current value which is on the top of the heap. Complexity O(1). * * @public - * returns {numner} The current top value. + * returns {Number} The current top value. */ Heap.prototype.top = function () { return this._heap[0]; @@ -116,7 +116,7 @@ * Complexity O(log n). * * @public - * @returns {number} The extremum value + * @returns {Number} The extremum value */ Heap.prototype.extract = function () { if (!this._heap.length) { From c5afad9cef89966b198752b678e325ef702376a1 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 9 Jan 2015 19:02:56 +0200 Subject: [PATCH 286/613] Update docs --- src/data-structures/binary-search-tree.js | 6 +++--- src/graphs/searching/bfs.js | 22 +++++++++++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 92c3981a..85ac9da5 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -39,7 +39,7 @@ * * @public * @param {Number|String} Value - * @param {[Node]} Current node + * @param {Node} Current node */ BinaryTree.prototype.insert = function (value, current) { if (this._root === null) { @@ -227,7 +227,7 @@ * * @private * @param {Node} Root of the sub-tree - * @param {[Number|String]} Current minimum value of the sub-tree + * @param {Number|String} Current minimum value of the sub-tree * @returns {Node} The node with minimum value in the sub-tree */ BinaryTree.prototype._findMin = function (node, current) { @@ -244,7 +244,7 @@ * * @private * @param {Node} Root of the sub-tree - * @param {[Number|String]} Current maximum value of the sub-tree + * @param {Number|String} Current maximum value of the sub-tree * @returns {Node} The node with maximum value in the sub-tree */ BinaryTree.prototype._findMax = function (node, current) { diff --git a/src/graphs/searching/bfs.js b/src/graphs/searching/bfs.js index 8f037681..0aadac94 100644 --- a/src/graphs/searching/bfs.js +++ b/src/graphs/searching/bfs.js @@ -13,14 +13,30 @@ } /** - * Returns the shortest path between - * startNode and targetNode. - * Time complexity O(|V|*|V|), because we use adjust matrix. + * Breath-First graph searching algorithm. + * Returns the shortest path between startNode and targetNode. + * Time complexity O(|V|*|V|). * + * @module graphs/searching + * @public * @param {array} graph The adjust matrix, which represents the graph * @param {number} startNode The start node * @param {number} targetNode The target, which should be reached + * @param {Array} graph Adjacency matrix, which represents the graph. * @returns {array} The shortest path from startNode to targetNode + * @param {Number} startNode Start node. + * @param {Number} targetNode Target, which should be reached. + * @returns {Array} Shortest path from startNode to targetNode. + * + * @example + * var bfs = require('path-to-algorithms/src/graphs/searching/bfs').bfs; + * var graph = [[1, 1, 0, 0, 1, 0], + * [1, 0, 1, 0, 1, 0], + * [0, 1, 0, 1, 0, 0], + * [0, 0, 1, 0, 1, 1], + * [1, 1, 0, 1, 0, 0], + * [0, 0, 0, 1, 0, 0]]; + * var shortestPath = bfs(graph, 1, 5); // [1, 2, 3, 5] */ return function (graph, startNode, targetNode) { var parents = [], From d0e6ca9c89d9109926b3e388bf78d897aee9400c Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 9 Jan 2015 19:14:42 +0200 Subject: [PATCH 287/613] Update the gulpfile --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 02de0e94..18d6d1c8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,5 +4,5 @@ var jsdoc = require('gulp-jsdoc'), gulp.task('jsdoc', function () { gulp.src('./src/**/*.js') - .pipe(jsdoc('./documentation')); + .pipe(jsdoc('../javascript-algorithms-docs')); }); \ No newline at end of file From 023167c40426f2a9d6936f47dd84b2ed6a027b67 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 9 Jan 2015 19:51:10 +0200 Subject: [PATCH 288/613] Add .jshintrc --- .jshintrc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.jshintrc b/.jshintrc index f715520a..c3863960 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,4 +1,6 @@ { + "browser": true, + "jquery": true, "node": true, "esnext": true, "bitwise": true, @@ -25,11 +27,5 @@ "loopfunc": true, "maxcomplexity": 9, "maxlen": 80, - "globals": { - "window": true, - "it": true, - "beforeEach": true, - "describe": true, - "expect": true - } + "maxparams": 4 } From 5dda0d108ac1c5f1d2f5c6bc175d06dacc4cbcca Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Fri, 9 Jan 2015 20:53:07 +0200 Subject: [PATCH 289/613] add first docs, fix readme --- .gitignore | 2 + gulpfile.js | 2 +- readme.md | 33 +++- src/graphs/others/topological-sort.js | 26 ++- src/graphs/searching/bfs.js | 12 +- src/graphs/searching/dfs.js | 36 ++-- src/graphs/shortest-path/bellman-ford.js | 55 ++++-- src/graphs/shortest-path/dijkstra.js | 203 +++++++++++---------- src/graphs/shortest-path/floyd-warshall.js | 80 ++++++++ src/graphs/shortest-path/floyd.js | 74 -------- 10 files changed, 288 insertions(+), 235 deletions(-) create mode 100644 .gitignore create mode 100644 src/graphs/shortest-path/floyd-warshall.js delete mode 100644 src/graphs/shortest-path/floyd.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..5171c540 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +npm-debug.log \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 18d6d1c8..ecc6f686 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,6 +3,6 @@ var jsdoc = require('gulp-jsdoc'), gulp = require('gulp'); gulp.task('jsdoc', function () { - gulp.src('./src/**/*.js') + gulp.src(['./src/**/*.js', "readme.md"]) .pipe(jsdoc('../javascript-algorithms-docs')); }); \ No newline at end of file diff --git a/readme.md b/readme.md index cdcdb9c2..16772f59 100644 --- a/readme.md +++ b/readme.md @@ -1,15 +1,34 @@ -## Note +## About -Note that not all algorithms are well tested so bugs are quite possible. +This repository contains JavaScript implementations of different famous Computer Science algorithms. -## About +API reference with usage examples available here. + +*Note: not all algorithms are well tested so bugs are quite possible.* + +## Development + +To install all dev dependencies use: + +```Bash +npm install +``` + +To setup documentation repository: + +* go to the parent directory of the root of `javascript-algorithms`; +* clone `javascript-algorithms` to directory called `javascript-algorithms-docs` (`git clone git@github.com:mgechev/javascript-algorithms.git javascript-algorithms-docs`); +* change current branch in `javascript-algorithms-docs` to `gh-pages` (`git checkout gh-pages`). + +To generate documentation call: + +`gulp jsdocs` inside `javascript-algorithms` folder. Content of the `javascript-algorithms-docs` will be updated and you will be able to look it in your browser. -This repository contains different famous Computer Science algorithms implemented in JavaScript -In order to run the tests use: +To run tests use: ```Bash -jasmine-node test/ +./node_modules/jasmine-node/bin/jasmine-node test/ ``` and all `*.spec.js` files will be executed. @@ -25,4 +44,4 @@ Initiate the PR. ## License -The code in this repository is distributed under the terms of the MIT license. +The code in this repository is distributed under the terms of the MIT license. \ No newline at end of file diff --git a/src/graphs/others/topological-sort.js b/src/graphs/others/topological-sort.js index 3272c75b..58945075 100644 --- a/src/graphs/others/topological-sort.js +++ b/src/graphs/others/topological-sort.js @@ -1,10 +1,6 @@ (function (exports) { 'use strict'; - /** - * Complexity O(|E|), where E is the set - * which contains all edges and |E| is their count. - */ var topologicalSort = (function () { function topologicalSortHelper(node, visited, temp, graph, result) { @@ -25,11 +21,24 @@ } /** - * Implements the topological sort algorithm. + * Topological sort algorithm of a directed acyclic graph.

+ * Time complexity: O(|E|) where E is a number of edges. * * @public - * @param {object} graph A graph represented with list of neighbors - * @return {array} The list containing all nodes in topological sorted order + * @module graphs/others/topological-sort + * @param {Array} graph Adjacency list, which represents the graph. + * @returns {Array} Ordered vertices. + * + * @example + * var topsort = require('path-to-algorithms/src/graphs/others/topological-sort').topologicalSort; + * var graph = { + * v1: ['v2', 'v5'], + * v2: [], + * v3: ['v1', 'v2', 'v4', 'v5'], + * v4: [], + * v5: [] + * }; + * var vertices = topsort(graph); // ['v3', 'v4', 'v1', 'v5', 'v2'] */ return function (graph) { var result = [], @@ -46,5 +55,4 @@ exports.topologicalSort = topologicalSort; -}(typeof exports === 'undefined' ? window : exports)); - +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file diff --git a/src/graphs/searching/bfs.js b/src/graphs/searching/bfs.js index 0aadac94..4711f5cd 100644 --- a/src/graphs/searching/bfs.js +++ b/src/graphs/searching/bfs.js @@ -14,16 +14,12 @@ /** * Breath-First graph searching algorithm. - * Returns the shortest path between startNode and targetNode. - * Time complexity O(|V|*|V|). + * Returns the shortest path between startNode and targetNode.

+ * Time complexity: O(|V|^2). * - * @module graphs/searching * @public - * @param {array} graph The adjust matrix, which represents the graph - * @param {number} startNode The start node - * @param {number} targetNode The target, which should be reached + * @module graphs/searching/bfs * @param {Array} graph Adjacency matrix, which represents the graph. - * @returns {array} The shortest path from startNode to targetNode * @param {Number} startNode Start node. * @param {Number} targetNode Target, which should be reached. * @returns {Array} Shortest path from startNode to targetNode. @@ -65,4 +61,4 @@ exports.bfs = bfs; -}((typeof window === 'undefined') ? module.exports : window)); +}((typeof window === 'undefined') ? module.exports : window)); \ No newline at end of file diff --git a/src/graphs/searching/dfs.js b/src/graphs/searching/dfs.js index e6df5d97..fdaa2524 100644 --- a/src/graphs/searching/dfs.js +++ b/src/graphs/searching/dfs.js @@ -1,18 +1,8 @@ -/** - * Depth-First Search graph searching algorithm. - * Finds out whether there's a path between - * two nodes - start node and a target. - */ - (function (exports) { 'use strict'; var dfs = (function () { - /** - * Implements an iterative DFS. - * Complexity O(|V|^2), since it uses adjust matrix. - */ function hasPath(graph, current, goal) { var stack = [], visited = [], @@ -35,14 +25,26 @@ } /** - * Returns whether there's a path between two nodes - * in a graph represented with adjust matrix. + * Depth-First graph searching algorithm. + * Returns whether there's a path between two nodes in a graph.

+ * Time complexity: O(|V|^2). * + * @module graphs/searching/dfs * @public - * @param {array} graph Adjust matrix representation of a graph - * @param {number} start A start node - * @param {number} goal The target node - * @return {boolean} Returns whether there's a path between start and goal + * @param {Array} graph Adjacency matrix, which represents the graph. + * @param {Number} start Start node. + * @param {Number} goal Target node. + * @return {Boolean} Returns true if path between two nodes exists. + * + * @example + * var dfs = require('../src/graphs/searching/dfs').dfs; + * var graph = [[1, 1, 0, 0, 1, 0], + * [1, 0, 1, 0, 1, 0], + * [0, 1, 0, 1, 0, 0], + * [0, 0, 1, 0, 1, 1], + * [1, 1, 0, 1, 0, 0], + * [0, 0, 0, 1, 0, 0]]; + * var pathExists = dfs(graph, 1, 5); // true */ return function (graph, start, goal) { return hasPath(graph, start, goal); @@ -51,4 +53,4 @@ exports.dfs = dfs; -}(typeof exports === 'undefined' ? window : exports)); +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file diff --git a/src/graphs/shortest-path/bellman-ford.js b/src/graphs/shortest-path/bellman-ford.js index b5d80939..3746d59e 100644 --- a/src/graphs/shortest-path/bellman-ford.js +++ b/src/graphs/shortest-path/bellman-ford.js @@ -7,7 +7,42 @@ this.weight = weight; } - // Complexity O(|V||E|) + /** + * Bellman–Ford algorithm computes shortest paths from a single source + * vertex to all of the other vertices in a weighted digraph (negative weights allowed).

+ * Time complexity: O(|V||E|) where V and E are the number of vertices and edges respectively. + * + * @public + * @module graphs/shortest-path/bellman-ford + * @param {Array} vertexes Vertices of the graph. + * @param {Array} edges Edges of the graph. + * @param {Number} source Start vertex. + * @returns {Object} Object with two arrays (parents and distances) with shortest-path information. + * + * @example + * require('path-to-algorithms/src/graphs/shortest-path/bellman-ford'); + * + * var glob = (typeof window === 'undefined') ? global : window; + * var Edge = glob.Edge; + * var bellmanFord = glob.bellmanFord; + * var edges = []; + * var vertexes = [0, 1, 2, 3, 4]; + * + * edges.push(new Edge(0, 1, -1)); + * edges.push(new Edge(0, 2, 4)); + * edges.push(new Edge(1, 2, 3)); + * edges.push(new Edge(1, 3, 2)); + * edges.push(new Edge(3, 1, 1)); + * edges.push(new Edge(4, 3, -3)); + * edges.push(new Edge(1, 4, 2)); + * edges.push(new Edge(3, 2, 5)); + * + * // { + * // parents: { '0': null, '1': 0, '2': 1, '3': 4, '4': 1 }, + * // distances: { '0': 0, '1': -1, '2': 2, '3': -2, '4': 1 } + * // } + * var pathInfo = bellmanFord(vertexes, edges, 0); + */ function bellmanFord(vertexes, edges, source) { var distances = {}, parents = {}, c; for (var i = 0; i < vertexes.length; i += 1) { @@ -38,20 +73,4 @@ global.Edge = Edge; global.bellmanFord = bellmanFord; -}((typeof window === 'undefined') ? global : window)); - -// var glob = (typeof window === 'undefined') ? global : window; -// var Edge = glob.Edge; -// var bellmanFord = glob.bellmanFord; -// var edges = []; -// var vertexes = [0, 1, 2, 3, 4]; -// edges.push(new Edge(0, 1, -1)); -// edges.push(new Edge(0, 2, 4)); -// edges.push(new Edge(1, 2, 3)); -// edges.push(new Edge(1, 3, 2)); -// edges.push(new Edge(3, 1, 1)); -// edges.push(new Edge(4, 3, -3)); -// edges.push(new Edge(1, 4, 2)); -// edges.push(new Edge(3, 2, 5)); -// -// console.log(bellmanFord(vertexes, edges, 0)); +}((typeof window === 'undefined') ? global : window)); \ No newline at end of file diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index 37de6669..433c40fd 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -1,114 +1,115 @@ -/*********************************************** - A sample distance matrix - -var graph = [[Infinity, 7, 9, Infinity, Infinity, 16], - [7, Infinity, 10, 15, Infinity, Infinity], - [9, 10, Infinity, 11, Infinity, 2], - [Infinity, 15, 11, Infinity, 6, Infinity], - [Infinity, Infinity, Infinity, 6, Infinity, 9], - [16, Infinity, 2, Infinity, 9, Infinity]]; -***********************************************/ - - -/** - * Dijstra's shortest path algorithm. - * For the implementation is not used the most - * suitable data structure (Fibonacci heap) - * but the binary heap gives also good results. The implementation bellow finds - * the minimum distance between two given nodes using a distance matrix. - */ -var dijstra = function () { +(function (exports) { 'use strict'; - var Heap = require('../../data-structures/heap.js').Heap, - current, - visited, - distance, - unvisited; + var dijkstra = (function() { + var Heap = require('../../data-structures/heap.js').Heap, + current, + visited, + distance, + unvisited; - /** - * Creates a new node instance - * - * @constructor - * @private - * @param {number} id The id of the node - * @param {number} distance The distance from the beginning - */ - function Node(id, distance) { - this.node = id; - this.distance = distance; - } + /** + * Creates a new node instance. + * + * @constructor + * @private + * @param {Number} id Id of the node. + * @param {Number} distance Distance from the beginning. + */ + function Node(id, distance) { + this.node = id; + this.distance = distance; + } - /** - * Compares the distances between two nodes. - * - * @private - * @param {object} a A node - * @param {object} b A graph node - * @returns {number} The - */ - function compareNodesDistance(a, b) { - return b.distance - a.distance; - } + /** + * Compares the distances between two nodes. + * + * @private + * @param {Node} a 1st node. + * @param {Node} b 2nd node. + * @returns {number} diff between node distances. + */ + function compareNodesDistance(a, b) { + return b.distance - a.distance; + } - /** - * Initialize all variables used for the algorithm - * - * @private - * @param {number} src A start node - */ - function init(src, graph) { - var currentTemp; - current = {}; - visited = []; - distance = []; - unvisited = new Heap(compareNodesDistance); - for (var i = 0; i < graph.length; i += 1) { - currentTemp = new Node(); - if (src === i) { - currentTemp.distance = 0; - } else { - currentTemp.distance = Infinity; + /** + * Initialize all variables used for the algorithm. + * + * @private + * @param {number} src Start node. + */ + function init(src, graph) { + var currentTemp; + current = {}; + visited = []; + distance = []; + unvisited = new Heap(compareNodesDistance); + for (var i = 0; i < graph.length; i += 1) { + currentTemp = new Node(); + if (src === i) { + currentTemp.distance = 0; + } else { + currentTemp.distance = Infinity; + } + currentTemp.node = i; + visited[i] = false; + distance[i] = currentTemp; + unvisited.add(currentTemp); } - currentTemp.node = i; - visited[i] = false; - distance[i] = currentTemp; - unvisited.add(currentTemp); + current.node = src; + current.distance = 0; } - current.node = src; - current.distance = 0; - } - /** - * Dijkstra's shortest path algorithm - * - * @public - * @param {number} src Source node - * @param {number} dest Destination node - * @param {array} graph A distance matrix of the graph - * @returns {number} The shortest distance between the nodes - */ - return function (src, dest, graph) { - var tempDistance = 0; - init(src, graph); - while (current.node !== dest && isFinite(current.distance)) { - for (var i = 0; i < graph.length; i += 1) { - if (current.node !== i && //if it's not the current node - !visited[i] && //and if we haven't visited this node - Number.isFinite(graph[i][current.node])) { //and this node is sibling of the current... + /** + * Dijkstra's shortest path algorithm. Finds the minimum + * distance between two given nodes using a distance matrix.

+ * For the implementation is not used the most suitable data structure + * (Fibonacci heap) but the Binary heap gives also good results. + * + * @public + * @module graphs/shortest-path/dijkstra + * @param {Number} src Source node. + * @param {Number} dest Destination node. + * @param {Array} graph A distance matrix of the graph. + * @returns {Number} The shortest distance between two nodes. + * + * @example + * var dijkstra = require('path-to-algorithms/src/graphs/shortest-path/dijkstra').dijkstra; + * var distMatrix = [[Infinity, 7, 9, Infinity, Infinity, 16], + * [7, Infinity, 10, 15, Infinity, Infinity], + * [9, 10, Infinity, 11, Infinity, 2], + * [Infinity, 15, 11, Infinity, 6, Infinity], + * [Infinity, Infinity, Infinity, 6, Infinity, 9], + * [16, Infinity, 2, Infinity, 9, Infinity]]; + * var shortestDist = dijkstra(0, 2, distMatrix); // 9 + */ + return function (src, dest, graph) { + var tempDistance = 0; + init(src, graph); + while (current.node !== dest && isFinite(current.distance)) { + for (var i = 0; i < graph.length; i += 1) { + if (current.node !== i && //if it's not the current node + !visited[i] && //and if we haven't visited this node + Number.isFinite(graph[i][current.node])) { //and this node is sibling of the current... - tempDistance = current.distance + graph[i][current.node]; - if (tempDistance < distance[i].distance) { - distance[i].distance = tempDistance; - current.distance = tempDistance; - unvisited.update(current); + tempDistance = current.distance + graph[i][current.node]; + if (tempDistance < distance[i].distance) { + distance[i].distance = tempDistance; + current.distance = tempDistance; + unvisited.update(current); + } } } + visited[current.node] = true; + current = unvisited.extract(); } - visited[current.node] = true; - current = unvisited.extract(); - } - return distance[dest].distance; - }; -}(); + return distance[dest].distance; + }; + + })(); + + exports.dijkstra = dijkstra; + +})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file diff --git a/src/graphs/shortest-path/floyd-warshall.js b/src/graphs/shortest-path/floyd-warshall.js new file mode 100644 index 00000000..565c8319 --- /dev/null +++ b/src/graphs/shortest-path/floyd-warshall.js @@ -0,0 +1,80 @@ +(function (exports) { + 'use strict'; + + var floydWarshall = (function () { + + /** + * Matrix used for the algorithm. + */ + var dist; + + /** + * Initialize the distance matrix. + * + * @private + * @param {array} graph Distance matrix of the array. + * @return {array} Distance matrix used for the algorithm. + */ + function init(graph) { + var dist = []; + var size = graph.length; + for (var i = 0; i < size; i += 1) { + dist[i] = []; + for (var j = 0; j < size; j += 1) { + if (i === j) { + dist[i][j] = 0; + } else if (isNaN(graph[i][j])) { + dist[i][j] = Infinity; + } else { + dist[i][j] = graph[i][j]; + } + } + } + return dist; + } + + /** + * Floyd-Warshall algorithm. Finds the shortest path between each two vertices.

+ * Complexity: O(|V|^3) where V is the number of vertices. + * + * @public + * @module graphs/shortest-path/floyd-warshall + * @param {Array} graph A distance matrix of the graph. + * @return {Array} Array which contains the shortest distance between each two vertices. + * + * @example + * var floydWarshall = require('path-to-algorithms/src/graphs/shortest-path/floyd-warshall').floydWarshall; + * var distMatrix = [[NaN, 7, 9, NaN, NaN, 16], + * [7, NaN, 10, 15, NaN, NaN], + * [9, 10, NaN, 11, NaN, 2], + * [NaN, 15, 11, NaN, 6, NaN], + * [NaN, NaN, NaN, 6, NaN, 9], + * [16, NaN, 2, NaN, 9, NaN]]; + * + * // [ [ 0, 7, 9, 20, 20, 11 ], + * // [ 7, 0, 10, 15, 21, 12 ], + * // [ 9, 10, 0, 11, 11, 2 ], + * // [ 20, 15, 11, 0, 6, 13 ], + * // [ 20, 21, 11, 6, 0, 9 ], + * // [ 11, 12, 2, 13, 9, 0 ] ] + * var shortestDists = floydWarshall(distMatrix); + */ + return function (graph) { + dist = init(graph); + var size = graph.length; + for (var k = 0; k < size; k += 1) { + for (var i = 0; i < size; i += 1) { + for (var j = 0; j < size; j += 1) { + if (dist[i][j] > dist[i][k] + dist[k][j]) { + dist[i][j] = dist[i][k] + dist[k][j]; + } + } + } + } + return dist; + }; + }()); + + exports.floydWarshall = floydWarshall; + +})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file diff --git a/src/graphs/shortest-path/floyd.js b/src/graphs/shortest-path/floyd.js deleted file mode 100644 index 41ff368e..00000000 --- a/src/graphs/shortest-path/floyd.js +++ /dev/null @@ -1,74 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * - - A sample distance matrix - -var graph = [[NaN, 7, 9, NaN, NaN, 16], - [7, NaN, 10, 15, NaN, NaN], - [9, 10, NaN, 11, NaN, 2], - [NaN, 15, 11, NaN, 6, NaN], - [NaN, NaN, NaN, 6, NaN, 9], - [16, NaN, 2, NaN, 9, NaN]]; - -* * * * * * * * * * * * * * * * * * * * * * * */ - -/** - * Finds the shortest distance between all vertices of the graph - * using the Floyd-Warshall algorithm. - * - * Complexity O(n^3) - */ -var floydWarshall = (function () { - - /** - * Matrix used for the algorithm. - */ - var dist; - - /** - * Initialize the distance matrix - * - * @private - * @param {array} graph Distance matrix of the array - * @return {array} Distance matrix used for the algorithm - */ - function init(graph) { - var dist = []; - var size = graph.length; - for (var i = 0; i < size; i += 1) { - dist[i] = []; - for (var j = 0; j < size; j += 1) { - if (i === j) { - dist[i][j] = 0; - } else if (isNaN(graph[i][j])) { - dist[i][j] = Infinity; - } else { - dist[i][j] = graph[i][j]; - } - } - } - return dist; - } - - /** - * Finds the shortest path between each two vertices - * Complexity O(n^3) - * - * @public - * @param {array} graph The graph which should be processed - * @return {array} The array which contains the shortest distance between each two vertices - */ - return function (graph) { - dist = init(graph); - var size = graph.length; - for (var k = 0; k < size; k += 1) { - for (var i = 0; i < size; i += 1) { - for (var j = 0; j < size; j += 1) { - if (dist[i][j] > dist[i][k] + dist[k][j]) { - dist[i][j] = dist[i][k] + dist[k][j]; - } - } - } - } - return dist; - }; -}()); From 8aa65272a03e854ebb06792c2c39159ae5c98e5c Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Fri, 9 Jan 2015 22:10:46 +0200 Subject: [PATCH 290/613] gulp jsdoc command fixed, now @param and @return works --- doc-config.json | 35 +++++++++++++++++++++++++++++++++++ gulpfile.js | 11 +++++------ package.json | 3 ++- 3 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 doc-config.json diff --git a/doc-config.json b/doc-config.json new file mode 100644 index 00000000..2b64214c --- /dev/null +++ b/doc-config.json @@ -0,0 +1,35 @@ +{ + "tags": { + "allowUnknownTags": true + }, + "source": { + "include": [ + "./src/graphs/searching/", + "./src/graphs/others/", + "./src/graphs/shortest-path/" + ], + "includePattern": ".+\\.js(doc)?$", + "excludePattern": "docs" + }, + "plugins": [], + "templates": { + "cleverLinks": false, + "monospaceLinks": true, + "systemName": "remoteFileExplorer", + "footer": "Created by Simon Speich", + "copyright": "2013", + "navType": "vertical", + "theme": "spacelab", + "linenums": true, + "collapseSymbols": true, + "inverseNav": false + }, + "opts": { + "template": "templates/default", + "encoding": "utf8", + "destination": "../javascript-algorithms-docs", + "recurse": true, + "private": true, + "readme": "./readme.md" + } +} \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index ecc6f686..b041d05b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,8 +1,7 @@ 'use strict'; -var jsdoc = require('gulp-jsdoc'), - gulp = require('gulp'); +var gulp = require('gulp'), + shell = require('gulp-shell'); -gulp.task('jsdoc', function () { - gulp.src(['./src/**/*.js', "readme.md"]) - .pipe(jsdoc('../javascript-algorithms-docs')); -}); \ No newline at end of file +gulp.task('jsdoc', shell.task([ + './node_modules/.bin/jsdoc -c ./doc-config.json', +])); \ No newline at end of file diff --git a/package.json b/package.json index 16215507..338952d2 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ }, "devDependencies": { "gulp": "^3.8.10", - "gulp-jsdoc": "^0.1.4" + "jsdoc": "^3.3.0", + "gulp-shell": "^0.2.11" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" From 1c312d8dfbae303311c4904cc00397d42e311d53 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Fri, 9 Jan 2015 22:50:35 +0200 Subject: [PATCH 291/613] fix readme.md --- readme.md | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index 16772f59..1602e33b 100644 --- a/readme.md +++ b/readme.md @@ -8,24 +8,43 @@ API reference with usage examples available Date: Sat, 10 Jan 2015 01:10:41 +0200 Subject: [PATCH 294/613] fix bellman-ford code&doc, add prim jsdoc --- src/graphs/shortest-path/bellman-ford.js | 79 +++--- src/graphs/spanning-trees/prim.js | 291 ++++++++++++----------- 2 files changed, 195 insertions(+), 175 deletions(-) diff --git a/src/graphs/shortest-path/bellman-ford.js b/src/graphs/shortest-path/bellman-ford.js index 3746d59e..6f7103b2 100644 --- a/src/graphs/shortest-path/bellman-ford.js +++ b/src/graphs/shortest-path/bellman-ford.js @@ -1,49 +1,63 @@ -(function (global) { +/** + * Bellman–Ford algorithm computes shortest paths from a single source + * vertex to all of the other vertices in a weighted digraph (negative weights allowed).

+ * Time complexity: O(|V||E|) where V and E are the number of vertices and edges respectively. + * + * @example + * + * var BellmanFord = require('../src/graphs/shortest-path/bellman-ford'); + * var Edge = BellmanFord.Edge; + * var bellmanFord = BellmanFord.bellmanFord; + * var edges = []; + * var vertexes = [0, 1, 2, 3, 4]; + * + * edges.push(new Edge(0, 1, -1)); + * edges.push(new Edge(0, 2, 4)); + * edges.push(new Edge(1, 2, 3)); + * edges.push(new Edge(1, 3, 2)); + * edges.push(new Edge(3, 1, 1)); + * edges.push(new Edge(4, 3, -3)); + * edges.push(new Edge(1, 4, 2)); + * edges.push(new Edge(3, 2, 5)); + * + * // { + * // parents: { '0': null, '1': 0, '2': 1, '3': 4, '4': 1 }, + * // distances: { '0': 0, '1': -1, '2': 2, '3': -2, '4': 1 } + * // } + * var pathInfo = bellmanFord(vertexes, edges, 0); + * + * @module graphs/shortest-path/bellman-ford + */ +(function (exports) { + 'use strict'; - function Edge(u, v, weight) { + /** + * Graph edge. + * + * @constructor + * @public + * @param {Vertex} u Start vertex. + * @param {Vertex} v End vertex. + * @param {Number} weight Weight of the edge. + */ + exports.Edge = function(u, v, weight) { this.from = u; this.to = v; this.weight = weight; } /** - * Bellman–Ford algorithm computes shortest paths from a single source - * vertex to all of the other vertices in a weighted digraph (negative weights allowed).

- * Time complexity: O(|V||E|) where V and E are the number of vertices and edges respectively. + * Computes shortest paths from a single source vertex to all of the other vertices. * * @public - * @module graphs/shortest-path/bellman-ford * @param {Array} vertexes Vertices of the graph. * @param {Array} edges Edges of the graph. * @param {Number} source Start vertex. * @returns {Object} Object with two arrays (parents and distances) with shortest-path information. * - * @example - * require('path-to-algorithms/src/graphs/shortest-path/bellman-ford'); - * - * var glob = (typeof window === 'undefined') ? global : window; - * var Edge = glob.Edge; - * var bellmanFord = glob.bellmanFord; - * var edges = []; - * var vertexes = [0, 1, 2, 3, 4]; - * - * edges.push(new Edge(0, 1, -1)); - * edges.push(new Edge(0, 2, 4)); - * edges.push(new Edge(1, 2, 3)); - * edges.push(new Edge(1, 3, 2)); - * edges.push(new Edge(3, 1, 1)); - * edges.push(new Edge(4, 3, -3)); - * edges.push(new Edge(1, 4, 2)); - * edges.push(new Edge(3, 2, 5)); - * - * // { - * // parents: { '0': null, '1': 0, '2': 1, '3': 4, '4': 1 }, - * // distances: { '0': 0, '1': -1, '2': 2, '3': -2, '4': 1 } - * // } - * var pathInfo = bellmanFord(vertexes, edges, 0); */ - function bellmanFord(vertexes, edges, source) { + exports.bellmanFord = function(vertexes, edges, source) { var distances = {}, parents = {}, c; for (var i = 0; i < vertexes.length; i += 1) { distances[vertexes[i]] = Infinity; @@ -70,7 +84,4 @@ return { parents: parents, distances: distances }; } - global.Edge = Edge; - global.bellmanFord = bellmanFord; - -}((typeof window === 'undefined') ? global : window)); \ No newline at end of file +})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file diff --git a/src/graphs/spanning-trees/prim.js b/src/graphs/spanning-trees/prim.js index 6e088852..fc1142cd 100644 --- a/src/graphs/spanning-trees/prim.js +++ b/src/graphs/spanning-trees/prim.js @@ -1,169 +1,178 @@ -var Heap = require('../../data-structures/heap').Heap; - /** - * Graph vertex + * Prim's algorithm is a greedy algorithm that finds a minimum + * spanning tree for a connected weighted undirected graph. * - * @constructor - * @public - * @param {number} id The id of the vertex - */ -function Vertex(id) { - 'use strict'; - this.id = id; -} - -/** - * Graph edge + * @example * - * @constructor - * @public - * @param {Vertex} e Vertex which this edge connects - * @param {Vertex} v Vertex which this edge connects - * @param {number} distance Weight of the node - */ -function Edge(e, v, distance) { - 'use strict'; - this.e = e; - this.v = v; - this.distance = distance; -} - -/** - * Graph + * var Prim = require('path-to-algorithms/src/graphs/spanning-trees/prim'); + * var Graph = Prim.Graph; + * var Edge = Prim.Edge; + * var Vertex = Prim.Vertex; * - * @constructor - * @public - */ -function Graph(edges, nodesCount) { - 'use strict'; - this.edges = edges || []; - this.nodesCount = nodesCount || 0; -} - -/** - * Prim's algorithm for minimum spanning tree + * var graph, edges = []; + * edges.push(new Edge(new Vertex(0), new Vertex(1), 4)); + * edges.push(new Edge(new Vertex(0), new Vertex(7), 8)); + * edges.push(new Edge(new Vertex(1), new Vertex(7), 11)); + * edges.push(new Edge(new Vertex(1), new Vertex(2), 8)); + * edges.push(new Edge(new Vertex(2), new Vertex(8), 2)); + * edges.push(new Edge(new Vertex(2), new Vertex(3), 7)); + * edges.push(new Edge(new Vertex(2), new Vertex(5), 4)); + * edges.push(new Edge(new Vertex(2), new Vertex(3), 7)); + * edges.push(new Edge(new Vertex(3), new Vertex(4), 9)); + * edges.push(new Edge(new Vertex(3), new Vertex(5), 14)); + * edges.push(new Edge(new Vertex(4), new Vertex(5), 10)); + * edges.push(new Edge(new Vertex(5), new Vertex(6), 2)); + * edges.push(new Edge(new Vertex(6), new Vertex(8), 6)); + * edges.push(new Edge(new Vertex(8), new Vertex(7), 7)); + * graph = new Graph(edges, 9); + * + * // { edges: + * // [ { e: '1', v: 0, distance: 4 }, + * // { e: '2', v: 8, distance: 2 }, + * // { e: '3', v: 2, distance: 7 }, + * // { e: '4', v: 3, distance: 9 }, + * // { e: '5', v: 2, distance: 4 }, + * // { e: '6', v: 5, distance: 2 }, + * // { e: '7', v: 0, distance: 8 }, + * // { e: '8', v: 7, distance: 7 } ], + * // nodesCount: 0 } + * var spanningTree = graph.prim(); * - * @public - * @return {Graph} Graph which is the minimum spanning tree + * @module graphs/spanning-trees/prim */ -Graph.prototype.prim = (function () { +(function (exports) { + 'use strict'; - var queue; + var Heap = require('../../data-structures/heap').Heap; /** - * Initialize the algorithm. + * Graph vertex. * - * @private + * @constructor + * @public + * @param {Number} id Id of the vertex. */ - function init() { - queue = new Heap(compareEdges); + exports.Vertex = function(id) { + this.id = id; } /** - * Used for comparitions in the heap + * Graph edge. * - * @private - * @param {Vertex} a First operand of the comparition - * @param {Vertex} b Second operand of the comparition - * @return {number} Number which which is equal, greater or less then zero and - * indicates whether the first vertex is "greater" than the second. + * @constructor + * @public + * @param {Vertex} e Vertex which this edge connects. + * @param {Vertex} v Vertex which this edge connects. + * @param {Number} distance Weight of the edge. */ - function compareEdges(a, b) { - return b.distance - a.distance; + exports.Edge = function(e, v, distance) { + this.e = e; + this.v = v; + this.distance = distance; } /** - * Prim's algorithm implementation + * Graph. * + * @constructor * @public - * @return {Graph} Minimum spanning tree. + * @param {Array} edges Array with graph edges. + * @param {Number} nodesCount Number of nodes in graph. */ - return function () { - init.call(this); - var inTheTree = {}, - startVertex = this.edges[0].e.id, - spannigTree = [], - parents = {}, - distances = {}, - current; - inTheTree[startVertex] = true; - queue.add({ - node: startVertex, - distance: 0 - }); - for (var i = 0; i < this.nodesCount - 1; i += 1) { - current = queue.extract().node; - inTheTree[current] = true; - this.edges.forEach(function (e) { - if (inTheTree[e.v.id] && inTheTree[e.e.id]) { - return; - } - var collection = queue.getCollection(), - node; - if (e.e.id === current) { - node = e.v.id; - } else if (e.v.id === current) { - node = e.e.id; - } else { - return; - } - for (var i = 0; i < collection.length; i += 1) { - if (collection[i].node === node) { - if (collection[i].distance > e.distance) { - queue.changeKey(i, { - node: node, - distance: e.distance - }); - parents[node] = current; - distances[node] = e.distance; - } - return; - } - } - queue.add({ - node: node, - distance: e.distance - }); - parents[node] = current; - distances[node] = e.distance; - }); - console.log(queue._heap); - console.log(); - } - for (var node in parents) { - spannigTree.push(new Edge(node, parents[node], distances[node])); - } - return new Graph(spannigTree); - }; + exports.Graph = function(edges, nodesCount) { + this.edges = edges || []; + this.nodesCount = nodesCount || 0; + } -}()); + /** + * Executes Prim's algorithm and returns minimum spanning tree. + * + * @public + * @method + * @return {Graph} Graph which is the minimum spanning tree. + */ + exports.Graph.prototype.prim = (function () { + var queue; -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * * * * * * * * * * * * * * Sample graph * * * * * * * * * * * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -(function () { - 'use strict'; - var graph, edges = []; - edges.push(new Edge(new Vertex(0), new Vertex(1), 4)); - edges.push(new Edge(new Vertex(0), new Vertex(7), 8)); - edges.push(new Edge(new Vertex(1), new Vertex(7), 11)); - edges.push(new Edge(new Vertex(1), new Vertex(2), 8)); - edges.push(new Edge(new Vertex(2), new Vertex(8), 2)); - edges.push(new Edge(new Vertex(2), new Vertex(3), 7)); - edges.push(new Edge(new Vertex(2), new Vertex(5), 4)); - edges.push(new Edge(new Vertex(2), new Vertex(3), 7)); - edges.push(new Edge(new Vertex(3), new Vertex(4), 9)); - edges.push(new Edge(new Vertex(3), new Vertex(5), 14)); - edges.push(new Edge(new Vertex(4), new Vertex(5), 10)); - edges.push(new Edge(new Vertex(5), new Vertex(6), 2)); - edges.push(new Edge(new Vertex(6), new Vertex(8), 6)); - edges.push(new Edge(new Vertex(8), new Vertex(7), 7)); - graph = new Graph(edges, 9); + /** + * Initialize the algorithm. + * + * @private + */ + function init() { + queue = new Heap(compareEdges); + } - console.log(graph.prim()); -}()); + /** + * Used for comparitions in the heap + * + * @private + * @param {Vertex} a First operand of the comparition. + * @param {Vertex} b Second operand of the comparition. + * @return {number} Number which which is equal, greater or less then zero and + * indicates whether the first vertex is "greater" than the second. + */ + function compareEdges(a, b) { + return b.distance - a.distance; + } + + return function () { + init.call(this); + var inTheTree = {}, + startVertex = this.edges[0].e.id, + spannigTree = [], + parents = {}, + distances = {}, + current; + inTheTree[startVertex] = true; + queue.add({ + node: startVertex, + distance: 0 + }); + for (var i = 0; i < this.nodesCount - 1; i += 1) { + current = queue.extract().node; + inTheTree[current] = true; + this.edges.forEach(function (e) { + if (inTheTree[e.v.id] && inTheTree[e.e.id]) { + return; + } + var collection = queue.getCollection(), + node; + if (e.e.id === current) { + node = e.v.id; + } else if (e.v.id === current) { + node = e.e.id; + } else { + return; + } + for (var i = 0; i < collection.length; i += 1) { + if (collection[i].node === node) { + if (collection[i].distance > e.distance) { + queue.changeKey(i, { + node: node, + distance: e.distance + }); + parents[node] = current; + distances[node] = e.distance; + } + return; + } + } + queue.add({ + node: node, + distance: e.distance + }); + parents[node] = current; + distances[node] = e.distance; + }); + } + for (var node in parents) { + spannigTree.push(new exports.Edge(node, parents[node], distances[node])); + } + return new exports.Graph(spannigTree); + }; + }()); -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file From 5f952685a8e9959bf38e3629441cc336698b1f5e Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sat, 10 Jan 2015 01:15:21 +0200 Subject: [PATCH 295/613] fix example --- src/graphs/shortest-path/bellman-ford.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphs/shortest-path/bellman-ford.js b/src/graphs/shortest-path/bellman-ford.js index 6f7103b2..1b4f9aff 100644 --- a/src/graphs/shortest-path/bellman-ford.js +++ b/src/graphs/shortest-path/bellman-ford.js @@ -5,7 +5,7 @@ * * @example * - * var BellmanFord = require('../src/graphs/shortest-path/bellman-ford'); + * var BellmanFord = require('path-to-algorithms/src/graphs/shortest-path/bellman-ford'); * var Edge = BellmanFord.Edge; * var bellmanFord = BellmanFord.bellmanFord; * var edges = []; From 1eef837da710d1a72089b1d0a62e34dee6b03ee8 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 10 Jan 2015 02:52:26 +0200 Subject: [PATCH 296/613] Update contributors list --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 16772f59..bbf4fc4b 100644 --- a/readme.md +++ b/readme.md @@ -40,7 +40,7 @@ Initiate the PR. ## Contributors -[![mgechev](https://avatars.githubusercontent.com/u/455023?v=3&s=117)](https://github.com/mgechev)[![Microfed](https://avatars.githubusercontent.com/u/613179?v=3&s=117)](https://github.com/Microfed)[![contra](https://avatars.githubusercontent.com/u/425716?v=3&s=117)](https://github.com/contra) +[![mgechev](https://avatars.githubusercontent.com/u/455023?v=3&s=117)](https://github.com/mgechev)[![AndreyGeonya](https://avatars.githubusercontent.com/u/773648?v=3&s=117)](https://github.com/AndreyGeonya)[![Microfed](https://avatars.githubusercontent.com/u/613179?v=3&s=117)](https://github.com/Microfed)[![contra](https://avatars.githubusercontent.com/u/425716?v=3&s=117)](https://github.com/contra) ## License From ade43d9e76367e66d8c6130ead3e15120fd0e3ec Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 10 Jan 2015 11:59:43 +0200 Subject: [PATCH 297/613] Update readme --- readme.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index 2c69b5f2..ab03808f 100644 --- a/readme.md +++ b/readme.md @@ -12,7 +12,7 @@ API reference with usage examples available
Date: Sat, 10 Jan 2015 12:04:11 +0200 Subject: [PATCH 299/613] Update Bellman-Ford formatting --- src/graphs/shortest-path/bellman-ford.js | 26 ++++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/graphs/shortest-path/bellman-ford.js b/src/graphs/shortest-path/bellman-ford.js index 1b4f9aff..ce836005 100644 --- a/src/graphs/shortest-path/bellman-ford.js +++ b/src/graphs/shortest-path/bellman-ford.js @@ -1,11 +1,14 @@ /** * Bellman–Ford algorithm computes shortest paths from a single source - * vertex to all of the other vertices in a weighted digraph (negative weights allowed).

- * Time complexity: O(|V||E|) where V and E are the number of vertices and edges respectively. + * vertex to all of the other vertices in a weighted digraph + * (negative weights allowed).

+ * Time complexity: O(|V||E|) where V and E are the number of + * vertices and edges respectively. * * @example * - * var BellmanFord = require('path-to-algorithms/src/graphs/shortest-path/bellman-ford'); + * var BellmanFord = + * require('path-to-algorithms/src/graphs/shortest-path/bellman-ford'); * var Edge = BellmanFord.Edge; * var bellmanFord = BellmanFord.bellmanFord; * var edges = []; @@ -20,7 +23,7 @@ * edges.push(new Edge(1, 4, 2)); * edges.push(new Edge(3, 2, 5)); * - * // { + * // { * // parents: { '0': null, '1': 0, '2': 1, '3': 4, '4': 1 }, * // distances: { '0': 0, '1': -1, '2': 2, '3': -2, '4': 1 } * // } @@ -41,23 +44,24 @@ * @param {Vertex} v End vertex. * @param {Number} weight Weight of the edge. */ - exports.Edge = function(u, v, weight) { + exports.Edge = function (u, v, weight) { this.from = u; this.to = v; this.weight = weight; - } + }; /** - * Computes shortest paths from a single source vertex to all of the other vertices. + * Computes shortest paths from a single source + * vertex to all of the other vertices. * * @public * @param {Array} vertexes Vertices of the graph. * @param {Array} edges Edges of the graph. * @param {Number} source Start vertex. - * @returns {Object} Object with two arrays (parents and distances) with shortest-path information. - * + * @returns {Object} Object with two arrays (parents and distances) + * with shortest-path information. */ - exports.bellmanFord = function(vertexes, edges, source) { + exports.bellmanFord = function (vertexes, edges, source) { var distances = {}, parents = {}, c; for (var i = 0; i < vertexes.length; i += 1) { distances[vertexes[i]] = Infinity; @@ -82,6 +86,6 @@ } return { parents: parents, distances: distances }; - } + }; })(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file From f48057148114a2f2059066c3fcbdeb86d620bb6b Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 10 Jan 2015 12:13:43 +0200 Subject: [PATCH 300/613] Fix the indentation according to jshintrc --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index b041d05b..e11ae96b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,5 +3,5 @@ var gulp = require('gulp'), shell = require('gulp-shell'); gulp.task('jsdoc', shell.task([ - './node_modules/.bin/jsdoc -c ./doc-config.json', + './node_modules/.bin/jsdoc -c ./doc-config.json', ])); \ No newline at end of file From 205fbe0cad53b2feac7dd5f9d177334e6edb8f0c Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 10 Jan 2015 12:18:47 +0200 Subject: [PATCH 301/613] Update the graph representation of the Floyd-Warshall algorithm --- src/graphs/shortest-path/floyd-warshall.js | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/graphs/shortest-path/floyd-warshall.js b/src/graphs/shortest-path/floyd-warshall.js index 565c8319..4e97fd12 100644 --- a/src/graphs/shortest-path/floyd-warshall.js +++ b/src/graphs/shortest-path/floyd-warshall.js @@ -23,7 +23,7 @@ for (var j = 0; j < size; j += 1) { if (i === j) { dist[i][j] = 0; - } else if (isNaN(graph[i][j])) { + } else if (!isFinite(graph[i][j])) { dist[i][j] = Infinity; } else { dist[i][j] = graph[i][j]; @@ -34,22 +34,26 @@ } /** - * Floyd-Warshall algorithm. Finds the shortest path between each two vertices.

+ * Floyd-Warshall algorithm. Finds the shortest path between + * each two vertices.

* Complexity: O(|V|^3) where V is the number of vertices. * * @public * @module graphs/shortest-path/floyd-warshall * @param {Array} graph A distance matrix of the graph. - * @return {Array} Array which contains the shortest distance between each two vertices. - * + * @return {Array} Array which contains the shortest + * distance between each two vertices. + * * @example - * var floydWarshall = require('path-to-algorithms/src/graphs/shortest-path/floyd-warshall').floydWarshall; - * var distMatrix = [[NaN, 7, 9, NaN, NaN, 16], - * [7, NaN, 10, 15, NaN, NaN], - * [9, 10, NaN, 11, NaN, 2], - * [NaN, 15, 11, NaN, 6, NaN], - * [NaN, NaN, NaN, 6, NaN, 9], - * [16, NaN, 2, NaN, 9, NaN]]; + * var floydWarshall = + * require('path-to-algorithms/src/graphs/shortest-path/floyd-warshall').floydWarshall; + * var distMatrix = + * [[Infinity, 7, 9, Infinity, Infinity, 16], + * [7, Infinity, 10, 15, Infinity, Infinity], + * [9, 10, Infinity, 11, Infinity, 2], + * [Infinity, 15, 11, Infinity, 6, Infinity], + * [Infinity, Infinity, Infinity, 6, Infinity, 9], + * [16, Infinity, 2, Infinity, 9, Infinity]]; * * // [ [ 0, 7, 9, 20, 20, 11 ], * // [ 7, 0, 10, 15, 21, 12 ], @@ -77,4 +81,4 @@ exports.floydWarshall = floydWarshall; -})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file +})(typeof window === 'undefined' ? module.exports : window); From 7bac8f585d334b5add27a87243b7a156bc3dacd0 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 10 Jan 2015 12:55:34 +0200 Subject: [PATCH 302/613] Update algorithms formatting --- src/combinatorics/cartesianproduct.js | 1 + src/combinatorics/combinations.js | 1 + src/data-structures/binary-search-tree.js | 92 ++++++++++++------- src/data-structures/interval-tree.js | 3 +- src/data-structures/red-black-tree.js | 1 - src/data-structures/suffix-tree.js | 7 -- src/graphs/others/topological-sort.js | 6 +- src/graphs/shortest-path/dijkstra.js | 23 +++-- src/others/hanoi.js | 26 ++++-- src/searching/binarysearch/binarysearch.js | 4 +- .../longest-increasing-subsequence.js | 42 ++++++--- .../maximum-subarray-divide-and-conquer.js | 1 - src/searching/subarray/maximum-subarray.js | 38 +++++--- src/sets/quickfind.js | 2 + src/sets/quickunion.js | 6 +- src/sets/weightquickunion.js | 6 +- src/shuffle/richarddurstenfeld.js | 1 + src/sorting/bubblesort/bubblesort.js | 1 + src/sorting/heapsort/heapsort.js | 1 - .../insertionsort/insertion-binary-sort.js | 1 - src/sorting/insertionsort/insertionsort.js | 1 - .../insertionsort/recursive-insertionsort.js | 1 - src/sorting/linearsort/bucketsort.js | 1 - src/sorting/linearsort/countingsort.js | 1 - src/sorting/mergesort/mergesort.js | 4 +- src/sorting/most-significant-digit/msd.js | 1 - src/sorting/selectionsort/selectionsort.js | 1 - src/sorting/shellsort/shellsort.js | 1 - test/data-structures/red-black-tree.spec.js | 10 +- test/sorting/bubblesort/bubblesort.spec.js | 3 +- .../insertionsort/insertionbinarysort.spec.js | 4 +- .../insertionsort/insertionsort.spec.js | 3 +- .../recursiveinsertionsort.spec.js | 3 +- test/sorting/mergesort/mergesort.spec.js | 3 +- .../quicksort/quicksort-middle.spec.js | 3 +- test/sorting/quicksort/quicksort.spec.js | 3 +- .../selectionsort/selectionsort.spec.js | 3 +- test/sorting/sort.testcase.js | 1 - 38 files changed, 190 insertions(+), 120 deletions(-) diff --git a/src/combinatorics/cartesianproduct.js b/src/combinatorics/cartesianproduct.js index 74024f41..e2c1a208 100644 --- a/src/combinatorics/cartesianproduct.js +++ b/src/combinatorics/cartesianproduct.js @@ -24,3 +24,4 @@ exports.cartesianProduct = cartesianProduct; }(typeof exports === 'undefined' ? window : exports)); + diff --git a/src/combinatorics/combinations.js b/src/combinatorics/combinations.js index fbd5fa3f..4c7ff38a 100644 --- a/src/combinatorics/combinations.js +++ b/src/combinatorics/combinations.js @@ -28,3 +28,4 @@ exports.combinations = combinations; }(typeof exports === 'undefined' ? window : exports)); + diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 85ac9da5..f9df6f49 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -34,7 +34,8 @@ } /** - * Inserts a node into the binary tree. The method's complexity is O(log n) in the average case and + * Inserts a node into the binary tree. The method's + * complexity is O(log n) in the average case and * O(n) in the worst case. * * @public @@ -48,29 +49,34 @@ } var insertKey; current = current || this._root; - if (current.value > value) + if (current.value > value) { insertKey = '_left'; - else + } else { insertKey = '_right'; - if (!current[insertKey]) + } + if (!current[insertKey]) { current[insertKey] = new Node(value, null, null, current); - else + } else { this.insert(value, current[insertKey]); + } }; /** - * Prints the nodes of the tree in order. It starts the tree traversal from a given node. + * Prints the nodes of the tree in order. + * It starts the tree traversal from a given node. * * @private * @param {Node} Node from which to start the traversal * @param {Function} Callback which will be called for each traversed node */ BinaryTree.prototype._inorder = function (current, callback) { - if (!current) + if (!current) { return; + } this._inorder(current._left, callback); - if (typeof callback === 'function') + if (typeof callback === 'function') { callback(current); + } this._inorder(current._right, callback); }; @@ -92,10 +98,12 @@ * @param {Function} Callback which will be called for each traversed node */ BinaryTree.prototype._postorder = function (current, callback) { - if (!current) + if (!current) { return; - if (typeof callback === 'function') + } + if (typeof callback === 'function') { callback(current); + } this._postorder(current._left, callback); this._postorder(current._right, callback); }; @@ -118,10 +126,12 @@ * @param {Function} Callback which will be called for each traversed node */ BinaryTree.prototype._preorder = function (current, callback) { - if (!current) + if (!current) { return; - if (typeof callback === 'function') + } + if (typeof callback === 'function') { callback(current); + } this._preorder(current._left, callback); this._preorder(current._right, callback); }; @@ -147,25 +157,29 @@ }; /** - * Finds a node by it's value in given sub-tree. Average runtime complexity: O(log n). + * Finds a node by it's value in + * given sub-tree. Average runtime complexity: O(log n). * * @private * @param {Number|String} Value of the node which should be found * @param {Node} Current node to be checked */ BinaryTree.prototype._find = function (value, current) { - if (!current) + if (!current) { return null; + } - if (current.value === value) + if (current.value === value) { return current; + } - if (current.value > value) + if (current.value > value) { return this._find(value, current._left); + } - if (current.value < value) + if (current.value < value) { return this._find(value, current._right); - + } }; /** @@ -182,10 +196,11 @@ this._root._parent = null; } else { - if (parent._left === oldChild) + if (parent._left === oldChild) { parent._left = newChild; - else + } else { parent._right = newChild; + } if (newChild) { newChild._parent = parent; @@ -198,11 +213,13 @@ * * @public * @param {Node} Node to be removed - * @returns {boolean} True/false depending on whether the given node is removed + * @returns {boolean} True/false depending + * on whether the given node is removed */ BinaryTree.prototype.remove = function (node) { - if (!node) + if (!node) { return false; + } if (node._left && node._right) { var min = this._findMin(node._right), @@ -212,12 +229,13 @@ min.value = temp; return this.remove(min); } else { - if (node._left) + if (node._left) { this._replaceChild(node._parent, node, node._left); - else if (node._right) + } else if (node._right) { this._replaceChild(node._parent, node, node._right); - else + } else { this._replaceChild(node._parent, node, null); + } return true; } }; @@ -232,10 +250,12 @@ */ BinaryTree.prototype._findMin = function (node, current) { current = current || { value: Infinity }; - if (!node) + if (!node) { return current; - if (current.value > node.value) + } + if (current.value > node.value) { current = node; + } return this._findMin(node._left, current); }; @@ -249,10 +269,12 @@ */ BinaryTree.prototype._findMax = function (node, current) { current = current || { value: -Infinity }; - if (!node) + if (!node) { return current; - if (current.value < node.value) + } + if (current.value < node.value) { current = node; + } return this._findMax(node._right, current); }; @@ -331,7 +353,8 @@ if (!node) { return 0; } - return 1 + Math.max(this._getHeight(node._left), this._getHeight(node._right)); + return 1 + Math.max(this._getHeight(node._left), + this._getHeight(node._right)); }; /** @@ -340,11 +363,13 @@ * @public * @returns {Node} The lowest common ancestor of the two nodes or null */ - BinaryTree.prototype.lowestCommonAncestor = function (firstNode, secondNode, current) { + BinaryTree.prototype.lowestCommonAncestor = + function (firstNode, secondNode) { return this._lowestCommonAncestor(firstNode, secondNode, this._root); }; - BinaryTree.prototype._lowestCommonAncestor = function (firstNode, secondNode, current) { + BinaryTree.prototype._lowestCommonAncestor = + function (firstNode, secondNode, current) { var firstNodeInLeft = this._existsInSubtree(firstNode, current._left), secondNodeInLeft = this._existsInSubtree(secondNode, current._left), firstNodeInRight = this._existsInSubtree(firstNode, current._right), @@ -369,7 +394,8 @@ if (node === root.value) { return true; } - return this._existsInSubtree(node, root._left) || this._existsInSubtree(node, root._right); + return this._existsInSubtree(node, root._left) || + this._existsInSubtree(node, root._right); }; exports.BinaryTree = BinaryTree; diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index 249daff9..67ce086c 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -131,7 +131,8 @@ }; // adjust the max value - IntervalTree.prototype._removeHelper = function (interval, node) { + IntervalTree.prototype._removeHelper = + function (interval, node) { if (!node) { return; } diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index 58dd7017..dcd00651 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -182,6 +182,5 @@ global.RBTree = RBTree; - }(typeof window === 'undefined' ? module.exports : window)); diff --git a/src/data-structures/suffix-tree.js b/src/data-structures/suffix-tree.js index 663234d0..296539e3 100644 --- a/src/data-structures/suffix-tree.js +++ b/src/data-structures/suffix-tree.js @@ -1,6 +1,3 @@ -// TODO -// 1) The algorithm is quite ineffective, better use -// Ukkomen's algorithm to build it in O(n) complexity. (function (exports) { 'use strict'; @@ -94,10 +91,6 @@ // var suffix = new SuffixTree(); // suffix.build('banana'); // console.log(suffix); - // - // var st = new SuffixTree(); - // st.build('Since these cases are very common use cases, the problem was easily solved by choosing either a random index for the pivot, choosing the middle index of the partition or (especially for longer partitions) choosing the median of the first, middle and last element of the partition for the pivot. With these modifications, the worst case of Quick sort has less chances to occur, but worst case can still occur if the input array is such that the maximum (or minimum) element is always chosen as pivot.'); - // console.log(JSON.stringify(st)); exports.Node = Node; exports.SuffixTree = SuffixTree; diff --git a/src/graphs/others/topological-sort.js b/src/graphs/others/topological-sort.js index 58945075..53fe7023 100644 --- a/src/graphs/others/topological-sort.js +++ b/src/graphs/others/topological-sort.js @@ -30,7 +30,9 @@ * @returns {Array} Ordered vertices. * * @example - * var topsort = require('path-to-algorithms/src/graphs/others/topological-sort').topologicalSort; + * var topsort = + * require('path-to-algorithms/src/graphs/' + + * 'others/topological-sort').topologicalSort; * var graph = { * v1: ['v2', 'v5'], * v2: [], @@ -55,4 +57,4 @@ exports.topologicalSort = topologicalSort; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index 433c40fd..2479a805 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -1,7 +1,7 @@ (function (exports) { 'use strict'; - var dijkstra = (function() { + var dijkstra = (function () { var Heap = require('../../data-structures/heap.js').Heap, current, @@ -76,13 +76,15 @@ * @returns {Number} The shortest distance between two nodes. * * @example - * var dijkstra = require('path-to-algorithms/src/graphs/shortest-path/dijkstra').dijkstra; - * var distMatrix = [[Infinity, 7, 9, Infinity, Infinity, 16], - * [7, Infinity, 10, 15, Infinity, Infinity], - * [9, 10, Infinity, 11, Infinity, 2], - * [Infinity, 15, 11, Infinity, 6, Infinity], - * [Infinity, Infinity, Infinity, 6, Infinity, 9], - * [16, Infinity, 2, Infinity, 9, Infinity]]; + * var dijkstra = + * require('path-to-algorithms/src/graphs/shortest-path/dijkstra').dijkstra; + * var distMatrix = + * [[Infinity, 7, 9, Infinity, Infinity, 16], + * [7, Infinity, 10, 15, Infinity, Infinity], + * [9, 10, Infinity, 11, Infinity, 2], + * [Infinity, 15, 11, Infinity, 6, Infinity], + * [Infinity, Infinity, Infinity, 6, Infinity, 9], + * [16, Infinity, 2, Infinity, 9, Infinity]]; * var shortestDist = dijkstra(0, 2, distMatrix); // 9 */ return function (src, dest, graph) { @@ -92,7 +94,8 @@ for (var i = 0; i < graph.length; i += 1) { if (current.node !== i && //if it's not the current node !visited[i] && //and if we haven't visited this node - Number.isFinite(graph[i][current.node])) { //and this node is sibling of the current... + //and this node is sibling of the current... + Number.isFinite(graph[i][current.node])) { tempDistance = current.distance + graph[i][current.node]; if (tempDistance < distance[i].distance) { @@ -107,7 +110,7 @@ } return distance[dest].distance; }; - + })(); exports.dijkstra = dijkstra; diff --git a/src/others/hanoi.js b/src/others/hanoi.js index 95ec58ea..4e5848d1 100644 --- a/src/others/hanoi.js +++ b/src/others/hanoi.js @@ -1,15 +1,21 @@ /* * Hanoi towers */ -function hanoi(count, source, intermediate, goal, result) { +(function (exports) { 'use strict'; - result = result || []; - if (count === 1) { - result.push([source, goal]); - } else { - hanoi(count - 1, source, goal, intermediate, result); - result.push([source, goal]); - hanoi(count - 1, intermediate, source, goal, result); + + function hanoi(count, source, intermediate, goal, result) { + result = result || []; + if (count === 1) { + result.push([source, goal]); + } else { + hanoi(count - 1, source, goal, intermediate, result); + result.push([source, goal]); + hanoi(count - 1, intermediate, source, goal, result); + } + return result; } - return result; -} + + exports.hanoi = hanoi; + +})(typeof window === 'undefined' ? module.exports : window); diff --git a/src/searching/binarysearch/binarysearch.js b/src/searching/binarysearch/binarysearch.js index ed6d1e8d..59989c76 100644 --- a/src/searching/binarysearch/binarysearch.js +++ b/src/searching/binarysearch/binarysearch.js @@ -1,7 +1,9 @@ (function (exports) { + 'use strict'; /** - * Searchs for specific element in given array using the binary search algorithm. + * Searchs for specific element in given array using + * the binary search algorithm. * It's complexity is O(log n) * * @public diff --git a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js index b71111bc..43df4d2e 100644 --- a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js +++ b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js @@ -1,4 +1,5 @@ (function (exports) { + 'use strict'; /** * Algorithm from dynamic programming. @@ -16,19 +17,25 @@ * Find the index of the first largest element in array. * Complexity O(n). * - * @param {Array} array The array in which the largest element should be found + * @param {Array} array The array in which the largest + * element should be found * @param {Function} cmp Function used for comparison * @return {number} The index of the first largest element */ function max(array, cmp) { - if (!array || !array.length) return -1; + if (!array || !array.length) { + return -1; + } if (!cmp) { - cmp = function (a, b) { return a - b }; + cmp = function (a, b) { return a - b; }; + } + var maxIdx = 0; + for (var i = 1; i < array.length; i += 1) { + if (cmp(array[maxIdx], array[i]) < 0) { + maxIdx = i; + } } - var max = 0; - for (var i = 1; i < array.length; i += 1) - if (cmp(array[max], array[i]) < 0) max = i; - return max; + return maxIdx; } /** @@ -52,7 +59,9 @@ for (var i = 0; i < array.length; i += 1) { result[i] = []; for (var j = i + 1; j < array.length; j += 1) { - if (array[i] < array[j]) result[i].push(j); + if (array[i] < array[j]) { + result[i].push(j); + } } } return result; @@ -68,20 +77,29 @@ */ function find(dag, node) { node = node || 0; - if (find.memo[node]) return find.memo[node]; + if (find.memo[node]) { + return find.memo[node]; + } var neighbours = dag[node], neighboursDistance = [], maxDist, maxNode, distance, result; - if (!neighbours.length) return { distance: 1, neighbour: undefined, node: node }; + if (!neighbours.length) { + return { distance: 1, neighbour: undefined, node: node }; + } - for (var i = 0; i < neighbours.length; i += 1) + for (var i = 0; i < neighbours.length; i += 1) { neighboursDistance[i] = find(dag, neighbours[i]); + } maxDist = max(neighboursDistance, cmp); maxNode = neighbours[maxDist]; distance = 1 + neighboursDistance[maxDist].distance; - find.memo[node] = result = { distance: distance, neighbour: neighboursDistance[maxDist], node: node }; + find.memo[node] = result = { + distance: distance, + neighbour: neighboursDistance[maxDist], + node: node + }; return result; } diff --git a/src/searching/subarray/maximum-subarray-divide-and-conquer.js b/src/searching/subarray/maximum-subarray-divide-and-conquer.js index 1e815a44..a5b16b41 100644 --- a/src/searching/subarray/maximum-subarray-divide-and-conquer.js +++ b/src/searching/subarray/maximum-subarray-divide-and-conquer.js @@ -4,7 +4,6 @@ */ (function (exports) { - 'use strict'; /** diff --git a/src/searching/subarray/maximum-subarray.js b/src/searching/subarray/maximum-subarray.js index c7603557..60dec6f8 100644 --- a/src/searching/subarray/maximum-subarray.js +++ b/src/searching/subarray/maximum-subarray.js @@ -1,20 +1,28 @@ -/** - * Finds the maximum sum of subarray's element of given array using the Kadane's algorithm - * It's complexity is O(n). The algorithm can be found here: https://en.wikipedia.org/wiki/Maximum_subarray_problem#Kadane.27s_algorithm - * - * @public - * @param {array} array Input array - * @returns {number} max The maximum sum of the elements of subarray of the input - * - */ -function maxSubarray(array) { +(function (exports) { + 'use strict'; + + /** + * Finds the maximum sum of subarray's element of given array + * using the Kadane's algorithm + * It's complexity is O(n). The algorithm can be found here: + * https://en.wikipedia.org/wiki/Maximum_subarray_problem#Kadane.27s_algorithm + * + * @public + * @param {array} array Input array + * @returns {number} max The maximum sum of + * the elements of subarray of the input + */ + function maxSubarray(array) { var currentMax = 0, - max = 0; + max = 0; for (var i = 0; i < array.length; i += 1) { - currentMax = Math.max(0, currentMax + array[i]); - max = Math.max(max, currentMax); + currentMax = Math.max(0, currentMax + array[i]); + max = Math.max(max, currentMax); } - return max; -} + } + + exports.maxSubarray = maxSubarray; + +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/sets/quickfind.js b/src/sets/quickfind.js index 0b048b1c..fc164f05 100644 --- a/src/sets/quickfind.js +++ b/src/sets/quickfind.js @@ -1,4 +1,6 @@ (function (exports) { + 'use strict'; + /** * Checks whether there is a path between two nodes. * The initialization is O(n). diff --git a/src/sets/quickunion.js b/src/sets/quickunion.js index 4ff3908a..a2606044 100644 --- a/src/sets/quickunion.js +++ b/src/sets/quickunion.js @@ -1,4 +1,6 @@ (function (exports) { + 'use strict'; + /** * Checks whether path between two nodes exists. * The initialization has O(n) complexity. @@ -22,7 +24,9 @@ * @return {number} The root of the given node */ QuickUnion.prototype._root = function (i) { - while (i !== this._ids[i]) i = this._ids[i]; + while (i !== this._ids[i]) { + i = this._ids[i]; + } return i; }; diff --git a/src/sets/weightquickunion.js b/src/sets/weightquickunion.js index cb88c289..d20879fe 100644 --- a/src/sets/weightquickunion.js +++ b/src/sets/weightquickunion.js @@ -1,4 +1,6 @@ (function (exports) { + 'use strict'; + /** * Checks whether there is a path between two nodes * Complexity of the initialization O(n). @@ -52,7 +54,9 @@ QuickUnion.prototype.union = function (p, q) { var pf = this._root(p); var qf = this._root(q); - if (pf == qf) return; // already linked + if (pf === qf) { + return; // already linked + } var psz = this._size[qf]; var qsz = this._size[pf]; if (psz < qsz) { diff --git a/src/shuffle/richarddurstenfeld.js b/src/shuffle/richarddurstenfeld.js index a409d8b2..0b91f1a5 100644 --- a/src/shuffle/richarddurstenfeld.js +++ b/src/shuffle/richarddurstenfeld.js @@ -1,5 +1,6 @@ (function (exports) { 'use strict'; + /** * Shuffle of an array elements. * This algorithm is modified version of Fisher-Yates shuffle diff --git a/src/sorting/bubblesort/bubblesort.js b/src/sorting/bubblesort/bubblesort.js index 9a481b89..b2668d27 100644 --- a/src/sorting/bubblesort/bubblesort.js +++ b/src/sorting/bubblesort/bubblesort.js @@ -1,4 +1,5 @@ (function (exports) { + 'use strict'; function comparator(a, b) { return a - b; diff --git a/src/sorting/heapsort/heapsort.js b/src/sorting/heapsort/heapsort.js index aeb2df1d..bbcd8c23 100644 --- a/src/sorting/heapsort/heapsort.js +++ b/src/sorting/heapsort/heapsort.js @@ -1,5 +1,4 @@ (function (exports) { - 'use strict'; function comparator(a, b) { diff --git a/src/sorting/insertionsort/insertion-binary-sort.js b/src/sorting/insertionsort/insertion-binary-sort.js index 1b632f88..c5ac874a 100644 --- a/src/sorting/insertionsort/insertion-binary-sort.js +++ b/src/sorting/insertionsort/insertion-binary-sort.js @@ -1,5 +1,4 @@ (function (exports) { - 'use strict'; function comparator(a, b) { diff --git a/src/sorting/insertionsort/insertionsort.js b/src/sorting/insertionsort/insertionsort.js index ef7bc1a1..ace59119 100644 --- a/src/sorting/insertionsort/insertionsort.js +++ b/src/sorting/insertionsort/insertionsort.js @@ -1,5 +1,4 @@ (function (exports) { - 'use strict'; function compare(a, b) { diff --git a/src/sorting/insertionsort/recursive-insertionsort.js b/src/sorting/insertionsort/recursive-insertionsort.js index fb94a3bd..380dc346 100644 --- a/src/sorting/insertionsort/recursive-insertionsort.js +++ b/src/sorting/insertionsort/recursive-insertionsort.js @@ -1,5 +1,4 @@ (function (exports) { - 'use strict'; function compare(a, b) { diff --git a/src/sorting/linearsort/bucketsort.js b/src/sorting/linearsort/bucketsort.js index b77c671e..9672bfee 100644 --- a/src/sorting/linearsort/bucketsort.js +++ b/src/sorting/linearsort/bucketsort.js @@ -1,5 +1,4 @@ (function (exports) { - 'use strict'; /** diff --git a/src/sorting/linearsort/countingsort.js b/src/sorting/linearsort/countingsort.js index b235f803..6d828be8 100644 --- a/src/sorting/linearsort/countingsort.js +++ b/src/sorting/linearsort/countingsort.js @@ -1,5 +1,4 @@ (function (exports) { - 'use strict'; /** diff --git a/src/sorting/mergesort/mergesort.js b/src/sorting/mergesort/mergesort.js index 506411f0..ef6effc3 100644 --- a/src/sorting/mergesort/mergesort.js +++ b/src/sorting/mergesort/mergesort.js @@ -1,5 +1,4 @@ (function (exports) { - 'use strict'; var mergeSort = (function () { @@ -34,7 +33,8 @@ * * @private * @param {array} array The array which subarrays should be sorted - * @param {number} start The start of the first subarray. This subarray is with end middle - 1. + * @param {number} start The start of the first subarray. + * This subarray is with end middle - 1. * @param {number} middle The start of the second array * @param {number} end end - 1 is the end of the second array * @returns {array} The array with sorted subarray diff --git a/src/sorting/most-significant-digit/msd.js b/src/sorting/most-significant-digit/msd.js index 2e4ab4f4..74f01d25 100644 --- a/src/sorting/most-significant-digit/msd.js +++ b/src/sorting/most-significant-digit/msd.js @@ -1,5 +1,4 @@ (function (exports) { - 'use strict'; function charCodeAt(str, i) { diff --git a/src/sorting/selectionsort/selectionsort.js b/src/sorting/selectionsort/selectionsort.js index d24a5762..78ea6117 100644 --- a/src/sorting/selectionsort/selectionsort.js +++ b/src/sorting/selectionsort/selectionsort.js @@ -1,5 +1,4 @@ (function (exports) { - 'use strict'; function compare(a, b) { diff --git a/src/sorting/shellsort/shellsort.js b/src/sorting/shellsort/shellsort.js index ba340aac..e78328a8 100644 --- a/src/sorting/shellsort/shellsort.js +++ b/src/sorting/shellsort/shellsort.js @@ -1,5 +1,4 @@ (function (exports) { - 'use strict'; diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index 219bf5eb..77635ff2 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -1,18 +1,18 @@ 'use strict'; var mod = require('../../src/data-structures/red-black-tree.js'), - Node = mod.Node, + Vertex = mod.Node, RBTree = mod.RBTree, Colors = mod.Colors; describe('Node', function () { it('should be a constructor function', function () { - expect(typeof Node).toBe('function'); + expect(typeof Vertex).toBe('function'); }); it('should set all properties via the constructor', function () { - var node = new Node('key', 'value', 1, 2, Colors.RED); + var node = new Vertex('key', 'value', 1, 2, Colors.RED); expect(node.getKey()).toBe('key'); expect(node.getLeft()).toBe(1); expect(node.getRight()).toBe(2); @@ -22,11 +22,11 @@ describe('Node', function () { describe('Node flipColor', function () { it('should has method flipColor', function () { - var node = new Node(); + var node = new Vertex(); expect(typeof node.flipColor).toBe('function'); }); it('should work properly', function () { - var node = new Node(); + var node = new Vertex(); expect(node.isRed()).toBe(false); node.flipColor(); expect(node.isRed()).toBe(true); diff --git a/test/sorting/bubblesort/bubblesort.spec.js b/test/sorting/bubblesort/bubblesort.spec.js index 706cba72..19b25d57 100644 --- a/test/sorting/bubblesort/bubblesort.spec.js +++ b/test/sorting/bubblesort/bubblesort.spec.js @@ -1,4 +1,5 @@ var sortTestCase = require('../sort.testcase.js'), - bubbleSort = require('../../../src/sorting/bubblesort/bubblesort.js').bubbleSort; + bubbleSort = + require('../../../src/sorting/bubblesort/bubblesort.js').bubbleSort; sortTestCase(bubbleSort, 'Bubble sort'); \ No newline at end of file diff --git a/test/sorting/insertionsort/insertionbinarysort.spec.js b/test/sorting/insertionsort/insertionbinarysort.spec.js index a7bc4861..7fd6bf0c 100644 --- a/test/sorting/insertionsort/insertionbinarysort.spec.js +++ b/test/sorting/insertionsort/insertionbinarysort.spec.js @@ -1,4 +1,6 @@ var sortTestCase = require('../sort.testcase.js'), - insertionBinarySort = require('../../../src/sorting/insertionsort/insertion-binary-sort.js').insertionBinarySort; + insertionBinarySort = + require('../../../src/sorting/insertionsort/' + + 'insertion-binary-sort.js').insertionBinarySort; sortTestCase(insertionBinarySort, 'Insertion binary sort'); \ No newline at end of file diff --git a/test/sorting/insertionsort/insertionsort.spec.js b/test/sorting/insertionsort/insertionsort.spec.js index 34057e4a..01fb28e0 100644 --- a/test/sorting/insertionsort/insertionsort.spec.js +++ b/test/sorting/insertionsort/insertionsort.spec.js @@ -1,4 +1,5 @@ var sortTestCase = require('../sort.testcase.js'), - insertionSort = require('../../../src/sorting/insertionsort/insertionsort.js').insertionSort; + insertionSort = require('../../../src/sorting/insertionsort/' + + 'insertionsort.js').insertionSort; sortTestCase(insertionSort, 'Insertion sort'); \ No newline at end of file diff --git a/test/sorting/insertionsort/recursiveinsertionsort.spec.js b/test/sorting/insertionsort/recursiveinsertionsort.spec.js index 6e96eafd..8282b81d 100644 --- a/test/sorting/insertionsort/recursiveinsertionsort.spec.js +++ b/test/sorting/insertionsort/recursiveinsertionsort.spec.js @@ -1,4 +1,5 @@ var sortTestCase = require('../sort.testcase.js'), - recursiveInsertionSort = require('../../../src/sorting/insertionsort/recursive-insertionsort.js').recursiveInsertionSort; + recursiveInsertionSort = require('../../../src/sorting/' + + 'insertionsort/recursive-insertionsort.js').recursiveInsertionSort; sortTestCase(recursiveInsertionSort, 'Recursive insertion sort'); \ No newline at end of file diff --git a/test/sorting/mergesort/mergesort.spec.js b/test/sorting/mergesort/mergesort.spec.js index 31d6028e..975e9711 100644 --- a/test/sorting/mergesort/mergesort.spec.js +++ b/test/sorting/mergesort/mergesort.spec.js @@ -1,4 +1,5 @@ var sortTestCase = require('../sort.testcase.js'), - mergeSort = require('../../../src/sorting/mergesort/mergesort.js').mergeSort; + mergeSort = + require('../../../src/sorting/mergesort/mergesort.js').mergeSort; sortTestCase(mergeSort, 'Merge sort'); \ No newline at end of file diff --git a/test/sorting/quicksort/quicksort-middle.spec.js b/test/sorting/quicksort/quicksort-middle.spec.js index d12276b8..e3b44136 100644 --- a/test/sorting/quicksort/quicksort-middle.spec.js +++ b/test/sorting/quicksort/quicksort-middle.spec.js @@ -1,4 +1,5 @@ var sortTestCase = require('../sort.testcase.js'), - quickSort = require('../../../src/sorting/quicksort/quicksort-middle.js').quickSort; + quickSort = + require('../../../src/sorting/quicksort/quicksort-middle.js').quickSort; sortTestCase(quickSort, 'Quick sort'); \ No newline at end of file diff --git a/test/sorting/quicksort/quicksort.spec.js b/test/sorting/quicksort/quicksort.spec.js index e6f84a8f..f3f668ee 100644 --- a/test/sorting/quicksort/quicksort.spec.js +++ b/test/sorting/quicksort/quicksort.spec.js @@ -1,4 +1,5 @@ var sortTestCase = require('../sort.testcase.js'), - quickSort = require('../../../src/sorting/quicksort/quicksort.js').quickSort; + quickSort = + require('../../../src/sorting/quicksort/quicksort.js').quickSort; sortTestCase(quickSort, 'Quick sort'); \ No newline at end of file diff --git a/test/sorting/selectionsort/selectionsort.spec.js b/test/sorting/selectionsort/selectionsort.spec.js index 73718b13..ac3b0fae 100644 --- a/test/sorting/selectionsort/selectionsort.spec.js +++ b/test/sorting/selectionsort/selectionsort.spec.js @@ -1,5 +1,6 @@ var sortTestCase = require('../sort.testcase.js'), - selectionSort = require('../../../src/sorting/selectionsort/selectionsort.js') + selectionSort = + require('../../../src/sorting/selectionsort/selectionsort.js') .selectionSort; sortTestCase(selectionSort, 'Selection sort'); \ No newline at end of file diff --git a/test/sorting/sort.testcase.js b/test/sorting/sort.testcase.js index 68382432..73bad801 100644 --- a/test/sorting/sort.testcase.js +++ b/test/sorting/sort.testcase.js @@ -1,5 +1,4 @@ module.exports = function (sort, algorithmName, options) { - 'use strict'; options = options || { From 9c7308fd92f6f3ebddb3e2930dfc2af02d609755 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 10 Jan 2015 12:55:59 +0200 Subject: [PATCH 303/613] Add additional gulp config --- .jshintrc | 13 ++++++++++--- gulpfile.js | 19 +++++++++++++++++-- package.json | 6 ++++-- readme.md | 2 ++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/.jshintrc b/.jshintrc index c3863960..4cabd67d 100644 --- a/.jshintrc +++ b/.jshintrc @@ -23,9 +23,16 @@ "plusplus": true, "undef": true, "laxbreak": true, - "maxdepth": 3, + "maxdepth": 4, "loopfunc": true, - "maxcomplexity": 9, + "maxcomplexity": 13, "maxlen": 80, - "maxparams": 4 + "maxparams": 5, + "globals": { + "expect": true, + "it": true, + "describe": true, + "beforeEach": true, + "afterEach": true + } } diff --git a/gulpfile.js b/gulpfile.js index e11ae96b..5bfc5607 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,7 +1,22 @@ 'use strict'; var gulp = require('gulp'), - shell = require('gulp-shell'); + shell = require('gulp-shell'), + jshint = require('gulp-jshint'), + jasmine = require('gulp-jasmine'); gulp.task('jsdoc', shell.task([ './node_modules/.bin/jsdoc -c ./doc-config.json', -])); \ No newline at end of file +])); + +gulp.task('lint', function () { + return gulp.src(['./src/**/*.js'], ['./test/**/*.js']) + .pipe(jshint()) + .pipe(jshint.reporter('default')); +}); + +gulp.task('test', function () { + return gulp.src('test/**/*.spec.js') + .pipe(jasmine()); +}); + +gulp.task('build', ['lint', 'test']); \ No newline at end of file diff --git a/package.json b/package.json index 338952d2..22ebd87d 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,10 @@ }, "devDependencies": { "gulp": "^3.8.10", - "jsdoc": "^3.3.0", - "gulp-shell": "^0.2.11" + "gulp-jasmine": "^1.0.1", + "gulp-jshint": "^1.9.0", + "gulp-shell": "^0.2.11", + "jsdoc": "^3.3.0" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" diff --git a/readme.md b/readme.md index ab03808f..c3da9651 100644 --- a/readme.md +++ b/readme.md @@ -63,6 +63,8 @@ and all `*.spec.js` files will be executed. Fork the repo and make requred changes. After that push your changes in branch, which is named according to the changes you did. Initiate the PR. +Make sure you're editor makes validations according to the `.jshintrc` in the root directory of the repository. + ## Contributors [![mgechev](https://avatars.githubusercontent.com/u/455023?v=3&s=117)](https://github.com/mgechev)[![AndreyGeonya](https://avatars.githubusercontent.com/u/773648?v=3&s=117)](https://github.com/AndreyGeonya)[![Microfed](https://avatars.githubusercontent.com/u/613179?v=3&s=117)](https://github.com/Microfed)[![contra](https://avatars.githubusercontent.com/u/425716?v=3&s=117)](https://github.com/contra) From 630db2709e23e68d385beec31df997350c572ccc Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 10 Jan 2015 12:58:00 +0200 Subject: [PATCH 304/613] Update readme --- readme.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/readme.md b/readme.md index c3da9651..8be8c935 100644 --- a/readme.md +++ b/readme.md @@ -65,6 +65,14 @@ Initiate the PR. Make sure you're editor makes validations according to the `.jshintrc` in the root directory of the repository. +Before pushing to the repository run: + +```bash +gulp build +``` + +If the build is not successful fix your code in order the tests and jshint validation to run successfully and after that create a pull request. + ## Contributors [![mgechev](https://avatars.githubusercontent.com/u/455023?v=3&s=117)](https://github.com/mgechev)[![AndreyGeonya](https://avatars.githubusercontent.com/u/773648?v=3&s=117)](https://github.com/AndreyGeonya)[![Microfed](https://avatars.githubusercontent.com/u/613179?v=3&s=117)](https://github.com/Microfed)[![contra](https://avatars.githubusercontent.com/u/425716?v=3&s=117)](https://github.com/contra) From c122f80bcab1c983834b62d5e92f3348c6e6bdda Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 10 Jan 2015 13:02:41 +0200 Subject: [PATCH 305/613] Add travis.yml --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..ac0ba1f1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: + - "0.11" + - "0.10" + - "0.9" +before_script: + - npm install -g gulp +script: gulp build \ No newline at end of file From cbd551829a09d50c472b524152d6b4b246d022a4 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 10 Jan 2015 13:03:43 +0200 Subject: [PATCH 306/613] Add travis icon --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 8be8c935..3988f65c 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,5 @@ +![](https://travis-ci.org/mgechev/javascript-algorithms.svg?branch=master) + ## About This repository contains JavaScript implementations of different famous Computer Science algorithms. From 5572ad9f389597ba1c5d86e455ede922a70e9dba Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 10 Jan 2015 13:07:49 +0200 Subject: [PATCH 307/613] Remove 0.9, jsdoc doesn't support it --- .travis.yml | 1 - package.json | 3 --- 2 files changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index ac0ba1f1..207c6cac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: node_js node_js: - "0.11" - "0.10" - - "0.9" before_script: - npm install -g gulp script: gulp build \ No newline at end of file diff --git a/package.json b/package.json index 22ebd87d..6b0a6d89 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,6 @@ "directories": { "test": "test" }, - "dependencies": { - "jsdoc": "^3.3.0-alpha13" - }, "devDependencies": { "gulp": "^3.8.10", "gulp-jasmine": "^1.0.1", From 685fb6684696548ec6eacb2b69d571e8bbd7bdf5 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sat, 10 Jan 2015 13:11:54 +0200 Subject: [PATCH 308/613] document djkstra complexity --- src/graphs/shortest-path/dijkstra.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index 2479a805..03fa397f 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -66,8 +66,11 @@ * Dijkstra's shortest path algorithm. Finds the minimum * distance between two given nodes using a distance matrix.

* For the implementation is not used the most suitable data structure - * (Fibonacci heap) but the Binary heap gives also good results. + * (Fibonacci heap) but the Binary heap gives also good results.

* + * Time complexity: O(|E|+|V|log(|V|)) where V and E are the number of + * vertices and edges respectively. + * * @public * @module graphs/shortest-path/dijkstra * @param {Number} src Source node. From 3bc5dc3cf01a9454452d52613205b75743d4a8bc Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 10 Jan 2015 13:22:27 +0200 Subject: [PATCH 309/613] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6b0a6d89..960259c0 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "gulp-jasmine": "^1.0.1", "gulp-jshint": "^1.9.0", "gulp-shell": "^0.2.11", - "jsdoc": "^3.3.0" + "jsdoc": "3.3.0-alpha13" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" From 424cf758b510801867e20497226cee1179e162a1 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sat, 10 Jan 2015 14:24:28 +0200 Subject: [PATCH 310/613] add BST jsdoc --- doc-config.json | 5 +- src/data-structures/binary-search-tree.js | 215 ++++++++++++---------- 2 files changed, 121 insertions(+), 99 deletions(-) diff --git a/doc-config.json b/doc-config.json index 9e345526..55965c84 100644 --- a/doc-config.json +++ b/doc-config.json @@ -7,7 +7,8 @@ "./src/graphs/searching/", "./src/graphs/others/", "./src/graphs/shortest-path/", - "./src/graphs/spanning-trees/" + "./src/graphs/spanning-trees/", + "./src/data-structures/" ], "includePattern": ".+\\.js(doc)?$", "excludePattern": "docs" @@ -18,7 +19,7 @@ "encoding": "utf8", "destination": "../javascript-algorithms-docs", "recurse": true, - "private": true, + "private": false, "readme": "./readme.md" } } \ No newline at end of file diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index f9df6f49..24cf2580 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -1,22 +1,45 @@ +/** + * Binary search tree. + * + * @example + * var BST = require('path-to-algorithms/src/data-structures'+ + * '/binary-search-tree'); + * var bst = new BST.BinaryTree(); + * + * bst.insert(2000); + * bst.insert(1989); + * bst.insert(1991); + * bst.insert(2001); + * bst.insert(1966); + * + * var node = bst.find(1989); + * console.log(node.value); // 1989 + * + * var minNode = bst.findMin(); + * console.log(minNode.value); // 1966 + * + * var maxNode = bst.findMax(); + * console.log(maxNode.value); //2001 + * + * @module data-structures/binary-search-tree + */ (function (exports) { 'use strict'; /** - * Implementation of binary search tree. - */ - - /** - * A node of the tree + * Node of the tree. * - * @class * @public * @constructor - * @param {Number|String} Value of the node - * @param {Node} Left subling - * @param {Node} Right sibling - * @param {Node} Parent of the node + * @param {Number|String} value Value of the node. + * @param {Node} left Left sibling. + * @param {Node} right Right sibling. + * @param {Node} parent Parent of the node. */ - function Node(value, left, right, parent) { + exports.Node = function(value, left, right, parent) { + /** + * @member {Number|String} + */ this.value = value; this._left = left; this._right = right; @@ -24,27 +47,28 @@ } /** - * Defines the binary tree + * Binary tree. * * @public * @constructor */ - function BinaryTree() { + exports.BinaryTree = function() { this._root = null; } /** - * Inserts a node into the binary tree. The method's - * complexity is O(log n) in the average case and - * O(n) in the worst case. + * Inserts a node into the binary search tree.

+ * Time complexity: O(log N) in the average case + * and O(N) in the worst case. * * @public - * @param {Number|String} Value - * @param {Node} Current node + * @method + * @param {Number|String} value Node value. + * @param {Node} current Current node. */ - BinaryTree.prototype.insert = function (value, current) { + exports.BinaryTree.prototype.insert = function (value, current) { if (this._root === null) { - this._root = new Node(value, null, null, null); + this._root = new exports.Node(value, null, null, null); return; } var insertKey; @@ -55,21 +79,20 @@ insertKey = '_right'; } if (!current[insertKey]) { - current[insertKey] = new Node(value, null, null, current); + current[insertKey] = new exports.Node(value, null, null, current); } else { this.insert(value, current[insertKey]); } }; /** - * Prints the nodes of the tree in order. - * It starts the tree traversal from a given node. + * In-order traversal from the given node. * * @private - * @param {Node} Node from which to start the traversal - * @param {Function} Callback which will be called for each traversed node + * @param {Node} current Node from which to start the traversal. + * @param {Function} callback Callback which will be called for each traversed node. */ - BinaryTree.prototype._inorder = function (current, callback) { + exports.BinaryTree.prototype._inorder = function (current, callback) { if (!current) { return; } @@ -81,23 +104,24 @@ }; /** - * Inorder traversal of the whole binary search tree + * In-order traversal of the whole binary search tree. * * @public - * @param {Function} Callback which will be called for each traversed node + * @method + * @param {Function} callback Callback which will be called for each traversed node. */ - BinaryTree.prototype.inorder = function (callback) { + exports.BinaryTree.prototype.inorder = function (callback) { return this._inorder(this._root, callback); }; /** - * Post-order traversal from given node + * Post-order traversal from given node. * * @private - * @param {Node} Node from which to start the traversal - * @param {Function} Callback which will be called for each traversed node + * @param {Node} current Node from which to start the traversal. + * @param {Function} callback Callback which will be called for each traversed node. */ - BinaryTree.prototype._postorder = function (current, callback) { + exports.BinaryTree.prototype._postorder = function (current, callback) { if (!current) { return; } @@ -109,23 +133,23 @@ }; /** - * Post-order traversal of the whole tree + * Post-order traversal of the whole tree. * * @public - * @param {Function} Callback which will be called for each traversed node + * @param {Function} callback Callback which will be called for each traversed node. */ - BinaryTree.prototype.postorder = function (callback) { + exports.BinaryTree.prototype.postorder = function (callback) { return this._postorder(this._root, callback); }; /** - * Pre-order traversal of the tree from given node + * Pre-order traversal of the tree from given node. * * @private - * @param {Node} Node from which to start the traversal - * @param {Function} Callback which will be called for each traversed node + * @param {Node} current Node from which to start the traversal. + * @param {Function} callback Callback which will be called for each traversed node. */ - BinaryTree.prototype._preorder = function (current, callback) { + exports.BinaryTree.prototype._preorder = function (current, callback) { if (!current) { return; } @@ -137,34 +161,35 @@ }; /** - * Pre-order preorder traversal of the whole tree + * Pre-order preorder traversal of the whole tree. * * @public - * @param {Function} Callback which will be called for each traversed node + * @param {Function} callback Callback which will be called for each traversed node. */ - BinaryTree.prototype.preorder = function (callback) { + exports.BinaryTree.prototype.preorder = function (callback) { return this._preorder(this._root, callback); }; /** - * Finds a node by it's value. Average runtime complexity O(log n) + * Finds a node by it's value.

+ * Average time complexity: O(log N). * * @public - * @param {Number|String} Value of the node which should be found + * @param {Number|String} Value of the node which should be found. */ - BinaryTree.prototype.find = function (value) { + exports.BinaryTree.prototype.find = function (value) { return this._find(value, this._root); }; /** - * Finds a node by it's value in - * given sub-tree. Average runtime complexity: O(log n). - * + * Finds a node by it's value in a given sub-tree. + * Average time complexity: O(log N). + * * @private - * @param {Number|String} Value of the node which should be found - * @param {Node} Current node to be checked + * @param {Number|String} Value of the node which should be found. + * @param {Node} Current node to be checked. */ - BinaryTree.prototype._find = function (value, current) { + exports.BinaryTree.prototype._find = function (value, current) { if (!current) { return null; } @@ -183,19 +208,18 @@ }; /** - * Replaces given child with new one, for given parent + * Replaces given child with new one, for given parent. * * @private - * @param {Node} Parent node - * @param {Node} Child to be replaced - * @param {Node} Child replacement + * @param {Node} parent Parent node. + * @param {Node} oldChild Child to be replaced. + * @param {Node} newChild Child replacement. */ - BinaryTree.prototype._replaceChild = function (parent, oldChild, newChild) { + exports.BinaryTree.prototype._replaceChild = function (parent, oldChild, newChild) { if (!parent) { this._root = newChild; this._root._parent = null; } else { - if (parent._left === oldChild) { parent._left = newChild; } else { @@ -209,14 +233,15 @@ }; /** - * Removes node from the tree. Average runtime complexity: O(log n). + * Removes node from the tree.

+ * Average runtime complexity: O(log N). * * @public * @param {Node} Node to be removed - * @returns {boolean} True/false depending - * on whether the given node is removed + * @returns {Boolean} True/false depending + * on whether the given node is removed. */ - BinaryTree.prototype.remove = function (node) { + exports.BinaryTree.prototype.remove = function (node) { if (!node) { return false; } @@ -241,14 +266,14 @@ }; /** - * Finds the node with minimum value in given sub-tree + * Finds the node with minimum value in given sub-tree. * * @private - * @param {Node} Root of the sub-tree - * @param {Number|String} Current minimum value of the sub-tree - * @returns {Node} The node with minimum value in the sub-tree + * @param {Node} node Root of the sub-tree. + * @param {Number|String} current Current minimum value of the sub-tree. + * @returns {Node} Node with the minimum value in the sub-tree. */ - BinaryTree.prototype._findMin = function (node, current) { + exports.BinaryTree.prototype._findMin = function (node, current) { current = current || { value: Infinity }; if (!node) { return current; @@ -260,14 +285,14 @@ }; /** - * Finds the node with maximum value in given sub-tree + * Finds the node with maximum value in given sub-tree. * * @private - * @param {Node} Root of the sub-tree - * @param {Number|String} Current maximum value of the sub-tree - * @returns {Node} The node with maximum value in the sub-tree + * @param {Node} node Root of the sub-tree. + * @param {Number|String} current Current maximum value of the sub-tree. + * @returns {Node} Node with the maximum value in the sub-tree. */ - BinaryTree.prototype._findMax = function (node, current) { + exports.BinaryTree.prototype._findMax = function (node, current) { current = current || { value: -Infinity }; if (!node) { return current; @@ -279,28 +304,27 @@ }; /** - * Finds the node with minimum value in the whole tree + * Finds the node with minimum value in the whole tree. * * @public - * @returns {Node} The minimum node of the tree + * @returns {Node} The minimum node of the tree. */ - BinaryTree.prototype.findMin = function () { + exports.BinaryTree.prototype.findMin = function () { return this._findMin(this._root); }; /** - * Finds the maximum node of the tree + * Finds the node with maximum value in the whole tree. * * @public - * @returns {Node} The maximum node of the tree + * @returns {Node} The maximum node of the tree. * */ - BinaryTree.prototype.findMax = function () { + exports.BinaryTree.prototype.findMax = function () { return this._findMax(this._root); }; - - BinaryTree.prototype._isBalanced = function (current) { + exports.BinaryTree.prototype._isBalanced = function (current) { if (!current) { return true; } @@ -311,22 +335,22 @@ }; /** - * Returns whether the BST is balanced + * Returns whether the BST is balanced. * * @public - * @returns {Boolean} Whether the tree is balanced or not + * @returns {Boolean} Whether the tree is balanced or not. */ - BinaryTree.prototype.isBalanced = function () { + exports.BinaryTree.prototype.isBalanced = function () { return this._isBalanced(this._root); }; /** - * Finds the diameter of the binary tree + * Finds the diameter of the binary tree. * * @public - * @returns {Number} The longest path in the BST + * @returns {Number} The longest path in the BST. */ - BinaryTree.prototype.getDiameter = function () { + exports.BinaryTree.prototype.getDiameter = function () { var getDiameter = function (root) { if (!root) { return 0; @@ -340,16 +364,16 @@ }; /** - * Returns the height of the tree + * Returns the height of the tree. * * @public - * @returns {Number} The height of the tree + * @returns {Number} The height of the tree. */ - BinaryTree.prototype.getHeight = function () { + exports.BinaryTree.prototype.getHeight = function () { return this._getHeight(this._root); }; - BinaryTree.prototype._getHeight = function (node) { + exports.BinaryTree.prototype._getHeight = function (node) { if (!node) { return 0; } @@ -361,14 +385,14 @@ * Finds the lowest common ancestor of two nodes. * * @public - * @returns {Node} The lowest common ancestor of the two nodes or null + * @returns {Node} The lowest common ancestor of the two nodes or null. */ - BinaryTree.prototype.lowestCommonAncestor = + exports.BinaryTree.prototype.lowestCommonAncestor = function (firstNode, secondNode) { return this._lowestCommonAncestor(firstNode, secondNode, this._root); }; - BinaryTree.prototype._lowestCommonAncestor = + exports.BinaryTree.prototype._lowestCommonAncestor = function (firstNode, secondNode, current) { var firstNodeInLeft = this._existsInSubtree(firstNode, current._left), secondNodeInLeft = this._existsInSubtree(secondNode, current._left), @@ -387,7 +411,7 @@ return null; }; - BinaryTree.prototype._existsInSubtree = function (node, root) { + exports.BinaryTree.prototype._existsInSubtree = function (node, root) { if (!root) { return false; } @@ -398,7 +422,4 @@ this._existsInSubtree(node, root._right); }; - exports.BinaryTree = BinaryTree; - exports.Node = Node; - }(typeof exports === 'undefined' ? window : exports)); From fa236dfd5986717f5ab14e68e44fd6a47a205e95 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sat, 10 Jan 2015 15:31:30 +0200 Subject: [PATCH 311/613] add binary heap doc --- src/data-structures/binary-search-tree.js | 2 +- src/data-structures/heap.js | 117 ++++++++++++++++------ 2 files changed, 85 insertions(+), 34 deletions(-) diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 24cf2580..546379fb 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -422,4 +422,4 @@ this._existsInSubtree(node, root._right); }; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index d702d69b..ce98a4bb 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -1,13 +1,54 @@ +/** + * A binary heap is a complete binary tree which satisfies the heap ordering property. + * + * @example + * var Heap = require('path-to-algorithms/src/data-structures/heap').Heap; + * + * var heap = new Heap(function(a, b) { + * return a.birthyear - b.birthyear; + * }); + * + * heap.add({ + * name: 'John', + * birthyear: 1981 + * }); + * heap.add({ + * name: 'Pavlo', + * birthyear: 2000 + * }); + * heap.add({ + * name: 'Garry', + * birthyear: 1989 + * }); + * heap.add({ + * name: 'Derek', + * birthyear: 1990 + * }); + * heap.add({ + * name: 'Ivan', + * birthyear: 1966 + * }); + * + * console.log(heap.extract()); // { name: 'Pavlo', birthyear: 2000 } + * console.log(heap.extract()); // { name: 'Derek', birthyear: 1990 } + * console.log(heap.extract()); // { name: 'Garry', birthyear: 1989 } + * console.log(heap.extract()); // { name: 'John', birthyear: 1981 } + * console.log(heap.extract()); // { name: 'Ivan', birthyear: 1966 } + * + * @module data-structures/heap + */ (function (exports) { + 'use strict'; /** - * Constructor function of minimum heap + * Minimum heap constructor. * * @public - * @param {function} Function used for comparition between the elements + * @constructor + * @param {Function} cmp Function used for comparition between the elements. */ - function Heap(cmp) { + exports.Heap = function(cmp) { this._heap = []; if (typeof cmp === 'function') { this._cmp = cmp; @@ -21,13 +62,14 @@ /** * Exchange indexes with start index given as argument * to turn the tree into a valid heap. On a single call - * this method maintains only a single "branch" of the heap. - * Complexity O(log n) + * this method maintains only a single "branch" of the heap.

+ * + * Time complexity: O(log N). * * @private - * @param {Number} index The parent + * @param {Number} index The parent. */ - Heap.prototype._heapify = function (index) { + exports.Heap.prototype._heapify = function (index) { var extr = index, left = 2 * index + 1, right = 2 * index + 2, @@ -52,14 +94,15 @@ }; /** - * Changes the key for give index. Complexity O(log n). - * + * Changes the key.

+ * Complexity: O(log N). + * * @public - * @param {Number} index Index which key should be changed - * @param {Number} value New value of the key - * @returns {Number} parent The new position of the element + * @param {Number} index Index of the value which should be changed. + * @param {Number|Object} value New value according to the index. + * @return {Number} New position of the element. */ - Heap.prototype.changeKey = function (index, value) { + exports.Heap.prototype.changeKey = function (index, value) { this._heap[index] = value; var elem = this._heap[index], parent = Math.floor(index / 2), @@ -77,11 +120,14 @@ }; /** - * Updates given node. This operation is useful + * Updates a given node. This operation is useful * in algorithms like Dijkstra, A* where we need - * to decrease/increase the value of givne node. + * to decrease/increase value of the given node. + * + * @public + * @param {Number|Object} node Node which should be updated. */ - Heap.prototype.update = function (node) { + exports.Heap.prototype.update = function (node) { var idx = this._heap.indexOf(node); if (idx >= 0) { this.changeKey(idx, node); @@ -89,53 +135,58 @@ }; /** - * Adds new element to the heap. Complexity O(log n). + * Adds new element to the heap.

+ * Complexity: O(log N). * * @public - * @param {Number} value The new value which will be inserted - * @returns {Number} The index of the inserted value + * @param {Number|Object} value Value which will be inserted. + * @return {Number} Index of the inserted value. */ - Heap.prototype.add = function (value) { + exports.Heap.prototype.add = function (value) { this._heap.push(value); return this.changeKey(this._heap.length - 1, value); }; /** - * Gets the current value which is on the top of the heap. Complexity O(1). + * Returns current value which is on the top of the heap.

+ * Complexity: O(1). * * @public - * returns {Number} The current top value. + * @return {Number|Object} Current top value. */ - Heap.prototype.top = function () { + exports.Heap.prototype.top = function () { return this._heap[0]; }; /** * Removes and returns the current extremum value - * which is on the top of the heap. - * Complexity O(log n). + * which is on the top of the heap.

+ * Complexity: O(log N). * * @public - * @returns {Number} The extremum value + * @returns {Number|Object} The extremum value. */ - Heap.prototype.extract = function () { + exports.Heap.prototype.extract = function () { if (!this._heap.length) { throw 'The heap is already empty!'; } - var extr = this._heap.shift(); this._heapify(0); return extr; }; - Heap.prototype.getCollection = function () { + exports.Heap.prototype.getCollection = function () { return this._heap; }; - Heap.prototype.isEmpty = function () { + /** + * Checks or heap is empty. + * + * @public + * @returns {Boolean} Returns true if heap is empty. + */ + exports.Heap.prototype.isEmpty = function () { return !this._heap.length; }; - exports.Heap = Heap; - -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file From 4e9ec58d0aa20a98e9516e667b5ed12c9cb18978 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 10 Jan 2015 17:31:35 +0200 Subject: [PATCH 312/613] Fix linting errors --- src/data-structures/binary-search-tree.js | 31 ++++++++++++++--------- src/data-structures/heap.js | 13 +++++----- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 546379fb..1cc20012 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -36,7 +36,7 @@ * @param {Node} right Right sibling. * @param {Node} parent Parent of the node. */ - exports.Node = function(value, left, right, parent) { + exports.Node = function (value, left, right, parent) { /** * @member {Number|String} */ @@ -44,7 +44,7 @@ this._left = left; this._right = right; this._parent = parent; - } + }; /** * Binary tree. @@ -52,9 +52,9 @@ * @public * @constructor */ - exports.BinaryTree = function() { + exports.BinaryTree = function () { this._root = null; - } + }; /** * Inserts a node into the binary search tree.

@@ -90,7 +90,8 @@ * * @private * @param {Node} current Node from which to start the traversal. - * @param {Function} callback Callback which will be called for each traversed node. + * @param {Function} callback Callback which + * will be called for each traversed node. */ exports.BinaryTree.prototype._inorder = function (current, callback) { if (!current) { @@ -108,7 +109,8 @@ * * @public * @method - * @param {Function} callback Callback which will be called for each traversed node. + * @param {Function} callback Callback which will + * be called for each traversed node. */ exports.BinaryTree.prototype.inorder = function (callback) { return this._inorder(this._root, callback); @@ -119,7 +121,8 @@ * * @private * @param {Node} current Node from which to start the traversal. - * @param {Function} callback Callback which will be called for each traversed node. + * @param {Function} callback Callback which will + * be called for each traversed node */ exports.BinaryTree.prototype._postorder = function (current, callback) { if (!current) { @@ -136,7 +139,8 @@ * Post-order traversal of the whole tree. * * @public - * @param {Function} callback Callback which will be called for each traversed node. + * @param {Function} callback Callback which will + * be called for each traversed node. */ exports.BinaryTree.prototype.postorder = function (callback) { return this._postorder(this._root, callback); @@ -147,7 +151,8 @@ * * @private * @param {Node} current Node from which to start the traversal. - * @param {Function} callback Callback which will be called for each traversed node. + * @param {Function} callback Callback which will + * be called for each traversed node. */ exports.BinaryTree.prototype._preorder = function (current, callback) { if (!current) { @@ -162,9 +167,10 @@ /** * Pre-order preorder traversal of the whole tree. - * + * * @public - * @param {Function} callback Callback which will be called for each traversed node. + * @param {Function} callback Callback which will be + * called for each traversed node. */ exports.BinaryTree.prototype.preorder = function (callback) { return this._preorder(this._root, callback); @@ -215,7 +221,8 @@ * @param {Node} oldChild Child to be replaced. * @param {Node} newChild Child replacement. */ - exports.BinaryTree.prototype._replaceChild = function (parent, oldChild, newChild) { + exports.BinaryTree.prototype._replaceChild = + function (parent, oldChild, newChild) { if (!parent) { this._root = newChild; this._root._parent = null; diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index ce98a4bb..963fc4a0 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -1,13 +1,14 @@ /** - * A binary heap is a complete binary tree which satisfies the heap ordering property. - * + * A binary heap is a complete binary tree which + * satisfies the heap ordering property. + * * @example * var Heap = require('path-to-algorithms/src/data-structures/heap').Heap; - * + * * var heap = new Heap(function(a, b) { * return a.birthyear - b.birthyear; * }); - * + * * heap.add({ * name: 'John', * birthyear: 1981 @@ -48,7 +49,7 @@ * @constructor * @param {Function} cmp Function used for comparition between the elements. */ - exports.Heap = function(cmp) { + exports.Heap = function (cmp) { this._heap = []; if (typeof cmp === 'function') { this._cmp = cmp; @@ -57,7 +58,7 @@ return a - b; }; } - } + }; /** * Exchange indexes with start index given as argument From b28985f936e0a48b577af97d7a076bc8ee56c865 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 10 Jan 2015 17:35:29 +0200 Subject: [PATCH 313/613] Intentionally break the build --- test/graphs/searching/bfs.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/graphs/searching/bfs.spec.js b/test/graphs/searching/bfs.spec.js index 4ffa6e1c..07a7786c 100644 --- a/test/graphs/searching/bfs.spec.js +++ b/test/graphs/searching/bfs.spec.js @@ -13,7 +13,7 @@ var bfs = require('../../../src/graphs/searching/bfs').bfs; describe('BFS', function () { it('should work with empty graph', function () { - expect(bfs([], 0, 0)).toEqual([0]); + expect(bfs([], 0, 0)).toEqual([1]); }); it('should return the correct output when used with\ From 865abc46bad761b13210845f11f00c6dfe9db298 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 10 Jan 2015 17:40:43 +0200 Subject: [PATCH 314/613] Fix jshint config --- gulpfile.js | 8 +++++--- package.json | 3 ++- src/compression/runlength/runlength.js | 2 +- test/graphs/searching/bfs.spec.js | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 5bfc5607..4d32a7eb 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,7 +2,8 @@ var gulp = require('gulp'), shell = require('gulp-shell'), jshint = require('gulp-jshint'), - jasmine = require('gulp-jasmine'); + jasmine = require('gulp-jasmine'), + stylish = require('jshint-stylish'); gulp.task('jsdoc', shell.task([ './node_modules/.bin/jsdoc -c ./doc-config.json', @@ -11,7 +12,8 @@ gulp.task('jsdoc', shell.task([ gulp.task('lint', function () { return gulp.src(['./src/**/*.js'], ['./test/**/*.js']) .pipe(jshint()) - .pipe(jshint.reporter('default')); + .pipe(jshint.reporter(stylish)) + .pipe(jshint.reporter('fail')); }); gulp.task('test', function () { @@ -19,4 +21,4 @@ gulp.task('test', function () { .pipe(jasmine()); }); -gulp.task('build', ['lint', 'test']); \ No newline at end of file +gulp.task('build', ['lint', 'test']); diff --git a/package.json b/package.json index 960259c0..d5c5aa75 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "gulp-jasmine": "^1.0.1", "gulp-jshint": "^1.9.0", "gulp-shell": "^0.2.11", - "jsdoc": "3.3.0-alpha13" + "jsdoc": "3.3.0-alpha13", + "jshint-stylish": "^1.0.0" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" diff --git a/src/compression/runlength/runlength.js b/src/compression/runlength/runlength.js index fa9e7532..f8a92c13 100644 --- a/src/compression/runlength/runlength.js +++ b/src/compression/runlength/runlength.js @@ -1,6 +1,6 @@ /** * Run-length encoding. - * The idea of this algorithm is to remove the usless zeros and + * The idea of this algorithm is to remove the usless zeros and * give us representation of string in binary which in which the * zeros will be stripped and replaced with their count. */ diff --git a/test/graphs/searching/bfs.spec.js b/test/graphs/searching/bfs.spec.js index 07a7786c..4ffa6e1c 100644 --- a/test/graphs/searching/bfs.spec.js +++ b/test/graphs/searching/bfs.spec.js @@ -13,7 +13,7 @@ var bfs = require('../../../src/graphs/searching/bfs').bfs; describe('BFS', function () { it('should work with empty graph', function () { - expect(bfs([], 0, 0)).toEqual([1]); + expect(bfs([], 0, 0)).toEqual([0]); }); it('should return the correct output when used with\ From 76b299dc96ee04add729c297047f3b1922c7cc44 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 10 Jan 2015 18:09:59 +0200 Subject: [PATCH 315/613] Fix the build --- src/compression/runlength/runlength.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compression/runlength/runlength.js b/src/compression/runlength/runlength.js index f8a92c13..889c7f16 100644 --- a/src/compression/runlength/runlength.js +++ b/src/compression/runlength/runlength.js @@ -1,6 +1,6 @@ /** * Run-length encoding. - * The idea of this algorithm is to remove the usless zeros and + * The idea of this algorithm is to remove the usless zeros and * give us representation of string in binary which in which the * zeros will be stripped and replaced with their count. */ From a70d9c6346e836c3649b5a73445536a35b2f67e4 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sat, 10 Jan 2015 18:19:58 +0200 Subject: [PATCH 316/613] doc interval-tree --- src/data-structures/interval-tree.js | 134 ++++++++++++++++++++++++--- 1 file changed, 119 insertions(+), 15 deletions(-) diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index 67ce086c..e9d602f8 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -1,20 +1,81 @@ +/** + * Interval tree is an ordered tree data structure to hold intervals. + * + * @example + * + * var IT = require('../src/data-structures/interval-tree'); + * var intervalTree = new IT.IntervalTree(); + * + * intervalTree.add([0, 100]); + * intervalTree.add([101, 200]); + * intervalTree.add([10, 50]); + * intervalTree.add([120, 220]); + * + * console.log(intervalTree.contains(150)); // true + * console.log(intervalTree.contains(250)); // false + * console.log(intervalTree.intersects([210, 310])); // true + * console.log(intervalTree.intersects([310, 320])); // false + * + * @module data-structures/interval-tree + */ (function (exports) { + 'use strict'; - function Node(start, end, left, right) { + /** + * Node which describes an interval. + * + * @public + * @constructor + * @param {Number} start Start of the interval. + * @param {Number} end End of the interval. + * @param {Node} left Left child node. + * @param {Node} right Right child node. + */ + exports.Node = function(start, end, left, right) { + /** + * Node interval. + * @member {Array} + */ this.interval = [start, end]; + /** + * Max endpoint in subtree which starts from this node. + * @member {Number} + */ this.max = -Infinity; + /** + * Parent node. + * @member {Node} + */ this.parentNode = null; + /** + * Left child node. + * @member {Node} + */ this.left = left; + /** + * Right child node. + * @member {Node} + */ this.right = right; } - function IntervalTree() { + /** + * Interval tree. + * + * @public + * @constructor + */ + exports.IntervalTree = function() { + /** + * Root node of the tree. + * @member {Node} + */ this.root = null; } function addNode(node, side, interval) { - var child = new Node(interval[0], interval[1]); + var child = new exports.Node(interval[0], interval[1]); child.parentNode = node; node[side] = child; if (node.max < interval[1]) { @@ -43,9 +104,15 @@ } } - IntervalTree.prototype.add = function (interval) { + /** + * Add new interval to the tree. + * + * @public + * @param {Array} intreval Array with start and end points of the interval. + */ + exports.IntervalTree.prototype.add = function (interval) { if (!this.root) { - this.root = new Node(interval[0], interval[1]); + this.root = new exports.Node(interval[0], interval[1]); return; } addHelper(this.root, interval); @@ -70,7 +137,16 @@ return result; } - IntervalTree.prototype.contains = function (point) { + /** + * Checks or point belongs to at least one intarval from the tree.

+ * Complexity: O(log N). + * + * @public + * @method + * @param {Number} point Point which should be checked. + * @return {Boolean} True if point belongs to one of the intervals. + */ + exports.IntervalTree.prototype.contains = function (point) { return contains(point, this.root); }; @@ -96,7 +172,16 @@ (b[0] <= a[0] && b[1] >= a[0]) || (b[0] <= a[1] && b[1] >= a[1]); } - IntervalTree.prototype.intersects = function (interval) { + /** + * Checks or interval belongs to at least one intarval from the tree.

+ * Complexity: O(log N). + * + * @public + * @method + * @param {Array} interval Interval which should be checked. + * @return {Boolean} True if interval intersects with one of the intervals. + */ + exports.IntervalTree.prototype.intersects = function (interval) { return intersectsHelper(interval, this.root); }; @@ -107,11 +192,26 @@ return 1 + Math.max(heightHelper(node.left), heightHelper(node.right)); } - IntervalTree.prototype.height = function () { + /** + * Returns height of the tree. + * + * @public + * @method + * @return {Number} Height of the tree. + */ + exports.IntervalTree.prototype.height = function () { return heightHelper(this.root); }; - IntervalTree.prototype.findMax = function (node) { + /** + * Returns node with the max endpoint in subtree. + * + * @public + * @method + * @param {Node} node Root node of subtree. + * @return {Node} Node with the largest endpoint. + */ + exports.IntervalTree.prototype.findMax = function (node) { var stack = [node], current, max = -Infinity, maxNode; while (stack.length) { @@ -131,7 +231,7 @@ }; // adjust the max value - IntervalTree.prototype._removeHelper = + exports.IntervalTree.prototype._removeHelper = function (interval, node) { if (!node) { return; @@ -193,11 +293,15 @@ } }; - IntervalTree.prototype.remove = function (interval) { + /** + * Remove interval from the tree. + * + * @public + * @method + * @param {Array} intreval Array with start and end of the interval. + */ + exports.IntervalTree.prototype.remove = function (interval) { return this._removeHelper(interval, this.root); }; - exports.Node = Node; - exports.IntervalTree = IntervalTree; - -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file From 24695165ae973d94fdf8f88266290fbf020dcd8e Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sat, 10 Jan 2015 18:24:06 +0200 Subject: [PATCH 317/613] fix jshint issues --- src/data-structures/binary-search-tree.js | 25 +++++++++++++++-------- src/data-structures/heap.js | 5 +++-- src/data-structures/interval-tree.js | 4 ++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 546379fb..33526183 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -44,7 +44,7 @@ this._left = left; this._right = right; this._parent = parent; - } + }; /** * Binary tree. @@ -54,7 +54,7 @@ */ exports.BinaryTree = function() { this._root = null; - } + }; /** * Inserts a node into the binary search tree.

@@ -90,7 +90,8 @@ * * @private * @param {Node} current Node from which to start the traversal. - * @param {Function} callback Callback which will be called for each traversed node. + * @param {Function} callback Callback which will be called + * for each traversed node. */ exports.BinaryTree.prototype._inorder = function (current, callback) { if (!current) { @@ -108,7 +109,8 @@ * * @public * @method - * @param {Function} callback Callback which will be called for each traversed node. + * @param {Function} callback Callback which will be + * called for each traversed node. */ exports.BinaryTree.prototype.inorder = function (callback) { return this._inorder(this._root, callback); @@ -119,7 +121,8 @@ * * @private * @param {Node} current Node from which to start the traversal. - * @param {Function} callback Callback which will be called for each traversed node. + * @param {Function} callback Callback which will be called + * for each traversed node. */ exports.BinaryTree.prototype._postorder = function (current, callback) { if (!current) { @@ -136,7 +139,8 @@ * Post-order traversal of the whole tree. * * @public - * @param {Function} callback Callback which will be called for each traversed node. + * @param {Function} callback Callback which + * will be called for each traversed node. */ exports.BinaryTree.prototype.postorder = function (callback) { return this._postorder(this._root, callback); @@ -147,7 +151,8 @@ * * @private * @param {Node} current Node from which to start the traversal. - * @param {Function} callback Callback which will be called for each traversed node. + * @param {Function} callback Callback which + * will be called for each traversed node. */ exports.BinaryTree.prototype._preorder = function (current, callback) { if (!current) { @@ -164,7 +169,8 @@ * Pre-order preorder traversal of the whole tree. * * @public - * @param {Function} callback Callback which will be called for each traversed node. + * @param {Function} callback Callback which will + * be called for each traversed node. */ exports.BinaryTree.prototype.preorder = function (callback) { return this._preorder(this._root, callback); @@ -215,7 +221,8 @@ * @param {Node} oldChild Child to be replaced. * @param {Node} newChild Child replacement. */ - exports.BinaryTree.prototype._replaceChild = function (parent, oldChild, newChild) { + exports.BinaryTree.prototype._replaceChild = + function (parent, oldChild, newChild) { if (!parent) { this._root = newChild; this._root._parent = null; diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index ce98a4bb..e366c7f7 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -1,5 +1,6 @@ /** - * A binary heap is a complete binary tree which satisfies the heap ordering property. + * A binary heap is a complete binary tree which + * satisfies the heap ordering property. * * @example * var Heap = require('path-to-algorithms/src/data-structures/heap').Heap; @@ -57,7 +58,7 @@ return a - b; }; } - } + }; /** * Exchange indexes with start index given as argument diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index e9d602f8..0c549f2a 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -58,7 +58,7 @@ * @member {Node} */ this.right = right; - } + }; /** * Interval tree. @@ -72,7 +72,7 @@ * @member {Node} */ this.root = null; - } + }; function addNode(node, side, interval) { var child = new exports.Node(interval[0], interval[1]); From 48030389856024314e1f4a02a8122a4f7b4a7c22 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sat, 10 Jan 2015 22:30:12 +0200 Subject: [PATCH 318/613] add linked-list jsdoc --- src/data-structures/linked-list.js | 140 +++++++++++++++++++++++++---- 1 file changed, 124 insertions(+), 16 deletions(-) diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index 74456600..c8cdca68 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -1,19 +1,87 @@ +/** + * Linked list. + * + * @example + * + * var LL = require('../src/data-structures/linked-list'); + * + * var linkedList = new LL.LinkedList(); + * + * linkedList.push({ + * name: 'John', + * birthyear: 1981 + * }); + * linkedList.push({ + * name: 'Pavlo', + * birthyear: 2000 + * }); + * linkedList.push({ + * name: 'Garry', + * birthyear: 1989 + * }); + * linkedList.push({ + * name: 'Derek', + * birthyear: 1990 + * }); + * linkedList.push({ + * name: 'Ivan', + * birthyear: 1966 + * }); + * + * console.log(linkedList.shift().data); // { name: 'John', birthyear: 1981 } + * console.log(linkedList.pop().data); // { name: 'Ivan', birthyear: 1966 } + * + * @module data-structures/linked-list + */ (function (exports) { + 'use strict'; - function Node(data) { + /** + * Linked list node. + * + * @public + * @constructor + * @param {Object} data Data of the node. + */ + exports.Node = function (data) { + /** + * Data of the node. + * @member {Object} + */ this.data = data; + /** + * Next node. + * @member {Node} + */ this.next = null; + /** + * Previous node. + * @member {Node} + */ this.prev = null; } - function LinkedList() { + /** + * Linked list. + * + * @public + * @constructor + */ + exports.LinkedList = function () { this.first = null; this.last = null; } - LinkedList.prototype.push = function (data) { - var node = new Node(data); + /** + * Add data to the end of linked list. + * + * @public + * @method + * @param {Object} data Data which should be added. + */ + exports.LinkedList.prototype.push = function (data) { + var node = new exports.Node(data); if (this.first === null) { this.first = this.last = node; } else { @@ -24,8 +92,15 @@ } }; - LinkedList.prototype.unshift = function (data) { - var node = new Node(data); + /** + * Add data to the beginning of linked list. + * + * @public + * @method + * @param {Object} data Data which should be added. + */ + exports.LinkedList.prototype.unshift = function (data) { + var node = new exports.Node(data); if (this.first === null) { this.first = this.last = node; } else { @@ -36,7 +111,14 @@ } }; - LinkedList.prototype.inorder = function (cb) { + /** + * In order traversal of the linked list. + * + * @public + * @method + * @param {Function} cb Callback which should be executed on each node. + */ + exports.LinkedList.prototype.inorder = function (cb) { var temp = this.first; while (temp) { cb(temp); @@ -44,7 +126,15 @@ } }; - LinkedList.prototype.remove = function (data) { + /** + * Remove data from the linked list. + * + * @public + * @method + * @param {Object} data Data which should be removed. + * @return {Boolean} Returns true if data has been removed. + */ + exports.LinkedList.prototype.remove = function (data) { if (this.first === null) { return false; } @@ -73,7 +163,14 @@ return false; }; - LinkedList.prototype.hasCycle = function () { + /** + * Check or linked list contains cycle. + * + * @public + * @method + * @return {Boolean} Returns true if linked list contains cycle. + */ + exports.LinkedList.prototype.hasCycle = function () { var fast = this.first, slow = this.first; while (true) { @@ -92,7 +189,14 @@ } }; - LinkedList.prototype.pop = function () { + /** + * Return last node from the linked list. + * + * @public + * @method + * @return {Node} Last node. + */ + exports.LinkedList.prototype.pop = function () { if (this.last === null) { return null; } @@ -101,7 +205,14 @@ return temp; }; - LinkedList.prototype.shift = function () { + /** + * Return first node from the linked list. + * + * @public + * @method + * @return {Node} First node. + */ + exports.LinkedList.prototype.shift = function () { if (this.first === null) { return null; } @@ -110,7 +221,7 @@ return temp; }; - LinkedList.prototype.recursiveReverse = function () { + exports.LinkedList.prototype.recursiveReverse = function () { function inverse(current, next) { if (!next) { @@ -130,7 +241,7 @@ this.last = temp; }; - LinkedList.prototype.reverse = function () { + exports.LinkedList.prototype.reverse = function () { if (!this.first || !this.first.next) { return; } @@ -151,8 +262,5 @@ this.last = temp; }; - exports.LinkedList = LinkedList; - exports.Node = Node; - }(typeof exports === 'undefined' ? window : exports)); From 947f392639f636687520a350d4432d9ac99034a3 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sat, 10 Jan 2015 22:34:57 +0200 Subject: [PATCH 319/613] fix jshint errors --- src/data-structures/linked-list.js | 7 +++---- src/data-structures/red-black-tree.js | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index c8cdca68..65045f3a 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -60,7 +60,7 @@ * @member {Node} */ this.prev = null; - } + }; /** * Linked list. @@ -71,7 +71,7 @@ exports.LinkedList = function () { this.first = null; this.last = null; - } + }; /** * Add data to the end of linked list. @@ -262,5 +262,4 @@ this.last = temp; }; -}(typeof exports === 'undefined' ? window : exports)); - +})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index dcd00651..5a6b2154 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -12,7 +12,6 @@ global.Colors = Colors; - /** * Represents given node in the tree. * From 87f7e0fb85d4e14cb0b16dacbc1ac8cd8c97c855 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sat, 10 Jan 2015 22:48:41 +0200 Subject: [PATCH 320/613] fix jsdoc paths --- src/data-structures/interval-tree.js | 2 +- src/data-structures/linked-list.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index 0c549f2a..072e16c0 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -3,7 +3,7 @@ * * @example * - * var IT = require('../src/data-structures/interval-tree'); + * var IT = require('path-to-algorithm/src/data-structures/interval-tree'); * var intervalTree = new IT.IntervalTree(); * * intervalTree.add([0, 100]); diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index 65045f3a..206cbf93 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -3,7 +3,7 @@ * * @example * - * var LL = require('../src/data-structures/linked-list'); + * var LL = require('path-to-algorithm/src/data-structures/linked-list'); * * var linkedList = new LL.LinkedList(); * From d6f70ed1c73fc8067b77d9e2a0b2b7a362fcd6ef Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sat, 10 Jan 2015 22:49:36 +0200 Subject: [PATCH 321/613] fix jsdoc paths --- src/data-structures/interval-tree.js | 2 +- src/data-structures/linked-list.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index 072e16c0..c6b5dd72 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -3,7 +3,7 @@ * * @example * - * var IT = require('path-to-algorithm/src/data-structures/interval-tree'); + * var IT = require('path-to-algorithms/src/data-structures/interval-tree'); * var intervalTree = new IT.IntervalTree(); * * intervalTree.add([0, 100]); diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index 206cbf93..a9ec74d3 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -3,7 +3,7 @@ * * @example * - * var LL = require('path-to-algorithm/src/data-structures/linked-list'); + * var LL = require('path-to-algorithms/src/data-structures/linked-list'); * * var linkedList = new LL.LinkedList(); * From c4b935c4486564acdcbd2519b30203bd80aa96e2 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sun, 11 Jan 2015 01:15:38 +0200 Subject: [PATCH 322/613] add red-black tree documentation --- src/data-structures/red-black-tree.js | 158 ++++++++++++++++++++------ 1 file changed, 121 insertions(+), 37 deletions(-) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index 5a6b2154..e05a1786 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -1,4 +1,34 @@ -(function (global) { +/** + * Red-Black tree is a data structure which is + * a type of self-balancing binary search tree. + * + * @example + * + * var RBTree = require('../src/data-structures/red-black-tree').RBTree; + * var rbTree = new RBTree(); + * + * rbTree.put(1981, { + * name: 'John', + * surname: 'Smith' + * }); + * rbTree.put(2000, { + * name: 'Pavlo', + * surname: 'Popov' + * }); + * rbTree.put(1989, { + * name: 'Garry', + * surname: 'Fisher' + * }); + * rbTree.put(1990, { + * name: 'Derek', + * surname: 'Anderson' + * }); + * + * console.log(rbTree.get(1989)); // { name: 'Garry', surname: 'Fisher' } + * + * @module data-structures/red-black-tree + */ +(function (exports) { 'use strict'; @@ -9,13 +39,18 @@ RED: 0, BLACK: 1 }; - - global.Colors = Colors; + exports.Colors = Colors; /** - * Represents given node in the tree. - * + * Node of the Red-Black tree. + * + * @private * @constructor + * @param {Number} key Key of the node. + * @param {Object} value Value assigned to the node. + * @param {Node} left Left node. + * @param {Node} right Right node. + * @param {Number} color Node color. */ function Node(key, value, left, right, color) { this._key = key; @@ -25,10 +60,23 @@ this._color = color; } + /** + * Check or node is red. + * + * @private + * @method + * @return {Boolean} Returns true if node is red. + */ Node.prototype.isRed = function () { return this._color === Colors.RED; }; + /** + * Changes node color. + * + * @private + * @method + */ Node.prototype.flipColor = function () { if (this._color === Colors.RED) { this._color = Colors.BLACK; @@ -53,23 +101,28 @@ }; }); - global.Node = Node; - + exports.Node = Node; /** - * Represents a Red-Black Tree - * + * Red-Black Tree. + * + * @public * @constructor */ - function RBTree() { + exports.RBTree = function () { this._root = null; - } + }; /** - * Adds value associated with given key. - * Complexity O(log n) + * Add value associated with a given key.

+ * Complexity: O(log N). + * + * @public + * @method + * @param {Number} key Key. + * @param {Object} value Value. */ - RBTree.prototype.put = function (key, value) { + exports.RBTree.prototype.put = function (key, value) { this._root = this._put(key, value, this._root); this._root.setColor(Colors.BLACK); }; @@ -77,8 +130,13 @@ /** * Returns true or false depending on whether * given node is red. + * + * @private + * @method + * @param {Node} node Node which sould be checked. + * @return Returns true if node is red. */ - RBTree.prototype.isRed = function (node) { + exports.RBTree.prototype.isRed = function (node) { if (!node) { return false; } @@ -86,10 +144,16 @@ }; /** - * Helper function for insertion of given key, value pair - * into the red-black tree. + * Helper function for insertion of given key, + * value pair into the Red-Black tree. + * + * @private + * @method + * @param {Number} key Key. + * @param {Object} value Value. + * @param {Node} node Node. */ - RBTree.prototype._put = function (key, value, node) { + exports.RBTree.prototype._put = function (key, value, node) { var newRoot = node; if (node === null) { return new Node(key, value, null, null, Colors.RED); @@ -114,19 +178,28 @@ }; /** - * Flip the colors of the both neighbours of given node. - * Complexity O(1). + * Flip the colors of the both neighbours of given node.

+ * Complexity: O(1). + * + * @private + * @method + * @param {Node} node Node. */ - RBTree.prototype._flipColors = function (node) { + exports.RBTree.prototype._flipColors = function (node) { node.getLeft().flipColor(); node.getRight().flipColor(); }; /* - * Rotates given node to left. - * Complexity O(1). + * Rotates given node to the left.

+ * Complexity: O(1). + * + * @private + * @method + * @param {Node} node Node. + * @return {Node} Right node. */ - RBTree.prototype._rotateLeft = function (node) { + exports.RBTree.prototype._rotateLeft = function (node) { var x = node.getRight(); if (x !== null) { var temp = x.getLeft(); @@ -139,10 +212,15 @@ }; /* - * Rotates given node to right. - * Complexity O(1). + * Rotates given node to the right.

+ * Complexity: O(1). + * + * @private + * @method + * @param {Node} node Node. + * @return {Node} Left node. */ - RBTree.prototype._rotateRight = function (node) { + exports.RBTree.prototype._rotateRight = function (node) { var x = node.getLeft(); if (x !== null) { var temp = x.getRight(); @@ -155,17 +233,26 @@ }; /** - * Gets value by given key. - * Complexity O(log n). + * Get value by the given key.

+ * Complexity: O(log N). * - * @param {*} key A key to be searched for - * @return {*} A value which will be returned based on the passed key + * @public + * @param {Number} key A key to be searched for. + * @return {Object} A value which will be returned based on the key. */ - RBTree.prototype.get = function (key) { + exports.RBTree.prototype.get = function (key) { return this._get(this._root, key); }; - RBTree.prototype._get = function (node, key) { + /** + * Get value by the given key.

+ * + * @private + * @param {Node} node Node to start with. + * @param {Number} key A key to be searched for. + * @return {Object} A value which will be returned based on the key. + */ + exports.RBTree.prototype._get = function (node, key) { if (node === null) { return undefined; } @@ -179,7 +266,4 @@ } }; - global.RBTree = RBTree; - -}(typeof window === 'undefined' ? module.exports : window)); - +})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file From 75f6d516b69d793fc37550297bcaa4ddcfb1f384 Mon Sep 17 00:00:00 2001 From: Pavlo Voznenko Date: Sun, 11 Jan 2015 13:56:52 +0100 Subject: [PATCH 323/613] added "Sieve of Eratosthenes" - Simple, ancient algorithm for finding all prime numbers up to any given limit --- .gitignore | 3 +- gulpfile.js | 2 +- src/primes/sieve-of-eratosthenes.js | 50 +++++++++++++++++++++++ test/primes/sieve-of-eratosthenes.spec.js | 17 ++++++++ 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 src/primes/sieve-of-eratosthenes.js create mode 100644 test/primes/sieve-of-eratosthenes.spec.js diff --git a/.gitignore b/.gitignore index f5e1cf62..7e6c166d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules npm-debug.log -debug \ No newline at end of file +debug +.idea \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 4d32a7eb..fbac400f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,7 +6,7 @@ var gulp = require('gulp'), stylish = require('jshint-stylish'); gulp.task('jsdoc', shell.task([ - './node_modules/.bin/jsdoc -c ./doc-config.json', + './node_modules/.bin/jsdoc -c ./doc-config.json' ])); gulp.task('lint', function () { diff --git a/src/primes/sieve-of-eratosthenes.js b/src/primes/sieve-of-eratosthenes.js new file mode 100644 index 00000000..77477bdf --- /dev/null +++ b/src/primes/sieve-of-eratosthenes.js @@ -0,0 +1,50 @@ +/** + * Sieve of Eratosthenes + * + * Simple, ancient algorithm for finding all prime numbers up to any given limit + */ +(function (exports) { + 'use strict'; + + /** + * Returns Sieve of Eratosthenes for specified number + * + * Simple, ancient algorithm for finding all prime numbers up to any given + * limit + * + * @param {Number} limit - algorithm will return list with prime numbers up + * to given limit + * + * @returns {Array} - will return array with all prime numbers up to + * provided limit + */ + exports.sieveOfEratosthenes = function (limit) { + var sieve = [], + primes = [], k, l; + + sieve[1] = false; + + for (k = 2; k <= limit; k += 1) { + sieve[k] = true; + } + + for (k = 2; k * k <= limit; k += 1) { + if (sieve[k] !== true) { + continue; + } + + for (l = k * k; l <= limit; l += k) { + sieve[l] = false; + } + } + + sieve.forEach(function (value, key) { + if (value) { + this.push(key); + } + }, primes); + + return primes; + }; + +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file diff --git a/test/primes/sieve-of-eratosthenes.spec.js b/test/primes/sieve-of-eratosthenes.spec.js new file mode 100644 index 00000000..d1dcb1dd --- /dev/null +++ b/test/primes/sieve-of-eratosthenes.spec.js @@ -0,0 +1,17 @@ +'use strict'; + +var sieveOfEratosthenes = + require('../../src/primes/sieve-of-eratosthenes').sieveOfEratosthenes; + +describe('Sieve Of Eratosthenes', function () { + it('should give the right sequence of primes for limit 12', function () { + expect(sieveOfEratosthenes(12).toString()) + .toBe([2, 3, 5, 7, 11].toString()); + }); + + it('should give the empty list for limit less or equal 1', function () { + expect(sieveOfEratosthenes(-12).toString()).toBe([].toString()); + expect(sieveOfEratosthenes(0).toString()).toBe([].toString()); + expect(sieveOfEratosthenes(1).toString()).toBe([].toString()); + }); +}); \ No newline at end of file From edc663418ad2924110a0bda898018aad7bc2d1c5 Mon Sep 17 00:00:00 2001 From: Pavlo Voznenko Date: Sun, 11 Jan 2015 14:09:51 +0100 Subject: [PATCH 324/613] added Advanced (optimised) method for checking if provided number is prime --- src/primes/is-prime.js | 57 ++++++++++++++++++++++++++++++++++++ test/primes/is-prime.spec.js | 13 ++++++++ 2 files changed, 70 insertions(+) create mode 100644 src/primes/is-prime.js create mode 100644 test/primes/is-prime.spec.js diff --git a/src/primes/is-prime.js b/src/primes/is-prime.js new file mode 100644 index 00000000..b3692c12 --- /dev/null +++ b/src/primes/is-prime.js @@ -0,0 +1,57 @@ +/** + * Advanced (optimised) method for checking if provided number is prime + */ +(function (exports) { + 'use strict'; + + /** + * Method will return true if provided number is prime + * + * + * @param {Number} number - number that we check on prime + * @returns {Boolean} + */ + exports.isPrime = function (number) { + if (number === 1) { + return false; + + } else if (number < 4) { + /** + * 2 and 3 are prime + */ + return true; + + } else if (number % 2 === 0) { + return false; + + } else if (number < 9) { + /** + * We have already excluded 4,6 and 8 + */ + return true; + + } else if (number % 3 === 0) { + return false; + + } else { + /** + * 'number' rounded to the greatest integer 'rounded' so that: + * rounded * rounded <= number + */ + var rounded = Math.floor(Math.sqrt(number)), + factor = 5; + while (factor <= rounded) { + if (number % factor === 0) { + return false; + } + if (number % (factor + 2) === 0) { + return false; + } + factor += 6; + } + } + + return true; + }; + +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file diff --git a/test/primes/is-prime.spec.js b/test/primes/is-prime.spec.js new file mode 100644 index 00000000..6a57757f --- /dev/null +++ b/test/primes/is-prime.spec.js @@ -0,0 +1,13 @@ +'use strict'; + +var isPrime = require('../../src/primes/is-prime').isPrime; + +describe('Advanced (optimised) method that checks number on prime', function () { + it('should give true for number 104743', function () { + expect(isPrime(104743)).toBe(true); + }); + + it('should give false for number 104744', function () { + expect(isPrime(104744)).toBe(false); + }); +}); \ No newline at end of file From 2b053e903b05d8f73a4227b26e408b4a1d7d8a50 Mon Sep 17 00:00:00 2001 From: Pavlo Voznenko Date: Sun, 11 Jan 2015 14:23:50 +0100 Subject: [PATCH 325/613] added method for returning Prime factor tree --- src/primes/is-prime.js | 2 ++ src/primes/prime-factor-tree.js | 32 +++++++++++++++++++++++ src/primes/sieve-of-eratosthenes.js | 3 +++ test/primes/prime-factor-tree.spec.js | 28 ++++++++++++++++++++ test/primes/sieve-of-eratosthenes.spec.js | 8 +++--- 5 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 src/primes/prime-factor-tree.js create mode 100644 test/primes/prime-factor-tree.spec.js diff --git a/src/primes/is-prime.js b/src/primes/is-prime.js index b3692c12..a24c2f5d 100644 --- a/src/primes/is-prime.js +++ b/src/primes/is-prime.js @@ -1,5 +1,7 @@ /** * Advanced (optimised) method for checking if provided number is prime + * + * For example for number 104743 it should return true, for 104744 - false */ (function (exports) { 'use strict'; diff --git a/src/primes/prime-factor-tree.js b/src/primes/prime-factor-tree.js new file mode 100644 index 00000000..7c5c9154 --- /dev/null +++ b/src/primes/prime-factor-tree.js @@ -0,0 +1,32 @@ +/** + * Method that will return list of all primes for provided number + * + * For example for number 18 it should return following list of primes [2, 3, 3] + */ +(function (exports) { + 'use strict'; + + /** + * Method will list of all primes for provided number + * + * @param {Number} number + * @returns {Array} + */ + exports.primeFactorTree = function (number) { + var div = 2, + array = []; + + while (number > 1) { + if (number % div === 0) { + number /= div; + + array.push(div); + } else { + div += 1; + } + } + + return array; + }; + +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file diff --git a/src/primes/sieve-of-eratosthenes.js b/src/primes/sieve-of-eratosthenes.js index 77477bdf..31564070 100644 --- a/src/primes/sieve-of-eratosthenes.js +++ b/src/primes/sieve-of-eratosthenes.js @@ -2,6 +2,9 @@ * Sieve of Eratosthenes * * Simple, ancient algorithm for finding all prime numbers up to any given limit + * + * For example for limit 12 it should return following list of primes: + * [2, 3, 5, 7, 11] */ (function (exports) { 'use strict'; diff --git a/test/primes/prime-factor-tree.spec.js b/test/primes/prime-factor-tree.spec.js new file mode 100644 index 00000000..4ace0539 --- /dev/null +++ b/test/primes/prime-factor-tree.spec.js @@ -0,0 +1,28 @@ +'use strict'; + +var primeFactorTree = require('../../src/primes/prime-factor-tree').primeFactorTree; + +describe('Prime factor tree', function () { + it('for number 104743 should return [104743]', function () { + expect(primeFactorTree(104743).toString()).toEqual([104743].toString()); + }); + + it('for number 18 should return [2, 3, 3]', function () { + expect(primeFactorTree(18).toString()).toEqual([2, 3, 3].toString()); + }); + + it('should give the empty list for number less or equal 1', function () { + expect(primeFactorTree(-12).toString()).toEqual([].toString()); + expect(primeFactorTree(0).toString()).toEqual([].toString()); + expect(primeFactorTree(1).toString()).toEqual([].toString()); + }); + + it('sum of primes for given number 600851475143 should be 9238', function () { + var primes = primeFactorTree(600851475143), + sumOfPrimes = primes.reduce(function (previousValue, currentValue) { + return previousValue + currentValue; + }); + + expect(sumOfPrimes).toEqual(9238); + }); +}); \ No newline at end of file diff --git a/test/primes/sieve-of-eratosthenes.spec.js b/test/primes/sieve-of-eratosthenes.spec.js index d1dcb1dd..d842e500 100644 --- a/test/primes/sieve-of-eratosthenes.spec.js +++ b/test/primes/sieve-of-eratosthenes.spec.js @@ -6,12 +6,12 @@ var sieveOfEratosthenes = describe('Sieve Of Eratosthenes', function () { it('should give the right sequence of primes for limit 12', function () { expect(sieveOfEratosthenes(12).toString()) - .toBe([2, 3, 5, 7, 11].toString()); + .toEqual([2, 3, 5, 7, 11].toString()); }); it('should give the empty list for limit less or equal 1', function () { - expect(sieveOfEratosthenes(-12).toString()).toBe([].toString()); - expect(sieveOfEratosthenes(0).toString()).toBe([].toString()); - expect(sieveOfEratosthenes(1).toString()).toBe([].toString()); + expect(sieveOfEratosthenes(-12).toString()).toEqual([].toString()); + expect(sieveOfEratosthenes(0).toString()).toEqual([].toString()); + expect(sieveOfEratosthenes(1).toString()).toEqual([].toString()); }); }); \ No newline at end of file From 3b9d5edef39faed8c6a5a7a3914d5b92546a4045 Mon Sep 17 00:00:00 2001 From: Pavlo Voznenko Date: Sun, 11 Jan 2015 15:36:08 +0100 Subject: [PATCH 326/613] some advanced algo tests for isPrime and SieveOfEratosthenes --- test/primes/is-prime.spec.js | 15 +++++++++++++++ test/primes/sieve-of-eratosthenes.spec.js | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/test/primes/is-prime.spec.js b/test/primes/is-prime.spec.js index 6a57757f..8399ff3a 100644 --- a/test/primes/is-prime.spec.js +++ b/test/primes/is-prime.spec.js @@ -10,4 +10,19 @@ describe('Advanced (optimised) method that checks number on prime', function () it('should give false for number 104744', function () { expect(isPrime(104744)).toBe(false); }); + + it('the 10001st prime number should be 104743', function () { + var count = 1, //we know that 2 is prime + value = 1; + + while (count < 10001) { + value += 2; + + if (isPrime(value)) { + count += 1; + } + } + + expect(value).toEqual(104743); + }); }); \ No newline at end of file diff --git a/test/primes/sieve-of-eratosthenes.spec.js b/test/primes/sieve-of-eratosthenes.spec.js index d842e500..f87d57ac 100644 --- a/test/primes/sieve-of-eratosthenes.spec.js +++ b/test/primes/sieve-of-eratosthenes.spec.js @@ -14,4 +14,13 @@ describe('Sieve Of Eratosthenes', function () { expect(sieveOfEratosthenes(0).toString()).toEqual([].toString()); expect(sieveOfEratosthenes(1).toString()).toEqual([].toString()); }); + + it('sum of prime numbers up to 2000000 limit should be 142913828922', function () { + var sieve = sieveOfEratosthenes(2000000), + sumOfPrimes = sieve.reduce(function (previousValue, currentValue) { + return previousValue + currentValue; + }); + + expect(sumOfPrimes).toEqual(142913828922); + }); }); \ No newline at end of file From 8fd4d163c1f44ba8ce7d8e1f78b9db442712eaae Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 11 Jan 2015 17:23:00 +0200 Subject: [PATCH 327/613] Add jscsrc and fix styles --- .jscsrc | 27 +++++ gulpfile.js | 9 +- package.json | 1 + src/combinatorics/cartesianproduct.js | 1 - src/combinatorics/combinations.js | 1 - src/compression/runlength/runlength.js | 2 +- src/data-structures/binary-search-tree.js | 2 +- src/data-structures/heap.js | 2 +- src/data-structures/interval-tree.js | 10 +- src/data-structures/linked-list.js | 2 +- src/data-structures/red-black-tree.js | 2 +- src/data-structures/suffix-tree.js | 3 +- src/graphs/searching/bfs.js | 2 +- src/graphs/searching/dfs.js | 2 +- src/graphs/shortest-path/bellman-ford.js | 2 +- src/graphs/shortest-path/dijkstra.js | 2 +- src/graphs/spanning-trees/prim.js | 2 +- src/others/levenshtein-distance.js | 2 +- src/primes/is-prime.js | 100 +++++++++--------- src/primes/prime-factor-tree.js | 43 ++++---- src/primes/sieve-of-eratosthenes.js | 89 ++++++++-------- .../knuth-morris-pratt/knuth-morris-pratt.js | 2 +- src/shuffle/fisheryates.js | 1 - src/shuffle/richarddurstenfeld.js | 1 - src/sorting/heapsort/heapsort.js | 2 +- .../insertionsort/insertion-binary-sort.js | 2 +- src/sorting/insertionsort/insertionsort.js | 2 +- .../insertionsort/recursive-insertionsort.js | 2 +- src/sorting/least-significant-digit/lsd.js | 1 - src/sorting/linearsort/bucketsort.js | 2 +- src/sorting/linearsort/countingsort.js | 2 +- src/sorting/quicksort/quicksort-middle.js | 2 +- src/sorting/quicksort/quicksort.js | 2 +- src/sorting/selectionsort/selectionsort.js | 2 +- src/sorting/shellsort/shellsort.js | 3 +- test/graphs/searching/bfs.spec.js | 2 +- test/graphs/searching/dfs.spec.js | 3 +- test/primes/is-prime.spec.js | 39 +++---- test/primes/prime-factor-tree.spec.js | 38 +++---- test/primes/sieve-of-eratosthenes.spec.js | 37 +++---- .../binarysearch/binarysearch.spec.js | 3 +- .../longest-increasing-subsequence.spec.js | 3 +- ...aximum-subarray-divide-and-conquer.spec.js | 2 +- test/sorting/bubblesort/bubblesort.spec.js | 2 +- test/sorting/heapsort/heapsort.spec.js | 2 +- .../insertionsort/insertionbinarysort.spec.js | 2 +- .../insertionsort/insertionsort.spec.js | 2 +- .../recursiveinsertionsort.spec.js | 2 +- test/sorting/mergesort/mergesort.spec.js | 2 +- .../quicksort/quicksort-middle.spec.js | 2 +- test/sorting/quicksort/quicksort.spec.js | 2 +- .../selectionsort/selectionsort.spec.js | 2 +- test/sorting/shellsort/shellsort.spec.js | 2 +- test/sorting/sort.testcase.js | 4 +- 54 files changed, 256 insertions(+), 227 deletions(-) create mode 100644 .jscsrc diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 00000000..dfbef8d6 --- /dev/null +++ b/.jscsrc @@ -0,0 +1,27 @@ +{ + "requireCurlyBraces": ["else", "for", "while", "do", "try", "catch"], + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], + "requireSpacesInFunctionExpression": { + "beforeOpeningCurlyBrace": true + }, + "requireSpacesInsideObjectBrackets": "allButNested", + "disallowSpacesInsideArrayBrackets": true, + "disallowSpacesInsideParentheses": true, + "disallowSpaceAfterObjectKeys": true, + "disallowQuotedKeysInObjects": true, + "requireSpaceBeforeBinaryOperators": ["?", "+", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], + "disallowSpaceAfterBinaryOperators": ["!"], + "requireSpaceAfterBinaryOperators": ["?", ",", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], + "disallowSpaceBeforeBinaryOperators": [","], + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "disallowImplicitTypeConversion": ["numeric", "binary", "string"], + "disallowKeywords": ["with", "eval"], + "disallowMultipleLineBreaks": true, + "disallowKeywordsOnNewLine": ["else"], + "requireLineFeedAtFileEnd": true, + "excludeFiles": ["node_modules/**", "bower_components/**"], + "validateIndentation": 2 +} \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index fbac400f..11fb723d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,7 +3,8 @@ var gulp = require('gulp'), shell = require('gulp-shell'), jshint = require('gulp-jshint'), jasmine = require('gulp-jasmine'), - stylish = require('jshint-stylish'); + stylish = require('jshint-stylish'), + jscs = require('gulp-jscs'); gulp.task('jsdoc', shell.task([ './node_modules/.bin/jsdoc -c ./doc-config.json' @@ -21,4 +22,10 @@ gulp.task('test', function () { .pipe(jasmine()); }); + +gulp.task('jscs', function () { + return gulp.src(['src/**/*.js', 'test/**/*.js']) + .pipe(jscs()); +}); + gulp.task('build', ['lint', 'test']); diff --git a/package.json b/package.json index d5c5aa75..2b85713a 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "devDependencies": { "gulp": "^3.8.10", "gulp-jasmine": "^1.0.1", + "gulp-jscs": "^1.4.0", "gulp-jshint": "^1.9.0", "gulp-shell": "^0.2.11", "jsdoc": "3.3.0-alpha13", diff --git a/src/combinatorics/cartesianproduct.js b/src/combinatorics/cartesianproduct.js index e2c1a208..74024f41 100644 --- a/src/combinatorics/cartesianproduct.js +++ b/src/combinatorics/cartesianproduct.js @@ -24,4 +24,3 @@ exports.cartesianProduct = cartesianProduct; }(typeof exports === 'undefined' ? window : exports)); - diff --git a/src/combinatorics/combinations.js b/src/combinatorics/combinations.js index 4c7ff38a..fbd5fa3f 100644 --- a/src/combinatorics/combinations.js +++ b/src/combinatorics/combinations.js @@ -28,4 +28,3 @@ exports.combinations = combinations; }(typeof exports === 'undefined' ? window : exports)); - diff --git a/src/compression/runlength/runlength.js b/src/compression/runlength/runlength.js index 889c7f16..fb044687 100644 --- a/src/compression/runlength/runlength.js +++ b/src/compression/runlength/runlength.js @@ -70,4 +70,4 @@ exports.runLength = runLengthEncoding; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 785a073b..d0285258 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -429,4 +429,4 @@ this._existsInSubtree(node, root._right); }; -})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file +})(typeof window === 'undefined' ? module.exports : window); diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index 963fc4a0..eb15d923 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -190,4 +190,4 @@ return !this._heap.length; }; -})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file +})(typeof window === 'undefined' ? module.exports : window); diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index c6b5dd72..b0ca1f00 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -32,7 +32,7 @@ * @param {Node} left Left child node. * @param {Node} right Right child node. */ - exports.Node = function(start, end, left, right) { + exports.Node = function (start, end, left, right) { /** * Node interval. * @member {Array} @@ -46,7 +46,7 @@ /** * Parent node. * @member {Node} - */ + */ this.parentNode = null; /** * Left child node. @@ -66,7 +66,7 @@ * @public * @constructor */ - exports.IntervalTree = function() { + exports.IntervalTree = function () { /** * Root node of the tree. * @member {Node} @@ -295,7 +295,7 @@ /** * Remove interval from the tree. - * + * * @public * @method * @param {Array} intreval Array with start and end of the interval. @@ -304,4 +304,4 @@ return this._removeHelper(interval, this.root); }; -})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file +})(typeof window === 'undefined' ? module.exports : window); diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index a9ec74d3..823abc73 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -262,4 +262,4 @@ this.last = temp; }; -})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file +})(typeof window === 'undefined' ? module.exports : window); diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index e05a1786..53ba159f 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -266,4 +266,4 @@ } }; -})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file +})(typeof window === 'undefined' ? module.exports : window); diff --git a/src/data-structures/suffix-tree.js b/src/data-structures/suffix-tree.js index 296539e3..d7e6671b 100644 --- a/src/data-structures/suffix-tree.js +++ b/src/data-structures/suffix-tree.js @@ -66,7 +66,6 @@ } }; - // function isSubstr(tree, str) { // if (!tree) { // return false; @@ -95,4 +94,4 @@ exports.Node = Node; exports.SuffixTree = SuffixTree; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/graphs/searching/bfs.js b/src/graphs/searching/bfs.js index 4711f5cd..14c9e532 100644 --- a/src/graphs/searching/bfs.js +++ b/src/graphs/searching/bfs.js @@ -61,4 +61,4 @@ exports.bfs = bfs; -}((typeof window === 'undefined') ? module.exports : window)); \ No newline at end of file +}((typeof window === 'undefined') ? module.exports : window)); diff --git a/src/graphs/searching/dfs.js b/src/graphs/searching/dfs.js index fdaa2524..d302beec 100644 --- a/src/graphs/searching/dfs.js +++ b/src/graphs/searching/dfs.js @@ -53,4 +53,4 @@ exports.dfs = dfs; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/graphs/shortest-path/bellman-ford.js b/src/graphs/shortest-path/bellman-ford.js index ce836005..2f7ee37b 100644 --- a/src/graphs/shortest-path/bellman-ford.js +++ b/src/graphs/shortest-path/bellman-ford.js @@ -88,4 +88,4 @@ return { parents: parents, distances: distances }; }; -})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file +})(typeof window === 'undefined' ? module.exports : window); diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index 03fa397f..95d5ba63 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -118,4 +118,4 @@ exports.dijkstra = dijkstra; -})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file +})(typeof window === 'undefined' ? module.exports : window); diff --git a/src/graphs/spanning-trees/prim.js b/src/graphs/spanning-trees/prim.js index b5100825..1a3f1bb4 100644 --- a/src/graphs/spanning-trees/prim.js +++ b/src/graphs/spanning-trees/prim.js @@ -177,4 +177,4 @@ }()); -})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file +})(typeof window === 'undefined' ? module.exports : window); diff --git a/src/others/levenshtein-distance.js b/src/others/levenshtein-distance.js index 07edbeef..c667875f 100644 --- a/src/others/levenshtein-distance.js +++ b/src/others/levenshtein-distance.js @@ -28,4 +28,4 @@ exports.levenshteinDistance = levenshteinDistance; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/primes/is-prime.js b/src/primes/is-prime.js index a24c2f5d..f1fd4f14 100644 --- a/src/primes/is-prime.js +++ b/src/primes/is-prime.js @@ -4,56 +4,56 @@ * For example for number 104743 it should return true, for 104744 - false */ (function (exports) { - 'use strict'; - - /** - * Method will return true if provided number is prime - * - * - * @param {Number} number - number that we check on prime - * @returns {Boolean} - */ - exports.isPrime = function (number) { - if (number === 1) { - return false; - - } else if (number < 4) { - /** - * 2 and 3 are prime - */ - return true; - - } else if (number % 2 === 0) { - return false; - - } else if (number < 9) { - /** - * We have already excluded 4,6 and 8 - */ - return true; - - } else if (number % 3 === 0) { - return false; - - } else { - /** - * 'number' rounded to the greatest integer 'rounded' so that: - * rounded * rounded <= number - */ - var rounded = Math.floor(Math.sqrt(number)), - factor = 5; - while (factor <= rounded) { - if (number % factor === 0) { - return false; - } - if (number % (factor + 2) === 0) { - return false; - } - factor += 6; - } + 'use strict'; + + /** + * Method will return true if provided number is prime + * + * @module primes + * @param {Number} number - number that we check on prime + * @returns {Boolean} + */ + exports.isPrime = function (number) { + if (number === 1) { + return false; + + } else if (number < 4) { + /** + * 2 and 3 are prime + */ + return true; + + } else if (number % 2 === 0) { + return false; + + } else if (number < 9) { + /** + * We have already excluded 4,6 and 8 + */ + return true; + + } else if (number % 3 === 0) { + return false; + + } else { + /** + * 'number' rounded to the greatest integer 'rounded' so that: + * rounded * rounded <= number + */ + var rounded = Math.floor(Math.sqrt(number)), + factor = 5; + while (factor <= rounded) { + if (number % factor === 0) { + return false; } + if (number % (factor + 2) === 0) { + return false; + } + factor += 6; + } + } - return true; - }; + return true; + }; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/primes/prime-factor-tree.js b/src/primes/prime-factor-tree.js index 7c5c9154..e1b444d2 100644 --- a/src/primes/prime-factor-tree.js +++ b/src/primes/prime-factor-tree.js @@ -4,29 +4,30 @@ * For example for number 18 it should return following list of primes [2, 3, 3] */ (function (exports) { - 'use strict'; + 'use strict'; - /** - * Method will list of all primes for provided number - * - * @param {Number} number - * @returns {Array} - */ - exports.primeFactorTree = function (number) { - var div = 2, - array = []; + /** + * Method will list of all primes for provided number + * + * @module primes + * @param {Number} number + * @returns {Array} + */ + exports.primeFactorTree = function (number) { + var div = 2, + array = []; - while (number > 1) { - if (number % div === 0) { - number /= div; + while (number > 1) { + if (number % div === 0) { + number /= div; - array.push(div); - } else { - div += 1; - } - } + array.push(div); + } else { + div += 1; + } + } - return array; - }; + return array; + }; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/primes/sieve-of-eratosthenes.js b/src/primes/sieve-of-eratosthenes.js index 31564070..d44a43c3 100644 --- a/src/primes/sieve-of-eratosthenes.js +++ b/src/primes/sieve-of-eratosthenes.js @@ -7,47 +7,48 @@ * [2, 3, 5, 7, 11] */ (function (exports) { - 'use strict'; - - /** - * Returns Sieve of Eratosthenes for specified number - * - * Simple, ancient algorithm for finding all prime numbers up to any given - * limit - * - * @param {Number} limit - algorithm will return list with prime numbers up - * to given limit - * - * @returns {Array} - will return array with all prime numbers up to - * provided limit - */ - exports.sieveOfEratosthenes = function (limit) { - var sieve = [], - primes = [], k, l; - - sieve[1] = false; - - for (k = 2; k <= limit; k += 1) { - sieve[k] = true; - } - - for (k = 2; k * k <= limit; k += 1) { - if (sieve[k] !== true) { - continue; - } - - for (l = k * k; l <= limit; l += k) { - sieve[l] = false; - } - } - - sieve.forEach(function (value, key) { - if (value) { - this.push(key); - } - }, primes); - - return primes; - }; - -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file + 'use strict'; + + /** + * Returns Sieve of Eratosthenes for specified number + * + * Simple, ancient algorithm for finding all prime numbers up to any given + * limit + * + * @module primes + * @param {Number} limit - algorithm will return list with prime numbers up + * to given limit + * + * @returns {Array} - will return array with all prime numbers up to + * provided limit + */ + exports.sieveOfEratosthenes = function (limit) { + var sieve = [], + primes = [], k, l; + + sieve[1] = false; + + for (k = 2; k <= limit; k += 1) { + sieve[k] = true; + } + + for (k = 2; k * k <= limit; k += 1) { + if (sieve[k] !== true) { + continue; + } + + for (l = k * k; l <= limit; l += k) { + sieve[l] = false; + } + } + + sieve.forEach(function (value, key) { + if (value) { + this.push(key); + } + }, primes); + + return primes; + }; + +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/searching/knuth-morris-pratt/knuth-morris-pratt.js b/src/searching/knuth-morris-pratt/knuth-morris-pratt.js index 83d02abb..060b356c 100644 --- a/src/searching/knuth-morris-pratt/knuth-morris-pratt.js +++ b/src/searching/knuth-morris-pratt/knuth-morris-pratt.js @@ -50,4 +50,4 @@ exports.kmp = kmp; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/shuffle/fisheryates.js b/src/shuffle/fisheryates.js index 1eaa460b..ee61fe8b 100644 --- a/src/shuffle/fisheryates.js +++ b/src/shuffle/fisheryates.js @@ -23,4 +23,3 @@ exports.shuffle = shuffle; }(typeof exports === 'undefined' ? window : exports)); - diff --git a/src/shuffle/richarddurstenfeld.js b/src/shuffle/richarddurstenfeld.js index 0b91f1a5..93ad93af 100644 --- a/src/shuffle/richarddurstenfeld.js +++ b/src/shuffle/richarddurstenfeld.js @@ -28,4 +28,3 @@ exports.shuffle = shuffle; }(typeof exports === 'undefined' ? window : exports)); - diff --git a/src/sorting/heapsort/heapsort.js b/src/sorting/heapsort/heapsort.js index bbcd8c23..5d0d96c7 100644 --- a/src/sorting/heapsort/heapsort.js +++ b/src/sorting/heapsort/heapsort.js @@ -80,4 +80,4 @@ exports.heapSort = heapSort; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/sorting/insertionsort/insertion-binary-sort.js b/src/sorting/insertionsort/insertion-binary-sort.js index c5ac874a..e3d41925 100644 --- a/src/sorting/insertionsort/insertion-binary-sort.js +++ b/src/sorting/insertionsort/insertion-binary-sort.js @@ -44,4 +44,4 @@ exports.insertionBinarySort = insertionBinarySort; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/sorting/insertionsort/insertionsort.js b/src/sorting/insertionsort/insertionsort.js index ace59119..1a638a3c 100644 --- a/src/sorting/insertionsort/insertionsort.js +++ b/src/sorting/insertionsort/insertionsort.js @@ -30,4 +30,4 @@ exports.insertionSort = insertionSort; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/sorting/insertionsort/recursive-insertionsort.js b/src/sorting/insertionsort/recursive-insertionsort.js index 380dc346..4ec51c9a 100644 --- a/src/sorting/insertionsort/recursive-insertionsort.js +++ b/src/sorting/insertionsort/recursive-insertionsort.js @@ -32,4 +32,4 @@ exports.recursiveInsertionSort = recursiveInsertionSort; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/sorting/least-significant-digit/lsd.js b/src/sorting/least-significant-digit/lsd.js index a1c3169f..ed802e8e 100644 --- a/src/sorting/least-significant-digit/lsd.js +++ b/src/sorting/least-significant-digit/lsd.js @@ -41,4 +41,3 @@ exports.lsd = lsd; }(typeof exports === 'undefined' ? window : exports)); - diff --git a/src/sorting/linearsort/bucketsort.js b/src/sorting/linearsort/bucketsort.js index 9672bfee..ef1feca0 100644 --- a/src/sorting/linearsort/bucketsort.js +++ b/src/sorting/linearsort/bucketsort.js @@ -104,4 +104,4 @@ exports.bucketSort = bucketSort; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/sorting/linearsort/countingsort.js b/src/sorting/linearsort/countingsort.js index 6d828be8..4d90e3c0 100644 --- a/src/sorting/linearsort/countingsort.js +++ b/src/sorting/linearsort/countingsort.js @@ -85,4 +85,4 @@ exports.countingSort = countingSort; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/sorting/quicksort/quicksort-middle.js b/src/sorting/quicksort/quicksort-middle.js index c85cdc8e..7312f7c7 100644 --- a/src/sorting/quicksort/quicksort-middle.js +++ b/src/sorting/quicksort/quicksort-middle.js @@ -85,4 +85,4 @@ exports.quickSort = quickSort; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/sorting/quicksort/quicksort.js b/src/sorting/quicksort/quicksort.js index 0650c786..fd3c56c0 100644 --- a/src/sorting/quicksort/quicksort.js +++ b/src/sorting/quicksort/quicksort.js @@ -84,4 +84,4 @@ exports.quickSort = quickSort; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/sorting/selectionsort/selectionsort.js b/src/sorting/selectionsort/selectionsort.js index 78ea6117..e7d0fbb9 100644 --- a/src/sorting/selectionsort/selectionsort.js +++ b/src/sorting/selectionsort/selectionsort.js @@ -33,4 +33,4 @@ exports.selectionSort = selectionSort; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/sorting/shellsort/shellsort.js b/src/sorting/shellsort/shellsort.js index e78328a8..270d7b10 100644 --- a/src/sorting/shellsort/shellsort.js +++ b/src/sorting/shellsort/shellsort.js @@ -1,7 +1,6 @@ (function (exports) { 'use strict'; - function compare(a, b) { return a - b; } @@ -45,4 +44,4 @@ exports.shellSort = shellSort; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/test/graphs/searching/bfs.spec.js b/test/graphs/searching/bfs.spec.js index 4ffa6e1c..3fbf453b 100644 --- a/test/graphs/searching/bfs.spec.js +++ b/test/graphs/searching/bfs.spec.js @@ -51,4 +51,4 @@ describe('BFS', function () { expect(bfs(graph, 0, 2)).toEqual([0, 2]); }); -}); \ No newline at end of file +}); diff --git a/test/graphs/searching/dfs.spec.js b/test/graphs/searching/dfs.spec.js index ad901350..b5d983d8 100644 --- a/test/graphs/searching/dfs.spec.js +++ b/test/graphs/searching/dfs.spec.js @@ -33,5 +33,4 @@ describe('dfs', function () { expect(dfs([[0, 0], [1, 0]], 0, 1)).toBeFalsy(); expect(dfs([[0, 0, 0], [0, 0, 1], [0, 0, 0]], 0, 2)).toBeFalsy(); }); - -}); \ No newline at end of file +}); diff --git a/test/primes/is-prime.spec.js b/test/primes/is-prime.spec.js index 8399ff3a..703d27b0 100644 --- a/test/primes/is-prime.spec.js +++ b/test/primes/is-prime.spec.js @@ -2,27 +2,28 @@ var isPrime = require('../../src/primes/is-prime').isPrime; -describe('Advanced (optimised) method that checks number on prime', function () { - it('should give true for number 104743', function () { - expect(isPrime(104743)).toBe(true); - }); +describe('Advanced (optimised) method that checks number on prime', + function () { + it('should give true for number 104743', function () { + expect(isPrime(104743)).toBe(true); + }); - it('should give false for number 104744', function () { - expect(isPrime(104744)).toBe(false); - }); + it('should give false for number 104744', function () { + expect(isPrime(104744)).toBe(false); + }); - it('the 10001st prime number should be 104743', function () { - var count = 1, //we know that 2 is prime - value = 1; + it('the 10001st prime number should be 104743', function () { + var count = 1, //we know that 2 is prime + value = 1; - while (count < 10001) { - value += 2; + while (count < 10001) { + value += 2; - if (isPrime(value)) { - count += 1; - } - } + if (isPrime(value)) { + count += 1; + } + } - expect(value).toEqual(104743); - }); -}); \ No newline at end of file + expect(value).toEqual(104743); + }); +}); diff --git a/test/primes/prime-factor-tree.spec.js b/test/primes/prime-factor-tree.spec.js index 4ace0539..f8912ccb 100644 --- a/test/primes/prime-factor-tree.spec.js +++ b/test/primes/prime-factor-tree.spec.js @@ -3,26 +3,26 @@ var primeFactorTree = require('../../src/primes/prime-factor-tree').primeFactorTree; describe('Prime factor tree', function () { - it('for number 104743 should return [104743]', function () { - expect(primeFactorTree(104743).toString()).toEqual([104743].toString()); - }); + it('for number 104743 should return [104743]', function () { + expect(primeFactorTree(104743).toString()).toEqual([104743].toString()); + }); - it('for number 18 should return [2, 3, 3]', function () { - expect(primeFactorTree(18).toString()).toEqual([2, 3, 3].toString()); - }); + it('for number 18 should return [2, 3, 3]', function () { + expect(primeFactorTree(18).toString()).toEqual([2, 3, 3].toString()); + }); - it('should give the empty list for number less or equal 1', function () { - expect(primeFactorTree(-12).toString()).toEqual([].toString()); - expect(primeFactorTree(0).toString()).toEqual([].toString()); - expect(primeFactorTree(1).toString()).toEqual([].toString()); - }); + it('should give the empty list for number less or equal 1', function () { + expect(primeFactorTree(-12).toString()).toEqual([].toString()); + expect(primeFactorTree(0).toString()).toEqual([].toString()); + expect(primeFactorTree(1).toString()).toEqual([].toString()); + }); - it('sum of primes for given number 600851475143 should be 9238', function () { - var primes = primeFactorTree(600851475143), - sumOfPrimes = primes.reduce(function (previousValue, currentValue) { - return previousValue + currentValue; - }); + it('sum of primes for given number 600851475143 should be 9238', function () { + var primes = primeFactorTree(600851475143), + sumOfPrimes = primes.reduce(function (previousValue, currentValue) { + return previousValue + currentValue; + }); - expect(sumOfPrimes).toEqual(9238); - }); -}); \ No newline at end of file + expect(sumOfPrimes).toEqual(9238); + }); +}); diff --git a/test/primes/sieve-of-eratosthenes.spec.js b/test/primes/sieve-of-eratosthenes.spec.js index f87d57ac..f75a47a7 100644 --- a/test/primes/sieve-of-eratosthenes.spec.js +++ b/test/primes/sieve-of-eratosthenes.spec.js @@ -1,26 +1,27 @@ 'use strict'; var sieveOfEratosthenes = - require('../../src/primes/sieve-of-eratosthenes').sieveOfEratosthenes; + require('../../src/primes/sieve-of-eratosthenes').sieveOfEratosthenes; describe('Sieve Of Eratosthenes', function () { - it('should give the right sequence of primes for limit 12', function () { - expect(sieveOfEratosthenes(12).toString()) - .toEqual([2, 3, 5, 7, 11].toString()); - }); + it('should give the right sequence of primes for limit 12', function () { + expect(sieveOfEratosthenes(12).toString()) + .toEqual([2, 3, 5, 7, 11].toString()); + }); - it('should give the empty list for limit less or equal 1', function () { - expect(sieveOfEratosthenes(-12).toString()).toEqual([].toString()); - expect(sieveOfEratosthenes(0).toString()).toEqual([].toString()); - expect(sieveOfEratosthenes(1).toString()).toEqual([].toString()); - }); + it('should give the empty list for limit less or equal 1', function () { + expect(sieveOfEratosthenes(-12).toString()).toEqual([].toString()); + expect(sieveOfEratosthenes(0).toString()).toEqual([].toString()); + expect(sieveOfEratosthenes(1).toString()).toEqual([].toString()); + }); - it('sum of prime numbers up to 2000000 limit should be 142913828922', function () { - var sieve = sieveOfEratosthenes(2000000), - sumOfPrimes = sieve.reduce(function (previousValue, currentValue) { - return previousValue + currentValue; - }); + it('sum of prime numbers up to 2000000 limit should be 142913828922', + function () { + var sieve = sieveOfEratosthenes(2000000), + sumOfPrimes = sieve.reduce(function (previousValue, currentValue) { + return previousValue + currentValue; + }); - expect(sumOfPrimes).toEqual(142913828922); - }); -}); \ No newline at end of file + expect(sumOfPrimes).toEqual(142913828922); + }); +}); diff --git a/test/searching/binarysearch/binarysearch.spec.js b/test/searching/binarysearch/binarysearch.spec.js index 606c8729..a4fd195e 100644 --- a/test/searching/binarysearch/binarysearch.spec.js +++ b/test/searching/binarysearch/binarysearch.spec.js @@ -25,5 +25,4 @@ describe('Binary search', function () { it('should work with empty arrays', function () { expect(binarySearch([], 4)).toBe(-1); }); - -}); \ No newline at end of file +}); diff --git a/test/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js b/test/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js index 78c48bb9..57d4612b 100644 --- a/test/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js +++ b/test/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js @@ -24,5 +24,4 @@ describe('longest subsequence', function () { expect(longestSubsequence(sequence).toString()) .toBe([2, 3, 6, 9, 11].toString()); }); - -}); \ No newline at end of file +}); diff --git a/test/searching/subarray/maximum-subarray-divide-and-conquer.spec.js b/test/searching/subarray/maximum-subarray-divide-and-conquer.spec.js index 40deb2e9..d53477a3 100644 --- a/test/searching/subarray/maximum-subarray-divide-and-conquer.spec.js +++ b/test/searching/subarray/maximum-subarray-divide-and-conquer.spec.js @@ -34,4 +34,4 @@ describe('Maximum subarray implemented with divide and conquer', function () { expect(maxSubArray([-10, -1, -2, -3, -1])).toBe(-1); }); -}); \ No newline at end of file +}); diff --git a/test/sorting/bubblesort/bubblesort.spec.js b/test/sorting/bubblesort/bubblesort.spec.js index 19b25d57..f3636912 100644 --- a/test/sorting/bubblesort/bubblesort.spec.js +++ b/test/sorting/bubblesort/bubblesort.spec.js @@ -2,4 +2,4 @@ var sortTestCase = require('../sort.testcase.js'), bubbleSort = require('../../../src/sorting/bubblesort/bubblesort.js').bubbleSort; -sortTestCase(bubbleSort, 'Bubble sort'); \ No newline at end of file +sortTestCase(bubbleSort, 'Bubble sort'); diff --git a/test/sorting/heapsort/heapsort.spec.js b/test/sorting/heapsort/heapsort.spec.js index 25e3173f..9fd6c912 100644 --- a/test/sorting/heapsort/heapsort.spec.js +++ b/test/sorting/heapsort/heapsort.spec.js @@ -1,4 +1,4 @@ var sortTestCase = require('../sort.testcase.js'), heapSort = require('../../../src/sorting/heapsort/heapsort.js').heapSort; -sortTestCase(heapSort, 'Heap sort'); \ No newline at end of file +sortTestCase(heapSort, 'Heap sort'); diff --git a/test/sorting/insertionsort/insertionbinarysort.spec.js b/test/sorting/insertionsort/insertionbinarysort.spec.js index 7fd6bf0c..9e33a5cc 100644 --- a/test/sorting/insertionsort/insertionbinarysort.spec.js +++ b/test/sorting/insertionsort/insertionbinarysort.spec.js @@ -3,4 +3,4 @@ var sortTestCase = require('../sort.testcase.js'), require('../../../src/sorting/insertionsort/' + 'insertion-binary-sort.js').insertionBinarySort; -sortTestCase(insertionBinarySort, 'Insertion binary sort'); \ No newline at end of file +sortTestCase(insertionBinarySort, 'Insertion binary sort'); diff --git a/test/sorting/insertionsort/insertionsort.spec.js b/test/sorting/insertionsort/insertionsort.spec.js index 01fb28e0..621f57c3 100644 --- a/test/sorting/insertionsort/insertionsort.spec.js +++ b/test/sorting/insertionsort/insertionsort.spec.js @@ -2,4 +2,4 @@ var sortTestCase = require('../sort.testcase.js'), insertionSort = require('../../../src/sorting/insertionsort/' + 'insertionsort.js').insertionSort; -sortTestCase(insertionSort, 'Insertion sort'); \ No newline at end of file +sortTestCase(insertionSort, 'Insertion sort'); diff --git a/test/sorting/insertionsort/recursiveinsertionsort.spec.js b/test/sorting/insertionsort/recursiveinsertionsort.spec.js index 8282b81d..3432df0b 100644 --- a/test/sorting/insertionsort/recursiveinsertionsort.spec.js +++ b/test/sorting/insertionsort/recursiveinsertionsort.spec.js @@ -2,4 +2,4 @@ var sortTestCase = require('../sort.testcase.js'), recursiveInsertionSort = require('../../../src/sorting/' + 'insertionsort/recursive-insertionsort.js').recursiveInsertionSort; -sortTestCase(recursiveInsertionSort, 'Recursive insertion sort'); \ No newline at end of file +sortTestCase(recursiveInsertionSort, 'Recursive insertion sort'); diff --git a/test/sorting/mergesort/mergesort.spec.js b/test/sorting/mergesort/mergesort.spec.js index 975e9711..0adec469 100644 --- a/test/sorting/mergesort/mergesort.spec.js +++ b/test/sorting/mergesort/mergesort.spec.js @@ -2,4 +2,4 @@ var sortTestCase = require('../sort.testcase.js'), mergeSort = require('../../../src/sorting/mergesort/mergesort.js').mergeSort; -sortTestCase(mergeSort, 'Merge sort'); \ No newline at end of file +sortTestCase(mergeSort, 'Merge sort'); diff --git a/test/sorting/quicksort/quicksort-middle.spec.js b/test/sorting/quicksort/quicksort-middle.spec.js index e3b44136..9b75819c 100644 --- a/test/sorting/quicksort/quicksort-middle.spec.js +++ b/test/sorting/quicksort/quicksort-middle.spec.js @@ -2,4 +2,4 @@ var sortTestCase = require('../sort.testcase.js'), quickSort = require('../../../src/sorting/quicksort/quicksort-middle.js').quickSort; -sortTestCase(quickSort, 'Quick sort'); \ No newline at end of file +sortTestCase(quickSort, 'Quick sort'); diff --git a/test/sorting/quicksort/quicksort.spec.js b/test/sorting/quicksort/quicksort.spec.js index f3f668ee..e754372f 100644 --- a/test/sorting/quicksort/quicksort.spec.js +++ b/test/sorting/quicksort/quicksort.spec.js @@ -2,4 +2,4 @@ var sortTestCase = require('../sort.testcase.js'), quickSort = require('../../../src/sorting/quicksort/quicksort.js').quickSort; -sortTestCase(quickSort, 'Quick sort'); \ No newline at end of file +sortTestCase(quickSort, 'Quick sort'); diff --git a/test/sorting/selectionsort/selectionsort.spec.js b/test/sorting/selectionsort/selectionsort.spec.js index ac3b0fae..d4a33237 100644 --- a/test/sorting/selectionsort/selectionsort.spec.js +++ b/test/sorting/selectionsort/selectionsort.spec.js @@ -3,4 +3,4 @@ var sortTestCase = require('../sort.testcase.js'), require('../../../src/sorting/selectionsort/selectionsort.js') .selectionSort; -sortTestCase(selectionSort, 'Selection sort'); \ No newline at end of file +sortTestCase(selectionSort, 'Selection sort'); diff --git a/test/sorting/shellsort/shellsort.spec.js b/test/sorting/shellsort/shellsort.spec.js index ec2a8674..fe8eff75 100644 --- a/test/sorting/shellsort/shellsort.spec.js +++ b/test/sorting/shellsort/shellsort.spec.js @@ -2,4 +2,4 @@ var sortTestCase = require('../sort.testcase.js'), shellSort = require('../../../src/sorting/shellsort/shellsort.js') .shellSort; -sortTestCase(shellSort, 'Shell sort'); \ No newline at end of file +sortTestCase(shellSort, 'Shell sort'); diff --git a/test/sorting/sort.testcase.js b/test/sorting/sort.testcase.js index 73bad801..0bac7c1a 100644 --- a/test/sorting/sort.testcase.js +++ b/test/sorting/sort.testcase.js @@ -3,7 +3,7 @@ module.exports = function (sort, algorithmName, options) { options = options || { integers: false, - reverse : true + reverse: true }; describe(algorithmName, function () { @@ -62,4 +62,4 @@ module.exports = function (sort, algorithmName, options) { } }); -}; \ No newline at end of file +}; From 31cf88aad3b022b75911219084d4bfaf7269d965 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sun, 11 Jan 2015 17:56:53 +0200 Subject: [PATCH 328/613] add cartesianproduct jsdoc --- doc-config.json | 3 ++- src/combinatorics/cartesianproduct.js | 25 ++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/doc-config.json b/doc-config.json index 55965c84..63776c85 100644 --- a/doc-config.json +++ b/doc-config.json @@ -8,7 +8,8 @@ "./src/graphs/others/", "./src/graphs/shortest-path/", "./src/graphs/spanning-trees/", - "./src/data-structures/" + "./src/data-structures/", + "./src/combinatorics/" ], "includePattern": ".+\\.js(doc)?$", "excludePattern": "docs" diff --git a/src/combinatorics/cartesianproduct.js b/src/combinatorics/cartesianproduct.js index 74024f41..b6618933 100644 --- a/src/combinatorics/cartesianproduct.js +++ b/src/combinatorics/cartesianproduct.js @@ -14,6 +14,29 @@ } } + /** + * Calculates Cartesian product of provided sets. + * + * @module combinatorics/cartesianproduct + * @public + * @param {Array} sets Array of sets. + * @return {Array} Cartesian product of provided sets. + * + * @example + * var product = require('../src/combinatorics/cartesianproduct') + * .cartesianProduct; + * var result = product([[1, 2, 3], [3, 2, 1]]); + * // [ [ 1, 3 ], + * // [ 1, 2 ], + * // [ 1, 1 ], + * // [ 2, 3 ], + * // [ 2, 2 ], + * // [ 2, 1 ], + * // [ 3, 3 ], + * // [ 3, 2 ], + * // [ 3, 1 ] ] + * console.log(result); + */ return function (sets) { result = []; cartesianProduct(sets, 0, []); @@ -23,4 +46,4 @@ exports.cartesianProduct = cartesianProduct; -}(typeof exports === 'undefined' ? window : exports)); +}((typeof window === 'undefined') ? module.exports : window)); From e86b9c9d723f0bc3f296a45f0c050bb116920053 Mon Sep 17 00:00:00 2001 From: Pavlo Voznenko Date: Sun, 11 Jan 2015 17:32:51 +0100 Subject: [PATCH 329/613] upated jsdoc for primes --- doc-config.json | 3 ++- src/primes/is-prime.js | 20 ++++++++++--------- src/primes/prime-factor-tree.js | 22 +++++++++++--------- src/primes/sieve-of-eratosthenes.js | 31 +++++++++++++++-------------- 4 files changed, 42 insertions(+), 34 deletions(-) diff --git a/doc-config.json b/doc-config.json index 55965c84..e3c9d146 100644 --- a/doc-config.json +++ b/doc-config.json @@ -8,7 +8,8 @@ "./src/graphs/others/", "./src/graphs/shortest-path/", "./src/graphs/spanning-trees/", - "./src/data-structures/" + "./src/data-structures/", + "./src/primes/" ], "includePattern": ".+\\.js(doc)?$", "excludePattern": "docs" diff --git a/src/primes/is-prime.js b/src/primes/is-prime.js index f1fd4f14..778c953b 100644 --- a/src/primes/is-prime.js +++ b/src/primes/is-prime.js @@ -1,17 +1,19 @@ -/** - * Advanced (optimised) method for checking if provided number is prime - * - * For example for number 104743 it should return true, for 104744 - false - */ (function (exports) { 'use strict'; /** - * Method will return true if provided number is prime + * Advanced (optimised) method for checking if provided number is prime. + * For example for number 104743 it should return true, for 104744 - false. * - * @module primes - * @param {Number} number - number that we check on prime - * @returns {Boolean} + * @module primes/is-prime + * @param {Number} number - Number that we check on prime + * @returns {Boolean} Will return true if provided number is prime + * + * @example + * var isPrime = require('path/to/primes/is-prime').isPrime; + * + * console.log(isPrime(7)); // true + * console.log(isPrime(18)); // false */ exports.isPrime = function (number) { if (number === 1) { diff --git a/src/primes/prime-factor-tree.js b/src/primes/prime-factor-tree.js index e1b444d2..6f1a8669 100644 --- a/src/primes/prime-factor-tree.js +++ b/src/primes/prime-factor-tree.js @@ -1,17 +1,21 @@ -/** - * Method that will return list of all primes for provided number - * - * For example for number 18 it should return following list of primes [2, 3, 3] - */ (function (exports) { 'use strict'; /** - * Method will list of all primes for provided number + * Method will return list of all primes for provided number. + * For example for number 18 it should return following list of primes + * [2, 3, 3]. * - * @module primes - * @param {Number} number - * @returns {Array} + * @module primes/prime-factor-tree + * @param {Number} number - Number for which method will find all primes + * @returns {Array} List of available primes for provided number + * + * @example + * var primeFactorTree = require('path/to/primes/prime-factor-tree') + * .primeFactorTree; + * + * console.log(primeFactorTree(18)); // [2, 3, 3] + * console.log(primeFactorTree(600851475143)); // [71, 839, 1471, 6857] */ exports.primeFactorTree = function (number) { var div = 2, diff --git a/src/primes/sieve-of-eratosthenes.js b/src/primes/sieve-of-eratosthenes.js index d44a43c3..f2e9930f 100644 --- a/src/primes/sieve-of-eratosthenes.js +++ b/src/primes/sieve-of-eratosthenes.js @@ -1,26 +1,27 @@ -/** - * Sieve of Eratosthenes - * - * Simple, ancient algorithm for finding all prime numbers up to any given limit - * - * For example for limit 12 it should return following list of primes: - * [2, 3, 5, 7, 11] - */ (function (exports) { 'use strict'; /** - * Returns Sieve of Eratosthenes for specified number + * Sieve of Eratosthenes. * - * Simple, ancient algorithm for finding all prime numbers up to any given + * Simple, ancient algorithm for finding all prime numbers up to given limit. + * + * Returns list of primes up to specified limit. + * + * For example, for limit 10 it should return following list of primes: + * [2, 3, 5, 7] + * + * @module primes/sieve-of-eratosthenes + * @param {Number} limit - Algorithm will returns list of primes up to + * specified limit + * @returns {Array} Will return list with all prime numbers up to provided * limit * - * @module primes - * @param {Number} limit - algorithm will return list with prime numbers up - * to given limit + * @example + * var sieveOfEratosthenes = require('path/to/primes/sieve-of-eratosthenes') + * .sieveOfEratosthenes; * - * @returns {Array} - will return array with all prime numbers up to - * provided limit + * console.log(sieveOfEratosthenes(12)); // [2, 3, 5, 7, 11] */ exports.sieveOfEratosthenes = function (limit) { var sieve = [], From 1c8e97547f2b65a7d8a42e3eb7cfdf228f49e465 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sun, 11 Jan 2015 18:33:01 +0200 Subject: [PATCH 330/613] combinations jsdoc --- src/combinatorics/cartesianproduct.js | 4 ++-- src/combinatorics/combinations.js | 25 ++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/combinatorics/cartesianproduct.js b/src/combinatorics/cartesianproduct.js index b6618933..a1940f32 100644 --- a/src/combinatorics/cartesianproduct.js +++ b/src/combinatorics/cartesianproduct.js @@ -23,8 +23,8 @@ * @return {Array} Cartesian product of provided sets. * * @example - * var product = require('../src/combinatorics/cartesianproduct') - * .cartesianProduct; + * var product = require('path-to-algorithms/src/combinatorics/' + + * 'cartesianproduct').cartesianProduct; * var result = product([[1, 2, 3], [3, 2, 1]]); * // [ [ 1, 3 ], * // [ 1, 2 ], diff --git a/src/combinatorics/combinations.js b/src/combinatorics/combinations.js index fbd5fa3f..fe7a91f1 100644 --- a/src/combinatorics/combinations.js +++ b/src/combinatorics/combinations.js @@ -15,6 +15,29 @@ } } + /** + * A combination is a way of selecting members from a grouping, + * such that (unlike permutations) the order of selection does not matter. + * For example given three fruits, say an apple, an orange and a pear, + * there are three combinations of two that can be drawn from this set: + * an apple and a pear; an apple and an orange; or a pear and an orange. + * + * @example + * + * var combinations = require('path-to-algorithms/src/' + + * 'combinatorics/combinations').combinations; + * var result = combinations(['apple', 'orange', 'pear'], 2); + * // [['apple', 'orange'], + * // ['apple', 'pear'], + * // ['orange', 'pear']] + * console.log(result); + * + * @module combinatorics/combinations + * @public + * @param arr {Array} Set of items. + * @param k {Number} Size of each combination. + * @return {Array} Returns all combinations. + */ return function (arr, k) { res = []; combinations(arr, k, 0, 0, []); @@ -27,4 +50,4 @@ exports.combinations = combinations; -}(typeof exports === 'undefined' ? window : exports)); +}((typeof window === 'undefined') ? module.exports : window)); From 2f20f81e40daeed297fe06c2ce7ec09b19fbae92 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 11 Jan 2015 18:57:09 +0200 Subject: [PATCH 331/613] Update code style --- .jscsrc | 1 + gulpfile.js | 2 +- src/compression/runlength/runlength.js | 16 ++++++++-------- src/data-structures/binary-search-tree.js | 18 +++++++++--------- src/data-structures/heap.js | 14 +++++++------- src/data-structures/interval-tree.js | 16 ++++++++++------ src/data-structures/linked-list.js | 15 ++++++++------- src/data-structures/suffix-tree.js | 6 +++--- src/graphics/bresenham-line-drawing.js | 12 ++++++------ src/graphs/others/topological-sort.js | 6 +++--- src/graphs/searching/dfs.js | 6 +++--- src/graphs/shortest-path/bellman-ford.js | 4 +++- src/graphs/shortest-path/dijkstra.js | 10 +++++----- src/graphs/spanning-trees/prim.js | 16 ++++++++-------- src/primes/is-prime.js | 4 ++-- src/primes/prime-factor-tree.js | 4 ++-- src/primes/sieve-of-eratosthenes.js | 6 ++++-- src/searching/binarysearch/binarysearch.js | 6 +++--- .../knuth-morris-pratt/knuth-morris-pratt.js | 12 ++++++++---- .../longest-increasing-subsequence.js | 15 +++++++++------ .../maximum-subarray-divide-and-conquer.js | 16 ++++++++-------- src/searching/subarray/maximum-subarray.js | 4 ++-- src/sets/quickfind.js | 6 +++--- src/sets/quickunion.js | 4 ++-- src/shuffle/fisheryates.js | 5 +++-- src/shuffle/richarddurstenfeld.js | 5 +++-- .../3-way-string-quicksort/quicksort.js | 10 +++++----- src/sorting/heapsort/heapsort.js | 10 +++++----- .../insertionsort/insertion-binary-sort.js | 8 ++++---- src/sorting/insertionsort/insertionsort.js | 4 ++-- src/sorting/least-significant-digit/lsd.js | 3 ++- src/sorting/linearsort/bucketsort.js | 13 +++++++------ src/sorting/linearsort/countingsort.js | 16 ++++++++-------- src/sorting/mergesort/mergesort.js | 14 +++++++------- src/sorting/most-significant-digit/msd.js | 7 ++++--- src/sorting/quicksort/quicksort-middle.js | 4 ++-- src/sorting/quicksort/quicksort.js | 6 +++--- src/sorting/selectionsort/selectionsort.js | 4 +++- src/sorting/shellsort/shellsort.js | 3 ++- test/data-structures/red-black-tree.spec.js | 8 ++++---- test/primes/is-prime.spec.js | 4 ++-- test/primes/prime-factor-tree.spec.js | 4 ++-- test/primes/sieve-of-eratosthenes.spec.js | 4 ++-- test/sorting/bubblesort/bubblesort.spec.js | 4 ++-- test/sorting/heapsort/heapsort.spec.js | 4 ++-- .../insertionsort/insertionbinarysort.spec.js | 4 ++-- .../insertionsort/insertionsort.spec.js | 4 ++-- .../recursiveinsertionsort.spec.js | 4 ++-- test/sorting/mergesort/mergesort.spec.js | 4 ++-- .../sorting/quicksort/quicksort-middle.spec.js | 4 ++-- test/sorting/quicksort/quicksort.spec.js | 4 ++-- .../selectionsort/selectionsort.spec.js | 4 ++-- test/sorting/shellsort/shellsort.spec.js | 4 ++-- test/sorting/sort.testcase.js | 8 ++++---- 54 files changed, 212 insertions(+), 187 deletions(-) diff --git a/.jscsrc b/.jscsrc index dfbef8d6..a600cc1e 100644 --- a/.jscsrc +++ b/.jscsrc @@ -4,6 +4,7 @@ "requireSpacesInFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowMultipleVarDecl": true, "requireSpacesInsideObjectBrackets": "allButNested", "disallowSpacesInsideArrayBrackets": true, "disallowSpacesInsideParentheses": true, diff --git a/gulpfile.js b/gulpfile.js index 11fb723d..e84fdf36 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -28,4 +28,4 @@ gulp.task('jscs', function () { .pipe(jscs()); }); -gulp.task('build', ['lint', 'test']); +gulp.task('build', ['lint', 'jscs', 'test']); diff --git a/src/compression/runlength/runlength.js b/src/compression/runlength/runlength.js index fb044687..cea0fc56 100644 --- a/src/compression/runlength/runlength.js +++ b/src/compression/runlength/runlength.js @@ -14,9 +14,9 @@ * This takes O(n). */ function convertToAscii(str) { - var result = '', - currentChar = '', - i = 0; + var result = ''; + var currentChar = ''; + var i = 0; for (; i < str.length; i += 1) { currentChar = str[i].charCodeAt(0).toString(2); if (currentChar.length < 8) { @@ -34,11 +34,11 @@ * Takes O(n^2). */ function runLength(vector) { - var result = '', - zeros = 0, - zerosTemp = '', - wordLength = 0, - i = 0; + var result = ''; + var zeros = 0; + var zerosTemp = ''; + var wordLength = 0; + var i = 0; for (; i < vector.length; i += 1) { if (vector[i] === '0') { zeros += 1; diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index d0285258..2b2d651c 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -254,8 +254,8 @@ } if (node._left && node._right) { - var min = this._findMin(node._right), - temp = node.value; + var min = this._findMin(node._right); + var temp = node.value; node.value = min.value; min.value = temp; @@ -362,9 +362,9 @@ if (!root) { return 0; } - var leftHeight = this._getHeight(root._left), - rightHeight = this._getHeight(root._right), - path = leftHeight + rightHeight + 1; + var leftHeight = this._getHeight(root._left); + var rightHeight = this._getHeight(root._right); + var path = leftHeight + rightHeight + 1; return Math.max(path, getDiameter(root._left), getDiameter(root._right)); }.bind(this); return getDiameter(this._root); @@ -401,10 +401,10 @@ exports.BinaryTree.prototype._lowestCommonAncestor = function (firstNode, secondNode, current) { - var firstNodeInLeft = this._existsInSubtree(firstNode, current._left), - secondNodeInLeft = this._existsInSubtree(secondNode, current._left), - firstNodeInRight = this._existsInSubtree(firstNode, current._right), - secondNodeInRight = this._existsInSubtree(secondNode, current._right); + var firstNodeInLeft = this._existsInSubtree(firstNode, current._left); + var secondNodeInLeft = this._existsInSubtree(secondNode, current._left); + var firstNodeInRight = this._existsInSubtree(firstNode, current._right); + var secondNodeInRight = this._existsInSubtree(secondNode, current._right); if ((firstNodeInLeft && secondNodeInRight) || (firstNodeInRight && secondNodeInLeft)) { return current; diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index eb15d923..044844e7 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -71,10 +71,10 @@ * @param {Number} index The parent. */ exports.Heap.prototype._heapify = function (index) { - var extr = index, - left = 2 * index + 1, - right = 2 * index + 2, - temp; + var extr = index; + var left = 2 * index + 1; + var right = 2 * index + 2; + var temp; if (left < this._heap.length && this._cmp(this._heap[left], this._heap[index]) > 0) { @@ -105,9 +105,9 @@ */ exports.Heap.prototype.changeKey = function (index, value) { this._heap[index] = value; - var elem = this._heap[index], - parent = Math.floor(index / 2), - temp; + var elem = this._heap[index]; + var parent = Math.floor(index / 2); + var temp; if (elem !== undefined) { while (parent >= 0 && this._cmp(elem, this._heap[parent]) > 0) { temp = this._heap[parent]; diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index b0ca1f00..cf5fbe62 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -125,7 +125,8 @@ if (node.interval[0] <= point && node.interval[1] >= point) { return true; } - var result = false, temp; + var result = false; + var temp; ['left', 'right'].forEach(function (key) { temp = node[key]; if (temp) { @@ -157,7 +158,8 @@ if (intersects(node.interval, interval)) { return true; } - var result = false, temp; + var result = false; + var temp; ['left', 'right'].forEach(function (side) { temp = node[side]; if (temp && temp.max >= interval[0]) { @@ -212,8 +214,10 @@ * @return {Node} Node with the largest endpoint. */ exports.IntervalTree.prototype.findMax = function (node) { - var stack = [node], - current, max = -Infinity, maxNode; + var stack = [node]; + var current; + var max = -Infinity; + var maxNode; while (stack.length) { current = stack.pop(); if (current.left) { @@ -275,8 +279,8 @@ // Adjust the max value var p = node.parentNode; if (p) { - var maxNode = this.findMax(p), - max = maxNode.interval[1]; + var maxNode = this.findMax(p); + var max = maxNode.interval[1]; while (maxNode) { if (maxNode.max === node.interval[1]) { maxNode.max = max; diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index 823abc73..9f997893 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -138,8 +138,9 @@ if (this.first === null) { return false; } - var temp = this.first, - next, prev; + var temp = this.first; + var next; + var prev; while (temp) { if (temp.data === data) { next = temp.next; @@ -171,8 +172,8 @@ * @return {Boolean} Returns true if linked list contains cycle. */ exports.LinkedList.prototype.hasCycle = function () { - var fast = this.first, - slow = this.first; + var fast = this.first; + var slow = this.first; while (true) { if (fast === null) { return false; @@ -245,9 +246,9 @@ if (!this.first || !this.first.next) { return; } - var current = this.first.next, - prev = this.first, - temp; + var current = this.first.next; + var prev = this.first; + var temp; while (current) { temp = current.next; current.next = prev; diff --git a/src/data-structures/suffix-tree.js b/src/data-structures/suffix-tree.js index d7e6671b..7fe73109 100644 --- a/src/data-structures/suffix-tree.js +++ b/src/data-structures/suffix-tree.js @@ -41,9 +41,9 @@ // Find the maximum prefix and split the current node if prefix exists var prefix = maxPrefix(current.value, suffix); if (prefix.length) { - var temp = current.value, - suffixSuffix = suffix.substr(prefix.length, suffix.length), - currentSuffix = temp.substr(prefix.length, temp.length); + var temp = current.value; + var suffixSuffix = suffix.substr(prefix.length, suffix.length); + var currentSuffix = temp.substr(prefix.length, temp.length); current.value = prefix; addNode(currentSuffix, current); addNode(suffixSuffix, current); diff --git a/src/graphics/bresenham-line-drawing.js b/src/graphics/bresenham-line-drawing.js index cc0f3112..d8f79c7e 100644 --- a/src/graphics/bresenham-line-drawing.js +++ b/src/graphics/bresenham-line-drawing.js @@ -11,12 +11,12 @@ */ function drawLine(x1, y1, x2, y2, draw) { drawPoint = draw || drawPoint; - var dx = Math.abs(x2 - x1), - dy = Math.abs(y2 - y1), - cx = (x1 < x2) ? 1 : -1, - cy = (y1 < y2) ? 1 : -1, - error = dx - dy, - doubledError; + var dx = Math.abs(x2 - x1); + var dy = Math.abs(y2 - y1); + var cx = (x1 < x2) ? 1 : -1; + var cy = (y1 < y2) ? 1 : -1; + var error = dx - dy; + var doubledError; while (x1 !== x2 || y1 !== y2) { drawPoint(x1, y1); diff --git a/src/graphs/others/topological-sort.js b/src/graphs/others/topological-sort.js index 53fe7023..b793d5a5 100644 --- a/src/graphs/others/topological-sort.js +++ b/src/graphs/others/topological-sort.js @@ -43,9 +43,9 @@ * var vertices = topsort(graph); // ['v3', 'v4', 'v1', 'v5', 'v2'] */ return function (graph) { - var result = [], - visited = [], - temp = []; + var result = []; + var visited = []; + var temp = []; for (var node in graph) { if (!visited[node] && !temp[node]) { topologicalSortHelper(node, visited, temp, graph, result); diff --git a/src/graphs/searching/dfs.js b/src/graphs/searching/dfs.js index d302beec..82f0caf3 100644 --- a/src/graphs/searching/dfs.js +++ b/src/graphs/searching/dfs.js @@ -4,9 +4,9 @@ var dfs = (function () { function hasPath(graph, current, goal) { - var stack = [], - visited = [], - node; + var stack = []; + var visited = []; + var node; stack.push(current); visited[current] = true; while (stack.length) { diff --git a/src/graphs/shortest-path/bellman-ford.js b/src/graphs/shortest-path/bellman-ford.js index 2f7ee37b..c21af6d3 100644 --- a/src/graphs/shortest-path/bellman-ford.js +++ b/src/graphs/shortest-path/bellman-ford.js @@ -62,7 +62,9 @@ * with shortest-path information. */ exports.bellmanFord = function (vertexes, edges, source) { - var distances = {}, parents = {}, c; + var distances = {}; + var parents = {}; + var c; for (var i = 0; i < vertexes.length; i += 1) { distances[vertexes[i]] = Infinity; parents[vertexes[i]] = null; diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index 95d5ba63..3591a3bb 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -3,11 +3,11 @@ var dijkstra = (function () { - var Heap = require('../../data-structures/heap.js').Heap, - current, - visited, - distance, - unvisited; + var Heap = require('../../data-structures/heap.js').Heap; + var current; + var visited; + var distance; + var unvisited; /** * Creates a new node instance. diff --git a/src/graphs/spanning-trees/prim.js b/src/graphs/spanning-trees/prim.js index 1a3f1bb4..7da93c28 100644 --- a/src/graphs/spanning-trees/prim.js +++ b/src/graphs/spanning-trees/prim.js @@ -120,12 +120,12 @@ return function () { init.call(this); - var inTheTree = {}, - startVertex = this.edges[0].e.id, - spannigTree = [], - parents = {}, - distances = {}, - current; + var inTheTree = {}; + var tartVertex = this.edges[0].e.id; + var pannigTree = []; + var arents = {}; + var istances = {}; + var urrent; inTheTree[startVertex] = true; queue.add({ node: startVertex, @@ -138,8 +138,8 @@ if (inTheTree[e.v.id] && inTheTree[e.e.id]) { return; } - var collection = queue.getCollection(), - node; + var collection = queue.getCollection(); + var node; if (e.e.id === current) { node = e.v.id; } else if (e.v.id === current) { diff --git a/src/primes/is-prime.js b/src/primes/is-prime.js index f1fd4f14..c888202e 100644 --- a/src/primes/is-prime.js +++ b/src/primes/is-prime.js @@ -40,8 +40,8 @@ * 'number' rounded to the greatest integer 'rounded' so that: * rounded * rounded <= number */ - var rounded = Math.floor(Math.sqrt(number)), - factor = 5; + var rounded = Math.floor(Math.sqrt(number)); + var factor = 5; while (factor <= rounded) { if (number % factor === 0) { return false; diff --git a/src/primes/prime-factor-tree.js b/src/primes/prime-factor-tree.js index e1b444d2..2f11d96b 100644 --- a/src/primes/prime-factor-tree.js +++ b/src/primes/prime-factor-tree.js @@ -14,8 +14,8 @@ * @returns {Array} */ exports.primeFactorTree = function (number) { - var div = 2, - array = []; + var div = 2; + var array = []; while (number > 1) { if (number % div === 0) { diff --git a/src/primes/sieve-of-eratosthenes.js b/src/primes/sieve-of-eratosthenes.js index d44a43c3..b2ab83db 100644 --- a/src/primes/sieve-of-eratosthenes.js +++ b/src/primes/sieve-of-eratosthenes.js @@ -23,8 +23,10 @@ * provided limit */ exports.sieveOfEratosthenes = function (limit) { - var sieve = [], - primes = [], k, l; + var sieve = []; + var primes = []; + var k; + var l; sieve[1] = false; diff --git a/src/searching/binarysearch/binarysearch.js b/src/searching/binarysearch/binarysearch.js index 59989c76..a95ffc08 100644 --- a/src/searching/binarysearch/binarysearch.js +++ b/src/searching/binarysearch/binarysearch.js @@ -12,9 +12,9 @@ * @returns {number} index The index of the element or -1 if not found */ function binarySearch(array, key) { - var middle = Math.floor(array.length / 2), - left = 0, - right = array.length; + var middle = Math.floor(array.length / 2); + var left = 0; + var right = array.length; while (right >= left) { if (array[middle] === key) { return middle; diff --git a/src/searching/knuth-morris-pratt/knuth-morris-pratt.js b/src/searching/knuth-morris-pratt/knuth-morris-pratt.js index 060b356c..8c0c7200 100644 --- a/src/searching/knuth-morris-pratt/knuth-morris-pratt.js +++ b/src/searching/knuth-morris-pratt/knuth-morris-pratt.js @@ -3,8 +3,11 @@ var kmp = (function () { function builtKMPTable(str) { - var res = [], - len, front, end, found; + var res = []; + var len; + var front; + var end; + var found; for (var i = 1; i <= str.length; i += 1) { front = Math.max(1, i - ((res[i - 2] || 0) + 1)); end = Math.min(i - 1, (res[i - 2] || 0) + 1); @@ -25,8 +28,9 @@ } function indexOf(str, substr) { - var table = builtKMPTable(substr), - i = 0, j = 0; + var table = builtKMPTable(substr); + var i = 0; + var j = 0; while (i < str.length) { if (str[i] === substr[j]) { i += 1; diff --git a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js index 43df4d2e..f7fd2441 100644 --- a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js +++ b/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js @@ -80,9 +80,12 @@ if (find.memo[node]) { return find.memo[node]; } - var neighbours = dag[node], - neighboursDistance = [], - maxDist, maxNode, distance, result; + var neighbours = dag[node]; + var neighboursDistance = []; + var maxDist; + var maxNode; + var distance; + var result; if (!neighbours.length) { return { distance: 1, neighbour: undefined, node: node }; @@ -104,9 +107,9 @@ } return function (array) { - var results = [], - dag = buildDag(array), - maxPath; + var results = []; + var dag = buildDag(array); + var maxPath; find.memo = []; for (var i = 0; i < array.length; i += 1) { results.push(find(dag, i)); diff --git a/src/searching/subarray/maximum-subarray-divide-and-conquer.js b/src/searching/subarray/maximum-subarray-divide-and-conquer.js index a5b16b41..bde7143d 100644 --- a/src/searching/subarray/maximum-subarray-divide-and-conquer.js +++ b/src/searching/subarray/maximum-subarray-divide-and-conquer.js @@ -17,10 +17,10 @@ * @return {number} the maximum sum including the middle element */ function crossSubarray(array, left, middle, right) { - var leftSum = -Infinity, - rightSum = -Infinity, - sum = 0, - i; + var leftSum = -Infinity; + var rightSum = -Infinity; + var sum = 0; + var i; for (i = middle; i >= left; i -= 1) { if (sum + array[i] >= leftSum) { @@ -51,10 +51,10 @@ if (right - left <= 1) { return array[left]; } - var middle = Math.floor((left + right) / 2), - leftSum = maxSubarrayPartitioner(array, left, middle), - rightSum = maxSubarrayPartitioner(array, middle, right), - crossSum = crossSubarray(array, left, middle, right); + var middle = Math.floor((left + right) / 2); + var leftSum = maxSubarrayPartitioner(array, left, middle); + var rightSum = maxSubarrayPartitioner(array, middle, right); + var crossSum = crossSubarray(array, left, middle, right); return Math.max(crossSum, leftSum, rightSum); } diff --git a/src/searching/subarray/maximum-subarray.js b/src/searching/subarray/maximum-subarray.js index 60dec6f8..11fd8f2f 100644 --- a/src/searching/subarray/maximum-subarray.js +++ b/src/searching/subarray/maximum-subarray.js @@ -13,8 +13,8 @@ * the elements of subarray of the input */ function maxSubarray(array) { - var currentMax = 0, - max = 0; + var currentMax = 0; + var max = 0; for (var i = 0; i < array.length; i += 1) { currentMax = Math.max(0, currentMax + array[i]); diff --git a/src/sets/quickfind.js b/src/sets/quickfind.js index fc164f05..67785715 100644 --- a/src/sets/quickfind.js +++ b/src/sets/quickfind.js @@ -23,9 +23,9 @@ * @param {number} q The second node */ QuickFind.prototype.union = function (p, q) { - var size = this._ids.length, - pval = this._ids[p], - qval = this._ids[q]; + var size = this._ids.length; + var pval = this._ids[p]; + var qval = this._ids[q]; for (var i = 0; i < size; i += 1) { if (this._ids[i] === qval) { this._ids[i] = pval; diff --git a/src/sets/quickunion.js b/src/sets/quickunion.js index a2606044..5413c6d2 100644 --- a/src/sets/quickunion.js +++ b/src/sets/quickunion.js @@ -38,8 +38,8 @@ * @param {number} q The second node */ QuickUnion.prototype.union = function (p, q) { - var pRoot = this._root(p), - qRoot = this._root(q); + var pRoot = this._root(p); + var qRoot = this._root(q); this._ids[pRoot] = qRoot; }; diff --git a/src/shuffle/fisheryates.js b/src/shuffle/fisheryates.js index ee61fe8b..08319d67 100644 --- a/src/shuffle/fisheryates.js +++ b/src/shuffle/fisheryates.js @@ -9,8 +9,9 @@ * @return {array} The shuffled array. */ function shuffle(array) { - var size = array.length, - rand, temp; + var size = array.length; + var rand; + var temp; for (var i = 1; i < size; i += 1) { rand = Math.round(Math.random() * i); temp = array[rand]; diff --git a/src/shuffle/richarddurstenfeld.js b/src/shuffle/richarddurstenfeld.js index 93ad93af..301f45ef 100644 --- a/src/shuffle/richarddurstenfeld.js +++ b/src/shuffle/richarddurstenfeld.js @@ -14,8 +14,9 @@ * @returns {array} Shuffled array */ function shuffle(array) { - var arraySize = array.length - 1, - rand, temp; + var arraySize = array.length - 1; + var rand; + var temp; for (var i = arraySize; i >= 0; i -= 1) { rand = Math.round(Math.random() * arraySize); temp = array[i]; diff --git a/src/sorting/3-way-string-quicksort/quicksort.js b/src/sorting/3-way-string-quicksort/quicksort.js index bf6b6a79..b59ef57e 100644 --- a/src/sorting/3-way-string-quicksort/quicksort.js +++ b/src/sorting/3-way-string-quicksort/quicksort.js @@ -21,11 +21,11 @@ if (lo >= hi) { return; } - var lowPointer = lo, - highPointer = hi, - p = charAt(arr[lo], d), - i = lo + 1, - current; + var lowPointer = lo; + var highPointer = hi; + var p = charAt(arr[lo], d); + var i = lo + 1; + var current; while (i <= highPointer) { current = charAt(arr[i], d); diff --git a/src/sorting/heapsort/heapsort.js b/src/sorting/heapsort/heapsort.js index 5d0d96c7..1aa1e16d 100644 --- a/src/sorting/heapsort/heapsort.js +++ b/src/sorting/heapsort/heapsort.js @@ -21,9 +21,9 @@ * the max heap should be found. */ function heapify(array, index, heapSize, cmp) { - var left = 2 * index + 1, - right = 2 * index + 2, - largest = index; + var left = 2 * index + 1; + var right = 2 * index + 2; + var largest = index; if (left < heapSize && cmp(array[left], array[index]) > 0) { largest = left; @@ -64,8 +64,8 @@ */ return function (array, cmp) { cmp = cmp || comparator; - var size = array.length, - temp; + var size = array.length; + var temp; buildMaxHeap(array, cmp); for (var i = array.length - 1; i > 0; i -= 1) { temp = array[0]; diff --git a/src/sorting/insertionsort/insertion-binary-sort.js b/src/sorting/insertionsort/insertion-binary-sort.js index e3d41925..f76c850a 100644 --- a/src/sorting/insertionsort/insertion-binary-sort.js +++ b/src/sorting/insertionsort/insertion-binary-sort.js @@ -17,10 +17,10 @@ */ function insertionBinarySort(array, cmp) { cmp = cmp || comparator; - var current, - middle, - left, - right; + var current; + var middle; + var left; + var right; for (var i = 1; i < array.length; i += 1) { current = array[i]; left = 0; diff --git a/src/sorting/insertionsort/insertionsort.js b/src/sorting/insertionsort/insertionsort.js index 1a638a3c..3e1ba70f 100644 --- a/src/sorting/insertionsort/insertionsort.js +++ b/src/sorting/insertionsort/insertionsort.js @@ -14,8 +14,8 @@ */ function insertionSort(array, cmp) { cmp = cmp || compare; - var current, - j; + var current; + var j; for (var i = 1; i < array.length; i += 1) { current = array[i]; j = i - 1; diff --git a/src/sorting/least-significant-digit/lsd.js b/src/sorting/least-significant-digit/lsd.js index ed802e8e..996ed736 100644 --- a/src/sorting/least-significant-digit/lsd.js +++ b/src/sorting/least-significant-digit/lsd.js @@ -11,7 +11,8 @@ * @returns {Array} Sorted array */ function lsd(arr, letterIdx) { - var temp, count; + var temp; + var count; letterIdx = letterIdx || 1; for (var i = letterIdx - 1; i >= 0; i -= 1) { count = []; diff --git a/src/sorting/linearsort/bucketsort.js b/src/sorting/linearsort/bucketsort.js index ef1feca0..9c69e74b 100644 --- a/src/sorting/linearsort/bucketsort.js +++ b/src/sorting/linearsort/bucketsort.js @@ -17,8 +17,8 @@ * @returns {array} array Sorted input array */ function insertionSort(array) { - var current, - j; + var current; + var j; for (var i = 1; i < array.length; i += 1) { current = array[i]; j = i - 1; @@ -41,8 +41,9 @@ * from the input which are with suitable size. */ function createBuckets(array) { - var buckets = [], - currentBucket, current; + var buckets = []; + var currentBucket; + var current; for (var i = 0; i < array.length; i += 1) { current = array[i]; currentBucket = Math.floor(current); @@ -77,8 +78,8 @@ * all elements form each bucket */ function unionBuckets(buckets) { - var result = [], - currentBucket; + var result = []; + var currentBucket; for (var i = 0; i < buckets.length; i += 1) { currentBucket = buckets[i]; if (currentBucket !== undefined) { diff --git a/src/sorting/linearsort/countingsort.js b/src/sorting/linearsort/countingsort.js index 4d90e3c0..809c305f 100644 --- a/src/sorting/linearsort/countingsort.js +++ b/src/sorting/linearsort/countingsort.js @@ -17,8 +17,8 @@ * @returns {array} count The count of each element from the input array */ function getCount(array) { - var count = [], - current; + var count = []; + var current; for (var i = 0; i < array.length; i += 1) { current = array[i]; count[current] = (count[current] || 0) + 1; @@ -35,8 +35,8 @@ * are less than each element from the input */ function getLessCount(array) { - var less = [], - last; + var less = []; + var last; less[0] = array[0] || 0; for (var i = 1; i < array.length; i += 1) { last = array[i - 1] || 0; @@ -54,10 +54,10 @@ * @returns {array} result The sorted input */ function sort(array, less) { - var result = [], - currentPositions = [], - current, - position; + var result = []; + var currentPositions = []; + var current; + var position; for (var i = 0; i < array.length; i += 1) { current = array[i]; position = less[current]; diff --git a/src/sorting/mergesort/mergesort.js b/src/sorting/mergesort/mergesort.js index ef6effc3..7e2d18e8 100644 --- a/src/sorting/mergesort/mergesort.js +++ b/src/sorting/mergesort/mergesort.js @@ -40,13 +40,13 @@ * @returns {array} The array with sorted subarray */ function merge(array, start, middle, end, cmp) { - var left = [], - right = [], - leftSize = middle - start, - rightSize = end - middle, - maxSize = Math.max(leftSize, rightSize), - size = end - start, - i; + var left = []; + var right = []; + var leftSize = middle - start; + var rightSize = end - middle; + var maxSize = Math.max(leftSize, rightSize); + var size = end - start; + var i; for (i = 0; i < maxSize; i += 1) { if (i < leftSize) { diff --git a/src/sorting/most-significant-digit/msd.js b/src/sorting/most-significant-digit/msd.js index 74f01d25..46dfcecd 100644 --- a/src/sorting/most-significant-digit/msd.js +++ b/src/sorting/most-significant-digit/msd.js @@ -6,9 +6,10 @@ } function sort(arr, lo, hi, d) { - var temp = [], - count = [], - j, idx; + var temp = []; + var count = []; + var j; + var idx; // Use Insertion sort when the // array is smaller than given threshold for (j = lo; j <= hi; j += 1) { diff --git a/src/sorting/quicksort/quicksort-middle.js b/src/sorting/quicksort/quicksort-middle.js index 7312f7c7..9a24daa5 100644 --- a/src/sorting/quicksort/quicksort-middle.js +++ b/src/sorting/quicksort/quicksort-middle.js @@ -32,8 +32,8 @@ * @return {number} */ function partition(array, left, right, cmp) { - var pivot = array[Math.floor((left + right) / 2)], - temp; + var pivot = array[Math.floor((left + right) / 2)]; + var temp; while (left <= right) { while (cmp(array[left], pivot) < 0) { left += 1; diff --git a/src/sorting/quicksort/quicksort.js b/src/sorting/quicksort/quicksort.js index fd3c56c0..73bd41b8 100644 --- a/src/sorting/quicksort/quicksort.js +++ b/src/sorting/quicksort/quicksort.js @@ -22,9 +22,9 @@ * @param {number} right The end of the subarray */ function partition(array, left, right, compare) { - var cmp = array[right - 1], - minEnd = left, - maxEnd; + var cmp = array[right - 1]; + var minEnd = left; + var maxEnd; for (maxEnd = left; maxEnd < right - 1; maxEnd += 1) { if (compare(array[maxEnd], cmp) < 0) { swap(array, maxEnd, minEnd); diff --git a/src/sorting/selectionsort/selectionsort.js b/src/sorting/selectionsort/selectionsort.js index e7d0fbb9..2cd83521 100644 --- a/src/sorting/selectionsort/selectionsort.js +++ b/src/sorting/selectionsort/selectionsort.js @@ -14,7 +14,9 @@ */ var selectionSort = function (array, cmp) { cmp = cmp || compare; - var min, idx, temp; + var min; + var idx; + var temp; for (var i = 0; i < array.length; i += 1) { idx = i; min = array[i]; diff --git a/src/sorting/shellsort/shellsort.js b/src/sorting/shellsort/shellsort.js index 270d7b10..6a5c82ff 100644 --- a/src/sorting/shellsort/shellsort.js +++ b/src/sorting/shellsort/shellsort.js @@ -25,7 +25,8 @@ return function (array, cmp) { cmp = cmp || compare; - var gap, current; + var gap; + var current; for (var k = 0; k < gaps.length; k += 1) { gap = gaps[k]; for (var i = gap; i < array.length; i += gap) { diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index 77635ff2..ca2ab9bd 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -1,9 +1,9 @@ 'use strict'; -var mod = require('../../src/data-structures/red-black-tree.js'), - Vertex = mod.Node, - RBTree = mod.RBTree, - Colors = mod.Colors; +var mod = require('../../src/data-structures/red-black-tree.js'); +var Vertex = mod.Node; +var RBTree = mod.RBTree; +var Colors = mod.Colors; describe('Node', function () { diff --git a/test/primes/is-prime.spec.js b/test/primes/is-prime.spec.js index 703d27b0..02a78b2d 100644 --- a/test/primes/is-prime.spec.js +++ b/test/primes/is-prime.spec.js @@ -13,8 +13,8 @@ describe('Advanced (optimised) method that checks number on prime', }); it('the 10001st prime number should be 104743', function () { - var count = 1, //we know that 2 is prime - value = 1; + var count = 1; //we know that 2 is prime + var value = 1; while (count < 10001) { value += 2; diff --git a/test/primes/prime-factor-tree.spec.js b/test/primes/prime-factor-tree.spec.js index f8912ccb..3daddef5 100644 --- a/test/primes/prime-factor-tree.spec.js +++ b/test/primes/prime-factor-tree.spec.js @@ -18,8 +18,8 @@ describe('Prime factor tree', function () { }); it('sum of primes for given number 600851475143 should be 9238', function () { - var primes = primeFactorTree(600851475143), - sumOfPrimes = primes.reduce(function (previousValue, currentValue) { + var primes = primeFactorTree(600851475143); + var sumOfPrimes = primes.reduce(function (previousValue, currentValue) { return previousValue + currentValue; }); diff --git a/test/primes/sieve-of-eratosthenes.spec.js b/test/primes/sieve-of-eratosthenes.spec.js index f75a47a7..96792263 100644 --- a/test/primes/sieve-of-eratosthenes.spec.js +++ b/test/primes/sieve-of-eratosthenes.spec.js @@ -17,8 +17,8 @@ describe('Sieve Of Eratosthenes', function () { it('sum of prime numbers up to 2000000 limit should be 142913828922', function () { - var sieve = sieveOfEratosthenes(2000000), - sumOfPrimes = sieve.reduce(function (previousValue, currentValue) { + var sieve = sieveOfEratosthenes(2000000); + var sumOfPrimes = sieve.reduce(function (previousValue, currentValue) { return previousValue + currentValue; }); diff --git a/test/sorting/bubblesort/bubblesort.spec.js b/test/sorting/bubblesort/bubblesort.spec.js index f3636912..281d5ac6 100644 --- a/test/sorting/bubblesort/bubblesort.spec.js +++ b/test/sorting/bubblesort/bubblesort.spec.js @@ -1,5 +1,5 @@ -var sortTestCase = require('../sort.testcase.js'), - bubbleSort = +var sortTestCase = require('../sort.testcase.js'); +var bubbleSort = require('../../../src/sorting/bubblesort/bubblesort.js').bubbleSort; sortTestCase(bubbleSort, 'Bubble sort'); diff --git a/test/sorting/heapsort/heapsort.spec.js b/test/sorting/heapsort/heapsort.spec.js index 9fd6c912..eb9441b3 100644 --- a/test/sorting/heapsort/heapsort.spec.js +++ b/test/sorting/heapsort/heapsort.spec.js @@ -1,4 +1,4 @@ -var sortTestCase = require('../sort.testcase.js'), - heapSort = require('../../../src/sorting/heapsort/heapsort.js').heapSort; +var sortTestCase = require('../sort.testcase.js'); +var heapSort = require('../../../src/sorting/heapsort/heapsort.js').heapSort; sortTestCase(heapSort, 'Heap sort'); diff --git a/test/sorting/insertionsort/insertionbinarysort.spec.js b/test/sorting/insertionsort/insertionbinarysort.spec.js index 9e33a5cc..43bed4d8 100644 --- a/test/sorting/insertionsort/insertionbinarysort.spec.js +++ b/test/sorting/insertionsort/insertionbinarysort.spec.js @@ -1,5 +1,5 @@ -var sortTestCase = require('../sort.testcase.js'), - insertionBinarySort = +var sortTestCase = require('../sort.testcase.js'); +var insertionBinarySort = require('../../../src/sorting/insertionsort/' + 'insertion-binary-sort.js').insertionBinarySort; diff --git a/test/sorting/insertionsort/insertionsort.spec.js b/test/sorting/insertionsort/insertionsort.spec.js index 621f57c3..d1bb8e3d 100644 --- a/test/sorting/insertionsort/insertionsort.spec.js +++ b/test/sorting/insertionsort/insertionsort.spec.js @@ -1,5 +1,5 @@ -var sortTestCase = require('../sort.testcase.js'), - insertionSort = require('../../../src/sorting/insertionsort/' + +var sortTestCase = require('../sort.testcase.js'); +var insertionSort = require('../../../src/sorting/insertionsort/' + 'insertionsort.js').insertionSort; sortTestCase(insertionSort, 'Insertion sort'); diff --git a/test/sorting/insertionsort/recursiveinsertionsort.spec.js b/test/sorting/insertionsort/recursiveinsertionsort.spec.js index 3432df0b..ab883083 100644 --- a/test/sorting/insertionsort/recursiveinsertionsort.spec.js +++ b/test/sorting/insertionsort/recursiveinsertionsort.spec.js @@ -1,5 +1,5 @@ -var sortTestCase = require('../sort.testcase.js'), - recursiveInsertionSort = require('../../../src/sorting/' + +var sortTestCase = require('../sort.testcase.js'); +var recursiveInsertionSort = require('../../../src/sorting/' + 'insertionsort/recursive-insertionsort.js').recursiveInsertionSort; sortTestCase(recursiveInsertionSort, 'Recursive insertion sort'); diff --git a/test/sorting/mergesort/mergesort.spec.js b/test/sorting/mergesort/mergesort.spec.js index 0adec469..e8bfa78e 100644 --- a/test/sorting/mergesort/mergesort.spec.js +++ b/test/sorting/mergesort/mergesort.spec.js @@ -1,5 +1,5 @@ -var sortTestCase = require('../sort.testcase.js'), - mergeSort = +var sortTestCase = require('../sort.testcase.js'); +var mergeSort = require('../../../src/sorting/mergesort/mergesort.js').mergeSort; sortTestCase(mergeSort, 'Merge sort'); diff --git a/test/sorting/quicksort/quicksort-middle.spec.js b/test/sorting/quicksort/quicksort-middle.spec.js index 9b75819c..4ba1efdb 100644 --- a/test/sorting/quicksort/quicksort-middle.spec.js +++ b/test/sorting/quicksort/quicksort-middle.spec.js @@ -1,5 +1,5 @@ -var sortTestCase = require('../sort.testcase.js'), - quickSort = +var sortTestCase = require('../sort.testcase.js'); +var quickSort = require('../../../src/sorting/quicksort/quicksort-middle.js').quickSort; sortTestCase(quickSort, 'Quick sort'); diff --git a/test/sorting/quicksort/quicksort.spec.js b/test/sorting/quicksort/quicksort.spec.js index e754372f..2a0be8bf 100644 --- a/test/sorting/quicksort/quicksort.spec.js +++ b/test/sorting/quicksort/quicksort.spec.js @@ -1,5 +1,5 @@ -var sortTestCase = require('../sort.testcase.js'), - quickSort = +var sortTestCase = require('../sort.testcase.js'); +var quickSort = require('../../../src/sorting/quicksort/quicksort.js').quickSort; sortTestCase(quickSort, 'Quick sort'); diff --git a/test/sorting/selectionsort/selectionsort.spec.js b/test/sorting/selectionsort/selectionsort.spec.js index d4a33237..0655a1bc 100644 --- a/test/sorting/selectionsort/selectionsort.spec.js +++ b/test/sorting/selectionsort/selectionsort.spec.js @@ -1,5 +1,5 @@ -var sortTestCase = require('../sort.testcase.js'), - selectionSort = +var sortTestCase = require('../sort.testcase.js'); +var selectionSort = require('../../../src/sorting/selectionsort/selectionsort.js') .selectionSort; diff --git a/test/sorting/shellsort/shellsort.spec.js b/test/sorting/shellsort/shellsort.spec.js index fe8eff75..34f56c06 100644 --- a/test/sorting/shellsort/shellsort.spec.js +++ b/test/sorting/shellsort/shellsort.spec.js @@ -1,5 +1,5 @@ -var sortTestCase = require('../sort.testcase.js'), - shellSort = require('../../../src/sorting/shellsort/shellsort.js') +var sortTestCase = require('../sort.testcase.js'); +var shellSort = require('../../../src/sorting/shellsort/shellsort.js') .shellSort; sortTestCase(shellSort, 'Shell sort'); diff --git a/test/sorting/sort.testcase.js b/test/sorting/sort.testcase.js index 0bac7c1a..65390edb 100644 --- a/test/sorting/sort.testcase.js +++ b/test/sorting/sort.testcase.js @@ -10,11 +10,11 @@ module.exports = function (sort, algorithmName, options) { function createRandomArray(config) { config = config || {}; - var size = config.size || 100, - precision = config.precision || 2, - multiplier = config.multiplier || 100; - + var size = config.size || 100; + var precision = config.precision || 2; + var multiplier = config.multiplier || 100; var result = []; + for (var i = size; i > 0; i -= 1) { result.push(parseFloat((Math.random() * multiplier).toFixed(precision))); From 67a9fd91d615ac209a26b06765c772b0fa9c614e Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 11 Jan 2015 19:03:13 +0200 Subject: [PATCH 332/613] Update prim and bfs --- src/graphs/searching/bfs.js | 8 ++++---- src/graphs/spanning-trees/prim.js | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/graphs/searching/bfs.js b/src/graphs/searching/bfs.js index 14c9e532..9b3e1cad 100644 --- a/src/graphs/searching/bfs.js +++ b/src/graphs/searching/bfs.js @@ -35,10 +35,10 @@ * var shortestPath = bfs(graph, 1, 5); // [1, 2, 3, 5] */ return function (graph, startNode, targetNode) { - var parents = [], - queue = [], - visited = [], - current; + var parents = []; + var queue = []; + var visited = []; + var current; queue.push(startNode); parents[startNode] = null; visited[startNode] = true; diff --git a/src/graphs/spanning-trees/prim.js b/src/graphs/spanning-trees/prim.js index 7da93c28..be7023df 100644 --- a/src/graphs/spanning-trees/prim.js +++ b/src/graphs/spanning-trees/prim.js @@ -26,7 +26,7 @@ * edges.push(new Edge(new Vertex(8), new Vertex(7), 7)); * graph = new Graph(edges, edges.length); * - * // { edges: + * // { edges: * // [ { e: '1', v: 0, distance: 4 }, * // { e: '2', v: 8, distance: 2 }, * // { e: '3', v: 2, distance: 7 }, @@ -121,11 +121,11 @@ return function () { init.call(this); var inTheTree = {}; - var tartVertex = this.edges[0].e.id; - var pannigTree = []; - var arents = {}; - var istances = {}; - var urrent; + var startVertex = this.edges[0].e.id; + var spannigTree = []; + var parents = {}; + var distances = {}; + var current; inTheTree[startVertex] = true; queue.add({ node: startVertex, From a2ef74e92a14313127846c1761995a8e9bcba2e6 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 11 Jan 2015 19:05:23 +0200 Subject: [PATCH 333/613] Update contributors list --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 3988f65c..eda76983 100644 --- a/readme.md +++ b/readme.md @@ -77,7 +77,7 @@ If the build is not successful fix your code in order the tests and jshint valid ## Contributors -[![mgechev](https://avatars.githubusercontent.com/u/455023?v=3&s=117)](https://github.com/mgechev)[![AndreyGeonya](https://avatars.githubusercontent.com/u/773648?v=3&s=117)](https://github.com/AndreyGeonya)[![Microfed](https://avatars.githubusercontent.com/u/613179?v=3&s=117)](https://github.com/Microfed)[![contra](https://avatars.githubusercontent.com/u/425716?v=3&s=117)](https://github.com/contra) +[![mgechev](https://avatars.githubusercontent.com/u/455023?v=3&s=117)](https://github.com/mgechev)[![AndreyGeonya](https://avatars.githubusercontent.com/u/773648?v=3&s=117)](https://github.com/AndreyGeonya)[![pvoznenko](https://avatars.githubusercontent.com/u/1098414?v=3&s=117)](https://github.com/pvoznenko)[![Microfed](https://avatars.githubusercontent.com/u/613179?v=3&s=117)](https://github.com/Microfed)[![contra](https://avatars.githubusercontent.com/u/425716?v=3&s=117)](https://github.com/contra) ## License From 401936a8b6f12a48c0a1d7a28e5c93bc8876b236 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 11 Jan 2015 19:13:48 +0200 Subject: [PATCH 334/613] Add disallowTrailingSpaces rule --- .jscsrc | 1 + src/compression/runlength/runlength.js | 2 +- src/data-structures/binary-search-tree.js | 4 ++-- src/data-structures/heap.js | 2 +- src/data-structures/interval-tree.js | 10 +++++----- src/data-structures/red-black-tree.js | 14 +++++++------- src/graphs/shortest-path/dijkstra.js | 6 +++--- test/graphs/searching/bfs.spec.js | 2 +- 8 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.jscsrc b/.jscsrc index a600cc1e..847fc3ee 100644 --- a/.jscsrc +++ b/.jscsrc @@ -23,6 +23,7 @@ "disallowMultipleLineBreaks": true, "disallowKeywordsOnNewLine": ["else"], "requireLineFeedAtFileEnd": true, + "disallowTrailingWhitespace": true, "excludeFiles": ["node_modules/**", "bower_components/**"], "validateIndentation": 2 } \ No newline at end of file diff --git a/src/compression/runlength/runlength.js b/src/compression/runlength/runlength.js index cea0fc56..2a5f7942 100644 --- a/src/compression/runlength/runlength.js +++ b/src/compression/runlength/runlength.js @@ -1,6 +1,6 @@ /** * Run-length encoding. - * The idea of this algorithm is to remove the usless zeros and + * The idea of this algorithm is to remove the usless zeros and * give us representation of string in binary which in which the * zeros will be stripped and replaced with their count. */ diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 2b2d651c..c1dc844d 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -190,7 +190,7 @@ /** * Finds a node by it's value in a given sub-tree. * Average time complexity: O(log N). - * + * * @private * @param {Number|String} Value of the node which should be found. * @param {Node} Current node to be checked. @@ -221,7 +221,7 @@ * @param {Node} oldChild Child to be replaced. * @param {Node} newChild Child replacement. */ - exports.BinaryTree.prototype._replaceChild = + exports.BinaryTree.prototype._replaceChild = function (parent, oldChild, newChild) { if (!parent) { this._root = newChild; diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index 044844e7..c654f815 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -97,7 +97,7 @@ /** * Changes the key.

* Complexity: O(log N). - * + * * @public * @param {Number} index Index of the value which should be changed. * @param {Number|Object} value New value according to the index. diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index cf5fbe62..bd247188 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -24,7 +24,7 @@ /** * Node which describes an interval. - * + * * @public * @constructor * @param {Number} start Start of the interval. @@ -39,7 +39,7 @@ */ this.interval = [start, end]; /** - * Max endpoint in subtree which starts from this node. + * Max endpoint in subtree which starts from this node. * @member {Number} */ this.max = -Infinity; @@ -106,7 +106,7 @@ /** * Add new interval to the tree. - * + * * @public * @param {Array} intreval Array with start and end points of the interval. */ @@ -141,7 +141,7 @@ /** * Checks or point belongs to at least one intarval from the tree.

* Complexity: O(log N). - * + * * @public * @method * @param {Number} point Point which should be checked. @@ -196,7 +196,7 @@ /** * Returns height of the tree. - * + * * @public * @method * @return {Number} Height of the tree. diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index 53ba159f..2a6c487d 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -1,7 +1,7 @@ /** * Red-Black tree is a data structure which is * a type of self-balancing binary search tree. - * + * * @example * * var RBTree = require('../src/data-structures/red-black-tree').RBTree; @@ -25,7 +25,7 @@ * }); * * console.log(rbTree.get(1989)); // { name: 'Garry', surname: 'Fisher' } - * + * * @module data-structures/red-black-tree */ (function (exports) { @@ -43,7 +43,7 @@ /** * Node of the Red-Black tree. - * + * * @private * @constructor * @param {Number} key Key of the node. @@ -105,7 +105,7 @@ /** * Red-Black Tree. - * + * * @public * @constructor */ @@ -116,7 +116,7 @@ /** * Add value associated with a given key.

* Complexity: O(log N). - * + * * @public * @method * @param {Number} key Key. @@ -130,7 +130,7 @@ /** * Returns true or false depending on whether * given node is red. - * + * * @private * @method * @param {Node} node Node which sould be checked. @@ -146,7 +146,7 @@ /** * Helper function for insertion of given key, * value pair into the Red-Black tree. - * + * * @private * @method * @param {Number} key Key. diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index 3591a3bb..38b7aa30 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -63,21 +63,21 @@ } /** - * Dijkstra's shortest path algorithm. Finds the minimum + * Dijkstra's shortest path algorithm. Finds the minimum * distance between two given nodes using a distance matrix.

* For the implementation is not used the most suitable data structure * (Fibonacci heap) but the Binary heap gives also good results.

* * Time complexity: O(|E|+|V|log(|V|)) where V and E are the number of * vertices and edges respectively. - * + * * @public * @module graphs/shortest-path/dijkstra * @param {Number} src Source node. * @param {Number} dest Destination node. * @param {Array} graph A distance matrix of the graph. * @returns {Number} The shortest distance between two nodes. - * + * * @example * var dijkstra = * require('path-to-algorithms/src/graphs/shortest-path/dijkstra').dijkstra; diff --git a/test/graphs/searching/bfs.spec.js b/test/graphs/searching/bfs.spec.js index 3fbf453b..9ade6961 100644 --- a/test/graphs/searching/bfs.spec.js +++ b/test/graphs/searching/bfs.spec.js @@ -41,7 +41,7 @@ describe('BFS', function () { * * 0 ---> 1 * \ | - * \ v + * \ v * -> 2 */ it('should not update the parent node once set', function () { From bc548ad0e6dc8b1e28161205af7041278787d9b1 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sun, 11 Jan 2015 19:13:49 +0200 Subject: [PATCH 335/613] fix combinations, add permutations jsdoc --- src/combinatorics/combinations.js | 1 + src/combinatorics/permutations.js | 38 +++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/combinatorics/combinations.js b/src/combinatorics/combinations.js index fe7a91f1..a5f026f8 100644 --- a/src/combinatorics/combinations.js +++ b/src/combinatorics/combinations.js @@ -16,6 +16,7 @@ } /** + * Finds all the combinations of given array.

* A combination is a way of selecting members from a grouping, * such that (unlike permutations) the order of selection does not matter. * For example given three fruits, say an apple, an orange and a pear, diff --git a/src/combinatorics/permutations.js b/src/combinatorics/permutations.js index 4430e33a..8b6946f7 100644 --- a/src/combinatorics/permutations.js +++ b/src/combinatorics/permutations.js @@ -10,14 +10,6 @@ arr[j] = temp; } - /** - * Finds all the permutations of given array. - * Complexity O(n*n!). - * - * @param {Array} arr Array to find the permutations of - * @param {Number} current Current element - * @returns {Array} Array containing all the permutations - */ function permutations(arr, current) { if (current >= arr.length) { return res.push(arr.slice()); @@ -29,6 +21,34 @@ } } + /** + * Finds all the permutations of given array.

+ * Permutation relates to the act of rearranging, or permuting, + * all the members of a set into some sequence or order. + * For example there are six permutations of the set {1,2,3}, namely: + * (1,2,3), (1,3,2), (2,1,3), (2,3,1), (3,1,2), and (3,2,1).

+ * Complexity: O(N*N!). + * + * @example + * + * var permutations = require('path-to-algorithms/src/' + + * 'combinatorics/permutations').permutations; + * var result = permutations(['apple', 'orange', 'pear']); + * + * // [ [ 'apple', 'orange', 'pear' ], + * // [ 'apple', 'pear', 'orange' ], + * // [ 'orange', 'apple', 'pear' ], + * // [ 'orange', 'pear', 'apple' ], + * // [ 'pear', 'orange', 'apple' ], + * // [ 'pear', 'apple', 'orange' ] ] + * console.log(result); + * + * @module combinatorics/permutations + * @public + * @param {Array} arr Array to find the permutations of. + * @param {Number} current Current element. + * @returns {Array} Array containing all the permutations. + */ return function (arr) { res = []; permutations(arr, 0); @@ -41,4 +61,4 @@ exports.permutations = permutations; -}(typeof exports === 'undefined' ? window : exports)); +}((typeof window === 'undefined') ? module.exports : window)); From ea88a544228d3017705505581e6dacd18e900f0d Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 11 Jan 2015 19:27:44 +0200 Subject: [PATCH 336/613] Update readme --- readme.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/readme.md b/readme.md index eda76983..3f128d67 100644 --- a/readme.md +++ b/readme.md @@ -20,13 +20,13 @@ npm install **To setup repository with documentation** -1) go to the parent directory of the `javascript-algorithms` folder and call: +- Go to the parent directory of the `javascript-algorithms` folder and call: ```bash git clone git@github.com:mgechev/javascript-algorithms.git javascript-algorithms-docs ``` -2) go to the `javascript-algorithms-docs` folder and change current branch to `gh-pages`: +- Go to the `javascript-algorithms-docs` folder and change current branch to `gh-pages`: ```bash git checkout gh-pages @@ -46,16 +46,10 @@ and all files in `javascript-algorithms-docs` folder will be updated. **To run tests** -You should install `jasmine-node`: - -```bash -npm install -g jasmine-node -``` - Call: ```bash -jasmine-node test/ +gulp test ``` and all `*.spec.js` files will be executed. From 9a22cc5bd9529c6eaf778a7fba9b7e91caa72fb4 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sun, 11 Jan 2015 19:41:50 +0200 Subject: [PATCH 337/613] jsdoc for variations-repetitions --- src/combinatorics/variations-repetion.js | 28 ----------- src/combinatorics/variations-repetition.js | 55 ++++++++++++++++++++++ 2 files changed, 55 insertions(+), 28 deletions(-) delete mode 100644 src/combinatorics/variations-repetion.js create mode 100644 src/combinatorics/variations-repetition.js diff --git a/src/combinatorics/variations-repetion.js b/src/combinatorics/variations-repetion.js deleted file mode 100644 index d9eb4984..00000000 --- a/src/combinatorics/variations-repetion.js +++ /dev/null @@ -1,28 +0,0 @@ -(function (exports) { - 'use strict'; - - var variationsWithRepetion = (function () { - var res; - - function variations(arr, k, index, current) { - if (k === index) { - return res.push(current.slice()); - } - for (var i = 0; i < arr.length; i += 1) { - current[index] = arr[i]; - variations(arr, k, index + 1, current); - } - } - - return function (arr, k) { - res = []; - variations(arr, k, 0, []); - var temp = res; - res = undefined; - return temp; - }; - }()); - - exports.variationsWithRepetion = variationsWithRepetion; - -}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/combinatorics/variations-repetition.js b/src/combinatorics/variations-repetition.js new file mode 100644 index 00000000..d6910f10 --- /dev/null +++ b/src/combinatorics/variations-repetition.js @@ -0,0 +1,55 @@ +(function (exports) { + 'use strict'; + + var variationsWithRepetion = (function () { + var res; + + function variations(arr, k, index, current) { + if (k === index) { + return res.push(current.slice()); + } + for (var i = 0; i < arr.length; i += 1) { + current[index] = arr[i]; + variations(arr, k, index + 1, current); + } + } + + /** + * Finds all the variations with repetition of given array.

+ * Variations with repetition is the number of ways to sample k elements + * from a set of elements (which may be repeated). + * + * @example + * var variations = require('path-to-algorithms/src/combinatorics/' + + * 'variations-repetition').variationsWithRepetion; + * var result = variations(['apple', 'orange', 'pear'], 2); + * + * // [['apple', 'apple'], + * // ['apple', 'orange'], + * // ['apple', 'pear'], + * // ['orange', 'apple'], + * // ['orange', 'orange'], + * // ['orange', 'pear'], + * // ['pear', 'apple'], + * // ['pear', 'orange'], + * // ['pear', 'pear']] + * console.log(result); + * + * @module combinatorics/variations-repetition + * @public + * @param arr {Array} Set of items. + * @param k {Number} Size of each combination. + * @return {Array} Returns all combinations. + */ + return function (arr, k) { + res = []; + variations(arr, k, 0, []); + var temp = res; + res = undefined; + return temp; + }; + }()); + + exports.variationsWithRepetion = variationsWithRepetion; + +}((typeof window === 'undefined') ? module.exports : window)); From f7ded3a78ade6934fbec0e169514d67b8c8c6b79 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sun, 11 Jan 2015 19:48:42 +0200 Subject: [PATCH 338/613] fix jshint issues --- src/combinatorics/combinations.js | 6 +++--- src/combinatorics/permutations.js | 2 +- src/combinatorics/variations-repetition.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/combinatorics/combinations.js b/src/combinatorics/combinations.js index a5f026f8..9f72d17e 100644 --- a/src/combinatorics/combinations.js +++ b/src/combinatorics/combinations.js @@ -22,9 +22,9 @@ * For example given three fruits, say an apple, an orange and a pear, * there are three combinations of two that can be drawn from this set: * an apple and a pear; an apple and an orange; or a pear and an orange. - * + * * @example - * + * * var combinations = require('path-to-algorithms/src/' + * 'combinatorics/combinations').combinations; * var result = combinations(['apple', 'orange', 'pear'], 2); @@ -32,7 +32,7 @@ * // ['apple', 'pear'], * // ['orange', 'pear']] * console.log(result); - * + * * @module combinatorics/combinations * @public * @param arr {Array} Set of items. diff --git a/src/combinatorics/permutations.js b/src/combinatorics/permutations.js index 8b6946f7..4ae6cba4 100644 --- a/src/combinatorics/permutations.js +++ b/src/combinatorics/permutations.js @@ -31,7 +31,7 @@ * * @example * - * var permutations = require('path-to-algorithms/src/' + + * var permutations = require('path-to-algorithms/src/' + * 'combinatorics/permutations').permutations; * var result = permutations(['apple', 'orange', 'pear']); * diff --git a/src/combinatorics/variations-repetition.js b/src/combinatorics/variations-repetition.js index d6910f10..71c68f6a 100644 --- a/src/combinatorics/variations-repetition.js +++ b/src/combinatorics/variations-repetition.js @@ -18,9 +18,9 @@ * Finds all the variations with repetition of given array.

* Variations with repetition is the number of ways to sample k elements * from a set of elements (which may be repeated). - * + * * @example - * var variations = require('path-to-algorithms/src/combinatorics/' + + * var variations = require('path-to-algorithms/src/combinatorics/' + * 'variations-repetition').variationsWithRepetion; * var result = variations(['apple', 'orange', 'pear'], 2); * From be2a18fcf5c712521f934ea2529ee74bcce296e1 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sun, 11 Jan 2015 19:54:41 +0200 Subject: [PATCH 339/613] fix js-doc fonfigand small fixes in primes jsdoc --- doc-config.json | 2 +- src/primes/is-prime.js | 6 +++--- src/primes/prime-factor-tree.js | 6 +++--- src/primes/sieve-of-eratosthenes.js | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/doc-config.json b/doc-config.json index 1fb4bfce..44c533d2 100644 --- a/doc-config.json +++ b/doc-config.json @@ -9,7 +9,7 @@ "./src/graphs/shortest-path/", "./src/graphs/spanning-trees/", "./src/data-structures/", - "./src/combinatorics/" + "./src/combinatorics/", "./src/primes/" ], "includePattern": ".+\\.js(doc)?$", diff --git a/src/primes/is-prime.js b/src/primes/is-prime.js index 951bc7de..38ec9afe 100644 --- a/src/primes/is-prime.js +++ b/src/primes/is-prime.js @@ -6,11 +6,11 @@ * For example for number 104743 it should return true, for 104744 - false. * * @module primes/is-prime - * @param {Number} number - Number that we check on prime - * @returns {Boolean} Will return true if provided number is prime + * @param {Number} number - Number that we check on prime. + * @returns {Boolean} Will return true if provided number is prime. * * @example - * var isPrime = require('path/to/primes/is-prime').isPrime; + * var isPrime = require('path-to-algorithms/src/is-prime').isPrime; * * console.log(isPrime(7)); // true * console.log(isPrime(18)); // false diff --git a/src/primes/prime-factor-tree.js b/src/primes/prime-factor-tree.js index 6777a3bf..b5f1a9de 100644 --- a/src/primes/prime-factor-tree.js +++ b/src/primes/prime-factor-tree.js @@ -7,11 +7,11 @@ * [2, 3, 3]. * * @module primes/prime-factor-tree - * @param {Number} number - Number for which method will find all primes - * @returns {Array} List of available primes for provided number + * @param {Number} number - Number for which method will find all primes. + * @returns {Array} List of available primes for provided number. * * @example - * var primeFactorTree = require('path/to/primes/prime-factor-tree') + * var primeFactorTree = require('path-to-algorithms/src/prime-factor-tree') * .primeFactorTree; * * console.log(primeFactorTree(18)); // [2, 3, 3] diff --git a/src/primes/sieve-of-eratosthenes.js b/src/primes/sieve-of-eratosthenes.js index b4337b83..cea5a8b5 100644 --- a/src/primes/sieve-of-eratosthenes.js +++ b/src/primes/sieve-of-eratosthenes.js @@ -9,16 +9,16 @@ * Returns list of primes up to specified limit. * * For example, for limit 10 it should return following list of primes: - * [2, 3, 5, 7] + * [2, 3, 5, 7]. * * @module primes/sieve-of-eratosthenes * @param {Number} limit - Algorithm will returns list of primes up to - * specified limit - * @returns {Array} Will return list with all prime numbers up to provided - * limit + * specified limit. + * @returns {Array} Will return list with all prime numbers up to provided. + * limit. * * @example - * var sieveOfEratosthenes = require('path/to/primes/sieve-of-eratosthenes') + * var sieveOfEratosthenes = require('path-to-algorithms/src/sieve-of-eratosthenes') * .sieveOfEratosthenes; * * console.log(sieveOfEratosthenes(12)); // [2, 3, 5, 7, 11] From 4845ff294f4224c21cdda678a131e6284e4b00b1 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sun, 11 Jan 2015 20:03:36 +0200 Subject: [PATCH 340/613] fix jshint error --- src/primes/sieve-of-eratosthenes.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/primes/sieve-of-eratosthenes.js b/src/primes/sieve-of-eratosthenes.js index cea5a8b5..0a549cf1 100644 --- a/src/primes/sieve-of-eratosthenes.js +++ b/src/primes/sieve-of-eratosthenes.js @@ -18,7 +18,8 @@ * limit. * * @example - * var sieveOfEratosthenes = require('path-to-algorithms/src/sieve-of-eratosthenes') + * var sieveOfEratosthenes = + * require('path-to-algorithms/src/sieve-of-eratosthenes') * .sieveOfEratosthenes; * * console.log(sieveOfEratosthenes(12)); // [2, 3, 5, 7, 11] From 6a14fcac53da59c612ed4cf0a1bb0a95959b5eb6 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sun, 11 Jan 2015 20:05:38 +0200 Subject: [PATCH 341/613] fix jshint error --- src/primes/sieve-of-eratosthenes.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/primes/sieve-of-eratosthenes.js b/src/primes/sieve-of-eratosthenes.js index 0a549cf1..c239ea0e 100644 --- a/src/primes/sieve-of-eratosthenes.js +++ b/src/primes/sieve-of-eratosthenes.js @@ -19,8 +19,7 @@ * * @example * var sieveOfEratosthenes = - * require('path-to-algorithms/src/sieve-of-eratosthenes') - * .sieveOfEratosthenes; + * require('path-to-algorithms/src/sieve-of-eratosthenes').sieveOfEratosthenes; * * console.log(sieveOfEratosthenes(12)); // [2, 3, 5, 7, 11] */ From 418968e36d690be4610dbc0d1a046b86f40234fd Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Sun, 11 Jan 2015 21:43:01 +0200 Subject: [PATCH 342/613] fix permutations doc --- src/combinatorics/permutations.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/combinatorics/permutations.js b/src/combinatorics/permutations.js index 4ae6cba4..915acea1 100644 --- a/src/combinatorics/permutations.js +++ b/src/combinatorics/permutations.js @@ -46,7 +46,6 @@ * @module combinatorics/permutations * @public * @param {Array} arr Array to find the permutations of. - * @param {Number} current Current element. * @returns {Array} Array containing all the permutations. */ return function (arr) { From 66c4af4f32314127caa209c831e771e12c80c497 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 12 Jan 2015 10:23:05 +0200 Subject: [PATCH 343/613] Add bucket sort spec --- test/sorting/linearsort/bucketsort.spec.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/sorting/linearsort/bucketsort.spec.js diff --git a/test/sorting/linearsort/bucketsort.spec.js b/test/sorting/linearsort/bucketsort.spec.js new file mode 100644 index 00000000..839ca502 --- /dev/null +++ b/test/sorting/linearsort/bucketsort.spec.js @@ -0,0 +1,18 @@ +var bs = + require('../../../src/sorting/linearsort/bucketsort').bucketSort; + +describe('bucketsort', function () { + 'use strict'; + + it('should sort the empty array', function () { + expect(bs([])).toEqual([]); + }); + + it('should return array with the same count of elements', function () { + expect(bs([2, 3, 4]).length).toBe(3); + }); + + it('should sort the given array in ascending order', function () { + expect(bs([42, 3, 10])).toEqual([3, 10, 42]); + }); +}); From 6034d8d4324235eb9abdf8dc267061fbfef6efb2 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 12 Jan 2015 10:27:16 +0200 Subject: [PATCH 344/613] Add specs for counting sort --- test/sorting/linearsort/countingsort.spec.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/sorting/linearsort/countingsort.spec.js diff --git a/test/sorting/linearsort/countingsort.spec.js b/test/sorting/linearsort/countingsort.spec.js new file mode 100644 index 00000000..c392c482 --- /dev/null +++ b/test/sorting/linearsort/countingsort.spec.js @@ -0,0 +1,18 @@ +var cs = + require('../../../src/sorting/linearsort/countingsort').countingSort; + +describe('countingsort', function () { + 'use strict'; + + it('should sort the empty array', function () { + expect(cs([])).toEqual([]); + }); + + it('should return array with the same count of elements', function () { + expect(cs([2, 3, 4]).length).toBe(3); + }); + + it('should sort the given array in ascending order', function () { + expect(cs([42, 3, 10])).toEqual([3, 10, 42]); + }); +}); From ead628f93454325af9698da641af94465ca7230d Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Mon, 12 Jan 2015 15:44:05 +0200 Subject: [PATCH 345/613] add livenshtein distance doc --- doc-config.json | 3 ++- src/others/levenshtein-distance.js | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/doc-config.json b/doc-config.json index 44c533d2..790d8799 100644 --- a/doc-config.json +++ b/doc-config.json @@ -10,7 +10,8 @@ "./src/graphs/spanning-trees/", "./src/data-structures/", "./src/combinatorics/", - "./src/primes/" + "./src/primes/", + "./src/others/" ], "includePattern": ".+\\.js(doc)?$", "excludePattern": "docs" diff --git a/src/others/levenshtein-distance.js b/src/others/levenshtein-distance.js index c667875f..c9fe2e81 100644 --- a/src/others/levenshtein-distance.js +++ b/src/others/levenshtein-distance.js @@ -21,6 +21,26 @@ levenshteinDistance(s, ls - 1, t, lt - 1) + cost); } + /** + * The Levenshtein distance between two strings is a minimum number + * of edits needed to transform one string into the other, with the + * allowable edit operations being insertion, deletion, + * or substitution of a single character. + * + * @public + * @module others/levenshtein-distance + * + * @example + * + * var dist = require('path-to-algorithms/src/others/' + + * 'levenshtein-distance').levenshteinDistance; + * console.log(dist('kitten', 'sitting')); // 3 + * + * @param {String} s Source string. + * @param {String} t Target string. + * @return {Number} Minimum number of edits needed + * to transform source string into the target string. + */ return function (s, t) { return levenshteinDistance(s, s.length, t, t.length); }; From e5a28b66f9977d168c17aa3e3697a4abc73a7d96 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Mon, 12 Jan 2015 18:47:00 +0200 Subject: [PATCH 346/613] add hanoi jsdoc --- src/others/hanoi.js | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/others/hanoi.js b/src/others/hanoi.js index 4e5848d1..b4bda331 100644 --- a/src/others/hanoi.js +++ b/src/others/hanoi.js @@ -1,9 +1,35 @@ -/* - * Hanoi towers - */ (function (exports) { 'use strict'; + /** + * Returns all movements needed to solve Hanoi Tower problem. + * + * @public + * @module others/hanoi + * + * @example + * + * var hanoi = require('../src/others/hanoi').hanoi; + * var movements = hanoi(3, 'a', 'b', 'c'); + * + * // Move a to c + * // Move a to b + * // Move c to b + * // Move a to c + * // Move b to a + * // Move b to c + * // Move a to c + * movements.forEach(function (move) { + * console.log('Move', move[0], 'to', move[1]); + * }); + * + * @param {Number} count Count of the plates/stones. + * @param {String|Number} source Identifier of the 1st peg. + * @param {String|Number} source Identifier of the 2nd peg. + * @param {String|Number} source Identifier of the 3rd peg. + * @return Array which contains all the moves required + * in order to place all the plates onto the last peg. + */ function hanoi(count, source, intermediate, goal, result) { result = result || []; if (count === 1) { From 8dd2e8e79d62e66d0ca304dd52a5565240f27eb1 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Tue, 13 Jan 2015 01:01:40 +0200 Subject: [PATCH 347/613] fix hanoi example, add binsearch jsdoc --- doc-config.json | 3 ++- src/others/hanoi.js | 2 +- src/searching/binarysearch/binarysearch.js | 27 ++++++++++++++-------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/doc-config.json b/doc-config.json index 790d8799..0ecc43b0 100644 --- a/doc-config.json +++ b/doc-config.json @@ -11,7 +11,8 @@ "./src/data-structures/", "./src/combinatorics/", "./src/primes/", - "./src/others/" + "./src/others/", + "./src/searching/" ], "includePattern": ".+\\.js(doc)?$", "excludePattern": "docs" diff --git a/src/others/hanoi.js b/src/others/hanoi.js index b4bda331..bbd6b052 100644 --- a/src/others/hanoi.js +++ b/src/others/hanoi.js @@ -9,7 +9,7 @@ * * @example * - * var hanoi = require('../src/others/hanoi').hanoi; + * var hanoi = require('path-to-algorithms/src/others/hanoi').hanoi; * var movements = hanoi(3, 'a', 'b', 'c'); * * // Move a to c diff --git a/src/searching/binarysearch/binarysearch.js b/src/searching/binarysearch/binarysearch.js index a95ffc08..5a9999a8 100644 --- a/src/searching/binarysearch/binarysearch.js +++ b/src/searching/binarysearch/binarysearch.js @@ -2,23 +2,30 @@ 'use strict'; /** - * Searchs for specific element in given array using - * the binary search algorithm. - * It's complexity is O(log n) + * Searchs for specific element in a given array using + * the binary search algorithm.

+ * Time complexity: O(log N). * + * @example + * + * var search = require('path-to-algorithms/src/searching/'+ + * 'binarysearch/binarysearch').binarySearch; + * console.log(search([1, 2, 3, 4, 5], 4)); // 3 + * * @public - * @param {array} array Input array - * @param {number} key The key of the element which index we should find - * @returns {number} index The index of the element or -1 if not found + * @module searching/binarysearch/binarysearch + * @param {Array} array Input array. + * @param {Number} value Value of the element which index should be found. + * @returns {Number} Index of the element or -1 if not found. */ - function binarySearch(array, key) { + function binarySearch(array, value) { var middle = Math.floor(array.length / 2); var left = 0; var right = array.length; while (right >= left) { - if (array[middle] === key) { + if (array[middle] === value) { return middle; - } else if (array[middle] > key) { + } else if (array[middle] > value) { right = middle - 1; } else { left = middle + 1; @@ -30,4 +37,4 @@ exports.binarySearch = binarySearch; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From 7be10e16da915f7cf5d03cb89d8fb6285b41d343 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Tue, 13 Jan 2015 01:02:20 +0200 Subject: [PATCH 348/613] fix jshint error --- src/searching/binarysearch/binarysearch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/searching/binarysearch/binarysearch.js b/src/searching/binarysearch/binarysearch.js index 5a9999a8..d66d18b2 100644 --- a/src/searching/binarysearch/binarysearch.js +++ b/src/searching/binarysearch/binarysearch.js @@ -11,7 +11,7 @@ * var search = require('path-to-algorithms/src/searching/'+ * 'binarysearch/binarysearch').binarySearch; * console.log(search([1, 2, 3, 4, 5], 4)); // 3 - * + * * @public * @module searching/binarysearch/binarysearch * @param {Array} array Input array. From fce486ec7d872c918771340d498294b826336ede Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Tue, 13 Jan 2015 01:09:01 +0200 Subject: [PATCH 349/613] recursive bin search jsdoc --- .../binarysearch/recursive-binarysearch.js | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/searching/binarysearch/recursive-binarysearch.js b/src/searching/binarysearch/recursive-binarysearch.js index b042e069..d0227a2a 100644 --- a/src/searching/binarysearch/recursive-binarysearch.js +++ b/src/searching/binarysearch/recursive-binarysearch.js @@ -1,49 +1,56 @@ (function (exports) { 'use strict'; - /** - * Recursive version of binary search. It's complexity is O(log n). - * - * @public - */ + var binarySearch = (function () { /** * Binary search. * * @pivate * @param {array} array Array where we should find the index of the element - * @param {number} key Key of the element which index should be found + * @param {number} value Value of the element which index should be found * @param {number} left Left index * @param {number} right Right index * @returns {number} index The index of the element or -1 if not found * */ - function recursiveBinarySearch(array, key, left, right) { + function recursiveBinarySearch(array, value, left, right) { if (left > right) { return -1; } var middle = Math.floor((right + left) / 2); - if (array[middle] === key) { + if (array[middle] === value) { return middle; - } else if (array[middle] > key) { - return recursiveBinarySearch(array, key, left, middle - 1); + } else if (array[middle] > value) { + return recursiveBinarySearch(array, value, left, middle - 1); } else { - return recursiveBinarySearch(array, key, middle + 1, right); + return recursiveBinarySearch(array, value, middle + 1, right); } } /** - * Calls the binary search function with it's initial values. + * Recursive version of binary search. + * Searchs for specific element in a given array using + * the binary search algorithm.

+ * Time complexity: O(log N). * - * @param {array} array The input array - * @param {number} key The key of the element which index should be found - * @returns {number} index The index of the element or -1 if not found + * @example + * + * var search = require('path-to-algorithms/src/searching/'+ + * 'binarysearch/recursive-binarysearch').binarySearch; + * console.log(search([1, 2, 3, 4, 5], 4)); // 3 + * + * @public + * @module searching/binarysearch/recursive-binarysearch + * @param {Array} array Input array. + * @param {Number} value Value of the element which index should be found. + * @returns {Number} Index of the element or -1 if not found. */ - return function (array, key) { - return recursiveBinarySearch(array, key, 0, array.length); + return function (array, value) { + return recursiveBinarySearch(array, value, 0, array.length); }; }()); exports.binarySearch = binarySearch; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From 7e7db9b8bc385eb28709c5a2b9086e501c67f145 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Tue, 13 Jan 2015 10:23:52 +0200 Subject: [PATCH 350/613] fix searching namespaces --- .../{binarysearch => }/binarysearch.js | 4 ++-- .../knuth-morris-pratt.js | 0 .../longest-increasing-subsequence.js | 0 .../maximum-subarray-divide-and-conquer.js | 0 .../{subarray => }/maximum-subarray.js | 0 src/searching/{quickselect => }/quickselect.js | 0 .../recursive-binarysearch.js | 17 +++++++---------- .../{binarysearch => }/binarysearch.spec.js | 2 +- .../longest-increasing-subsequence.spec.js | 4 ++-- .../maximum-subarray-divide-and-conquer.spec.js | 2 +- 10 files changed, 13 insertions(+), 16 deletions(-) rename src/searching/{binarysearch => }/binarysearch.js (91%) rename src/searching/{knuth-morris-pratt => }/knuth-morris-pratt.js (100%) rename src/searching/{longest-increasing-subsequence => }/longest-increasing-subsequence.js (100%) rename src/searching/{subarray => }/maximum-subarray-divide-and-conquer.js (100%) rename src/searching/{subarray => }/maximum-subarray.js (100%) rename src/searching/{quickselect => }/quickselect.js (100%) rename src/searching/{binarysearch => }/recursive-binarysearch.js (76%) rename test/searching/{binarysearch => }/binarysearch.spec.js (90%) rename test/searching/{longest-increasing-subsequence => }/longest-increasing-subsequence.spec.js (84%) rename test/searching/{subarray => }/maximum-subarray-divide-and-conquer.spec.js (92%) diff --git a/src/searching/binarysearch/binarysearch.js b/src/searching/binarysearch.js similarity index 91% rename from src/searching/binarysearch/binarysearch.js rename to src/searching/binarysearch.js index d66d18b2..1b7ec295 100644 --- a/src/searching/binarysearch/binarysearch.js +++ b/src/searching/binarysearch.js @@ -9,11 +9,11 @@ * @example * * var search = require('path-to-algorithms/src/searching/'+ - * 'binarysearch/binarysearch').binarySearch; + * 'binarysearch').binarySearch; * console.log(search([1, 2, 3, 4, 5], 4)); // 3 * * @public - * @module searching/binarysearch/binarysearch + * @module searching/binarysearch * @param {Array} array Input array. * @param {Number} value Value of the element which index should be found. * @returns {Number} Index of the element or -1 if not found. diff --git a/src/searching/knuth-morris-pratt/knuth-morris-pratt.js b/src/searching/knuth-morris-pratt.js similarity index 100% rename from src/searching/knuth-morris-pratt/knuth-morris-pratt.js rename to src/searching/knuth-morris-pratt.js diff --git a/src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js b/src/searching/longest-increasing-subsequence.js similarity index 100% rename from src/searching/longest-increasing-subsequence/longest-increasing-subsequence.js rename to src/searching/longest-increasing-subsequence.js diff --git a/src/searching/subarray/maximum-subarray-divide-and-conquer.js b/src/searching/maximum-subarray-divide-and-conquer.js similarity index 100% rename from src/searching/subarray/maximum-subarray-divide-and-conquer.js rename to src/searching/maximum-subarray-divide-and-conquer.js diff --git a/src/searching/subarray/maximum-subarray.js b/src/searching/maximum-subarray.js similarity index 100% rename from src/searching/subarray/maximum-subarray.js rename to src/searching/maximum-subarray.js diff --git a/src/searching/quickselect/quickselect.js b/src/searching/quickselect.js similarity index 100% rename from src/searching/quickselect/quickselect.js rename to src/searching/quickselect.js diff --git a/src/searching/binarysearch/recursive-binarysearch.js b/src/searching/recursive-binarysearch.js similarity index 76% rename from src/searching/binarysearch/recursive-binarysearch.js rename to src/searching/recursive-binarysearch.js index d0227a2a..8eb4d2f5 100644 --- a/src/searching/binarysearch/recursive-binarysearch.js +++ b/src/searching/recursive-binarysearch.js @@ -3,15 +3,12 @@ var binarySearch = (function () { /** - * Binary search. - * * @pivate - * @param {array} array Array where we should find the index of the element - * @param {number} value Value of the element which index should be found - * @param {number} left Left index - * @param {number} right Right index - * @returns {number} index The index of the element or -1 if not found - * + * @param {Array} array Array where we should find the index of the element + * @param {Number} value Value of the element which index should be found + * @param {Number} left Left index + * @param {Number} right Right index + * @returns {Number} index The index of the element or -1 if not found */ function recursiveBinarySearch(array, value, left, right) { if (left > right) { @@ -36,11 +33,11 @@ * @example * * var search = require('path-to-algorithms/src/searching/'+ - * 'binarysearch/recursive-binarysearch').binarySearch; + * 'recursive-binarysearch').binarySearch; * console.log(search([1, 2, 3, 4, 5], 4)); // 3 * * @public - * @module searching/binarysearch/recursive-binarysearch + * @module searching/recursive-binarysearch * @param {Array} array Input array. * @param {Number} value Value of the element which index should be found. * @returns {Number} Index of the element or -1 if not found. diff --git a/test/searching/binarysearch/binarysearch.spec.js b/test/searching/binarysearch.spec.js similarity index 90% rename from test/searching/binarysearch/binarysearch.spec.js rename to test/searching/binarysearch.spec.js index a4fd195e..13777dd7 100644 --- a/test/searching/binarysearch/binarysearch.spec.js +++ b/test/searching/binarysearch.spec.js @@ -1,7 +1,7 @@ 'use strict'; var binarySearch = - require('../../../src/searching/binarysearch/binarysearch').binarySearch; + require('../../src/searching/binarysearch').binarySearch; describe('Binary search', function () { diff --git a/test/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js b/test/searching/longest-increasing-subsequence.spec.js similarity index 84% rename from test/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js rename to test/searching/longest-increasing-subsequence.spec.js index 57d4612b..ae72a3a0 100644 --- a/test/searching/longest-increasing-subsequence/longest-increasing-subsequence.spec.js +++ b/test/searching/longest-increasing-subsequence.spec.js @@ -1,8 +1,8 @@ 'use strict'; var longestSubsequence = - require('../../../src/searching/' + - 'longest-increasing-subsequence/longest-increasing-subsequence') + require('../../src/searching/' + + 'longest-increasing-subsequence') .longestSubsequence; describe('longest subsequence', function () { diff --git a/test/searching/subarray/maximum-subarray-divide-and-conquer.spec.js b/test/searching/maximum-subarray-divide-and-conquer.spec.js similarity index 92% rename from test/searching/subarray/maximum-subarray-divide-and-conquer.spec.js rename to test/searching/maximum-subarray-divide-and-conquer.spec.js index d53477a3..f84f60d2 100644 --- a/test/searching/subarray/maximum-subarray-divide-and-conquer.spec.js +++ b/test/searching/maximum-subarray-divide-and-conquer.spec.js @@ -1,7 +1,7 @@ 'use strict'; var maxSubArray = - require('../../../src/searching/subarray/maximum-subarray-divide-and-conquer') + require('../../src/searching/maximum-subarray-divide-and-conquer') .maxSubarray; describe('Maximum subarray implemented with divide and conquer', function () { From a6c5334ae1dd1b7bffff19cb0295e8432764e6ca Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Tue, 13 Jan 2015 10:35:29 +0200 Subject: [PATCH 351/613] fix sorting namespaces --- .../quicksort.js => 3-way-string-quicksort.js} | 0 src/sorting/{bubblesort => }/bubblesort.js | 0 src/sorting/{linearsort => }/bucketsort.js | 0 src/sorting/{linearsort => }/countingsort.js | 0 src/sorting/{heapsort => }/heapsort.js | 0 src/sorting/{insertionsort => }/insertion-binary-sort.js | 0 src/sorting/{insertionsort => }/insertionsort.js | 0 src/sorting/{least-significant-digit => }/lsd.js | 0 src/sorting/{mergesort => }/mergesort.js | 0 src/sorting/{most-significant-digit => }/msd.js | 0 src/sorting/{quicksort => }/quicksort-middle.js | 0 src/sorting/{quicksort => }/quicksort.js | 0 src/sorting/{insertionsort => }/recursive-insertionsort.js | 0 src/sorting/{selectionsort => }/selectionsort.js | 0 src/sorting/{shellsort => }/shellsort.js | 0 .../quicksort.spec.js => 3-way-string-quicksort.spec.js} | 2 +- test/sorting/bubblesort.spec.js | 5 +++++ test/sorting/bubblesort/bubblesort.spec.js | 5 ----- test/sorting/{linearsort => }/bucketsort.spec.js | 2 +- test/sorting/{linearsort => }/countingsort.spec.js | 2 +- test/sorting/heapsort.spec.js | 4 ++++ test/sorting/heapsort/heapsort.spec.js | 4 ---- .../sorting/{insertionsort => }/insertionbinarysort.spec.js | 4 ++-- test/sorting/insertionsort.spec.js | 5 +++++ test/sorting/insertionsort/insertionsort.spec.js | 5 ----- test/sorting/insertionsort/recursiveinsertionsort.spec.js | 5 ----- test/sorting/{least-significant-digit => }/lsd.spec.js | 2 +- test/sorting/mergesort.spec.js | 5 +++++ test/sorting/mergesort/mergesort.spec.js | 5 ----- test/sorting/{most-significant-digit => }/msd.spec.js | 2 +- test/sorting/quicksort-middle.spec.js | 5 +++++ test/sorting/quicksort.spec.js | 5 +++++ test/sorting/quicksort/quicksort-middle.spec.js | 5 ----- test/sorting/quicksort/quicksort.spec.js | 5 ----- test/sorting/recursiveinsertionsort.spec.js | 5 +++++ test/sorting/selectionsort.spec.js | 6 ++++++ test/sorting/selectionsort/selectionsort.spec.js | 6 ------ test/sorting/shellsort.spec.js | 5 +++++ test/sorting/shellsort/shellsort.spec.js | 5 ----- 39 files changed, 52 insertions(+), 52 deletions(-) rename src/sorting/{3-way-string-quicksort/quicksort.js => 3-way-string-quicksort.js} (100%) rename src/sorting/{bubblesort => }/bubblesort.js (100%) rename src/sorting/{linearsort => }/bucketsort.js (100%) rename src/sorting/{linearsort => }/countingsort.js (100%) rename src/sorting/{heapsort => }/heapsort.js (100%) rename src/sorting/{insertionsort => }/insertion-binary-sort.js (100%) rename src/sorting/{insertionsort => }/insertionsort.js (100%) rename src/sorting/{least-significant-digit => }/lsd.js (100%) rename src/sorting/{mergesort => }/mergesort.js (100%) rename src/sorting/{most-significant-digit => }/msd.js (100%) rename src/sorting/{quicksort => }/quicksort-middle.js (100%) rename src/sorting/{quicksort => }/quicksort.js (100%) rename src/sorting/{insertionsort => }/recursive-insertionsort.js (100%) rename src/sorting/{selectionsort => }/selectionsort.js (100%) rename src/sorting/{shellsort => }/shellsort.js (100%) rename test/sorting/{3-way-string-quicksort/quicksort.spec.js => 3-way-string-quicksort.spec.js} (91%) create mode 100644 test/sorting/bubblesort.spec.js delete mode 100644 test/sorting/bubblesort/bubblesort.spec.js rename test/sorting/{linearsort => }/bucketsort.spec.js (85%) rename test/sorting/{linearsort => }/countingsort.spec.js (84%) create mode 100644 test/sorting/heapsort.spec.js delete mode 100644 test/sorting/heapsort/heapsort.spec.js rename test/sorting/{insertionsort => }/insertionbinarysort.spec.js (57%) create mode 100644 test/sorting/insertionsort.spec.js delete mode 100644 test/sorting/insertionsort/insertionsort.spec.js delete mode 100644 test/sorting/insertionsort/recursiveinsertionsort.spec.js rename test/sorting/{least-significant-digit => }/lsd.spec.js (91%) create mode 100644 test/sorting/mergesort.spec.js delete mode 100644 test/sorting/mergesort/mergesort.spec.js rename test/sorting/{most-significant-digit => }/msd.spec.js (92%) create mode 100644 test/sorting/quicksort-middle.spec.js create mode 100644 test/sorting/quicksort.spec.js delete mode 100644 test/sorting/quicksort/quicksort-middle.spec.js delete mode 100644 test/sorting/quicksort/quicksort.spec.js create mode 100644 test/sorting/recursiveinsertionsort.spec.js create mode 100644 test/sorting/selectionsort.spec.js delete mode 100644 test/sorting/selectionsort/selectionsort.spec.js create mode 100644 test/sorting/shellsort.spec.js delete mode 100644 test/sorting/shellsort/shellsort.spec.js diff --git a/src/sorting/3-way-string-quicksort/quicksort.js b/src/sorting/3-way-string-quicksort.js similarity index 100% rename from src/sorting/3-way-string-quicksort/quicksort.js rename to src/sorting/3-way-string-quicksort.js diff --git a/src/sorting/bubblesort/bubblesort.js b/src/sorting/bubblesort.js similarity index 100% rename from src/sorting/bubblesort/bubblesort.js rename to src/sorting/bubblesort.js diff --git a/src/sorting/linearsort/bucketsort.js b/src/sorting/bucketsort.js similarity index 100% rename from src/sorting/linearsort/bucketsort.js rename to src/sorting/bucketsort.js diff --git a/src/sorting/linearsort/countingsort.js b/src/sorting/countingsort.js similarity index 100% rename from src/sorting/linearsort/countingsort.js rename to src/sorting/countingsort.js diff --git a/src/sorting/heapsort/heapsort.js b/src/sorting/heapsort.js similarity index 100% rename from src/sorting/heapsort/heapsort.js rename to src/sorting/heapsort.js diff --git a/src/sorting/insertionsort/insertion-binary-sort.js b/src/sorting/insertion-binary-sort.js similarity index 100% rename from src/sorting/insertionsort/insertion-binary-sort.js rename to src/sorting/insertion-binary-sort.js diff --git a/src/sorting/insertionsort/insertionsort.js b/src/sorting/insertionsort.js similarity index 100% rename from src/sorting/insertionsort/insertionsort.js rename to src/sorting/insertionsort.js diff --git a/src/sorting/least-significant-digit/lsd.js b/src/sorting/lsd.js similarity index 100% rename from src/sorting/least-significant-digit/lsd.js rename to src/sorting/lsd.js diff --git a/src/sorting/mergesort/mergesort.js b/src/sorting/mergesort.js similarity index 100% rename from src/sorting/mergesort/mergesort.js rename to src/sorting/mergesort.js diff --git a/src/sorting/most-significant-digit/msd.js b/src/sorting/msd.js similarity index 100% rename from src/sorting/most-significant-digit/msd.js rename to src/sorting/msd.js diff --git a/src/sorting/quicksort/quicksort-middle.js b/src/sorting/quicksort-middle.js similarity index 100% rename from src/sorting/quicksort/quicksort-middle.js rename to src/sorting/quicksort-middle.js diff --git a/src/sorting/quicksort/quicksort.js b/src/sorting/quicksort.js similarity index 100% rename from src/sorting/quicksort/quicksort.js rename to src/sorting/quicksort.js diff --git a/src/sorting/insertionsort/recursive-insertionsort.js b/src/sorting/recursive-insertionsort.js similarity index 100% rename from src/sorting/insertionsort/recursive-insertionsort.js rename to src/sorting/recursive-insertionsort.js diff --git a/src/sorting/selectionsort/selectionsort.js b/src/sorting/selectionsort.js similarity index 100% rename from src/sorting/selectionsort/selectionsort.js rename to src/sorting/selectionsort.js diff --git a/src/sorting/shellsort/shellsort.js b/src/sorting/shellsort.js similarity index 100% rename from src/sorting/shellsort/shellsort.js rename to src/sorting/shellsort.js diff --git a/test/sorting/3-way-string-quicksort/quicksort.spec.js b/test/sorting/3-way-string-quicksort.spec.js similarity index 91% rename from test/sorting/3-way-string-quicksort/quicksort.spec.js rename to test/sorting/3-way-string-quicksort.spec.js index 0fcf13e5..57d8114a 100644 --- a/test/sorting/3-way-string-quicksort/quicksort.spec.js +++ b/test/sorting/3-way-string-quicksort.spec.js @@ -1,5 +1,5 @@ var quicksort = - require('../../../src/sorting/3-way-string-quicksort/quicksort.js').quicksort; + require('../../src/sorting/3-way-string-quicksort.js').quicksort; describe('Most-Significant Digit', function () { 'use strict'; diff --git a/test/sorting/bubblesort.spec.js b/test/sorting/bubblesort.spec.js new file mode 100644 index 00000000..d0cf17b4 --- /dev/null +++ b/test/sorting/bubblesort.spec.js @@ -0,0 +1,5 @@ +var sortTestCase = require('./sort.testcase.js'); +var bubbleSort = + require('../../src/sorting/bubblesort.js').bubbleSort; + +sortTestCase(bubbleSort, 'Bubble sort'); diff --git a/test/sorting/bubblesort/bubblesort.spec.js b/test/sorting/bubblesort/bubblesort.spec.js deleted file mode 100644 index 281d5ac6..00000000 --- a/test/sorting/bubblesort/bubblesort.spec.js +++ /dev/null @@ -1,5 +0,0 @@ -var sortTestCase = require('../sort.testcase.js'); -var bubbleSort = - require('../../../src/sorting/bubblesort/bubblesort.js').bubbleSort; - -sortTestCase(bubbleSort, 'Bubble sort'); diff --git a/test/sorting/linearsort/bucketsort.spec.js b/test/sorting/bucketsort.spec.js similarity index 85% rename from test/sorting/linearsort/bucketsort.spec.js rename to test/sorting/bucketsort.spec.js index 839ca502..cbae094e 100644 --- a/test/sorting/linearsort/bucketsort.spec.js +++ b/test/sorting/bucketsort.spec.js @@ -1,5 +1,5 @@ var bs = - require('../../../src/sorting/linearsort/bucketsort').bucketSort; + require('../../src/sorting/bucketsort').bucketSort; describe('bucketsort', function () { 'use strict'; diff --git a/test/sorting/linearsort/countingsort.spec.js b/test/sorting/countingsort.spec.js similarity index 84% rename from test/sorting/linearsort/countingsort.spec.js rename to test/sorting/countingsort.spec.js index c392c482..4d5cf771 100644 --- a/test/sorting/linearsort/countingsort.spec.js +++ b/test/sorting/countingsort.spec.js @@ -1,5 +1,5 @@ var cs = - require('../../../src/sorting/linearsort/countingsort').countingSort; + require('../../src/sorting/countingsort').countingSort; describe('countingsort', function () { 'use strict'; diff --git a/test/sorting/heapsort.spec.js b/test/sorting/heapsort.spec.js new file mode 100644 index 00000000..2546a007 --- /dev/null +++ b/test/sorting/heapsort.spec.js @@ -0,0 +1,4 @@ +var sortTestCase = require('./sort.testcase.js'); +var heapSort = require('../../src/sorting/heapsort.js').heapSort; + +sortTestCase(heapSort, 'Heap sort'); diff --git a/test/sorting/heapsort/heapsort.spec.js b/test/sorting/heapsort/heapsort.spec.js deleted file mode 100644 index eb9441b3..00000000 --- a/test/sorting/heapsort/heapsort.spec.js +++ /dev/null @@ -1,4 +0,0 @@ -var sortTestCase = require('../sort.testcase.js'); -var heapSort = require('../../../src/sorting/heapsort/heapsort.js').heapSort; - -sortTestCase(heapSort, 'Heap sort'); diff --git a/test/sorting/insertionsort/insertionbinarysort.spec.js b/test/sorting/insertionbinarysort.spec.js similarity index 57% rename from test/sorting/insertionsort/insertionbinarysort.spec.js rename to test/sorting/insertionbinarysort.spec.js index 43bed4d8..6718b240 100644 --- a/test/sorting/insertionsort/insertionbinarysort.spec.js +++ b/test/sorting/insertionbinarysort.spec.js @@ -1,6 +1,6 @@ -var sortTestCase = require('../sort.testcase.js'); +var sortTestCase = require('./sort.testcase.js'); var insertionBinarySort = - require('../../../src/sorting/insertionsort/' + + require('../../src/sorting/' + 'insertion-binary-sort.js').insertionBinarySort; sortTestCase(insertionBinarySort, 'Insertion binary sort'); diff --git a/test/sorting/insertionsort.spec.js b/test/sorting/insertionsort.spec.js new file mode 100644 index 00000000..0be5a50d --- /dev/null +++ b/test/sorting/insertionsort.spec.js @@ -0,0 +1,5 @@ +var sortTestCase = require('./sort.testcase.js'); +var insertionSort = require('../../src/sorting/' + + 'insertionsort.js').insertionSort; + +sortTestCase(insertionSort, 'Insertion sort'); diff --git a/test/sorting/insertionsort/insertionsort.spec.js b/test/sorting/insertionsort/insertionsort.spec.js deleted file mode 100644 index d1bb8e3d..00000000 --- a/test/sorting/insertionsort/insertionsort.spec.js +++ /dev/null @@ -1,5 +0,0 @@ -var sortTestCase = require('../sort.testcase.js'); -var insertionSort = require('../../../src/sorting/insertionsort/' + - 'insertionsort.js').insertionSort; - -sortTestCase(insertionSort, 'Insertion sort'); diff --git a/test/sorting/insertionsort/recursiveinsertionsort.spec.js b/test/sorting/insertionsort/recursiveinsertionsort.spec.js deleted file mode 100644 index ab883083..00000000 --- a/test/sorting/insertionsort/recursiveinsertionsort.spec.js +++ /dev/null @@ -1,5 +0,0 @@ -var sortTestCase = require('../sort.testcase.js'); -var recursiveInsertionSort = require('../../../src/sorting/' + - 'insertionsort/recursive-insertionsort.js').recursiveInsertionSort; - -sortTestCase(recursiveInsertionSort, 'Recursive insertion sort'); diff --git a/test/sorting/least-significant-digit/lsd.spec.js b/test/sorting/lsd.spec.js similarity index 91% rename from test/sorting/least-significant-digit/lsd.spec.js rename to test/sorting/lsd.spec.js index 6115998d..738ae492 100644 --- a/test/sorting/least-significant-digit/lsd.spec.js +++ b/test/sorting/lsd.spec.js @@ -1,4 +1,4 @@ -var lsd = require('../../../src/sorting/least-significant-digit/lsd.js').lsd; +var lsd = require('../../src/sorting/lsd.js').lsd; describe('Least-Significant Digit', function () { 'use strict'; diff --git a/test/sorting/mergesort.spec.js b/test/sorting/mergesort.spec.js new file mode 100644 index 00000000..528d0a55 --- /dev/null +++ b/test/sorting/mergesort.spec.js @@ -0,0 +1,5 @@ +var sortTestCase = require('./sort.testcase.js'); +var mergeSort = + require('../../src/sorting/mergesort.js').mergeSort; + +sortTestCase(mergeSort, 'Merge sort'); diff --git a/test/sorting/mergesort/mergesort.spec.js b/test/sorting/mergesort/mergesort.spec.js deleted file mode 100644 index e8bfa78e..00000000 --- a/test/sorting/mergesort/mergesort.spec.js +++ /dev/null @@ -1,5 +0,0 @@ -var sortTestCase = require('../sort.testcase.js'); -var mergeSort = - require('../../../src/sorting/mergesort/mergesort.js').mergeSort; - -sortTestCase(mergeSort, 'Merge sort'); diff --git a/test/sorting/most-significant-digit/msd.spec.js b/test/sorting/msd.spec.js similarity index 92% rename from test/sorting/most-significant-digit/msd.spec.js rename to test/sorting/msd.spec.js index b1f4bc74..245acfbd 100644 --- a/test/sorting/most-significant-digit/msd.spec.js +++ b/test/sorting/msd.spec.js @@ -1,4 +1,4 @@ -var msd = require('../../../src/sorting/most-significant-digit/msd.js').msd; +var msd = require('../../src/sorting/msd.js').msd; describe('Most-Significant Digit', function () { 'use strict'; diff --git a/test/sorting/quicksort-middle.spec.js b/test/sorting/quicksort-middle.spec.js new file mode 100644 index 00000000..02745cb2 --- /dev/null +++ b/test/sorting/quicksort-middle.spec.js @@ -0,0 +1,5 @@ +var sortTestCase = require('./sort.testcase.js'); +var quickSort = + require('../../src/sorting/quicksort-middle.js').quickSort; + +sortTestCase(quickSort, 'Quick sort'); diff --git a/test/sorting/quicksort.spec.js b/test/sorting/quicksort.spec.js new file mode 100644 index 00000000..2d1e6baa --- /dev/null +++ b/test/sorting/quicksort.spec.js @@ -0,0 +1,5 @@ +var sortTestCase = require('./sort.testcase.js'); +var quickSort = + require('../../src/sorting/quicksort.js').quickSort; + +sortTestCase(quickSort, 'Quick sort'); diff --git a/test/sorting/quicksort/quicksort-middle.spec.js b/test/sorting/quicksort/quicksort-middle.spec.js deleted file mode 100644 index 4ba1efdb..00000000 --- a/test/sorting/quicksort/quicksort-middle.spec.js +++ /dev/null @@ -1,5 +0,0 @@ -var sortTestCase = require('../sort.testcase.js'); -var quickSort = - require('../../../src/sorting/quicksort/quicksort-middle.js').quickSort; - -sortTestCase(quickSort, 'Quick sort'); diff --git a/test/sorting/quicksort/quicksort.spec.js b/test/sorting/quicksort/quicksort.spec.js deleted file mode 100644 index 2a0be8bf..00000000 --- a/test/sorting/quicksort/quicksort.spec.js +++ /dev/null @@ -1,5 +0,0 @@ -var sortTestCase = require('../sort.testcase.js'); -var quickSort = - require('../../../src/sorting/quicksort/quicksort.js').quickSort; - -sortTestCase(quickSort, 'Quick sort'); diff --git a/test/sorting/recursiveinsertionsort.spec.js b/test/sorting/recursiveinsertionsort.spec.js new file mode 100644 index 00000000..1f9d409a --- /dev/null +++ b/test/sorting/recursiveinsertionsort.spec.js @@ -0,0 +1,5 @@ +var sortTestCase = require('./sort.testcase.js'); +var recursiveInsertionSort = require('../../src/sorting/' + + 'recursive-insertionsort.js').recursiveInsertionSort; + +sortTestCase(recursiveInsertionSort, 'Recursive insertion sort'); diff --git a/test/sorting/selectionsort.spec.js b/test/sorting/selectionsort.spec.js new file mode 100644 index 00000000..d36ad19a --- /dev/null +++ b/test/sorting/selectionsort.spec.js @@ -0,0 +1,6 @@ +var sortTestCase = require('./sort.testcase.js'); +var selectionSort = + require('../../src/sorting/selectionsort.js') + .selectionSort; + +sortTestCase(selectionSort, 'Selection sort'); diff --git a/test/sorting/selectionsort/selectionsort.spec.js b/test/sorting/selectionsort/selectionsort.spec.js deleted file mode 100644 index 0655a1bc..00000000 --- a/test/sorting/selectionsort/selectionsort.spec.js +++ /dev/null @@ -1,6 +0,0 @@ -var sortTestCase = require('../sort.testcase.js'); -var selectionSort = - require('../../../src/sorting/selectionsort/selectionsort.js') - .selectionSort; - -sortTestCase(selectionSort, 'Selection sort'); diff --git a/test/sorting/shellsort.spec.js b/test/sorting/shellsort.spec.js new file mode 100644 index 00000000..ec644711 --- /dev/null +++ b/test/sorting/shellsort.spec.js @@ -0,0 +1,5 @@ +var sortTestCase = require('./sort.testcase.js'); +var shellSort = require('../../src/sorting/shellsort.js') + .shellSort; + +sortTestCase(shellSort, 'Shell sort'); diff --git a/test/sorting/shellsort/shellsort.spec.js b/test/sorting/shellsort/shellsort.spec.js deleted file mode 100644 index 34f56c06..00000000 --- a/test/sorting/shellsort/shellsort.spec.js +++ /dev/null @@ -1,5 +0,0 @@ -var sortTestCase = require('../sort.testcase.js'); -var shellSort = require('../../../src/sorting/shellsort/shellsort.js') - .shellSort; - -sortTestCase(shellSort, 'Shell sort'); From dc52d5f3b3b7b874359b8e36c1ebe7455a1961f4 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Tue, 13 Jan 2015 11:24:04 +0200 Subject: [PATCH 352/613] add kmp jsdoc --- src/searching/knuth-morris-pratt.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/searching/knuth-morris-pratt.js b/src/searching/knuth-morris-pratt.js index 8c0c7200..c29be4c1 100644 --- a/src/searching/knuth-morris-pratt.js +++ b/src/searching/knuth-morris-pratt.js @@ -27,6 +27,24 @@ return res; } + /** + * Knuth–Morris–Pratt algorithm. Searches for the position of + * the first occurrence of a specified value in a string. + * + * @example + * + * var indexOf = require('path-to-algorithm/src/searching/'+ + * 'knuth-morris-pratt').kmp; + * console.log(indexOf('hello', 'll')); // 2 + * + * @public + * @module searching/knuth-morris-pratt + * @param {String} str String. + * @param {String} substr Substring. + * @return {Number} A Number, representing the position + * where the specified substring occurs for the first + * time, or -1 if it never occurs. + */ function indexOf(str, substr) { var table = builtKMPTable(substr); var i = 0; @@ -54,4 +72,4 @@ exports.kmp = kmp; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From e0685b80a62fdb5effeb97bc2b7e9fa3775169ba Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Tue, 13 Jan 2015 11:41:26 +0200 Subject: [PATCH 353/613] jsdooc for the longest increasing subsequence --- .../longest-increasing-subsequence.js | 58 +++++++++++-------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/src/searching/longest-increasing-subsequence.js b/src/searching/longest-increasing-subsequence.js index f7fd2441..54129632 100644 --- a/src/searching/longest-increasing-subsequence.js +++ b/src/searching/longest-increasing-subsequence.js @@ -1,26 +1,17 @@ (function (exports) { 'use strict'; - /** - * Algorithm from dynamic programming. - * It finds the longest sub-sequence of - * increasing numbers. It is not required - * the numbers to be neighboring. - * - * Example: - * 1,5,2 - * The longest sub-sequence is 1,2. - */ exports.longestSubsequence = (function () { /** * Find the index of the first largest element in array. - * Complexity O(n). + * Complexity: O(N). * - * @param {Array} array The array in which the largest - * element should be found - * @param {Function} cmp Function used for comparison - * @return {number} The index of the first largest element + * @private + * @param {Array} array The array in which the largest + * element should be found. + * @param {Function} cmp Function used for comparison. + * @return {Number} index of the first largest element */ function max(array, cmp) { if (!array || !array.length) { @@ -40,6 +31,7 @@ /** * Default comparison method. + * @private */ function cmp(a, b) { return a.distance - b.distance; @@ -48,11 +40,11 @@ /** * Creates directed graph from given array. * Each element's neighbours are the elements which can be - * after the element in the resulting sequence. - * Complexity O(n^2). - * - * @param {Array} array The input array - * @return {Object} Graph represented with list of neighbours + * after the element in the resulting sequence.

+ * Complexity: O(N^2). + * @private + * @param {Array} array The input array. + * @return {Object} Graph represented with list of neighbours. */ function buildDag(array) { var result = []; @@ -68,12 +60,12 @@ } /** - * Finds the longest sub-sequence for given node. - * O(n^n). - * + * Finds the longest sub-sequence for given node.

+ * Complexity: O(N^N). + * @private * @param {Object} dag Graph represented with list of neighbours. * @param {number} node The current node. - * @return {object} The longest sub-sequence for given node. + * @return {object} The longest sub-sequence for given node. */ function find(dag, node) { node = node || 0; @@ -106,6 +98,22 @@ return result; } + /** + * Algorithm from dynamic programming. It finds the longest + * sub-sequence of increasing numbers. It is not required + * the numbers to be neighboring. For example for 1, 5, 2 + * sequence the longest sub-sequence is 1, 2. + * + * @example + * var subsequence = require('path-to-algorithms/src/searching/'+ + * 'longest-increasing-subsequence').longestSubsequence; + * console.log(subsequence([1, 0, 4, 3, 5])); // 1, 4, 5 + * + * @public + * @module searching/longest-increasing-subsequence + * @param {Array} array Input sequence. + * @return {Array} Longest increasing subsequence. + */ return function (array) { var results = []; var dag = buildDag(array); @@ -124,4 +132,4 @@ }; })(); -}(typeof exports === 'undefined' ? exports : this)); +})(typeof window === 'undefined' ? module.exports : window); From fc412bb4c27568233e66f95111381cc444355a12 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Tue, 13 Jan 2015 12:02:01 +0200 Subject: [PATCH 354/613] add maximum-subarray-divide-and-conquer jsdoc --- .../maximum-subarray-divide-and-conquer.js | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/searching/maximum-subarray-divide-and-conquer.js b/src/searching/maximum-subarray-divide-and-conquer.js index bde7143d..31a7dd66 100644 --- a/src/searching/maximum-subarray-divide-and-conquer.js +++ b/src/searching/maximum-subarray-divide-and-conquer.js @@ -1,20 +1,15 @@ -/** - * Finds the maximum subarray using the divide and conquer algorithm - * by Bentley, Jon (1984) (complexity O(n(logn))); - */ - (function (exports) { 'use strict'; /** * Accepts an array and range. Finds the maximum sum of elements * around the middle of the range. - * - * @param {array} array - * @param {number} left - the left interval of the range - * @param {number} middle - the middle of the range - * @param {number} right - the right side of the range - * @return {number} the maximum sum including the middle element + * @private + * @param {Array} array Input array. + * @param {Number} left Left interval of the range. + * @param {Number} middle Middle of the range. + * @param {Number} right Right side of the range. + * @return {Number} The maximum sum including the middle element. */ function crossSubarray(array, left, middle, right) { var leftSum = -Infinity; @@ -39,13 +34,12 @@ } /** - * Using divide and conquer finds the maximum sum of subarray of the given - * - * @param {array} array - * @param {number} left side of the range - * @param {number} the right side of the range - * @return {number} the maximum sum of the elements of - * subarray whithin the given range + * @private + * @param {Array} array Input array. + * @param {Number} left Left side of the range. + * @param {Number} right Right side of the range. + * @return {Number} Maximum sum of the elements of + * subarray whithin the given range. */ function maxSubarrayPartitioner(array, left, right) { if (right - left <= 1) { @@ -60,10 +54,22 @@ } /** - * Returns the maximum sum of the elements of a subarray of the given array + * Finds the maximum sum of the elements of a subarray in a given array + * using the divide and conquer algorithm by Bentley, Jon (1984). + * For example, for the sequence of values -2, 1, -3, 4, -1, 2, 1, -5, 4 + * the contiguous subarray with the largest sum is 4, -1, 2, 1, with sum 6. + *

+ * Time complexity: O(N log N). + * + * @example + * var max = require('path-to-algorithms/src/searching/'+ + * 'maximum-subarray-divide-and-conquer').maxSubarray; + * console.log(max([-2, 1, -3, 4, -1, 2, 1, -5, 4])); // 6 * - * @param {array} the array - * @return the maximum sum + * @public + * @module searching/maximum-subarray-divide-and-conquer + * @param {Array} array Input array. + * @return {Number} Maximum sum of the elements of a subarray. */ function maxSubarray(array) { return maxSubarrayPartitioner(array, 0, array.length); @@ -71,4 +77,4 @@ exports.maxSubarray = maxSubarray; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From 2849ea921a172d482bda50f805490b3c6a66c5b3 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Tue, 13 Jan 2015 12:09:20 +0200 Subject: [PATCH 355/613] max-subarray jsdoc --- src/searching/maximum-subarray.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/searching/maximum-subarray.js b/src/searching/maximum-subarray.js index 11fd8f2f..4628369e 100644 --- a/src/searching/maximum-subarray.js +++ b/src/searching/maximum-subarray.js @@ -2,15 +2,22 @@ 'use strict'; /** - * Finds the maximum sum of subarray's element of given array - * using the Kadane's algorithm - * It's complexity is O(n). The algorithm can be found here: - * https://en.wikipedia.org/wiki/Maximum_subarray_problem#Kadane.27s_algorithm + * Finds the maximum sum of the elements of a subarray in a given array + * using the Kadane's algorithm. + * For example, for the sequence of values -2, 1, -3, 4, -1, 2, 1, -5, 4 + * the contiguous subarray with the largest sum is 4, -1, 2, 1, with sum 6. + *

+ * Time complexity: O(N). + * + * @example + * var max = require('path-to-algorithms/src/searching/'+ + * 'maximum-subarray').maxSubarray; + * console.log(max([-2, 1, -3, 4, -1, 2, 1, -5, 4])); // 6 * * @public - * @param {array} array Input array - * @returns {number} max The maximum sum of - * the elements of subarray of the input + * @module searching/maximum-subarray + * @param {Array} array Input array. + * @return {Number} Maximum sum of the elements of a subarray. */ function maxSubarray(array) { var currentMax = 0; @@ -25,4 +32,4 @@ exports.maxSubarray = maxSubarray; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From 18968afb2103672ba442e45aa8d3091e0e6823c0 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Tue, 13 Jan 2015 12:28:00 +0200 Subject: [PATCH 356/613] quickselect jsdoc --- src/searching/quickselect.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/searching/quickselect.js b/src/searching/quickselect.js index d49ca2e6..6a16457f 100644 --- a/src/searching/quickselect.js +++ b/src/searching/quickselect.js @@ -1,7 +1,26 @@ (function (exports) { 'use strict'; - // O(n) + /** + * Returns the n-th smallest element of list within + * lo..hi inclusive (i.e. lo <= n <= hi).

+ * Time complexity: O(N). + * + * @example + * + * var quickselect = require('path-to-algorithms/src/searching/'+ + * 'quickselect').quickselect; + * var result = quickselect([5, 1, 2, 2, 0, 3], 1, 0, 5); + * console.log(result); // 1 + * + * @public + * @module searching/quickselect + * @param {Array} arr Input array. + * @param {Number} n A number of an element. + * @param {Number} lo Low index. + * @param {Number} lo High index. + * @return Returns n-th smallest element. + */ function quickselect(arr, n, lo, hi) { function partition(arr, lo, hi, pivotIdx) { function swap(arr, i, j) { @@ -45,4 +64,4 @@ } exports.quickselect = quickselect; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From 89f0caad3dbc1361745423b80be978baa901645e Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Tue, 13 Jan 2015 16:00:48 +0200 Subject: [PATCH 357/613] quickfind jsdoc --- doc-config.json | 3 ++- src/sets/quickfind.js | 54 ++++++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/doc-config.json b/doc-config.json index 0ecc43b0..db96100b 100644 --- a/doc-config.json +++ b/doc-config.json @@ -12,7 +12,8 @@ "./src/combinatorics/", "./src/primes/", "./src/others/", - "./src/searching/" + "./src/searching/", + "./src/sets/" ], "includePattern": ".+\\.js(doc)?$", "excludePattern": "docs" diff --git a/src/sets/quickfind.js b/src/sets/quickfind.js index 67785715..9bc25ffe 100644 --- a/src/sets/quickfind.js +++ b/src/sets/quickfind.js @@ -1,12 +1,33 @@ +/** + * Keeps track of a set of elements partitioned into a + * number of disjoint (nonoverlapping) subsets. + * + * @example + * + * var QuickFind = require('path-to-algorithms/src/sets/quickfind').QuickFind; + * + * var find = new QuickFind(10); + * find.union(0, 1); + * find.union(2, 1); + * find.union(3, 4); + * find.union(8, 9); + * find.union(4, 8); + * + * console.log(find.connected(0, 9)); // false + * console.log(find.connected(3, 9)); // true + * + * @public + * @module sets/quickfind + */ (function (exports) { 'use strict'; /** - * Checks whether there is a path between two nodes. - * The initialization is O(n). + * Initialization.

+ * Complexity: O(N). * * @constructor - * @param {numner} size The count of the nodes + * @param {Numner} size Count of the nodes. */ function QuickFind(size) { this._ids = []; @@ -16,11 +37,11 @@ } /** - * Connects two nodes - p and q. - * Complexity O(n). + * Connects two nodes - p and q.

+ * Complexity: O(N). * - * @param {number} p The first node - * @param {number} q The second node + * @param {Number} p The first node. + * @param {Number} q The second node. */ QuickFind.prototype.union = function (p, q) { var size = this._ids.length; @@ -34,11 +55,11 @@ }; /** - * Checks whether two nodes are connected. - * Complexity O(1). + * Checks whether two nodes are connected.

+ * Complexity: O(1). * - * @param {number} p The first node - * @param {number} q The second node + * @param {number} p The first node. + * @param {number} q The second node. * */ QuickFind.prototype.connected = function (p, q) { @@ -47,13 +68,4 @@ exports.QuickFind = QuickFind; - //var find = new QuickFind(10); - //find.union(0, 1); - //find.union(2, 1); - //find.union(3, 4); - //find.union(8, 9); - //find.union(4, 8); - // - //console.log(find.connected(0, 9)); //expected false - //console.log(find.connected(3, 9)); //expected true -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From 98b5b4acbe93a0858e904a133d0040c159f6fef6 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Tue, 13 Jan 2015 17:26:00 +0200 Subject: [PATCH 358/613] fix quickfind jsdoc --- src/sets/quickfind.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/sets/quickfind.js b/src/sets/quickfind.js index 9bc25ffe..93809cab 100644 --- a/src/sets/quickfind.js +++ b/src/sets/quickfind.js @@ -1,6 +1,7 @@ /** * Keeps track of a set of elements partitioned into a * number of disjoint (nonoverlapping) subsets. + * Allows to check whether the path between two nodes exists. * * @example * @@ -26,24 +27,27 @@ * Initialization.

* Complexity: O(N). * + * @public * @constructor * @param {Numner} size Count of the nodes. */ - function QuickFind(size) { + exports.QuickFind = function (size) { this._ids = []; for (var i = 0; i < size; i += 1) { this._ids[i] = i; } - } + }; /** * Connects two nodes - p and q.

* Complexity: O(N). * + * @public + * @method * @param {Number} p The first node. * @param {Number} q The second node. */ - QuickFind.prototype.union = function (p, q) { + exports.QuickFind.prototype.union = function (p, q) { var size = this._ids.length; var pval = this._ids[p]; var qval = this._ids[q]; @@ -58,14 +62,14 @@ * Checks whether two nodes are connected.

* Complexity: O(1). * - * @param {number} p The first node. - * @param {number} q The second node. - * + * @public + * @method + * @param {Number} p The first node. + * @param {Number} q The second node. + * @return {Boolean} */ - QuickFind.prototype.connected = function (p, q) { + exports.QuickFind.prototype.connected = function (p, q) { return this._ids[p] === this._ids[q]; }; - exports.QuickFind = QuickFind; - })(typeof window === 'undefined' ? module.exports : window); From 007f1a9d7c13b67465761f6203a23301bbdb0363 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Tue, 13 Jan 2015 17:37:23 +0200 Subject: [PATCH 359/613] add quickunion jsdoc --- src/sets/quickfind.js | 16 ++++----- src/sets/quickunion.js | 75 +++++++++++++++++++++++++----------------- 2 files changed, 53 insertions(+), 38 deletions(-) diff --git a/src/sets/quickfind.js b/src/sets/quickfind.js index 93809cab..40f97df3 100644 --- a/src/sets/quickfind.js +++ b/src/sets/quickfind.js @@ -7,15 +7,15 @@ * * var QuickFind = require('path-to-algorithms/src/sets/quickfind').QuickFind; * - * var find = new QuickFind(10); - * find.union(0, 1); - * find.union(2, 1); - * find.union(3, 4); - * find.union(8, 9); - * find.union(4, 8); + * var qfind = new QuickFind(10); + * qfind.union(0, 1); + * qfind.union(2, 1); + * qfind.union(3, 4); + * qfind.union(8, 9); + * qfind.union(4, 8); * - * console.log(find.connected(0, 9)); // false - * console.log(find.connected(3, 9)); // true + * console.log(qfind.connected(0, 9)); // false + * console.log(qfind.connected(3, 9)); // true * * @public * @module sets/quickfind diff --git a/src/sets/quickunion.js b/src/sets/quickunion.js index 5413c6d2..bbc8bcaa 100644 --- a/src/sets/quickunion.js +++ b/src/sets/quickunion.js @@ -1,29 +1,53 @@ +/** + * Keeps track of a set of elements partitioned into a + * number of disjoint (nonoverlapping) subsets. + * Allows to check whether the path between two nodes exists. + * + * @example + * + * var QuickUnion = require('path-to-algorithms/' + + * 'src/sets/quickunion').QuickUnion; + * + * var qunion = new QuickUnion(10); + * qunion.union(0, 1); + * qunion.union(2, 1); + * qunion.union(3, 4); + * qunion.union(8, 9); + * qunion.union(4, 8); + * + * console.log(qunion.connected(0, 9)); // false + * console.log(qunion.connected(3, 9)); // true + * + * @public + * @module sets/quickunion + */ + (function (exports) { 'use strict'; /** - * Checks whether path between two nodes exists. - * The initialization has O(n) complexity. + * Initialization.

+ * Complexity: O(N). * + * @public * @constructor - * @param {number} n Nodes count - * + * @param {Numner} size Count of the nodes. */ - function QuickUnion(n) { + exports.QuickUnion = function (n) { this._ids = []; for (var i = 0; i < n; i += 1) { this._ids[i] = i; } - } + }; /** - * Finds the root of given node. - * Complexity O(n). - * - * @param {number} i The given node - * @return {number} The root of the given node + * Finds the root of given node.

+ * Complexity: O(N). + * @private + * @param {Number} i The given node. + * @return {Number} Root of the given node. */ - QuickUnion.prototype._root = function (i) { + exports.QuickUnion.prototype._root = function (i) { while (i !== this._ids[i]) { i = this._ids[i]; } @@ -31,13 +55,15 @@ }; /** - * Unions two nodes. - * Complexity O(n). + * Connects two nodes - p and q.

+ * Complexity: O(N). * - * @param {number} p The first node - * @param {number} q The second node + * @public + * @method + * @param {Number} p The first node. + * @param {Number} q The second node. */ - QuickUnion.prototype.union = function (p, q) { + exports.QuickUnion.prototype.union = function (p, q) { var pRoot = this._root(p); var qRoot = this._root(q); this._ids[pRoot] = qRoot; @@ -51,18 +77,7 @@ * @param {number} q The second node. * @return {boolean} True/false depending on whether the nodes are connected. */ - QuickUnion.prototype.connected = function (p, q) { + exports.QuickUnion.prototype.connected = function (p, q) { return this._root(p) === this._root(q); }; - - //var union = new QuickUnion(10); - //union.union(0, 1); - //union.union(2, 1); - //union.union(3, 4); - //union.union(8, 9); - //union.union(4, 8); - // - //console.log(union.connected(0, 9)); //expected false - //console.log(union.connected(3, 9)); //expected true - exports.QuickUnion = QuickUnion; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From 52ee34794ba21975d7d283ade5a0848b82962702 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Tue, 13 Jan 2015 17:45:50 +0200 Subject: [PATCH 360/613] weighted quickunion jsdoc --- src/sets/quickfind.js | 7 ++- src/sets/quickunion.js | 16 +++---- src/sets/weightquickunion.js | 83 ++++++++++++++++++++++-------------- 3 files changed, 61 insertions(+), 45 deletions(-) diff --git a/src/sets/quickfind.js b/src/sets/quickfind.js index 40f97df3..15ab2fa7 100644 --- a/src/sets/quickfind.js +++ b/src/sets/quickfind.js @@ -25,7 +25,7 @@ /** * Initialization.

- * Complexity: O(N). + * Time complexity: O(N). * * @public * @constructor @@ -40,7 +40,7 @@ /** * Connects two nodes - p and q.

- * Complexity: O(N). + * Time complexity: O(N). * * @public * @method @@ -60,7 +60,7 @@ /** * Checks whether two nodes are connected.

- * Complexity: O(1). + * Time complexity: O(1). * * @public * @method @@ -71,5 +71,4 @@ exports.QuickFind.prototype.connected = function (p, q) { return this._ids[p] === this._ids[q]; }; - })(typeof window === 'undefined' ? module.exports : window); diff --git a/src/sets/quickunion.js b/src/sets/quickunion.js index bbc8bcaa..21f6b8d8 100644 --- a/src/sets/quickunion.js +++ b/src/sets/quickunion.js @@ -27,7 +27,7 @@ /** * Initialization.

- * Complexity: O(N). + * Time complexity: O(N). * * @public * @constructor @@ -42,7 +42,7 @@ /** * Finds the root of given node.

- * Complexity: O(N). + * Time complexity: O(N). * @private * @param {Number} i The given node. * @return {Number} Root of the given node. @@ -56,7 +56,7 @@ /** * Connects two nodes - p and q.

- * Complexity: O(N). + * Time complexity: O(N). * * @public * @method @@ -70,12 +70,12 @@ }; /** - * Checks whether two nodes are connected. - * Complexity O(n). + * Checks whether two nodes are connected.

+ * Time complexity: O(N). * - * @param {number} p The first node. - * @param {number} q The second node. - * @return {boolean} True/false depending on whether the nodes are connected. + * @param {Number} p The first node. + * @param {Number} q The second node. + * @return {Boolean} True/false depending on whether the nodes are connected. */ exports.QuickUnion.prototype.connected = function (p, q) { return this._root(p) === this._root(q); diff --git a/src/sets/weightquickunion.js b/src/sets/weightquickunion.js index d20879fe..f541320c 100644 --- a/src/sets/weightquickunion.js +++ b/src/sets/weightquickunion.js @@ -1,30 +1,55 @@ +/** + * Keeps track of a set of elements partitioned into a + * number of disjoint (nonoverlapping) subsets. + * Allows to check whether the path between two nodes exists. + * + * @example + * + * var QuickUnion = require('path-to-algorithms/' + + * 'src/sets/weightquickunion').QuickUnion; + * + * var qunion = new QuickUnion(10); + * qunion.union(0, 1); + * qunion.union(2, 1); + * qunion.union(3, 4); + * qunion.union(8, 9); + * qunion.union(4, 8); + * + * console.log(qunion.connected(0, 9)); // false + * console.log(qunion.connected(3, 9)); // true + * + * @public + * @module sets/quickunion + */ + (function (exports) { 'use strict'; /** - * Checks whether there is a path between two nodes - * Complexity of the initialization O(n). + * Initialization.

+ * Time complexity: O(N). * + * @public * @constructor - * @param {number} n The nodes count + * @param {Numner} size Count of the nodes. */ - function QuickUnion(n) { + exports.QuickUnion = function (n) { this._ids = []; this._size = []; for (var i = 0; i < n; i += 1) { this._ids[i] = i; this._size[i] = 1; } - } + }; /** - * Finds the root of given node. - * The complexity is around O(logn) - * - * @param {number} i The given node - * @return {number} The root of the node + * Finds the root of given node.

+ * Time complexity: O(log N). + * @private + * @param {Number} i The given node. + * @return {Number} Root of the given node. */ - QuickUnion.prototype._root = function (i) { + exports.QuickUnion.prototype._root = function (i) { while (i !== this._ids[i]) { // this._ids[i] = this._ids[this._ids[i]]; //enables the path compression i = this._ids[i]; @@ -33,25 +58,27 @@ }; /** - * Checks whether two nodes are connected. - * Complexity O(logn) + * Checks whether two nodes are connected.

+ * Time complexity: O(log N). * - * @param {number} p The first node - * @param {number} q The second node - * @return {boolean} True/false depending on whether the nodes are connected + * @param {Number} p The first node. + * @param {Number} q The second node. + * @return {Boolean} True/false depending on whether the nodes are connected. */ - QuickUnion.prototype.connected = function (p, q) { + exports.QuickUnion.prototype.connected = function (p, q) { return this._root(p) === this._root(q); }; /** - * Unions two nodes. - * Complexity O(logn) + * Connects two nodes - p and q.

+ * Time complexity: O(log N). * - * @param {number} p The first node - * @param {number} q The second node + * @public + * @method + * @param {Number} p The first node. + * @param {Number} q The second node. */ - QuickUnion.prototype.union = function (p, q) { + exports.QuickUnion.prototype.union = function (p, q) { var pf = this._root(p); var qf = this._root(q); if (pf === qf) { @@ -68,14 +95,4 @@ } }; - //var union = new QuickUnion(10); - //union.union(0, 1); - //union.union(2, 1); - //union.union(3, 4); - //union.union(8, 9); - //union.union(4, 8); - // - //console.log(union.connected(0, 9)); //expected false - //console.log(union.connected(3, 9)); //expected true - exports.QuickUnion = QuickUnion; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From cafe3575a5478f24ae92d9b2fa27128be15ea5d6 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Tue, 13 Jan 2015 17:46:49 +0200 Subject: [PATCH 361/613] fix weightedquickunion jsdoc --- src/sets/weightquickunion.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sets/weightquickunion.js b/src/sets/weightquickunion.js index f541320c..765fcb85 100644 --- a/src/sets/weightquickunion.js +++ b/src/sets/weightquickunion.js @@ -19,7 +19,7 @@ * console.log(qunion.connected(3, 9)); // true * * @public - * @module sets/quickunion + * @module sets/weightquickunion */ (function (exports) { From 3e51f6be44cfbb258652909ce5e134cd61792e65 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 14 Jan 2015 11:22:41 +0200 Subject: [PATCH 362/613] Fix issue in KMP --- src/searching/knuth-morris-pratt.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/searching/knuth-morris-pratt.js b/src/searching/knuth-morris-pratt.js index c29be4c1..4a11164a 100644 --- a/src/searching/knuth-morris-pratt.js +++ b/src/searching/knuth-morris-pratt.js @@ -58,7 +58,7 @@ return i - j; } if (i < str.length && str[i] !== substr[j]) { - if (table[j - 1] !== 0) { + if (j > 0 && table[j - 1] !== 0) { j = table[j - 1]; } else { i += 1; @@ -73,3 +73,5 @@ exports.kmp = kmp; })(typeof window === 'undefined' ? module.exports : window); + +exports.kmp('hello', 'll'); From aa749bf7e37e54f9120138073b38d3f1f14713fb Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 14 Jan 2015 11:23:49 +0200 Subject: [PATCH 363/613] Remove multiple line breaks --- src/searching/knuth-morris-pratt.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/searching/knuth-morris-pratt.js b/src/searching/knuth-morris-pratt.js index 4a11164a..1b0826bd 100644 --- a/src/searching/knuth-morris-pratt.js +++ b/src/searching/knuth-morris-pratt.js @@ -73,5 +73,3 @@ exports.kmp = kmp; })(typeof window === 'undefined' ? module.exports : window); - -exports.kmp('hello', 'll'); From e817fbc02689f94f800ffd2ed22c6681fb4ada99 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 14 Jan 2015 11:30:03 +0200 Subject: [PATCH 364/613] Add case when the searching string is the string we're looking for --- src/searching/knuth-morris-pratt.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/searching/knuth-morris-pratt.js b/src/searching/knuth-morris-pratt.js index 1b0826bd..7acf0ab2 100644 --- a/src/searching/knuth-morris-pratt.js +++ b/src/searching/knuth-morris-pratt.js @@ -46,6 +46,9 @@ * time, or -1 if it never occurs. */ function indexOf(str, substr) { + if (str === substr) { + return 0; + } var table = builtKMPTable(substr); var i = 0; var j = 0; From 401f3f1ea0b2f6c006fe112472ef47cc49c1443f Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 14 Jan 2015 11:38:46 +0200 Subject: [PATCH 365/613] Fix bug in KMP --- src/searching/knuth-morris-pratt.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/searching/knuth-morris-pratt.js b/src/searching/knuth-morris-pratt.js index 7acf0ab2..b4aeb85b 100644 --- a/src/searching/knuth-morris-pratt.js +++ b/src/searching/knuth-morris-pratt.js @@ -65,6 +65,7 @@ j = table[j - 1]; } else { i += 1; + j = 0; } } } From 8cab588448a0bd5380a8f0520b255ee5cf1fc06e Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 14 Jan 2015 11:39:12 +0200 Subject: [PATCH 366/613] Add tests for KMP --- test/searching/knuth-morris-pratt.spec.js | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/searching/knuth-morris-pratt.spec.js diff --git a/test/searching/knuth-morris-pratt.spec.js b/test/searching/knuth-morris-pratt.spec.js new file mode 100644 index 00000000..b12b7a0e --- /dev/null +++ b/test/searching/knuth-morris-pratt.spec.js @@ -0,0 +1,25 @@ +var indexOf = require('../../src/searching/knuth-morris-pratt').kmp; + +describe('The string searching algorithm of Knuth-Morris-Pratt', function () { + 'use strict'; + + it('should find the empty string in any string', function () { + expect(indexOf('', '')).toBe(0); + expect(indexOf('foo', '')).toBe(0); + }); + + it('should return negative value for patterns, which are ' + + 'not part of the string', function () { + expect(indexOf('foo', 'bar') < 0).toBeTruthy(); + expect(indexOf('f', 'foobar') < 0).toBeTruthy(); + expect(indexOf('foobar', 'fobar') < 0).toBeTruthy(); + }); + + it('should return the first index of the matching pattern', function () { + expect(indexOf('foo', 'f')).toBe(0); + expect(indexOf('foo', 'oo')).toBe(1); + expect(indexOf('foo', 'o')).toBe(1); + expect(indexOf('foobar', 'foo')).toBe(0); + expect(indexOf('foobar', 'bar')).toBe(3); + }); +}); From f7afa7441f3683abf1440cc4b953285b79984eb5 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 00:51:49 +0200 Subject: [PATCH 367/613] add Fisher-Yates jsdoc --- doc-config.json | 3 ++- src/shuffle/fisheryates.js | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/doc-config.json b/doc-config.json index db96100b..d6fe3bef 100644 --- a/doc-config.json +++ b/doc-config.json @@ -13,7 +13,8 @@ "./src/primes/", "./src/others/", "./src/searching/", - "./src/sets/" + "./src/sets/", + "./src/shuffle/" ], "includePattern": ".+\\.js(doc)?$", "excludePattern": "docs" diff --git a/src/shuffle/fisheryates.js b/src/shuffle/fisheryates.js index 08319d67..c4e5bd85 100644 --- a/src/shuffle/fisheryates.js +++ b/src/shuffle/fisheryates.js @@ -1,12 +1,20 @@ (function (exports) { + 'use strict'; /** * The shuffling algorithm of - * Fisher-Yates. Complexity O(n) + * Fisher-Yates.

+ * Time complexity: O(N). * - * @param {array} array The array which should be shuffled - * @return {array} The shuffled array. + * @example + * var shuffle = require('path-to-algorithms/src/' + + * 'shuffle/fisheryates').shuffle; + * console.log(shuffle([1, 2, 3, 4, 5])); // shuffled array + * @public + * @module shuffle/fisheryates + * @param {Array} array Array which should be shuffled. + * @return {Array} Shuffled array. */ function shuffle(array) { var size = array.length; @@ -23,4 +31,4 @@ exports.shuffle = shuffle; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From 15ded21bea6f857ecf0ac18658df448d6a32bcda Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 00:56:59 +0200 Subject: [PATCH 368/613] add richarddurstenfeld jsdoc --- src/shuffle/fisheryates.js | 1 + src/shuffle/richarddurstenfeld.js | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/shuffle/fisheryates.js b/src/shuffle/fisheryates.js index c4e5bd85..75721e04 100644 --- a/src/shuffle/fisheryates.js +++ b/src/shuffle/fisheryates.js @@ -11,6 +11,7 @@ * var shuffle = require('path-to-algorithms/src/' + * 'shuffle/fisheryates').shuffle; * console.log(shuffle([1, 2, 3, 4, 5])); // shuffled array + * * @public * @module shuffle/fisheryates * @param {Array} array Array which should be shuffled. diff --git a/src/shuffle/richarddurstenfeld.js b/src/shuffle/richarddurstenfeld.js index 301f45ef..789d8517 100644 --- a/src/shuffle/richarddurstenfeld.js +++ b/src/shuffle/richarddurstenfeld.js @@ -1,17 +1,22 @@ (function (exports) { + 'use strict'; /** * Shuffle of an array elements. * This algorithm is modified version of Fisher-Yates shuffle - * algorithm and is introduced by Richard Durstenfeld. - */ - - /** - * Shuffles an array. Complexity O(n). + * algorithm and is introduced by Richard Durstenfeld.

+ * Time complexity: O(N). + * + * @example + * var shuffle = require('path-to-algorithms/src/shuffle' + + * '/richarddurstenfeld').shuffle; + * console.log(shuffle([1, 2, 3, 4, 5])); // random shuffled * - * @param {array} array An array which should be shuffled - * @returns {array} Shuffled array + * @public + * @module shuffle/richarddurstenfeld + * @param {Array} array An array which should be shuffled. + * @return {Array} Shuffled array. */ function shuffle(array) { var arraySize = array.length - 1; From 74d1acc0db464e10ca6c68245b474a69bfba5770 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 02:31:50 +0200 Subject: [PATCH 369/613] add 3-way-quicksort jsdoc --- doc-config.json | 3 ++- src/sorting/3-way-string-quicksort.js | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/doc-config.json b/doc-config.json index d6fe3bef..bddd99b3 100644 --- a/doc-config.json +++ b/doc-config.json @@ -14,7 +14,8 @@ "./src/others/", "./src/searching/", "./src/sets/", - "./src/shuffle/" + "./src/shuffle/", + "./src/sorting/" ], "includePattern": ".+\\.js(doc)?$", "excludePattern": "docs" diff --git a/src/sorting/3-way-string-quicksort.js b/src/sorting/3-way-string-quicksort.js index b59ef57e..ff8460e4 100644 --- a/src/sorting/3-way-string-quicksort.js +++ b/src/sorting/3-way-string-quicksort.js @@ -1,10 +1,6 @@ (function (exports) { 'use strict'; - /** - * Effective inplace string sorting algorithm. - * The algorithm is NOT stable. - */ var quicksort = (function () { function charAt(str, i) { @@ -48,6 +44,21 @@ quicksort(arr, highPointer + 1, hi, d); } + /** + * Effective inplace string sorting algorithm. + * Algorithm is NOT stable. + * + * @example + * + * var sort = require('path-to-algorithms/src/sorting'+ + * '/3-way-string-quicksort').quicksort; + * console.log(sort(['bb', 'aa', 'cc'])); // [ 'aa', 'bb', 'cc' ] + * + * @public + * @module sorting/3-way-string-quicksort + * @param arr {Array} array which should be sorted. + * @return {Array} Sorted array. + */ return function sort(arr) { quicksort(arr, 0, arr.length - 1, 0); return arr; @@ -56,4 +67,4 @@ exports.quicksort = quicksort; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From ed4ac01c0e11305e1feea2b6ead53685dc742729 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 02:53:52 +0200 Subject: [PATCH 370/613] add bucketsort jsdoc --- src/sorting/bubblesort.js | 18 ++++++++++++++---- src/sorting/bucketsort.js | 24 ++++++++++++++---------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/sorting/bubblesort.js b/src/sorting/bubblesort.js index b2668d27..7b5440ee 100644 --- a/src/sorting/bubblesort.js +++ b/src/sorting/bubblesort.js @@ -6,11 +6,21 @@ } /** - * The bubblesort algorithm. Complexity O(n^2). + * Bubble sort algorithm.

+ * Complexity: O(N^2). + * + * @example + * var sort = require('path-to-algorithms/src/' + + * 'sorting/bubblesort').bubbleSort; + * console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ] * * @public - * @param {array} array Input array - * @returns {array} array Sorted array + * @module sorting/bubblesort + * @param {Array} array Input array. + * @param {Function} cmp Optional. A function that defines an + * alternative sort order. The function should return a negative, + * zero, or positive value, depending on the arguments. + * @return {Array} Sorted array. */ function bubbleSort(array, cmp) { cmp = cmp || comparator; @@ -29,4 +39,4 @@ exports.bubbleSort = bubbleSort; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); diff --git a/src/sorting/bucketsort.js b/src/sorting/bucketsort.js index 9c69e74b..73dab2f1 100644 --- a/src/sorting/bucketsort.js +++ b/src/sorting/bucketsort.js @@ -1,12 +1,7 @@ (function (exports) { + 'use strict'; - /** - * Bucket sort. This algorithm has complexity O(n) in case the - * data is with uniform distribution. - * - * @public - */ var bucketSort = (function () { /** @@ -90,11 +85,20 @@ } /** - * Sorts given array with bucketsort + * Sorts given array with bucketsort.

+ * Time complexity: O(N) in case the + * data is with uniform distribution. + * + * @example + * + * var sort = require('path-to-algorithms/src/'+ + * 'sorting/bucketsort').bucketSort; + * console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ] * * @public - * @param {array} array Input array which should be sorted - * @returns {array} Sorted array + * @module sorting/bucketsort + * @param {Array} array Input array which should be sorted. + * @return {Array} Sorted array. */ return function (array) { var buckets = createBuckets(array); @@ -105,4 +109,4 @@ exports.bucketSort = bucketSort; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From 3ab98146f252776ba5e38b155ecb59f1d391425f Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 15:05:00 +0200 Subject: [PATCH 371/613] add countingsort jsdoc --- src/sorting/countingsort.js | 44 +++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/sorting/countingsort.js b/src/sorting/countingsort.js index 809c305f..fc8f809d 100644 --- a/src/sorting/countingsort.js +++ b/src/sorting/countingsort.js @@ -1,20 +1,14 @@ (function (exports) { 'use strict'; - /** - * Counting sort algorithm. It's with complexity O(n) but it's - * correct only for array of integers. - * - * @public - */ var countingSort = (function () { /** - * Gets the count of the elements into the input array + * Gets the count of the elements into the input array. * * @private - * @param {array} array The input array - * @returns {array} count The count of each element from the input array + * @param {Array} array The input array. + * @return {Array} The count of each element from the input array. */ function getCount(array) { var count = []; @@ -27,12 +21,12 @@ } /** - * Gets the count of the elements which are less than a given + * Gets the count of the elements which are less than a given. * * @private - * @param {array} array The input array - * @returns {array} less The count of the elements which - * are less than each element from the input + * @param {Array} array The input array. + * @return {Array} less The count of the elements which. + * are less than each element from the input. */ function getLessCount(array) { var less = []; @@ -46,12 +40,12 @@ } /** - * Sorts the input array + * Sorts the input array. * * @private - * @param {array} array Input which should be sorted - * @param {array} less Count of the less elements for each element - * @returns {array} result The sorted input + * @param {Array} array Input which should be sorted. + * @param {Array} less Count of the less elements for each element. + * @return {Array} The sorted input. */ function sort(array, less) { var result = []; @@ -71,11 +65,19 @@ } /** - * Sorts a given array + * Counting sort algorithm. It's correct only + * for array of integers.

+ * Time complexity: O(N). + * + * @example + * var sort = require('path-to-algorithms/src/' + + * 'sorting/countingsort').countingSort; + * console.log(sort([2, 5, 1, 3, 4])); // [ 1, 2, 3, 4, 5 ] * * @public - * @param {array} array Array which should be sorted - * @returns {array} array Sorted array + * @module sorting/countingsort + * @param {Array} array Array which should be sorted. + * @return {Array} Sorted array. */ return function (array) { var less = getLessCount(getCount(array)); @@ -85,4 +87,4 @@ exports.countingSort = countingSort; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From 756acc393511a80b9b037aaecba6709ff38d9631 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 15:21:18 +0200 Subject: [PATCH 372/613] add heapsort jsdoc --- src/sorting/heapsort.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/sorting/heapsort.js b/src/sorting/heapsort.js index 1aa1e16d..7f6d1021 100644 --- a/src/sorting/heapsort.js +++ b/src/sorting/heapsort.js @@ -5,20 +5,15 @@ return a - b; } - /** - * The heapsort algorithm. It's complexity is O(nlog n). - * - * @public - */ var heapSort = (function () { /** * Finds the correct place of given element in given max heap. * * @private - * @param {array} array Array - * @param {number} index Index of the element which palce in - * the max heap should be found. + * @param {Array} array Array. + * @param {Number} index Index of the element which palce in + * the max heap should be found. */ function heapify(array, index, heapSize, cmp) { var left = 2 * index + 1; @@ -45,8 +40,8 @@ * Builds max heap from given array. * * @private - * @param {array} array Array which should be turned into max heap - * @returns {array} array Array turned into max heap + * @param {Array} array Array which should be turned into max heap. + * @return {Array} array Array turned into max heap. */ function buildMaxHeap(array, cmp) { for (var i = Math.floor(array.length / 2); i >= 0; i -= 1) { @@ -56,11 +51,20 @@ } /** - * Heapsort. Turns the input array into max heap and after that sorts it. + * Heapsort. Turns the input array into max + * heap and after that sorts it.

+ * Time complexity: O(N log N). + * + * @example + * + * var sort = require('path-to-algorithms/src' + + * '/sorting/heapsort').heapSort; + * console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ] * * @public - * @param {array} array Input array - * @returns {array} array Sorted array + * @module sorting/heapsort + * @param {Array} array Input array. + * @return {Array} Sorted array. */ return function (array, cmp) { cmp = cmp || comparator; @@ -80,4 +84,4 @@ exports.heapSort = heapSort; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From 0d143db55214e35624a948cbed3dc551bc9eab90 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 15:37:53 +0200 Subject: [PATCH 373/613] fix heapsort jsdoc --- src/sorting/heapsort.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sorting/heapsort.js b/src/sorting/heapsort.js index 7f6d1021..b661a827 100644 --- a/src/sorting/heapsort.js +++ b/src/sorting/heapsort.js @@ -64,6 +64,9 @@ * @public * @module sorting/heapsort * @param {Array} array Input array. + * @param {Function} cmp Optional. A function that defines an + * alternative sort order. The function should return a negative, + * zero, or positive value, depending on the arguments. * @return {Array} Sorted array. */ return function (array, cmp) { From ef68c0ad7a54c9f5fa252e201713868685deae92 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 15:42:29 +0200 Subject: [PATCH 374/613] add insertion-binary-sort jsdoc --- src/sorting/insertion-binary-sort.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/sorting/insertion-binary-sort.js b/src/sorting/insertion-binary-sort.js index f76c850a..a952b15c 100644 --- a/src/sorting/insertion-binary-sort.js +++ b/src/sorting/insertion-binary-sort.js @@ -6,14 +6,25 @@ } /** - * Modified version of insertionsort. It uses binary search for finding + * Modified version of insertion sort. It uses binary search for finding * where the current element should be inserted. It's correct because * the binary search looks just in the first part of the array - * which is actually sorted. It's complexity is O(n^2) + * which is actually sorted.

+ * Time complexity: O(N^2). + * + * @example + * + * var sort = require('path-to-algorithms/src' + + * '/sorting/insertion-binary-sort').insertionBinarySort; + * console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ] * * @public - * @param {array} array Input array - * @param {array} array Sorted array + * @module sorting/insertion-binary-sort + * @param {Array} array Input array. + * @param {Function} cmp Optional. A function that defines an + * alternative sort order. The function should return a negative, + * zero, or positive value, depending on the arguments. + * @return {Array} Sorted array. */ function insertionBinarySort(array, cmp) { cmp = cmp || comparator; From e4589d7b4b698b9a3b51b5d6e2d8221cc8a14e4f Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 16:07:35 +0200 Subject: [PATCH 375/613] insertionsort jsdoc --- src/sorting/insertionsort.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/sorting/insertionsort.js b/src/sorting/insertionsort.js index 3e1ba70f..90f5ea3a 100644 --- a/src/sorting/insertionsort.js +++ b/src/sorting/insertionsort.js @@ -6,11 +6,22 @@ } /** - * Insertionsort algorithm. It's complexity is O(n^2). + * Insertionsort algorithm. + * Time complexity: O(N^2). + * + * @example + * + * var sort = require('path-to-algorithms/src' + + * '/sorting/insertion-sort').insertionSort; + * console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ] * * @public - * @param {array} array Input array - * @returns {array} array Sorted array + * @module sorting/insertionsort + * @param {Array} array Input array. + * @param {Function} cmp Optional. A function that defines an + * alternative sort order. The function should return a negative, + * zero, or positive value, depending on the arguments. + * @return {Array} Sorted array. */ function insertionSort(array, cmp) { cmp = cmp || compare; From 29051faebdcb690798f274be489a8f6da1ffaf7e Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 16:08:01 +0200 Subject: [PATCH 376/613] insertionsort jsdoc dix --- src/sorting/insertionsort.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sorting/insertionsort.js b/src/sorting/insertionsort.js index 90f5ea3a..36f2a3f2 100644 --- a/src/sorting/insertionsort.js +++ b/src/sorting/insertionsort.js @@ -6,7 +6,7 @@ } /** - * Insertionsort algorithm. + * Insertionsort algorithm.

* Time complexity: O(N^2). * * @example From f79e88fba22cf1c5350c6f0f9c5a0259b58f2b51 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 17:46:31 +0200 Subject: [PATCH 377/613] lsd and msd jsdoc --- src/sorting/lsd.js | 17 ++++++++++++----- src/sorting/msd.js | 20 +++++++++++++------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/sorting/lsd.js b/src/sorting/lsd.js index 996ed736..7dff4401 100644 --- a/src/sorting/lsd.js +++ b/src/sorting/lsd.js @@ -2,13 +2,20 @@ 'use strict'; /** - * Sorts strings lexicographically. - * Complexity O(n*m) + * Sorts strings lexicographically.

+ * Time complexity: O(N*M) for N keys which have M or fewer digits. + * + * @example + * + * var sort = require('../src/sorting/lsd').lsd; + * // [ 'aab', 'aaa', 'acc', 'bbb', 'bcc' ] + * console.log(sort(['aab', 'bbb', 'aaa', 'acc', 'bcc'])); * * @public - * @param {Array} arr Input array - * @param {Number} letterIdx Index to start sorting from - * @returns {Array} Sorted array + * @module sorting/lsd + * @param {Array} arr Array which should be sorted. + * @param {Number} letterIdx Optional. Index to start sorting from. + * @return {Array} Sorted array. */ function lsd(arr, letterIdx) { var temp; diff --git a/src/sorting/msd.js b/src/sorting/msd.js index 46dfcecd..aa6ee4ee 100644 --- a/src/sorting/msd.js +++ b/src/sorting/msd.js @@ -37,16 +37,22 @@ /** * Sorts given array lexicographically. - * The algorithms knows how to treat - * differently length strings. - * The algorithm is stable. + * Algorithms knows how to treat + * differently length strings.

+ * Algorithm is stable. + * Time complexity: O(N*M) for N keys which have M or fewer digits. * - * Complexity O(n*m) + * @example + * + * var sort = require('../src/sorting/msd').msd; + * // [ 'aab', 'aaa', 'acc', 'bbb', 'bcc' ] + * console.log(sort(['aab', 'bbb', 'aaa', 'acc', 'bcc'])); * * @public - * @param {Array} arr The array, which needs to be sorted - * @param {Number} d The digit from which the sorting should start - * @return {Array} The sorted array + * @module sorting/msd + * @param {Array} arr Array which should be sorted. + * @param {Number} d Digit from which sorting should start. + * @return {Array} Sorted array. */ function msd(arr, d) { From 43b6652beb487f5846035516ba7a46fd373d4ece Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 17:47:23 +0200 Subject: [PATCH 378/613] fix msd jsdoc --- src/sorting/msd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sorting/msd.js b/src/sorting/msd.js index aa6ee4ee..3f87e250 100644 --- a/src/sorting/msd.js +++ b/src/sorting/msd.js @@ -51,7 +51,7 @@ * @public * @module sorting/msd * @param {Array} arr Array which should be sorted. - * @param {Number} d Digit from which sorting should start. + * @param {Number} d Optional. Digit from which sorting should start. * @return {Array} Sorted array. */ From 0728085c71f23b8615908ee7a7117e1913381786 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 17:54:04 +0200 Subject: [PATCH 379/613] add mergesort jsdoc --- src/sorting/insertion-binary-sort.js | 2 +- src/sorting/insertionsort.js | 2 +- src/sorting/lsd.js | 2 +- src/sorting/mergesort.js | 19 +++++++++++++++---- src/sorting/msd.js | 3 +-- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/sorting/insertion-binary-sort.js b/src/sorting/insertion-binary-sort.js index a952b15c..4ee6518a 100644 --- a/src/sorting/insertion-binary-sort.js +++ b/src/sorting/insertion-binary-sort.js @@ -55,4 +55,4 @@ exports.insertionBinarySort = insertionBinarySort; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); diff --git a/src/sorting/insertionsort.js b/src/sorting/insertionsort.js index 36f2a3f2..3e5e6659 100644 --- a/src/sorting/insertionsort.js +++ b/src/sorting/insertionsort.js @@ -41,4 +41,4 @@ exports.insertionSort = insertionSort; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); diff --git a/src/sorting/lsd.js b/src/sorting/lsd.js index 7dff4401..d1445203 100644 --- a/src/sorting/lsd.js +++ b/src/sorting/lsd.js @@ -48,4 +48,4 @@ exports.lsd = lsd; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); diff --git a/src/sorting/mergesort.js b/src/sorting/mergesort.js index 7e2d18e8..20330321 100644 --- a/src/sorting/mergesort.js +++ b/src/sorting/mergesort.js @@ -75,11 +75,22 @@ } /** - * Initial call to the mergesort method + * Merge sort algorithm.

+ * Time complexity: O(N logN). + * + * @example + * + * var sort = require('path-to-algorithms/src' + + * '/sorting/mergesort').mergesortSort; + * console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ] * * @public - * @param {array} array The array which will be sorted - * @returns {array} Sorted array + * @module sorting/mergesort + * @param {Array} array Input array. + * @param {Function} cmp Optional. A function that defines an + * alternative sort order. The function should return a negative, + * zero, or positive value, depending on the arguments. + * @return {Array} Sorted array. */ return function (array, cmp) { cmp = cmp || compare; @@ -90,4 +101,4 @@ exports.mergeSort = mergeSort; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); diff --git a/src/sorting/msd.js b/src/sorting/msd.js index 3f87e250..f59e1718 100644 --- a/src/sorting/msd.js +++ b/src/sorting/msd.js @@ -54,7 +54,6 @@ * @param {Number} d Optional. Digit from which sorting should start. * @return {Array} Sorted array. */ - function msd(arr, d) { d = d || 0; sort(arr, 0, arr.length - 1, d); @@ -62,4 +61,4 @@ } exports.msd = msd; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From 115fde4cd26145ac48277207b9ca77c437fd110e Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 17:58:16 +0200 Subject: [PATCH 380/613] add quicksort-middle jsdoc --- src/sorting/mergesort.js | 2 +- src/sorting/quicksort-middle.js | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/sorting/mergesort.js b/src/sorting/mergesort.js index 20330321..73bb1160 100644 --- a/src/sorting/mergesort.js +++ b/src/sorting/mergesort.js @@ -76,7 +76,7 @@ /** * Merge sort algorithm.

- * Time complexity: O(N logN). + * Time complexity: O(N log(N)). * * @example * diff --git a/src/sorting/quicksort-middle.js b/src/sorting/quicksort-middle.js index 9a24daa5..0a16f66d 100644 --- a/src/sorting/quicksort-middle.js +++ b/src/sorting/quicksort-middle.js @@ -1,9 +1,3 @@ -/** - * Quicksort algorithm. It's with complexity O(n log(n)). - * In this version of quicksort I use the middle element of the - * array for pivot. - */ - (function (exports) { 'use strict'; @@ -72,8 +66,23 @@ } /** - * Quicksort's initial point + * Quicksort algorithm. In this version of quicksort used + * middle element of array for the pivot.

+ * Time complexity: O(N log(N)). + * + * @example + * + * var sort = require('path-to-algorithms/src' + + * '/sorting/quicksort-middle').quickSort; + * console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ] + * * @public + * @module sorting/mergesort + * @param {Array} array Input array. + * @param {Function} cmp Optional. A function that defines an + * alternative sort order. The function should return a negative, + * zero, or positive value, depending on the arguments. + * @return {Array} Sorted array. */ return function (array, cmp) { cmp = cmp || compare; @@ -85,4 +94,4 @@ exports.quickSort = quickSort; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From 2830903fe49cd9fcd71c729b98d6fae6b447d1d5 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 17:59:01 +0200 Subject: [PATCH 381/613] fix quicksort-middle jsdoc --- src/sorting/quicksort-middle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sorting/quicksort-middle.js b/src/sorting/quicksort-middle.js index 0a16f66d..b841f31b 100644 --- a/src/sorting/quicksort-middle.js +++ b/src/sorting/quicksort-middle.js @@ -77,7 +77,7 @@ * console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ] * * @public - * @module sorting/mergesort + * @module sorting/quicksort-middle * @param {Array} array Input array. * @param {Function} cmp Optional. A function that defines an * alternative sort order. The function should return a negative, From 35c0cdbd8f47639bc448735225be273e4af3d933 Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 18:08:24 +0200 Subject: [PATCH 382/613] add recurisve insertionsort jsdoc --- src/sorting/recursive-insertionsort.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/sorting/recursive-insertionsort.js b/src/sorting/recursive-insertionsort.js index 4ec51c9a..aa3c77b6 100644 --- a/src/sorting/recursive-insertionsort.js +++ b/src/sorting/recursive-insertionsort.js @@ -6,13 +6,25 @@ } /** - * Recursive version of insertionsort. Complexity O(n^2). + * Recursive version of insertion sort.

+ * Time complexity: O(N^2). + * + * @example + * + * var sort = require('path-to-algorithms/src/sorting/'+ + * 'recursive-insertionsort').recursiveInsertionSort; + * console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ] * * @public - * @param {array} array Input array - * @param {number} [max] Index of the element which place we should find - * in the current function call - */ + * @module sorting/recursive-insertionsort + * @param {Array} array Input array. + * @param {Function} cmp Optional. A function that defines an + * alternative sort order. The function should return a negative, + * zero, or positive value, depending on the arguments. + * @param {Number} max Optional. Index of the element which place + * we should find in the current function call. + * @return {Array} Sorted array. + */ function recursiveInsertionSort(array, cmp, max) { cmp = cmp || compare; if (max <= 0) { @@ -32,4 +44,4 @@ exports.recursiveInsertionSort = recursiveInsertionSort; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From 9239afacf450db6cdc8d1c0e4c4b1b5c132e3a4b Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 18:42:28 +0200 Subject: [PATCH 383/613] add selection sort jsdoc --- src/sorting/selectionsort.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/sorting/selectionsort.js b/src/sorting/selectionsort.js index 2cd83521..dab9e000 100644 --- a/src/sorting/selectionsort.js +++ b/src/sorting/selectionsort.js @@ -6,11 +6,22 @@ } /** - * Selection sort. It's complexity is O(n^2) + * Selection sort.

+ * Time complexity: O(N^2). + * + * @example + * + * var sort = require('path-to-algorithms/src/sorting/'+ + * 'selectionsort').selectionSort; + * console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ] * * @public - * @param {array} array Array to be sorted - * @return {array} The sorted array + * @module sorting/selectionsort + * @param {Array} array Input array. + * @param {Function} cmp Optional. A function that defines an + * alternative sort order. The function should return a negative, + * zero, or positive value, depending on the arguments. + * @return {Array} Sorted array. */ var selectionSort = function (array, cmp) { cmp = cmp || compare; @@ -35,4 +46,4 @@ exports.selectionSort = selectionSort; -}(typeof exports === 'undefined' ? window : exports)); +})(typeof window === 'undefined' ? module.exports : window); From 2dc73ba4608fd24dc515be07ceb9d82762bef62d Mon Sep 17 00:00:00 2001 From: AndreyGeonya Date: Thu, 15 Jan 2015 18:49:49 +0200 Subject: [PATCH 384/613] shellsort jsdoc --- src/sorting/recursive-insertionsort.js | 2 +- src/sorting/shellsort.js | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/sorting/recursive-insertionsort.js b/src/sorting/recursive-insertionsort.js index aa3c77b6..87c564c2 100644 --- a/src/sorting/recursive-insertionsort.js +++ b/src/sorting/recursive-insertionsort.js @@ -24,7 +24,7 @@ * @param {Number} max Optional. Index of the element which place * we should find in the current function call. * @return {Array} Sorted array. - */ + */ function recursiveInsertionSort(array, cmp, max) { cmp = cmp || compare; if (max <= 0) { diff --git a/src/sorting/shellsort.js b/src/sorting/shellsort.js index 6a5c82ff..b5b3d033 100644 --- a/src/sorting/shellsort.js +++ b/src/sorting/shellsort.js @@ -5,22 +5,27 @@ return a - b; } - /** - * Shellsort - * - * Shellsort uses the gaps 701, 301, 132, 57, 23, 10, 4, 1 and uses - * insertion sort to sort the sub-arrays which match for the different gaps. - */ var shellSort = (function () { var gaps = [701, 301, 132, 57, 23, 10, 4, 1]; /** - * Shellsort which uses the gaps in the lexical scope of the IIFE. + * Shellsort which uses the gaps 701, 301, 132, 57, 23, 10, 4, 1 and + * insertion sort to sort sub-arrays which match for the different gaps. + * + * @example + * + * var sort = require('path-to-algorithms/src/' + + * 'sorting/shellsort').shellSort; + * console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ] * * @public - * @param {array} array Array which should be sorted - * @return {array} Sorted array + * @module sorting/shellsort + * @param {Array} array Input array. + * @param {Function} cmp Optional. A function that defines an + * alternative sort order. The function should return a negative, + * zero, or positive value, depending on the arguments. + * @return {Array} Sorted array. */ return function (array, cmp) { cmp = cmp || compare; From 8828b848f45674dc0e6b264ce0fcedaa5805ca9c Mon Sep 17 00:00:00 2001 From: Dan Kaplun Date: Thu, 15 Jan 2015 13:48:58 -0600 Subject: [PATCH 385/613] Adds key function to binarysearch.js If an element is not found, return -x - 1 where x is the index into which the element should be inserted Closes #36 --- src/searching/binarysearch.js | 13 +++++++++---- test/searching/binarysearch.spec.js | 12 ++++++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/searching/binarysearch.js b/src/searching/binarysearch.js index 1b7ec295..d871ee56 100644 --- a/src/searching/binarysearch.js +++ b/src/searching/binarysearch.js @@ -18,22 +18,27 @@ * @param {Number} value Value of the element which index should be found. * @returns {Number} Index of the element or -1 if not found. */ - function binarySearch(array, value) { + function binarySearch(array, value, key) { + key = !key ? id : typeof key === 'string' ? get(key) : key; + value = key(value); var middle = Math.floor(array.length / 2); var left = 0; var right = array.length; while (right >= left) { - if (array[middle] === value) { + var middleValue = key(array[middle]); + if (middleValue === value) { return middle; - } else if (array[middle] > value) { + } else if (middleValue > value) { right = middle - 1; } else { left = middle + 1; } middle = Math.floor((left + right) / 2); } - return -1; + return -middle - 1; } + function id (val) { return val; } + function get (key) { return function (val) { return val[key]; }; } exports.binarySearch = binarySearch; diff --git a/test/searching/binarysearch.spec.js b/test/searching/binarysearch.spec.js index 13777dd7..ef12ea45 100644 --- a/test/searching/binarysearch.spec.js +++ b/test/searching/binarysearch.spec.js @@ -18,11 +18,19 @@ describe('Binary search', function () { expect(binarySearch([1, 8], 8)).toBe(1); }); - it('should return -1 for missing elements', function () { - expect(binarySearch([1, 2, 3], 4)).toBe(-1); + it('should return a negative number for missing elements', function () { + expect(binarySearch([1, 2, 3], 4)).toBeLessThan(0); }); it('should work with empty arrays', function () { expect(binarySearch([], 4)).toBe(-1); }); + + it('should work with a key string', function () { + expect(binarySearch([{ x: 1 }, { x: 2 }, { x: 3 }], { x: 2 }, 'x')).toBe(1); + }); + + it('should work with a key function', function () { + expect(binarySearch([{ x: 1 }, { x: 2 }, { x: 3 }], { x: 2 }, function (o) { return o.x; })).toBe(1); + }); }); From 779c7ec1525e750e50883bd3e1253df983067b20 Mon Sep 17 00:00:00 2001 From: Dan Kaplun Date: Sun, 18 Jan 2015 14:05:29 -0600 Subject: [PATCH 386/613] Refactors src/sorting/mergesort.js Adds optional `start` and `end` parameters to `mergeSort` Exposes `mergeSort.merge` Updates documentation --- src/sorting/mergesort.js | 151 +++++++++++++++++---------------------- 1 file changed, 64 insertions(+), 87 deletions(-) diff --git a/src/sorting/mergesort.js b/src/sorting/mergesort.js index 73bb1160..fc4e60c1 100644 --- a/src/sorting/mergesort.js +++ b/src/sorting/mergesort.js @@ -1,104 +1,81 @@ (function (exports) { 'use strict'; - var mergeSort = (function () { + function compare(a, b) { + return a - b; + } - function compare(a, b) { - return a - b; + /** + * Mergesort method which is recursively called for sorting the input array. + * + * @public + * @param {array} array The array which should be sorted + * @param {Function} cmp Compares two items in an array + * @param {number} start Left side of the subarray + * @param {number} end Right side of the subarray + * @returns {array} Array with sorted subarray + */ + function mergeSort(array, cmp, start, end) { + cmp = cmp || compare; + start = start || 0; + end = end || array.length; + if (Math.abs(end - start) <= 1) { + return []; } + var middle = Math.ceil((start + end) / 2); - /** - * Mergesort method which is recursively called for sorting the input array. - * - * @private - * @param {array} array The array which should be sorted - * @param {number} start Left side of the subarray - * @param {number} end Right side of the subarray - * @returns {array} Array with sorted subarray - */ - function mergesort(array, start, end, cmp) { - if (Math.abs(end - start) <= 1) { - return []; - } - var middle = Math.ceil((start + end) / 2); - - mergesort(array, start, middle, cmp); - mergesort(array, middle, end, cmp); + mergeSort(array, cmp, start, middle); + mergeSort(array, cmp, middle, end); - return merge(array, start, middle, end, cmp); - } + return mergeSort.merge(array, cmp, start, middle, end); + } - /** - * Devides and sort merges two subarrays of given array - * - * @private - * @param {array} array The array which subarrays should be sorted - * @param {number} start The start of the first subarray. - * This subarray is with end middle - 1. - * @param {number} middle The start of the second array - * @param {number} end end - 1 is the end of the second array - * @returns {array} The array with sorted subarray - */ - function merge(array, start, middle, end, cmp) { - var left = []; - var right = []; - var leftSize = middle - start; - var rightSize = end - middle; - var maxSize = Math.max(leftSize, rightSize); - var size = end - start; - var i; + /** + * Devides and sort merges two subarrays of given array + * + * @public + * @param {array} array The array which subarrays should be sorted + * @param {number} start The start of the first subarray. + * This subarray is with end middle - 1. + * @param {number} middle The start of the second array + * @param {number} end end - 1 is the end of the second array + * @returns {array} The array with sorted subarray + */ + mergeSort.merge = function (array, cmp, start, middle, end) { + var left = []; + var right = []; + var leftSize = middle - start; + var rightSize = end - middle; + var maxSize = Math.max(leftSize, rightSize); + var size = end - start; + var i; - for (i = 0; i < maxSize; i += 1) { - if (i < leftSize) { - left[i] = array[start + i]; - } - if (i < rightSize) { - right[i] = array[middle + i]; - } + for (i = 0; i < maxSize; i += 1) { + if (i < leftSize) { + left[i] = array[start + i]; } - i = 0; - while (i < size) { - if (left.length && right.length) { - if (cmp(left[0], right[0]) > 0) { - array[start + i] = right.shift(); - } else { - array[start + i] = left.shift(); - } - } else if (left.length) { - array[start + i] = left.shift(); - } else { + if (i < rightSize) { + right[i] = array[middle + i]; + } + } + i = 0; + while (i < size) { + if (left.length && right.length) { + if (cmp(left[0], right[0]) > 0) { array[start + i] = right.shift(); + } else { + array[start + i] = left.shift(); } - i += 1; + } else if (left.length) { + array[start + i] = left.shift(); + } else { + array[start + i] = right.shift(); } - return array; + i += 1; } - - /** - * Merge sort algorithm.

- * Time complexity: O(N log(N)). - * - * @example - * - * var sort = require('path-to-algorithms/src' + - * '/sorting/mergesort').mergesortSort; - * console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ] - * - * @public - * @module sorting/mergesort - * @param {Array} array Input array. - * @param {Function} cmp Optional. A function that defines an - * alternative sort order. The function should return a negative, - * zero, or positive value, depending on the arguments. - * @return {Array} Sorted array. - */ - return function (array, cmp) { - cmp = cmp || compare; - return mergesort(array, 0, array.length, cmp); - }; - - }()); + return array; + }; exports.mergeSort = mergeSort; -})(typeof window === 'undefined' ? module.exports : window); +}(typeof exports === 'undefined' ? window : exports)); From 2bbc4d11fe6a83346af242d434f99df923adb845 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 19 Jan 2015 09:10:17 +0200 Subject: [PATCH 387/613] Update readme --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 3f128d67..39f7ba74 100644 --- a/readme.md +++ b/readme.md @@ -71,7 +71,7 @@ If the build is not successful fix your code in order the tests and jshint valid ## Contributors -[![mgechev](https://avatars.githubusercontent.com/u/455023?v=3&s=117)](https://github.com/mgechev)[![AndreyGeonya](https://avatars.githubusercontent.com/u/773648?v=3&s=117)](https://github.com/AndreyGeonya)[![pvoznenko](https://avatars.githubusercontent.com/u/1098414?v=3&s=117)](https://github.com/pvoznenko)[![Microfed](https://avatars.githubusercontent.com/u/613179?v=3&s=117)](https://github.com/Microfed)[![contra](https://avatars.githubusercontent.com/u/425716?v=3&s=117)](https://github.com/contra) +[mgechev](https://github.com/mgechev)[AndreyGeonya](https://github.com/AndreyGeonya)[pvoznenko](https://github.com/pvoznenko)[Microfed](https://github.com/Microfed)[secrettriangle](https://github.com/secrettriangle)[contra](https://github.com/contra) ## License From 71459b3891099a1f1c1067fc9e7754fe7e2914a9 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 19 Jan 2015 09:54:15 +0200 Subject: [PATCH 388/613] Update gulpfile according to jscs --- gulpfile.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index e84fdf36..57841253 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,10 +1,10 @@ 'use strict'; -var gulp = require('gulp'), - shell = require('gulp-shell'), - jshint = require('gulp-jshint'), - jasmine = require('gulp-jasmine'), - stylish = require('jshint-stylish'), - jscs = require('gulp-jscs'); +var gulp = require('gulp'); +var shell = require('gulp-shell'); +var jshint = require('gulp-jshint'); +var jasmine = require('gulp-jasmine'); +var stylish = require('jshint-stylish'); +var jscs = require('gulp-jscs'); gulp.task('jsdoc', shell.task([ './node_modules/.bin/jsdoc -c ./doc-config.json' @@ -22,7 +22,6 @@ gulp.task('test', function () { .pipe(jasmine()); }); - gulp.task('jscs', function () { return gulp.src(['src/**/*.js', 'test/**/*.js']) .pipe(jscs()); From 83250d7a491bec7992c23cf040099f39b4d7c1a6 Mon Sep 17 00:00:00 2001 From: Dan Kaplun Date: Mon, 19 Jan 2015 15:24:28 -0600 Subject: [PATCH 389/613] Fixes jsdoc for mergesort Closes #40 --- src/sorting/mergesort.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sorting/mergesort.js b/src/sorting/mergesort.js index fc4e60c1..622a81bd 100644 --- a/src/sorting/mergesort.js +++ b/src/sorting/mergesort.js @@ -1,4 +1,8 @@ (function (exports) { + /** + * Mergesort module. + * @module sorting/mergesort + */ 'use strict'; function compare(a, b) { From ac43d796187b0aea4937987017f02d050a93306b Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 20 Jan 2015 00:02:21 +0200 Subject: [PATCH 390/613] Update jsdocs --- src/sorting/mergesort.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sorting/mergesort.js b/src/sorting/mergesort.js index 622a81bd..2cf80971 100644 --- a/src/sorting/mergesort.js +++ b/src/sorting/mergesort.js @@ -13,6 +13,7 @@ * Mergesort method which is recursively called for sorting the input array. * * @public + * @module sorting/mergesort * @param {array} array The array which should be sorted * @param {Function} cmp Compares two items in an array * @param {number} start Left side of the subarray @@ -38,6 +39,7 @@ * Devides and sort merges two subarrays of given array * * @public + * @module sorting/mergesort * @param {array} array The array which subarrays should be sorted * @param {number} start The start of the first subarray. * This subarray is with end middle - 1. From 8311f6c0c53088bd51acb3a26fb5091cf87c70ff Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 20 Jan 2015 00:15:09 +0200 Subject: [PATCH 391/613] Update jsdocs --- src/sorting/mergesort.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sorting/mergesort.js b/src/sorting/mergesort.js index 2cf80971..9456bbba 100644 --- a/src/sorting/mergesort.js +++ b/src/sorting/mergesort.js @@ -1,7 +1,6 @@ (function (exports) { /** * Mergesort module. - * @module sorting/mergesort */ 'use strict'; @@ -39,7 +38,7 @@ * Devides and sort merges two subarrays of given array * * @public - * @module sorting/mergesort + * @module sorting/mergesort/merge * @param {array} array The array which subarrays should be sorted * @param {number} start The start of the first subarray. * This subarray is with end middle - 1. From a05e7d96ab444549e24b6fc30d8f848a31059186 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 20 Jan 2015 09:21:42 +0200 Subject: [PATCH 392/613] Fix #42 --- src/sorting/mergesort.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/sorting/mergesort.js b/src/sorting/mergesort.js index 9456bbba..29b4e043 100644 --- a/src/sorting/mergesort.js +++ b/src/sorting/mergesort.js @@ -13,11 +13,15 @@ * * @public * @module sorting/mergesort - * @param {array} array The array which should be sorted - * @param {Function} cmp Compares two items in an array - * @param {number} start Left side of the subarray - * @param {number} end Right side of the subarray - * @returns {array} Array with sorted subarray + * @param {Array} array The array which should be sorted. + * @param {Function} cmp Compares two items in an array. + * @param {Number} start Left side of the subarray. + * @param {Number} end Right side of the subarray. + * @returns {Array} Array with sorted subarray. + * + * @example + * var array = [2, 4, 1, 5, 6, 7]; + * mergeSort(array); // [1, 2, 4, 5, 6, 7] */ function mergeSort(array, cmp, start, end) { cmp = cmp || compare; @@ -39,12 +43,18 @@ * * @public * @module sorting/mergesort/merge - * @param {array} array The array which subarrays should be sorted - * @param {number} start The start of the first subarray. + * @param {Array} array The array which subarrays should be sorted. + * @param {Number} start The start of the first subarray. * This subarray is with end middle - 1. - * @param {number} middle The start of the second array - * @param {number} end end - 1 is the end of the second array - * @returns {array} The array with sorted subarray + * @param {Number} middle The start of the second array. + * @param {Number} end end - 1 is the end of the second array. + * @returns {Array} The array with sorted subarray. + * + * @example + * var array = [1, 2, 3, 1, 4, 5, 6] + * merge(array, function (a, b) { // [1, 1, 2, 3, 4, 5, 6] + * return a - b; + * }, 0, 4, 7); */ mergeSort.merge = function (array, cmp, start, middle, end) { var left = []; From 8e6dbce4d05191a7a89d7be2f10462142b27f701 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 20 Jan 2015 09:24:57 +0200 Subject: [PATCH 393/613] Update examples for mergesort --- src/sorting/mergesort.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sorting/mergesort.js b/src/sorting/mergesort.js index 29b4e043..8b447492 100644 --- a/src/sorting/mergesort.js +++ b/src/sorting/mergesort.js @@ -21,6 +21,8 @@ * * @example * var array = [2, 4, 1, 5, 6, 7]; + * var mergeSort = + * require('path-to-algorithms/src/sorting/mergesort').mergeSort; * mergeSort(array); // [1, 2, 4, 5, 6, 7] */ function mergeSort(array, cmp, start, end) { @@ -52,6 +54,8 @@ * * @example * var array = [1, 2, 3, 1, 4, 5, 6] + * var merge = + * require('path-to-algorithms/src/sorting/mergesort').merge; * merge(array, function (a, b) { // [1, 1, 2, 3, 4, 5, 6] * return a - b; * }, 0, 4, 7); From 1e7bc063d2c771d4bfab75faa3a1be02de78fd8d Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 20 Jan 2015 09:26:10 +0200 Subject: [PATCH 394/613] Add missing semicolon in merge example --- src/sorting/mergesort.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sorting/mergesort.js b/src/sorting/mergesort.js index 8b447492..e4e0557d 100644 --- a/src/sorting/mergesort.js +++ b/src/sorting/mergesort.js @@ -53,7 +53,7 @@ * @returns {Array} The array with sorted subarray. * * @example - * var array = [1, 2, 3, 1, 4, 5, 6] + * var array = [1, 2, 3, 1, 4, 5, 6]; * var merge = * require('path-to-algorithms/src/sorting/mergesort').merge; * merge(array, function (a, b) { // [1, 1, 2, 3, 4, 5, 6] From a8ce3592b66eedd82da4c2908cf4d77d1603f3e2 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 25 Jan 2015 18:35:54 +0200 Subject: [PATCH 395/613] Add the partitioning function's names --- src/sorting/quicksort-middle.js | 1 + src/sorting/quicksort.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sorting/quicksort-middle.js b/src/sorting/quicksort-middle.js index b841f31b..3e348765 100644 --- a/src/sorting/quicksort-middle.js +++ b/src/sorting/quicksort-middle.js @@ -19,6 +19,7 @@ * Partitions the array in two parts by the middle elements. * All elemnts which are less than the chosen one goes left from it * all which are greater goes right from it. + * Uses Hoare's partitioning algorithm. * * @param {array} array Array which should be partitioned * @param {number} left Left part of the array diff --git a/src/sorting/quicksort.js b/src/sorting/quicksort.js index 73bd41b8..8a645323 100644 --- a/src/sorting/quicksort.js +++ b/src/sorting/quicksort.js @@ -14,7 +14,7 @@ } /** - * Partitions given subarray. + * Partitions given subarray using Lomuto's partitioning algorithm. * * @private * @param {array} array Input array From 4dfd3e9d5c4591d1e1adee43d1570f5465095c9e Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 25 Jan 2015 18:38:30 +0200 Subject: [PATCH 396/613] Update contributors list --- readme.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 39f7ba74..f7c4b264 100644 --- a/readme.md +++ b/readme.md @@ -71,7 +71,9 @@ If the build is not successful fix your code in order the tests and jshint valid ## Contributors -[mgechev](https://github.com/mgechev)[AndreyGeonya](https://github.com/AndreyGeonya)[pvoznenko](https://github.com/pvoznenko)[Microfed](https://github.com/Microfed)[secrettriangle](https://github.com/secrettriangle)[contra](https://github.com/contra) +[mgechev](https://github.com/mgechev) |[AndreyGeonya](https://github.com/AndreyGeonya) |[pvoznenko](https://github.com/pvoznenko) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) | +:---: |:---: |:---: |:---: |:---: |:---: | +[mgechev](https://github.com/mgechev) |[AndreyGeonya](https://github.com/AndreyGeonya) |[pvoznenko](https://github.com/pvoznenko) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) | ## License From 20057a988ae6487b201a38906af65ea8a69febed Mon Sep 17 00:00:00 2001 From: fanixk Date: Mon, 9 Feb 2015 02:52:17 +0200 Subject: [PATCH 397/613] Added odd even sort algorithm --- src/sorting/oddeven-sort.js | 47 +++++++++++++++++++++++++++++++ test/sorting/oddeven-sort.spec.js | 18 ++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/sorting/oddeven-sort.js create mode 100644 test/sorting/oddeven-sort.spec.js diff --git a/src/sorting/oddeven-sort.js b/src/sorting/oddeven-sort.js new file mode 100644 index 00000000..2ed2a9ee --- /dev/null +++ b/src/sorting/oddeven-sort.js @@ -0,0 +1,47 @@ +(function (exports) { + 'use strict'; + + /** + * Odd even sort algorithm.

+ * Complexity: O(N^2). + * + * @example + * var sort = require('path-to-algorithms/src/' + + * 'sorting/oddeven-sort').oddEvenSort; + * console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ] + * + * @public + * @module sorting/oddeven-sort + * @param {Array} array Input array. + * @return {Array} Sorted array. + */ + function oddEvenSort(arr) { + function swap(arr, i, j) { + var temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + + var sorted = false; + while (!sorted) { + sorted = true; + for (var i = 1; i < arr.length - 1; i += 2) { + if (arr[i] > arr[i + 1]) { + swap(arr, i, i + 1); + sorted = false; + } + } + + for (i = 0; i < arr.length - 1; i += 2) { + if (arr[i] > arr[i + 1]) { + swap(arr, i, i + 1); + sorted = false; + } + } + } + return arr; + } + + exports.oddEvenSort = oddEvenSort; + +})(typeof window === 'undefined' ? module.exports : window); diff --git a/test/sorting/oddeven-sort.spec.js b/test/sorting/oddeven-sort.spec.js new file mode 100644 index 00000000..bc928ab4 --- /dev/null +++ b/test/sorting/oddeven-sort.spec.js @@ -0,0 +1,18 @@ +var oes = + require('../../src/sorting/oddeven-sort').oddEvenSort; + +describe('oddeven-sort', function () { + 'use strict'; + + it('should sort the empty array', function () { + expect(oes([])).toEqual([]); + }); + + it('should return array with the same count of elements', function () { + expect(oes([2, 3, 4]).length).toBe(3); + }); + + it('should sort the given array in ascending order', function () { + expect(oes([42, 3, 10])).toEqual([3, 10, 42]); + }); +}); From 2a2849652acbbe91470e3aaf30e9cc7a1361ef88 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 9 Feb 2015 19:08:18 +0200 Subject: [PATCH 398/613] Update the contributors list --- readme.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index f7c4b264..aa5ab073 100644 --- a/readme.md +++ b/readme.md @@ -32,14 +32,14 @@ git clone git@github.com:mgechev/javascript-algorithms.git javascript-algorithms git checkout gh-pages ``` -Now you can see `index.html` file in this folder and open it in your browser. +Now you can see `index.html` file in this folder and open it in your browser. **To update .html files with documentation** Go to the `javascript-algorithms` folder and call: ```bash -gulp jsdoc +gulp jsdoc ``` and all files in `javascript-algorithms-docs` folder will be updated. @@ -71,9 +71,13 @@ If the build is not successful fix your code in order the tests and jshint valid ## Contributors -[mgechev](https://github.com/mgechev) |[AndreyGeonya](https://github.com/AndreyGeonya) |[pvoznenko](https://github.com/pvoznenko) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[pvoznenko](https://github.com/pvoznenko) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) | :---: |:---: |:---: |:---: |:---: |:---: | -[mgechev](https://github.com/mgechev) |[AndreyGeonya](https://github.com/AndreyGeonya) |[pvoznenko](https://github.com/pvoznenko) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[pvoznenko](https://github.com/pvoznenko) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) | + +[fanixk](https://github.com/fanixk) | +:---: | +[fanixk](https://github.com/fanixk) | ## License From bcdb908412d5a20cd8935bb02fa92b59d21a9277 Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Sun, 22 Feb 2015 22:18:43 -0600 Subject: [PATCH 399/613] splay tree impl. --- src/data-structures/splay-tree.js | 559 ++++++++++++++++++++++++ test/data-structures/splay-tree.spec.js | 80 ++++ 2 files changed, 639 insertions(+) create mode 100644 src/data-structures/splay-tree.js create mode 100644 test/data-structures/splay-tree.spec.js diff --git a/src/data-structures/splay-tree.js b/src/data-structures/splay-tree.js new file mode 100644 index 00000000..6e55ea26 --- /dev/null +++ b/src/data-structures/splay-tree.js @@ -0,0 +1,559 @@ +/** + * Splay Tree. + * + * @example + * var STree = require('path-to-algorithms/src/data-structures'+ + * '/splay-tree'); + * var sTree = new STree.SplayTree(); + * sTree.insert(10); + * sTree.insert(5); + * sTree.insert(15); + * sTree.insert(7); + * sTree.insert(12); + * sTree.search(10); + * console.log(sTree._root); + * sTree.remove(10); + * console.log(sTree._root); + * sTree.search(15); + * console.log(sTree._root); + * + * @module data-structures/splay-tree + */ +(function (exports) { + 'use strict'; + + /** + * Node of the tree. + * + * @public + * @constructor + * @param {Number|String} value Value of the node. + * @param {Node} left Left sibling. + * @param {Node} right Right sibling. + * @param {Node} parent Parent of the node. + */ + exports.Node = function (value, left, right, parent) { + /** + * @member {Number|String} + */ + this.value = value; + this._left = left; + this._right = right; + this._parent = parent; + }; + + /** + * Splay tree. + * http://en.wikipedia.org/wiki/Splay_tree + * @public + * @constructor + */ + exports.SplayTree = function () { + this._root = null; + }; + + /** + * Splays a node to the root.

+ * + * @private + * @method + * @param {Node} node Node to be splayed. + */ + exports.SplayTree.prototype._splay = function(node){ + while(this._root !== node){ + var hasParent = node._parent !== null; + var hasGrandparent = (hasParent && node._parent._parent !== null); + if(hasParent && hasGrandparent){ + var isLeftChild = node._parent._left === node; + var isParentLeftChild = node._parent._parent._left === node._parent; + if((isLeftChild && isParentLeftChild) || (!isLeftChild && !isParentLeftChild)){ + node = this._zigZig(node); + }else{ + node = this._zigZag(node); + } + }else{ + node = this._zig(node); + } + } + return node; + }; + + /** + * Performs a zig-zig splay pattern

+ * + * @private + * @method + * @param {Node} node Node to be zig-zig'd. + */ + exports.SplayTree.prototype._zigZig = function(node){ + + var parent = node._parent; + var grandParent = node._parent._parent; + var greatGrandParent = grandParent._parent !== undefined ? + grandParent._parent : null; + + var orientation = (parent._right === node) ? '_right' : '_left'; + var oppositeOrientation = (orientation === '_left') ? '_right' : '_left'; + var grandParentOrientation = (greatGrandParent !== null + && greatGrandParent._left === grandParent) ? '_left' : '_right'; + + // Fix grandparent & great if it exists/not root + if(this._root === grandParent){ + this._root = node; + }else{ + greatGrandParent[grandParentOrientation] = node; + } + grandParent._parent = parent; + // Fix grandparent subtree + grandParent[orientation] = parent[oppositeOrientation]; + if(grandParent[orientation] !== null){ + grandParent[orientation]._parent = grandParent; + } + // Fix Parent + parent[oppositeOrientation] = grandParent; + parent[orientation] = node[oppositeOrientation]; + if(parent[orientation] !== null){ + parent[orientation]._parent = parent; + } + parent._parent = node; + // Fix Curr Node + node[oppositeOrientation] = parent; + if(node === this._root){ + node._parent = null; + }else if(greatGrandParent !== null){ + node._parent = greatGrandParent; + } + + return node; + }; + + /** + * Performs a zig-zag splay pattern

+ * + * @private + * @method + * @param {Node} node Node to be zig-zag'd. + */ + exports.SplayTree.prototype._zigZag = function(node){ + + var parent = node._parent; + var grandParent = parent._parent; + var greatGrandParent = grandParent._parent !== undefined ? + grandParent._parent : null; + + var orientation = (parent._left === node) ? '_left' : '_right'; + var oppositeOrientation = (orientation === '_right') ? '_left' : '_right'; + var grandParentOrientation = (greatGrandParent !== null + && greatGrandParent._left === grandParent) ? '_left' : '_right'; + + // Fix GrandParent + if(this._root === grandParent){ + this._root = node; + }else{ + greatGrandParent[grandParentOrientation] = node; + } + grandParent._parent = node; + // Fix GrandParent subtree + grandParent[oppositeOrientation] = node[orientation]; + if(grandParent[oppositeOrientation] !== null){ + grandParent[oppositeOrientation]._parent = grandParent; + } + // Fix Parent + parent[orientation] = node[oppositeOrientation]; + if(parent[orientation] !== null){ + parent[orientation]._parent = parent; + } + parent._parent = node; + // Fix Curr Node + node[orientation] = grandParent; + node[oppositeOrientation] = parent; + if(this._root === node){ + node._parent = null; + }else if(greatGrandParent !== null){ + node._parent = greatGrandParent; + } + + return node; + }; + + /** + * Performs a zig splay pattern

+ * + * @private + * @method + * @param {Node} node Node to be zig'd. + */ + exports.SplayTree.prototype._zig = function(node){ + + var parent = node._parent; + var orientation = (parent._right === node) ? '_right' : '_left'; + var oppositeOrientation = (orientation === '_right') ? '_left' : '_right'; + + if(this._root === parent){ + this._root = node; + } + // Fix Parent + parent[orientation] = node[oppositeOrientation]; + if(parent[orientation] !== null){ + parent[orientation]._parent = parent; + } + parent._parent = node; + // Fix Curr Node + node[oppositeOrientation] = parent; + node._parent = null; + + return node; + }; + + /** + * Inserts a node into the splay tree.

+ * Time complexity: O(log N) in the average case + * and amortized O(log n) in the worst case. + * + * @public + * @method + * @param {Number|String} value Node value. + * @param {Node} current Current node. + */ + exports.SplayTree.prototype.insert = function (value, current) { + if (this._root === null) { + this._root = new exports.Node(value, null, null, null); + return; + } + var insertKey; + current = current || this._root; + if (current.value > value) { + insertKey = '_left'; + } else { + insertKey = '_right'; + } + if (!current[insertKey]) { + current[insertKey] = new exports.Node(value, null, null, current); + this._splay(current[insertKey]); + } else { + this.insert(value, current[insertKey]); + } + }; + + /** + * In-order traversal from the given node. + * + * @private + * @param {Node} current Node from which to start the traversal. + * @param {Function} callback Callback which + * will be called for each traversed node. + */ + exports.SplayTree.prototype._inorder = function (current, callback) { + if (!current) { + return; + } + this._inorder(current._left, callback); + if (typeof callback === 'function') { + callback(current); + } + this._inorder(current._right, callback); + }; + + /** + * In-order traversal of the whole Splay Tree. + * + * @public + * @method + * @param {Function} callback Callback which will be + * called for each traversed node. + */ + exports.SplayTree.prototype.inorder = function (callback) { + return this._inorder(this._root, callback); + }; + + /** + * Post-order traversal from given node. + * + * @private + * @param {Node} current Node from which to start the traversal. + * @param {Function} callback Callback which will + * be called for each traversed node + */ + exports.SplayTree.prototype._postorder = function (current, callback) { + if (!current) { + return; + } + if (typeof callback === 'function') { + callback(current); + } + this._postorder(current._left, callback); + this._postorder(current._right, callback); + }; + + /** + * Post-order traversal of the whole tree. + * + * @public + * @param {Function} callback Callback which + * will be called for each traversed node. + */ + exports.SplayTree.prototype.postorder = function (callback) { + return this._postorder(this._root, callback); + }; + + /** + * Pre-order traversal of the tree from given node. + * + * @private + * @param {Node} current Node from which to start the traversal. + * @param {Function} callback Callback which + * will be called for each traversed node. + */ + exports.SplayTree.prototype._preorder = function (current, callback) { + if (!current) { + return; + } + if (typeof callback === 'function') { + callback(current); + } + this._preorder(current._left, callback); + this._preorder(current._right, callback); + }; + + /** + * Pre-order preorder traversal of the whole tree. + * + * @public + * @param {Function} callback Callback which will + * be called for each traversed node. + */ + exports.SplayTree.prototype.preorder = function (callback) { + return this._preorder(this._root, callback); + }; + + /** + * Finds a node by it's value.

+ * Average time complexity: O(log N). + * + * @public + * @param {Number|String} Value of the node which should be found. + */ + exports.SplayTree.prototype.search = function (value) { + var node = this._search(value, this._root); + return this._splay(node); + }; + + /** + * Finds a node by it's value.

+ * Average time complexity: O(log N). + * + * @public + * @param {Number|String} Value of the node which should be found. + */ + exports.SplayTree.prototype._splaylessSearch = function (value) { + return this._search(value, this._root); + }; + + /** + * Finds a node by it's value in a given sub-tree. + * Average time complexity: O(log N). + * + * @private + * @param {Number|String} Value of the node which should be found. + * @param {Node} Current node to be checked. + */ + exports.SplayTree.prototype._search = function (value, current) { + if (!current) { + return null; + } + + if (current.value === value) { + return current; + } + + if (current.value > value) { + return this._search(value, current._left); + } + + if (current.value < value) { + return this._search(value, current._right); + } + }; + + /** + * Replaces given child with new one, for given parent. + * + * @private + * @param {Node} parent Parent node. + * @param {Node} oldChild Child to be replaced. + * @param {Node} newChild Child replacement. + */ + exports.SplayTree.prototype._replaceChild = + function (parent, oldChild, newChild) { + if (!parent) { + this._root = newChild; + this._root._parent = null; + } else { + if (parent._left === oldChild) { + parent._left = newChild; + } else { + parent._right = newChild; + } + + if (newChild) { + newChild._parent = parent; + } + } + }; + + /** + * Removes node with given value from the tree.

+ * Average runtime complexity: O(log N). + * + * @public + * @param {Number|String} value Value to be removed + * @returns {Boolean} True/false depending + * on whether the given node is removed. + */ + exports.SplayTree.prototype.remove = function (value) { + var node = this._splaylessSearch(value); + if (!node) { + return false; + } + if (node._left && node._right) { + var min = this._findMin(node._right); + var temp = node.value; + + node.value = min.value; + min.value = temp; + return this.remove(min); + } else { + if(node._parent !== null){ + if (node._left) { + this._replaceChild(node._parent, node, node._left); + } else if (node._right) { + this._replaceChild(node._parent, node, node._right); + } else { + this._replaceChild(node._parent, node, null); + } + this._splay(node._parent); + }else{ + this._root = null; + } + return true; + } + }; + + /** + * Finds the node with minimum value in given sub-tree. + * + * @private + * @param {Node} node Root of the sub-tree. + * @param {Number|String} current Current minimum value of the sub-tree. + * @returns {Node} Node with the minimum value in the sub-tree. + */ + exports.SplayTree.prototype._findMin = function (node, current) { + current = current || { value: Infinity }; + if (!node) { + return current; + } + if (current.value > node.value) { + current = node; + } + return this._findMin(node._left, current); + }; + + exports.SplayTree.prototype._isBalanced = function (current) { + if (!current) { + return true; + } + return this._isBalanced(current._left) && + this._isBalanced(current._right) && + Math.abs(this._getHeight(current._left) - + this._getHeight(current._right)) <= 1; + }; + + /** + * Returns whether the Splay Tree is balanced. + * + * @public + * @returns {Boolean} Whether the tree is balanced or not. + */ + exports.SplayTree.prototype.isBalanced = function () { + return this._isBalanced(this._root); + }; + + /** + * Finds the diameter of the Splay Tree. + * + * @public + * @returns {Number} The longest path in the BST. + */ + exports.SplayTree.prototype.getDiameter = function () { + var getDiameter = function (root) { + if (!root) { + return 0; + } + var leftHeight = this._getHeight(root._left); + var rightHeight = this._getHeight(root._right); + var path = leftHeight + rightHeight + 1; + return Math.max(path, getDiameter(root._left), getDiameter(root._right)); + }.bind(this); + return getDiameter(this._root); + }; + + /** + * Returns the height of the tree. + * + * @public + * @returns {Number} The height of the tree. + */ + exports.SplayTree.prototype.getHeight = function () { + return this._getHeight(this._root); + }; + + exports.SplayTree.prototype._getHeight = function (node) { + if (!node) { + return 0; + } + return 1 + Math.max(this._getHeight(node._left), + this._getHeight(node._right)); + }; + + /** + * Finds the lowest common ancestor of two nodes. + * + * @public + * @returns {Node} The lowest common ancestor of the two nodes or null. + */ + exports.SplayTree.prototype.lowestCommonAncestor = + function (firstNode, secondNode) { + return this._lowestCommonAncestor(firstNode, secondNode, this._root); + }; + + exports.SplayTree.prototype._lowestCommonAncestor = + function (firstNode, secondNode, current) { + var firstNodeInLeft = this._existsInSubtree(firstNode, current._left); + var secondNodeInLeft = this._existsInSubtree(secondNode, current._left); + var firstNodeInRight = this._existsInSubtree(firstNode, current._right); + var secondNodeInRight = this._existsInSubtree(secondNode, current._right); + if ((firstNodeInLeft && secondNodeInRight) || + (firstNodeInRight && secondNodeInLeft)) { + return current; + } + if (secondNodeInLeft && firstNodeInLeft) { + return this._lowestCommonAncestor(firstNode, secondNode, current._left); + } + if (secondNodeInRight && secondNodeInLeft) { + return this._lowestCommonAncestor(firstNode, secondNode, current._right); + } + return null; + }; + + exports.SplayTree.prototype._existsInSubtree = function (node, root) { + if (!root) { + return false; + } + if (node === root.value) { + return true; + } + return this._existsInSubtree(node, root._left) || + this._existsInSubtree(node, root._right); + }; + +})(typeof window === 'undefined' ? module.exports : window); diff --git a/test/data-structures/splay-tree.spec.js b/test/data-structures/splay-tree.spec.js new file mode 100644 index 00000000..24609d30 --- /dev/null +++ b/test/data-structures/splay-tree.spec.js @@ -0,0 +1,80 @@ +'use strict'; + +var mod = require('../../src/data-structures/splay-tree.js'); +var Node = mod.Node; +var SplayTree = mod.SplayTree; + +describe('Node', function () { + it('should be a constructor function', function () { + expect(typeof Node).toBe('function'); + }); + it('should be a construct properly', function () { + var node = new Node(10, null, null, null); + expect(node.value).toBe(10); + expect(node._left).toBe(null); + expect(node._right).toBe(null); + expect(node._parent).toBe(null); + }); + it('should reference children/parent properly', function () { + var root = new Node(10, null, null, null); + var left = new Node(5, null, null, root); + var right = new Node(15, null, null, root); + root._left = left; + root._right = right; + expect(root.value).toBe(10); + expect(root._left).toBe(left); + expect(root._right).toBe(right); + expect(root._parent).toBe(null); + }); +}); + +describe('SplayTree', function () { + it('should be a constructor function', function () { + expect(typeof SplayTree).toBe('function'); + }); + it('should start with null root', function () { + expect(new SplayTree()._root).toBe(null); + }); + it('should insert and remove correctly', function () { + var sTree = new SplayTree(); + sTree.insert(10); + sTree.remove(10); + expect(sTree._root).toBe(null); + }); + it('should splay correctly upon inserts', function () { + var sTree = new SplayTree(); + sTree.insert(10); + sTree.insert(5); + sTree.insert(15); + sTree.insert(7); + sTree.insert(12); + expect(sTree._root.value).toBe(12); + expect(sTree._root._left.value).toBe(7); + expect(sTree._root._right.value).toBe(15); + }); + it('should splay correctly upon search', function () { + var sTree = new SplayTree(); + sTree.insert(10); + sTree.insert(5); + sTree.insert(15); + sTree.insert(7); + sTree.insert(12); + sTree.search(5); + expect(sTree._root.value).toBe(5); + expect(sTree._root._right.value).toBe(7); + expect(sTree._root._right._right.value).toBe(12); + }); + it('should splay correctly upon remove', function () { + var sTree = new SplayTree(); + sTree.insert(10); + sTree.insert(5); + sTree.insert(15); + sTree.insert(7); + sTree.insert(12); + sTree.remove(10); + expect(sTree._root.value).toBe(7); + expect(sTree._root._left.value).toBe(5); + expect(sTree._root._right.value).toBe(12); + expect(sTree._root._right._right.value).toBe(15); + }); +}); From feb63e322606ddf2ddc0d7b69c9abcf35faacec7 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 22 Feb 2015 20:25:21 -0800 Subject: [PATCH 400/613] Fix #13 --- src/data-structures/edge.js | 20 +++++++++++++++++ src/data-structures/vertex.js | 16 ++++++++++++++ src/graphs/shortest-path/bellman-ford.js | 16 ++------------ src/graphs/spanning-trees/prim.js | 28 ++---------------------- 4 files changed, 40 insertions(+), 40 deletions(-) create mode 100644 src/data-structures/edge.js create mode 100644 src/data-structures/vertex.js diff --git a/src/data-structures/edge.js b/src/data-structures/edge.js new file mode 100644 index 00000000..48fe5ec7 --- /dev/null +++ b/src/data-structures/edge.js @@ -0,0 +1,20 @@ +(function (exports) { + 'use strict'; + + /** + * Graph edge. + * + * @constructor + * @public + * @param {Vertex} e Vertex which this edge connects. + * @param {Vertex} v Vertex which this edge connects. + * @param {Number} distance Weight of the edge. + * @module data-structures/edge + */ + exports.Edge = function (e, v, distance) { + this.e = e; + this.v = v; + this.distance = distance; + }; + +})(typeof window === 'undefined' ? module.exports : window); diff --git a/src/data-structures/vertex.js b/src/data-structures/vertex.js new file mode 100644 index 00000000..93afa98e --- /dev/null +++ b/src/data-structures/vertex.js @@ -0,0 +1,16 @@ +(function (exports) { + 'use strict'; + + /** + * Graph vertex. + * + * @constructor + * @public + * @param {Number} id Id of the vertex. + * @module data-structures/vertex + */ + exports.Vertex = function (id) { + this.id = id; + }; + +})(typeof window === 'undefined' ? module.exports : window); diff --git a/src/graphs/shortest-path/bellman-ford.js b/src/graphs/shortest-path/bellman-ford.js index c21af6d3..47f05b85 100644 --- a/src/graphs/shortest-path/bellman-ford.js +++ b/src/graphs/shortest-path/bellman-ford.js @@ -35,20 +35,8 @@ 'use strict'; - /** - * Graph edge. - * - * @constructor - * @public - * @param {Vertex} u Start vertex. - * @param {Vertex} v End vertex. - * @param {Number} weight Weight of the edge. - */ - exports.Edge = function (u, v, weight) { - this.from = u; - this.to = v; - this.weight = weight; - }; + exports.Vertex = require('../../data-structures/vertex').Vertex; + exports.Edge = require('../../data-structures/edge').Edge; /** * Computes shortest paths from a single source diff --git a/src/graphs/spanning-trees/prim.js b/src/graphs/spanning-trees/prim.js index be7023df..f0bb9bc4 100644 --- a/src/graphs/spanning-trees/prim.js +++ b/src/graphs/spanning-trees/prim.js @@ -45,32 +45,8 @@ 'use strict'; var Heap = require('../../data-structures/heap').Heap; - - /** - * Graph vertex. - * - * @constructor - * @public - * @param {Number} id Id of the vertex. - */ - exports.Vertex = function (id) { - this.id = id; - }; - - /** - * Graph edge. - * - * @constructor - * @public - * @param {Vertex} e Vertex which this edge connects. - * @param {Vertex} v Vertex which this edge connects. - * @param {Number} distance Weight of the edge. - */ - exports.Edge = function (e, v, distance) { - this.e = e; - this.v = v; - this.distance = distance; - }; + exports.Vertex = require('../../data-structures/vertex').Vertex; + exports.Edge = require('../../data-structures/edge').Edge; /** * Graph. From f164e7e81e0ac5c4330155591df386a1d4c47048 Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Sun, 22 Feb 2015 22:47:37 -0600 Subject: [PATCH 401/613] switched to 2 space indentation. --- src/data-structures/splay-tree.js | 1044 ++++++++++++----------- test/data-structures/splay-tree.spec.js | 138 +-- 2 files changed, 594 insertions(+), 588 deletions(-) diff --git a/src/data-structures/splay-tree.js b/src/data-structures/splay-tree.js index 6e55ea26..b7aff748 100644 --- a/src/data-structures/splay-tree.js +++ b/src/data-structures/splay-tree.js @@ -20,540 +20,546 @@ * @module data-structures/splay-tree */ (function (exports) { - 'use strict'; - - /** - * Node of the tree. - * - * @public - * @constructor - * @param {Number|String} value Value of the node. - * @param {Node} left Left sibling. - * @param {Node} right Right sibling. - * @param {Node} parent Parent of the node. - */ - exports.Node = function (value, left, right, parent) { - /** - * @member {Number|String} - */ - this.value = value; - this._left = left; - this._right = right; - this._parent = parent; - }; - - /** - * Splay tree. - * http://en.wikipedia.org/wiki/Splay_tree - * @public - * @constructor - */ - exports.SplayTree = function () { - this._root = null; - }; - - /** - * Splays a node to the root.

- * - * @private - * @method - * @param {Node} node Node to be splayed. - */ - exports.SplayTree.prototype._splay = function(node){ - while(this._root !== node){ - var hasParent = node._parent !== null; - var hasGrandparent = (hasParent && node._parent._parent !== null); - if(hasParent && hasGrandparent){ - var isLeftChild = node._parent._left === node; - var isParentLeftChild = node._parent._parent._left === node._parent; - if((isLeftChild && isParentLeftChild) || (!isLeftChild && !isParentLeftChild)){ - node = this._zigZig(node); - }else{ - node = this._zigZag(node); - } - }else{ - node = this._zig(node); - } - } - return node; - }; - - /** - * Performs a zig-zig splay pattern

- * - * @private - * @method - * @param {Node} node Node to be zig-zig'd. - */ - exports.SplayTree.prototype._zigZig = function(node){ - - var parent = node._parent; - var grandParent = node._parent._parent; - var greatGrandParent = grandParent._parent !== undefined ? - grandParent._parent : null; - - var orientation = (parent._right === node) ? '_right' : '_left'; - var oppositeOrientation = (orientation === '_left') ? '_right' : '_left'; - var grandParentOrientation = (greatGrandParent !== null - && greatGrandParent._left === grandParent) ? '_left' : '_right'; - - // Fix grandparent & great if it exists/not root - if(this._root === grandParent){ - this._root = node; - }else{ - greatGrandParent[grandParentOrientation] = node; - } - grandParent._parent = parent; - // Fix grandparent subtree - grandParent[orientation] = parent[oppositeOrientation]; - if(grandParent[orientation] !== null){ - grandParent[orientation]._parent = grandParent; - } - // Fix Parent - parent[oppositeOrientation] = grandParent; - parent[orientation] = node[oppositeOrientation]; - if(parent[orientation] !== null){ - parent[orientation]._parent = parent; - } - parent._parent = node; - // Fix Curr Node - node[oppositeOrientation] = parent; - if(node === this._root){ - node._parent = null; - }else if(greatGrandParent !== null){ - node._parent = greatGrandParent; - } - - return node; - }; - + 'use strict'; + + /** + * Node of the tree. + * + * @public + * @constructor + * @param {Number|String} value Value of the node. + * @param {Node} left Left sibling. + * @param {Node} right Right sibling. + * @param {Node} parent Parent of the node. + */ + exports.Node = function (value, left, right, parent) { /** - * Performs a zig-zag splay pattern

- * - * @private - * @method - * @param {Node} node Node to be zig-zag'd. + * @member {Number|String} */ - exports.SplayTree.prototype._zigZag = function(node){ - - var parent = node._parent; - var grandParent = parent._parent; - var greatGrandParent = grandParent._parent !== undefined ? - grandParent._parent : null; - - var orientation = (parent._left === node) ? '_left' : '_right'; - var oppositeOrientation = (orientation === '_right') ? '_left' : '_right'; - var grandParentOrientation = (greatGrandParent !== null - && greatGrandParent._left === grandParent) ? '_left' : '_right'; - - // Fix GrandParent - if(this._root === grandParent){ - this._root = node; - }else{ - greatGrandParent[grandParentOrientation] = node; - } - grandParent._parent = node; - // Fix GrandParent subtree - grandParent[oppositeOrientation] = node[orientation]; - if(grandParent[oppositeOrientation] !== null){ - grandParent[oppositeOrientation]._parent = grandParent; - } - // Fix Parent - parent[orientation] = node[oppositeOrientation]; - if(parent[orientation] !== null){ - parent[orientation]._parent = parent; - } - parent._parent = node; - // Fix Curr Node - node[orientation] = grandParent; - node[oppositeOrientation] = parent; - if(this._root === node){ - node._parent = null; - }else if(greatGrandParent !== null){ - node._parent = greatGrandParent; - } - - return node; - }; - - /** - * Performs a zig splay pattern

- * - * @private - * @method - * @param {Node} node Node to be zig'd. - */ - exports.SplayTree.prototype._zig = function(node){ - - var parent = node._parent; - var orientation = (parent._right === node) ? '_right' : '_left'; - var oppositeOrientation = (orientation === '_right') ? '_left' : '_right'; - - if(this._root === parent){ - this._root = node; - } - // Fix Parent - parent[orientation] = node[oppositeOrientation]; - if(parent[orientation] !== null){ - parent[orientation]._parent = parent; - } - parent._parent = node; - // Fix Curr Node - node[oppositeOrientation] = parent; - node._parent = null; - - return node; - }; - - /** - * Inserts a node into the splay tree.

- * Time complexity: O(log N) in the average case - * and amortized O(log n) in the worst case. - * - * @public - * @method - * @param {Number|String} value Node value. - * @param {Node} current Current node. - */ - exports.SplayTree.prototype.insert = function (value, current) { - if (this._root === null) { - this._root = new exports.Node(value, null, null, null); - return; - } - var insertKey; - current = current || this._root; - if (current.value > value) { - insertKey = '_left'; + this.value = value; + this._left = left; + this._right = right; + this._parent = parent; + }; + + /** + * Splay tree. + * http://en.wikipedia.org/wiki/Splay_tree + * @public + * @constructor + */ + exports.SplayTree = function () { + this._root = null; + }; + + /** + * Splays a node to the root.

+ * + * @private + * @method + * @param {Node} node Node to be splayed. + */ + exports.SplayTree.prototype._splay = function (node) { + while (this._root !== node) { + var hasParent = node._parent !== null; + var hasGrandparent = (hasParent && node._parent._parent !== null); + if (hasParent && hasGrandparent) { + var isLeftChild = node._parent._left === node; + var isParentLeftChild = node._parent._parent._left === node._parent; + if ( + (isLeftChild && isParentLeftChild) || + (!isLeftChild && !isParentLeftChild) + ) { + node = this._zigZig(node); } else { - insertKey = '_right'; - } - if (!current[insertKey]) { - current[insertKey] = new exports.Node(value, null, null, current); - this._splay(current[insertKey]); + node = this._zigZag(node); + } + } else { + node = this._zig(node); + } + } + return node; + }; + + /** + * Performs a zig-zig splay pattern

+ * + * @private + * @method + * @param {Node} node Node to be zig-zig'd. + */ + exports.SplayTree.prototype._zigZig = function (node) { + + var parent = node._parent; + var grandParent = node._parent._parent; + var greatGrandParent = grandParent._parent !== undefined ? + grandParent._parent : null; + + var orientation = (parent._right === node) ? '_right' : '_left'; + var oppositeOrientation = (orientation === '_left') ? '_right' : '_left'; + var grandParentOrientation = (greatGrandParent !== null && + greatGrandParent._left === grandParent) ? '_left' : '_right'; + + // Fix grandparent & great if it exists/not root + if (this._root === grandParent) { + this._root = node; + } else { + greatGrandParent[grandParentOrientation] = node; + } + grandParent._parent = parent; + // Fix grandparent subtree + grandParent[orientation] = parent[oppositeOrientation]; + if (grandParent[orientation] !== null) { + grandParent[orientation]._parent = grandParent; + } + // Fix Parent + parent[oppositeOrientation] = grandParent; + parent[orientation] = node[oppositeOrientation]; + if (parent[orientation] !== null) { + parent[orientation]._parent = parent; + } + parent._parent = node; + // Fix Curr Node + node[oppositeOrientation] = parent; + if (node === this._root) { + node._parent = null; + } else if (greatGrandParent !== null) { + node._parent = greatGrandParent; + } + + return node; + }; + + /** + * Performs a zig-zag splay pattern

+ * + * @private + * @method + * @param {Node} node Node to be zig-zag'd. + */ + exports.SplayTree.prototype._zigZag = function (node) { + + var parent = node._parent; + var grandParent = parent._parent; + var greatGrandParent = grandParent._parent !== undefined ? + grandParent._parent : null; + + var orientation = (parent._left === node) ? '_left' : '_right'; + var oppositeOrientation = (orientation === '_right') ? '_left' : '_right'; + var grandParentOrientation = (greatGrandParent !== null && + greatGrandParent._left === grandParent) ? '_left' : '_right'; + + // Fix GrandParent + if (this._root === grandParent) { + this._root = node; + } else { + greatGrandParent[grandParentOrientation] = node; + } + grandParent._parent = node; + // Fix GrandParent subtree + grandParent[oppositeOrientation] = node[orientation]; + if (grandParent[oppositeOrientation] !== null) { + grandParent[oppositeOrientation]._parent = grandParent; + } + // Fix Parent + parent[orientation] = node[oppositeOrientation]; + if (parent[orientation] !== null) { + parent[orientation]._parent = parent; + } + parent._parent = node; + // Fix Curr Node + node[orientation] = grandParent; + node[oppositeOrientation] = parent; + if (this._root === node) { + node._parent = null; + } else if (greatGrandParent !== null) { + node._parent = greatGrandParent; + } + + return node; + }; + + /** + * Performs a zig splay pattern

+ * + * @private + * @method + * @param {Node} node Node to be zig'd. + */ + exports.SplayTree.prototype._zig = function (node) { + + var parent = node._parent; + var orientation = (parent._right === node) ? '_right' : '_left'; + var oppositeOrientation = (orientation === '_right') ? '_left' : '_right'; + + if (this._root === parent) { + this._root = node; + } + // Fix Parent + parent[orientation] = node[oppositeOrientation]; + if (parent[orientation] !== null) { + parent[orientation]._parent = parent; + } + parent._parent = node; + // Fix Curr Node + node[oppositeOrientation] = parent; + node._parent = null; + + return node; + }; + + /** + * Inserts a node into the splay tree.

+ * Time complexity: O(log N) in the average case + * and amortized O(log n) in the worst case. + * + * @public + * @method + * @param {Number|String} value Node value. + * @param {Node} current Current node. + */ + exports.SplayTree.prototype.insert = function (value, current) { + if (this._root === null) { + this._root = new exports.Node(value, null, null, null); + return; + } + var insertKey; + current = current || this._root; + if (current.value > value) { + insertKey = '_left'; + } else { + insertKey = '_right'; + } + if (!current[insertKey]) { + current[insertKey] = new exports.Node(value, null, null, current); + this._splay(current[insertKey]); + } else { + this.insert(value, current[insertKey]); + } + }; + + /** + * In-order traversal from the given node. + * + * @private + * @param {Node} current Node from which to start the traversal. + * @param {Function} callback Callback which + * will be called for each traversed node. + */ + exports.SplayTree.prototype._inorder = function (current, callback) { + if (!current) { + return; + } + this._inorder(current._left, callback); + if (typeof callback === 'function') { + callback(current); + } + this._inorder(current._right, callback); + }; + + /** + * In-order traversal of the whole Splay Tree. + * + * @public + * @method + * @param {Function} callback Callback which will be + * called for each traversed node. + */ + exports.SplayTree.prototype.inorder = function (callback) { + return this._inorder(this._root, callback); + }; + + /** + * Post-order traversal from given node. + * + * @private + * @param {Node} current Node from which to start the traversal. + * @param {Function} callback Callback which will + * be called for each traversed node + */ + exports.SplayTree.prototype._postorder = function (current, callback) { + if (!current) { + return; + } + if (typeof callback === 'function') { + callback(current); + } + this._postorder(current._left, callback); + this._postorder(current._right, callback); + }; + + /** + * Post-order traversal of the whole tree. + * + * @public + * @param {Function} callback Callback which + * will be called for each traversed node. + */ + exports.SplayTree.prototype.postorder = function (callback) { + return this._postorder(this._root, callback); + }; + + /** + * Pre-order traversal of the tree from given node. + * + * @private + * @param {Node} current Node from which to start the traversal. + * @param {Function} callback Callback which + * will be called for each traversed node. + */ + exports.SplayTree.prototype._preorder = function (current, callback) { + if (!current) { + return; + } + if (typeof callback === 'function') { + callback(current); + } + this._preorder(current._left, callback); + this._preorder(current._right, callback); + }; + + /** + * Pre-order preorder traversal of the whole tree. + * + * @public + * @param {Function} callback Callback which will + * be called for each traversed node. + */ + exports.SplayTree.prototype.preorder = function (callback) { + return this._preorder(this._root, callback); + }; + + /** + * Finds a node by it's value.

+ * Average time complexity: O(log N). + * + * @public + * @param {Number|String} Value of the node which should be found. + */ + exports.SplayTree.prototype.search = function (value) { + var node = this._search(value, this._root); + return this._splay(node); + }; + + /** + * Finds a node by it's value.

+ * Average time complexity: O(log N). + * + * @public + * @param {Number|String} Value of the node which should be found. + */ + exports.SplayTree.prototype._splaylessSearch = function (value) { + return this._search(value, this._root); + }; + + /** + * Finds a node by it's value in a given sub-tree. + * Average time complexity: O(log N). + * + * @private + * @param {Number|String} Value of the node which should be found. + * @param {Node} Current node to be checked. + */ + exports.SplayTree.prototype._search = function (value, current) { + if (!current) { + return null; + } + + if (current.value === value) { + return current; + } + + if (current.value > value) { + return this._search(value, current._left); + } + + if (current.value < value) { + return this._search(value, current._right); + } + }; + + /** + * Replaces given child with new one, for given parent. + * + * @private + * @param {Node} parent Parent node. + * @param {Node} oldChild Child to be replaced. + * @param {Node} newChild Child replacement. + */ + exports.SplayTree.prototype._replaceChild = + function (parent, oldChild, newChild) { + if (!parent) { + this._root = newChild; + this._root._parent = null; + } else { + if (parent._left === oldChild) { + parent._left = newChild; } else { - this.insert(value, current[insertKey]); + parent._right = newChild; } - }; - /** - * In-order traversal from the given node. - * - * @private - * @param {Node} current Node from which to start the traversal. - * @param {Function} callback Callback which - * will be called for each traversed node. - */ - exports.SplayTree.prototype._inorder = function (current, callback) { - if (!current) { - return; - } - this._inorder(current._left, callback); - if (typeof callback === 'function') { - callback(current); + if (newChild) { + newChild._parent = parent; } - this._inorder(current._right, callback); + } }; - /** - * In-order traversal of the whole Splay Tree. - * - * @public - * @method - * @param {Function} callback Callback which will be - * called for each traversed node. - */ - exports.SplayTree.prototype.inorder = function (callback) { - return this._inorder(this._root, callback); - }; - - /** - * Post-order traversal from given node. - * - * @private - * @param {Node} current Node from which to start the traversal. - * @param {Function} callback Callback which will - * be called for each traversed node - */ - exports.SplayTree.prototype._postorder = function (current, callback) { - if (!current) { - return; - } - if (typeof callback === 'function') { - callback(current); - } - this._postorder(current._left, callback); - this._postorder(current._right, callback); - }; - - /** - * Post-order traversal of the whole tree. - * - * @public - * @param {Function} callback Callback which - * will be called for each traversed node. - */ - exports.SplayTree.prototype.postorder = function (callback) { - return this._postorder(this._root, callback); - }; - - /** - * Pre-order traversal of the tree from given node. - * - * @private - * @param {Node} current Node from which to start the traversal. - * @param {Function} callback Callback which - * will be called for each traversed node. - */ - exports.SplayTree.prototype._preorder = function (current, callback) { - if (!current) { - return; - } - if (typeof callback === 'function') { - callback(current); - } - this._preorder(current._left, callback); - this._preorder(current._right, callback); - }; - - /** - * Pre-order preorder traversal of the whole tree. - * - * @public - * @param {Function} callback Callback which will - * be called for each traversed node. - */ - exports.SplayTree.prototype.preorder = function (callback) { - return this._preorder(this._root, callback); - }; - - /** - * Finds a node by it's value.

- * Average time complexity: O(log N). - * - * @public - * @param {Number|String} Value of the node which should be found. - */ - exports.SplayTree.prototype.search = function (value) { - var node = this._search(value, this._root); - return this._splay(node); - }; - - /** - * Finds a node by it's value.

- * Average time complexity: O(log N). - * - * @public - * @param {Number|String} Value of the node which should be found. - */ - exports.SplayTree.prototype._splaylessSearch = function (value) { - return this._search(value, this._root); - }; - - /** - * Finds a node by it's value in a given sub-tree. - * Average time complexity: O(log N). - * - * @private - * @param {Number|String} Value of the node which should be found. - * @param {Node} Current node to be checked. - */ - exports.SplayTree.prototype._search = function (value, current) { - if (!current) { - return null; - } - - if (current.value === value) { - return current; - } - - if (current.value > value) { - return this._search(value, current._left); - } - - if (current.value < value) { - return this._search(value, current._right); - } - }; - - /** - * Replaces given child with new one, for given parent. - * - * @private - * @param {Node} parent Parent node. - * @param {Node} oldChild Child to be replaced. - * @param {Node} newChild Child replacement. - */ - exports.SplayTree.prototype._replaceChild = - function (parent, oldChild, newChild) { - if (!parent) { - this._root = newChild; - this._root._parent = null; - } else { - if (parent._left === oldChild) { - parent._left = newChild; - } else { - parent._right = newChild; - } - - if (newChild) { - newChild._parent = parent; - } - } - }; - - /** - * Removes node with given value from the tree.

- * Average runtime complexity: O(log N). - * - * @public - * @param {Number|String} value Value to be removed - * @returns {Boolean} True/false depending - * on whether the given node is removed. - */ - exports.SplayTree.prototype.remove = function (value) { - var node = this._splaylessSearch(value); - if (!node) { - return false; - } - if (node._left && node._right) { - var min = this._findMin(node._right); - var temp = node.value; - - node.value = min.value; - min.value = temp; - return this.remove(min); + /** + * Removes node with given value from the tree.

+ * Average runtime complexity: O(log N). + * + * @public + * @param {Number|String} value Value to be removed + * @returns {Boolean} True/false depending + * on whether the given node is removed. + */ + exports.SplayTree.prototype.remove = function (value) { + var node = this._splaylessSearch(value); + if (!node) { + return false; + } + if (node._left && node._right) { + var min = this._findMin(node._right); + var temp = node.value; + + node.value = min.value; + min.value = temp; + return this.remove(min); + } else { + if (node._parent !== null) { + if (node._left) { + this._replaceChild(node._parent, node, node._left); + } else if (node._right) { + this._replaceChild(node._parent, node, node._right); } else { - if(node._parent !== null){ - if (node._left) { - this._replaceChild(node._parent, node, node._left); - } else if (node._right) { - this._replaceChild(node._parent, node, node._right); - } else { - this._replaceChild(node._parent, node, null); - } - this._splay(node._parent); - }else{ - this._root = null; - } - return true; - } - }; - - /** - * Finds the node with minimum value in given sub-tree. - * - * @private - * @param {Node} node Root of the sub-tree. - * @param {Number|String} current Current minimum value of the sub-tree. - * @returns {Node} Node with the minimum value in the sub-tree. - */ - exports.SplayTree.prototype._findMin = function (node, current) { - current = current || { value: Infinity }; - if (!node) { - return current; - } - if (current.value > node.value) { - current = node; - } - return this._findMin(node._left, current); - }; - - exports.SplayTree.prototype._isBalanced = function (current) { - if (!current) { - return true; + this._replaceChild(node._parent, node, null); } - return this._isBalanced(current._left) && - this._isBalanced(current._right) && - Math.abs(this._getHeight(current._left) - - this._getHeight(current._right)) <= 1; - }; - - /** - * Returns whether the Splay Tree is balanced. - * - * @public - * @returns {Boolean} Whether the tree is balanced or not. - */ - exports.SplayTree.prototype.isBalanced = function () { - return this._isBalanced(this._root); + this._splay(node._parent); + } else { + this._root = null; + } + return true; + } + }; + + /** + * Finds the node with minimum value in given sub-tree. + * + * @private + * @param {Node} node Root of the sub-tree. + * @param {Number|String} current Current minimum value of the sub-tree. + * @returns {Node} Node with the minimum value in the sub-tree. + */ + exports.SplayTree.prototype._findMin = function (node, current) { + current = current || { + value: Infinity }; - - /** - * Finds the diameter of the Splay Tree. - * - * @public - * @returns {Number} The longest path in the BST. - */ - exports.SplayTree.prototype.getDiameter = function () { - var getDiameter = function (root) { - if (!root) { - return 0; - } - var leftHeight = this._getHeight(root._left); - var rightHeight = this._getHeight(root._right); - var path = leftHeight + rightHeight + 1; - return Math.max(path, getDiameter(root._left), getDiameter(root._right)); - }.bind(this); - return getDiameter(this._root); + if (!node) { + return current; + } + if (current.value > node.value) { + current = node; + } + return this._findMin(node._left, current); + }; + + exports.SplayTree.prototype._isBalanced = function (current) { + if (!current) { + return true; + } + return this._isBalanced(current._left) && + this._isBalanced(current._right) && + Math.abs(this._getHeight(current._left) - + this._getHeight(current._right)) <= 1; + }; + + /** + * Returns whether the Splay Tree is balanced. + * + * @public + * @returns {Boolean} Whether the tree is balanced or not. + */ + exports.SplayTree.prototype.isBalanced = function () { + return this._isBalanced(this._root); + }; + + /** + * Finds the diameter of the Splay Tree. + * + * @public + * @returns {Number} The longest path in the tree. + */ + exports.SplayTree.prototype.getDiameter = function () { + var getDiameter = function (root) { + if (!root) { + return 0; + } + var leftHeight = this._getHeight(root._left); + var rightHeight = this._getHeight(root._right); + var path = leftHeight + rightHeight + 1; + return Math.max(path, getDiameter(root._left), getDiameter(root._right)); + }.bind(this); + return getDiameter(this._root); + }; + + /** + * Returns the height of the tree. + * + * @public + * @returns {Number} The height of the tree. + */ + exports.SplayTree.prototype.getHeight = function () { + return this._getHeight(this._root); + }; + + exports.SplayTree.prototype._getHeight = function (node) { + if (!node) { + return 0; + } + return 1 + Math.max(this._getHeight(node._left), + this._getHeight(node._right)); + }; + + /** + * Finds the lowest common ancestor of two nodes. + * + * @public + * @returns {Node} The lowest common ancestor of the two nodes or null. + */ + exports.SplayTree.prototype.lowestCommonAncestor = + function (firstNode, secondNode) { + return this._lowestCommonAncestor(firstNode, secondNode, this._root); }; - /** - * Returns the height of the tree. - * - * @public - * @returns {Number} The height of the tree. - */ - exports.SplayTree.prototype.getHeight = function () { - return this._getHeight(this._root); + exports.SplayTree.prototype._lowestCommonAncestor = + function (firstNode, secondNode, current) { + var firstNodeInLeft = this._existsInSubtree(firstNode, current._left); + var secondNodeInLeft = this._existsInSubtree(secondNode, current._left); + var firstNodeInRight = this._existsInSubtree(firstNode, current._right); + var secondNodeInRight = this._existsInSubtree(secondNode, current._right); + if ((firstNodeInLeft && secondNodeInRight) || + (firstNodeInRight && secondNodeInLeft)) { + return current; + } + if (secondNodeInLeft && firstNodeInLeft) { + return this._lowestCommonAncestor(firstNode, secondNode, current._left); + } + if (secondNodeInRight && secondNodeInLeft) { + return this._lowestCommonAncestor(firstNode, secondNode, + current._right); + } + return null; }; - exports.SplayTree.prototype._getHeight = function (node) { - if (!node) { - return 0; - } - return 1 + Math.max(this._getHeight(node._left), - this._getHeight(node._right)); - }; - - /** - * Finds the lowest common ancestor of two nodes. - * - * @public - * @returns {Node} The lowest common ancestor of the two nodes or null. - */ - exports.SplayTree.prototype.lowestCommonAncestor = - function (firstNode, secondNode) { - return this._lowestCommonAncestor(firstNode, secondNode, this._root); - }; - - exports.SplayTree.prototype._lowestCommonAncestor = - function (firstNode, secondNode, current) { - var firstNodeInLeft = this._existsInSubtree(firstNode, current._left); - var secondNodeInLeft = this._existsInSubtree(secondNode, current._left); - var firstNodeInRight = this._existsInSubtree(firstNode, current._right); - var secondNodeInRight = this._existsInSubtree(secondNode, current._right); - if ((firstNodeInLeft && secondNodeInRight) || - (firstNodeInRight && secondNodeInLeft)) { - return current; - } - if (secondNodeInLeft && firstNodeInLeft) { - return this._lowestCommonAncestor(firstNode, secondNode, current._left); - } - if (secondNodeInRight && secondNodeInLeft) { - return this._lowestCommonAncestor(firstNode, secondNode, current._right); - } - return null; - }; - - exports.SplayTree.prototype._existsInSubtree = function (node, root) { - if (!root) { - return false; - } - if (node === root.value) { - return true; - } - return this._existsInSubtree(node, root._left) || - this._existsInSubtree(node, root._right); - }; + exports.SplayTree.prototype._existsInSubtree = function (node, root) { + if (!root) { + return false; + } + if (node === root.value) { + return true; + } + return this._existsInSubtree(node, root._left) || + this._existsInSubtree(node, root._right); + }; })(typeof window === 'undefined' ? module.exports : window); diff --git a/test/data-structures/splay-tree.spec.js b/test/data-structures/splay-tree.spec.js index 24609d30..05e13a0d 100644 --- a/test/data-structures/splay-tree.spec.js +++ b/test/data-structures/splay-tree.spec.js @@ -5,76 +5,76 @@ var Node = mod.Node; var SplayTree = mod.SplayTree; describe('Node', function () { - it('should be a constructor function', function () { - expect(typeof Node).toBe('function'); - }); - it('should be a construct properly', function () { - var node = new Node(10, null, null, null); - expect(node.value).toBe(10); - expect(node._left).toBe(null); - expect(node._right).toBe(null); - expect(node._parent).toBe(null); - }); - it('should reference children/parent properly', function () { - var root = new Node(10, null, null, null); - var left = new Node(5, null, null, root); - var right = new Node(15, null, null, root); - root._left = left; - root._right = right; - expect(root.value).toBe(10); - expect(root._left).toBe(left); - expect(root._right).toBe(right); - expect(root._parent).toBe(null); - }); + it('should be a constructor function', function () { + expect(typeof Node).toBe('function'); + }); + it('should be a construct properly', function () { + var node = new Node(10, null, null, null); + expect(node.value).toBe(10); + expect(node._left).toBe(null); + expect(node._right).toBe(null); + expect(node._parent).toBe(null); + }); + it('should reference children/parent properly', function () { + var root = new Node(10, null, null, null); + var left = new Node(5, null, null, root); + var right = new Node(15, null, null, root); + root._left = left; + root._right = right; + expect(root.value).toBe(10); + expect(root._left).toBe(left); + expect(root._right).toBe(right); + expect(root._parent).toBe(null); + }); }); describe('SplayTree', function () { - it('should be a constructor function', function () { - expect(typeof SplayTree).toBe('function'); - }); - it('should start with null root', function () { - expect(new SplayTree()._root).toBe(null); - }); - it('should insert and remove correctly', function () { - var sTree = new SplayTree(); - sTree.insert(10); - sTree.remove(10); - expect(sTree._root).toBe(null); - }); - it('should splay correctly upon inserts', function () { - var sTree = new SplayTree(); - sTree.insert(10); - sTree.insert(5); - sTree.insert(15); - sTree.insert(7); - sTree.insert(12); - expect(sTree._root.value).toBe(12); - expect(sTree._root._left.value).toBe(7); - expect(sTree._root._right.value).toBe(15); - }); - it('should splay correctly upon search', function () { - var sTree = new SplayTree(); - sTree.insert(10); - sTree.insert(5); - sTree.insert(15); - sTree.insert(7); - sTree.insert(12); - sTree.search(5); - expect(sTree._root.value).toBe(5); - expect(sTree._root._right.value).toBe(7); - expect(sTree._root._right._right.value).toBe(12); - }); - it('should splay correctly upon remove', function () { - var sTree = new SplayTree(); - sTree.insert(10); - sTree.insert(5); - sTree.insert(15); - sTree.insert(7); - sTree.insert(12); - sTree.remove(10); - expect(sTree._root.value).toBe(7); - expect(sTree._root._left.value).toBe(5); - expect(sTree._root._right.value).toBe(12); - expect(sTree._root._right._right.value).toBe(15); - }); + it('should be a constructor function', function () { + expect(typeof SplayTree).toBe('function'); + }); + it('should start with null root', function () { + expect(new SplayTree()._root).toBe(null); + }); + it('should insert and remove correctly', function () { + var sTree = new SplayTree(); + sTree.insert(10); + sTree.remove(10); + expect(sTree._root).toBe(null); + }); + it('should splay correctly upon inserts', function () { + var sTree = new SplayTree(); + sTree.insert(10); + sTree.insert(5); + sTree.insert(15); + sTree.insert(7); + sTree.insert(12); + expect(sTree._root.value).toBe(12); + expect(sTree._root._left.value).toBe(7); + expect(sTree._root._right.value).toBe(15); + }); + it('should splay correctly upon search', function () { + var sTree = new SplayTree(); + sTree.insert(10); + sTree.insert(5); + sTree.insert(15); + sTree.insert(7); + sTree.insert(12); + sTree.search(5); + expect(sTree._root.value).toBe(5); + expect(sTree._root._right.value).toBe(7); + expect(sTree._root._right._right.value).toBe(12); + }); + it('should splay correctly upon remove', function () { + var sTree = new SplayTree(); + sTree.insert(10); + sTree.insert(5); + sTree.insert(15); + sTree.insert(7); + sTree.insert(12); + sTree.remove(10); + expect(sTree._root.value).toBe(7); + expect(sTree._root._left.value).toBe(5); + expect(sTree._root._right.value).toBe(12); + expect(sTree._root._right._right.value).toBe(15); + }); }); From f562911434e7bc32da56da8327a9f80d9c89ac9b Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Mon, 23 Feb 2015 19:12:32 -0600 Subject: [PATCH 402/613] bst remove root node fix. bst specs. --- src/data-structures/binary-search-tree.js | 25 +++--- .../binary-search-tree.spec.js | 77 +++++++++++++++++++ 2 files changed, 91 insertions(+), 11 deletions(-) create mode 100644 test/data-structures/binary-search-tree.spec.js diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index c1dc844d..9aa08f28 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -181,7 +181,7 @@ * Average time complexity: O(log N). * * @public - * @param {Number|String} Value of the node which should be found. + * @param {Number|String} value of the node which should be found. */ exports.BinaryTree.prototype.find = function (value) { return this._find(value, this._root); @@ -192,8 +192,8 @@ * Average time complexity: O(log N). * * @private - * @param {Number|String} Value of the node which should be found. - * @param {Node} Current node to be checked. + * @param {Number|String} value of the node which should be found. + * @param {Node} current node to be checked. */ exports.BinaryTree.prototype._find = function (value, current) { if (!current) { @@ -232,7 +232,6 @@ } else { parent._right = newChild; } - if (newChild) { newChild._parent = parent; } @@ -244,7 +243,7 @@ * Average runtime complexity: O(log N). * * @public - * @param {Node} Node to be removed + * @param {Node} node to be removed * @returns {Boolean} True/false depending * on whether the given node is removed. */ @@ -261,12 +260,16 @@ min.value = temp; return this.remove(min); } else { - if (node._left) { - this._replaceChild(node._parent, node, node._left); - } else if (node._right) { - this._replaceChild(node._parent, node, node._right); - } else { - this._replaceChild(node._parent, node, null); + if (node._parent !== null) { + if (node._left) { + this._replaceChild(node._parent, node, node._left); + } else if (node._right) { + this._replaceChild(node._parent, node, node._right); + } else { + this._replaceChild(node._parent, node, null); + } + }else { + this._root = null; } return true; } diff --git a/test/data-structures/binary-search-tree.spec.js b/test/data-structures/binary-search-tree.spec.js new file mode 100644 index 00000000..f889dcdd --- /dev/null +++ b/test/data-structures/binary-search-tree.spec.js @@ -0,0 +1,77 @@ +'use strict'; + +var mod = require('../../src/data-structures/binary-search-tree.js'); +var Node = mod.Node; +var BinaryTree = mod.BinaryTree; + +describe('Node', function () { + it('should be a constructor function', function () { + expect(typeof Node).toBe('function'); + }); +}); + +describe('Binary Tree', function () { + it('should be a constructor function', function () { + expect(typeof BinaryTree).toBe('function'); + }); + it('should start with null root', function () { + expect(new BinaryTree()._root).toBe(null); + }); + it('should insert and remove single node properly', function () { + var bTree = new BinaryTree(); + bTree.insert(15); + var node = bTree.find(15); + bTree.remove(node); + expect(bTree._root).toBe(null); + }); + it('should insert multiple nodes properly', function () { + var bTree = new BinaryTree(); + bTree.insert(10); + bTree.insert(5); + bTree.insert(15); + bTree.insert(4); + bTree.insert(6); + bTree.insert(14); + bTree.insert(16); + var leftRootChild = bTree._root._left; + var rightRootChild = bTree._root._right; + expect(bTree._root.value).toBe(10); + expect(leftRootChild.value).toBe(5); + expect(rightRootChild.value).toBe(15); + expect(leftRootChild._left.value).toBe(4); + expect(leftRootChild._right.value).toBe(6); + expect(rightRootChild._left.value).toBe(14); + expect(rightRootChild._right.value).toBe(16); + }); + it('should remove multiple nodes properly', function () { + var bTree = new BinaryTree(); + bTree.insert(10); + bTree.insert(5); + bTree.insert(15); + bTree.insert(4); + bTree.insert(6); + bTree.insert(7); + bTree.insert(14); + bTree.insert(16); + var leftRootChild = bTree._root._left; + var rightRootChild = bTree._root._right; + var sixteen = bTree.find(16); + bTree.remove(sixteen); + expect(bTree._root.value).toBe(10); + expect(leftRootChild.value).toBe(5); + expect(rightRootChild.value).toBe(15); + expect(leftRootChild._left.value).toBe(4); + expect(leftRootChild._right.value).toBe(6); + expect(leftRootChild._right._right.value).toBe(7); + expect(rightRootChild._left.value).toBe(14); + expect(rightRootChild._right).toBe(null); + var fourteen = bTree.find(14); + bTree.remove(fourteen); + expect(rightRootChild._left).toBe(null); + var five = bTree.find(5); + bTree.remove(five); + expect(leftRootChild.value).toBe(6); + expect(leftRootChild._left.value).toBe(4); + expect(leftRootChild._right.value).toBe(7); + }); +}); From f9f5c65db603518483b9b8024ea76b7958c8d71c Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 25 Feb 2015 18:09:18 -0800 Subject: [PATCH 403/613] Update the contributors list --- readme.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index aa5ab073..239e9256 100644 --- a/readme.md +++ b/readme.md @@ -71,13 +71,13 @@ If the build is not successful fix your code in order the tests and jshint valid ## Contributors -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[pvoznenko](https://github.com/pvoznenko) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[pvoznenko](https://github.com/pvoznenko) |[secrettriangle](https://github.com/secrettriangle) |[Jakehp](https://github.com/Jakehp) |[Microfed](https://github.com/Microfed) | :---: |:---: |:---: |:---: |:---: |:---: | -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[pvoznenko](https://github.com/pvoznenko) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[pvoznenko](https://github.com/pvoznenko) |[secrettriangle](https://github.com/secrettriangle) |[Jakehp](https://github.com/Jakehp) |[Microfed](https://github.com/Microfed) | -[fanixk](https://github.com/fanixk) | -:---: | -[fanixk](https://github.com/fanixk) | +[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | +:---: |:---: | +[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | ## License From c6e3f8ee4bd9d86a049225622626be650a5a39db Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Thu, 26 Feb 2015 22:32:48 -0600 Subject: [PATCH 404/613] AVL Tree and spec. --- src/data-structures/avl-tree.js | 693 ++++++++++++++++++++++++++ test/data-structures/avl-tree.spec.js | 126 +++++ 2 files changed, 819 insertions(+) create mode 100644 src/data-structures/avl-tree.js create mode 100644 test/data-structures/avl-tree.spec.js diff --git a/src/data-structures/avl-tree.js b/src/data-structures/avl-tree.js new file mode 100644 index 00000000..4e6aa075 --- /dev/null +++ b/src/data-structures/avl-tree.js @@ -0,0 +1,693 @@ +/** + * AVL tree, a Binary Search Tree that satisfies the Height-Balance + * Property. + * + * @example + * var avlTree = require('path-to-algorithms/src/data-structures'+ + * '/avl-tree'); + * var avl = new avlTree.AVLTree(); + * + * avl.insert(2000); + * avl.insert(1989); + * avl.insert(1991); + * avl.insert(2001); + * avl.insert(1966); + * + * @module data-structures/avl-tree + */ +(function (exports) { + 'use strict'; + + /** + * Node of the tree. + * + * @public + * @constructor + * @param {Number|String} value Value of the node. + * @param {Node} left Left sibling. + * @param {Node} right Right sibling. + * @param {Node} parent Parent of the node. + * @param {Number} height Height of the node. + */ + exports.Node = function (value, left, right, parent, height) { + /** + * @member {Number|String} + */ + this.value = value; + this._left = left; + this._right = right; + this._parent = parent; + this._height = height; + }; + + /** + * AVL Tree. + * + * @public + * @constructor + */ + exports.AVLTree = function () { + this._root = null; + }; + + /** + * Calculates the height of a node based on height + * property of children. + * + * @public + * @method + * @param {Node} node Given node's height is returned. + */ + exports.AVLTree.prototype._getHeightAtNode = function (node) { + if (node._left !== null && node._right !== null){ + var height = Math.max(node._left._height, node._right._height); + height += 1; + return height; + }else if (node._left !== null){ + return node._left._height + 1; + }else if (node._right !== null){ + return node._right._height + 1; + }else { + return 1; + } + }; + + /** + * Checks if a given node has an imbalance. + * + * @public + * @method + * @param {Node} node Given node's children are checked for + * imbalance. + */ + exports.AVLTree.prototype._isBalancedAtNode = function (node) { + if (node._left !== null && node._right !== null){ + return (Math.abs(node._left._height - node._right._height) <= 1); + } + if (node._right !== null && node._left === null){ + return node._right._height < 2; + } + if (node._left !== null && node._right === null){ + return node._left._height < 2; + } + return true; + }; + + /** + * Maintains the height balance property by + * walking to root and checking for invalid height + * differences between children and restructuring + * appropriately. + * + * @public + * @method + * @param {Node} node Started node. + */ + exports.AVLTree.prototype._maintainHeightBalanceProperty = function (node) { + var current = node; + var path = []; //During restructure, use last 3 nodes traveled. + while (current !== null){ + path.push(current); + current._height = this._getHeightAtNode(current); + if (!this._isBalancedAtNode(current)){ + if (path.length >= 3){ + var nodesToRestructure = path.slice(0, 3); + var x = nodesToRestructure[0]; + var y = nodesToRestructure[1]; + var z = nodesToRestructure[2]; + this._restructure(x, y, z); + } + } + current = current._parent; + } + }; + + /** + * Identifies the pattern of given nodes, then calls + * the appropriate pattern rotator. + * + * @public + * @method + * @param {Node} x node with lowest height to be restructured. + * @param {Node} y parent of x parameter. + * @param {Node} z grandparent of x, largest height. + */ + exports.AVLTree.prototype._restructure = function (x, y, z) { + //Determine Rotation Pattern + if (z._right === y && y._right === x){ + this._rightRight(x, y, z); + }else if (z._left === y && y._left === x){ + this._leftLeft(x, y, z); + }else if (z._right === y && y._left === x){ + this._rightLeft(x, y, z); + }else if (z._left === y && y._right === x){ + this._leftRight(x, y, z); + } + }; + + /** + * Rotates the given nodes from a right right pattern + * to a parent, with 2 children. + * + * @public + * @method + * @param {Node} x node with lowest height to be restructured. + * @param {Node} y parent of x parameter. + * @param {Node} z grandparent of x, largest height. + */ + exports.AVLTree.prototype._rightRight = function (x, y, z) { + /* + z + y => y + x z x + */ + // pass z parent to y and move y's left to z's right + if (z._parent !== null){ + var orientation = (z._parent._left === z) ? '_left' : '_right'; + z._parent[orientation] = y; + y._parent = z._parent; + }else { + this._root = y; + y._parent = null; + } + // z adopts y's left. + z._right = y._left; + if (z._right !== null){ + z._right._parent = z; + } + // y adopts z + y._left = z; + z._parent = y; + // Correct each nodes height - order matters, children first + x._height = this._getHeightAtNode(x); + z._height = this._getHeightAtNode(z); + y._height = this._getHeightAtNode(y); + }; + + /** + * Rotates the given nodes from a left left pattern + * to a parent, with 2 children. + * + * @public + * @method + * @param {Node} x node with lowest height to be restructured. + * @param {Node} y parent of x parameter. + * @param {Node} z grandparent of x, largest height. + */ + exports.AVLTree.prototype._leftLeft = function (x, y, z) { + /* + z + y => y + x x z + */ + //pass z parent to y and move y's right to z's left + if (z._parent !== null){ + var orientation = (z._parent._left === z) ? '_left' : '_right'; + z._parent[orientation] = y; + y._parent = z._parent; + }else { + this._root = y; + y._parent = null; + } + z._left = y._right; + if (z._left !== null) { + z._left._parent = z; + } + //fix y right child + y._right = z; + z._parent = y; + // Correct each nodes height - order matters, children first + x._height = this._getHeightAtNode(x); + z._height = this._getHeightAtNode(z); + y._height = this._getHeightAtNode(y); + }; + + /** + * Rotates the given nodes from a right left pattern + * to a parent, with 2 children. + * + * @public + * @method + * @param {Node} x node with lowest height to be restructured. + * @param {Node} y parent of x parameter. + * @param {Node} z grandparent of x, largest height. + */ + exports.AVLTree.prototype._rightLeft = function (x, y, z) { + /* + z + y => x + x z y + */ + //pass z parent to x + if (z._parent !== null){ + var orientation = (z._parent._left === z) ? '_left' : '_right'; + z._parent[orientation] = x; + x._parent = z._parent; + }else { + this._root = x; + x._parent = null; + } + // Adoptions + z._right = x._left; + if (z._right !== null){ + z._right._parent = z; + } + y._left = x._right; + if (y._left !== null){ + y._left._parent = y; + } + // Point to new children (x new parent) + x._left = z; + x._right = y; + x._left._parent = x; + x._right._parent = x; + // Correct each nodes height - order matters, children first + y._height = this._getHeightAtNode(y); + z._height = this._getHeightAtNode(z); + x._height = this._getHeightAtNode(x); + }; + + /** + * Rotates the given nodes from a left right pattern + * to a parent, with 2 children. + * + * @public + * @method + * @param {Node} x node with lowest height to be restructured. + * @param {Node} y parent of x parameter. + * @param {Node} z grandparent of x, largest height. + */ + exports.AVLTree.prototype._leftRight = function (x, y, z) { + /* + z + y => x + x y z + */ + //pass z parent to x + if (z._parent !== null){ + var orientation = (z._parent._left === z) ? '_left' : '_right'; + z._parent[orientation] = x; + x._parent = z._parent; + }else { + this._root = x; + x._parent = null; + } + // Adoptions + z._left = x._right; + if (z._left !== null){ + z._left._parent = z; + } + y._right = x._left; + if (y._right !== null){ + y._right._parent = y; + } + // Point to new children (x new parent) + x._right = z; + x._left = y; + x._left._parent = x; + x._right._parent = x; + // Correct each nodes height - order matters, children first + y._height = this._getHeightAtNode(y); + z._height = this._getHeightAtNode(z); + x._height = this._getHeightAtNode(x); + }; + + /** + * Inserts a node into the AVL Tree.

+ * Time complexity: O(log N) in the average case + * and O(N) in the worst case. + * + * @public + * @method + * @param {Number|String} value Node value. + * @param {Node} current Current node. + */ + exports.AVLTree.prototype.insert = function (value, current) { + if (this._root === null) { + this._root = new exports.Node(value, null, null, null, 1); + this._maintainHeightBalanceProperty(this._root); + return; + } + var insertKey; + current = current || this._root; + if (current.value > value) { + insertKey = '_left'; + } else { + insertKey = '_right'; + } + if (!current[insertKey]) { + current[insertKey] = new exports.Node(value, null, null, current); + this._maintainHeightBalanceProperty(current[insertKey]); + } else { + this.insert(value, current[insertKey]); + } + }; + + /** + * In-order traversal from the given node. + * + * @private + * @param {Node} current Node from which to start the traversal. + * @param {Function} callback Callback which + * will be called for each traversed node. + */ + exports.AVLTree.prototype._inorder = function (current, callback) { + if (!current) { + return; + } + this._inorder(current._left, callback); + if (typeof callback === 'function') { + callback(current); + } + this._inorder(current._right, callback); + }; + + /** + * In-order traversal of the whole AVL tree. + * + * @public + * @method + * @param {Function} callback Callback which will be + * called for each traversed node. + */ + exports.AVLTree.prototype.inorder = function (callback) { + return this._inorder(this._root, callback); + }; + + /** + * Post-order traversal from given node. + * + * @private + * @param {Node} current Node from which to start the traversal. + * @param {Function} callback Callback which will + * be called for each traversed node + */ + exports.AVLTree.prototype._postorder = function (current, callback) { + if (!current) { + return; + } + if (typeof callback === 'function') { + callback(current); + } + this._postorder(current._left, callback); + this._postorder(current._right, callback); + }; + + /** + * Post-order traversal of the whole tree. + * + * @public + * @param {Function} callback Callback which + * will be called for each traversed node. + */ + exports.AVLTree.prototype.postorder = function (callback) { + return this._postorder(this._root, callback); + }; + + /** + * Pre-order traversal of the tree from given node. + * + * @private + * @param {Node} current Node from which to start the traversal. + * @param {Function} callback Callback which + * will be called for each traversed node. + */ + exports.AVLTree.prototype._preorder = function (current, callback) { + if (!current) { + return; + } + if (typeof callback === 'function') { + callback(current); + } + this._preorder(current._left, callback); + this._preorder(current._right, callback); + }; + + /** + * Pre-order preorder traversal of the whole tree. + * + * @public + * @param {Function} callback Callback which will + * be called for each traversed node. + */ + exports.AVLTree.prototype.preorder = function (callback) { + return this._preorder(this._root, callback); + }; + + /** + * Finds a node by it's value.

+ * Average time complexity: O(log N). + * + * @public + * @param {Number|String} value of the node which should be found. + */ + exports.AVLTree.prototype.find = function (value) { + return this._find(value, this._root); + }; + + /** + * Finds a node by it's value in a given sub-tree. + * Average time complexity: O(log N). + * + * @private + * @param {Number|String} value of the node which should be found. + * @param {Node} current node to be checked. + */ + exports.AVLTree.prototype._find = function (value, current) { + if (!current) { + return null; + } + + if (current.value === value) { + return current; + } + + if (current.value > value) { + return this._find(value, current._left); + } + + if (current.value < value) { + return this._find(value, current._right); + } + }; + + /** + * Replaces given child with new one, for given parent. + * + * @private + * @param {Node} parent Parent node. + * @param {Node} oldChild Child to be replaced. + * @param {Node} newChild Child replacement. + */ + exports.AVLTree.prototype._replaceChild = + function (parent, oldChild, newChild) { + if (!parent) { + this._root = newChild; + this._root._parent = null; + } else { + if (parent._left === oldChild) { + parent._left = newChild; + } else { + parent._right = newChild; + } + if (newChild) { + newChild._parent = parent; + } + } + }; + + /** + * Removes node from the tree.

+ * Average runtime complexity: O(log N). + * + * @public + * @param {Node} node to be removed + * @returns {Boolean} True/false depending + * on whether the given node is removed. + */ + exports.AVLTree.prototype.remove = function (node) { + if (!node) { + return false; + } + + if (node._left && node._right) { + var min = this._findMin(node._right); + var temp = node.value; + + node.value = min.value; + min.value = temp; + return this.remove(min); + } else { + if (node._parent !== null) { + if (node._left) { + this._replaceChild(node._parent, node, node._left); + } else if (node._right) { + this._replaceChild(node._parent, node, node._right); + } else { + this._replaceChild(node._parent, node, null); + } + }else { + this._root = null; + } + return true; + } + }; + + /** + * Finds the node with minimum value in given sub-tree. + * + * @private + * @param {Node} node Root of the sub-tree. + * @param {Number|String} current Current minimum value of the sub-tree. + * @returns {Node} Node with the minimum value in the sub-tree. + */ + exports.AVLTree.prototype._findMin = function (node, current) { + current = current || { value: Infinity }; + if (!node) { + return current; + } + if (current.value > node.value) { + current = node; + } + return this._findMin(node._left, current); + }; + + /** + * Finds the node with maximum value in given sub-tree. + * + * @private + * @param {Node} node Root of the sub-tree. + * @param {Number|String} current Current maximum value of the sub-tree. + * @returns {Node} Node with the maximum value in the sub-tree. + */ + exports.AVLTree.prototype._findMax = function (node, current) { + current = current || { value: -Infinity }; + if (!node) { + return current; + } + if (current.value < node.value) { + current = node; + } + return this._findMax(node._right, current); + }; + + /** + * Finds the node with minimum value in the whole tree. + * + * @public + * @returns {Node} The minimum node of the tree. + */ + exports.AVLTree.prototype.findMin = function () { + return this._findMin(this._root); + }; + + /** + * Finds the node with maximum value in the whole tree. + * + * @public + * @returns {Node} The maximum node of the tree. + * + */ + exports.AVLTree.prototype.findMax = function () { + return this._findMax(this._root); + }; + + exports.AVLTree.prototype._isBalanced = function (current) { + if (!current) { + return true; + } + return this._isBalanced(current._left) && + this._isBalanced(current._right) && + Math.abs(this._getHeight(current._left) - + this._getHeight(current._right)) <= 1; + }; + + /** + * Returns whether the AVL Tree is balanced. + * + * @public + * @returns {Boolean} Whether the tree is balanced or not. + */ + exports.AVLTree.prototype.isBalanced = function () { + return this._isBalanced(this._root); + }; + + /** + * Finds the diameter of the AVL tree. + * + * @public + * @returns {Number} The longest path in the AVL Tree. + */ + exports.AVLTree.prototype.getDiameter = function () { + var getDiameter = function (root) { + if (!root) { + return 0; + } + var leftHeight = this._getHeight(root._left); + var rightHeight = this._getHeight(root._right); + var path = leftHeight + rightHeight + 1; + return Math.max(path, getDiameter(root._left), getDiameter(root._right)); + }.bind(this); + return getDiameter(this._root); + }; + + /** + * Returns the height of the tree. + * + * @public + * @returns {Number} The height of the tree. + */ + exports.AVLTree.prototype.getTreeHeight = function () { + return this._getHeight(this._root); + }; + + exports.AVLTree.prototype._getHeight = function (node) { + if (!node) { + return 0; + } + return 1 + Math.max(this._getHeight(node._left), + this._getHeight(node._right)); + }; + + /** + * Finds the lowest common ancestor of two nodes. + * + * @public + * @returns {Node} The lowest common ancestor of the two nodes or null. + */ + exports.AVLTree.prototype.lowestCommonAncestor = + function (firstNode, secondNode) { + return this._lowestCommonAncestor(firstNode, secondNode, this._root); + }; + + exports.AVLTree.prototype._lowestCommonAncestor = + function (firstNode, secondNode, current) { + var firstNodeInLeft = this._existsInSubtree(firstNode, current._left); + var secondNodeInLeft = this._existsInSubtree(secondNode, current._left); + var firstNodeInRight = this._existsInSubtree(firstNode, current._right); + var secondNodeInRight = this._existsInSubtree(secondNode, current._right); + if ((firstNodeInLeft && secondNodeInRight) || + (firstNodeInRight && secondNodeInLeft)) { + return current; + } + if (secondNodeInLeft && firstNodeInLeft) { + return this._lowestCommonAncestor(firstNode, secondNode, current._left); + } + if (secondNodeInRight && secondNodeInLeft) { + return this._lowestCommonAncestor(firstNode, secondNode, current._right); + } + return null; + }; + + exports.AVLTree.prototype._existsInSubtree = function (node, root) { + if (!root) { + return false; + } + if (node === root.value) { + return true; + } + return this._existsInSubtree(node, root._left) || + this._existsInSubtree(node, root._right); + }; + +})(typeof window === 'undefined' ? module.exports : window); diff --git a/test/data-structures/avl-tree.spec.js b/test/data-structures/avl-tree.spec.js new file mode 100644 index 00000000..3345e52e --- /dev/null +++ b/test/data-structures/avl-tree.spec.js @@ -0,0 +1,126 @@ +'use strict'; + +var mod = require('../../src/data-structures/avl-tree.js'); +var Node = mod.Node; +var AVLTree = mod.AVLTree; + +describe('Node', function () { + it('should be a constructor function', function () { + expect(typeof Node).toBe('function'); + }); +}); + +describe('AVL Tree', function () { + it('should be a constructor function', function () { + expect(typeof AVLTree).toBe('function'); + }); + it('should start with null root', function () { + expect(new AVLTree()._root).toBe(null); + }); + it('should insert and single rotate (leftRight) properly', function () { + var avlTree = new AVLTree(); + avlTree.insert(66); + avlTree.insert(3); + avlTree.insert(5); + expect(avlTree._root.value).toBe(5); + expect(avlTree._root._left.value).toBe(3); + expect(avlTree._root._right.value).toBe(66); + + expect(avlTree._root._height).toBe(2); + expect(avlTree._root._left._height).toBe(1); + expect(avlTree._root._right._height).toBe(1); + }); + it('should insert and single rotate (rightLeft) properly', function () { + var avlTree = new AVLTree(); + avlTree.insert(50); + avlTree.insert(75); + avlTree.insert(60); + expect(avlTree._root.value).toBe(60); + expect(avlTree._root._left.value).toBe(50); + expect(avlTree._root._right.value).toBe(75); + + expect(avlTree._root._height).toBe(2); + expect(avlTree._root._left._height).toBe(1); + expect(avlTree._root._right._height).toBe(1); + }); + it('should insert and double rotate (leftLeft) properly', function () { + var avlTree = new AVLTree(); + avlTree.insert(50); + avlTree.insert(25); + avlTree.insert(10); + expect(avlTree._root.value).toBe(25); + expect(avlTree._root._left.value).toBe(10); + expect(avlTree._root._right.value).toBe(50); + + expect(avlTree._root._height).toBe(2); + expect(avlTree._root._left._height).toBe(1); + expect(avlTree._root._right._height).toBe(1); + }); + it('should insert and double rotate (rightRight) properly', function () { + var avlTree = new AVLTree(); + avlTree.insert(50); + avlTree.insert(75); + avlTree.insert(100); + expect(avlTree._root.value).toBe(75); + expect(avlTree._root._left.value).toBe(50); + expect(avlTree._root._right.value).toBe(100); + + expect(avlTree._root._height).toBe(2); + expect(avlTree._root._left._height).toBe(1); + expect(avlTree._root._right._height).toBe(1); + }); + it('should insert multiple nodes and balance properly (1)', function () { + var avlTree = new AVLTree(); + avlTree.insert(30); + avlTree.insert(15); + avlTree.insert(60); + avlTree.insert(90); + avlTree.insert(100); + expect(avlTree._root.value).toBe(30); + expect(avlTree._root._left.value).toBe(15); + expect(avlTree._root._right.value).toBe(90); + expect(avlTree._root._right._left.value).toBe(60); + expect(avlTree._root._right._right.value).toBe(100); + + expect(avlTree._root._height).toBe(3); + expect(avlTree._root._left._height).toBe(1); + expect(avlTree._root._right._height).toBe(2); + expect(avlTree._root._right._left._height).toBe(1); + expect(avlTree._root._right._right._height).toBe(1); + }); + it('should insert multiple nodes and balance properly (2)', function () { + var avlTree = new AVLTree(); + avlTree.insert(24); + avlTree.insert(67); + avlTree.insert(33); + avlTree.insert(52); + avlTree.insert(11); + avlTree.insert(15); + avlTree.insert(26); + avlTree.insert(27); + // depth 1 + expect(avlTree._root.value).toBe(33); + expect(avlTree._root._height).toBe(4); + // depth 2 + expect(avlTree._root._left.value).toBe(15); + expect(avlTree._root._left._height).toBe(3); + + expect(avlTree._root._right.value).toBe(67); + expect(avlTree._root._right._height).toBe(2); + // depth 3 + expect(avlTree._root._left._left.value).toBe(11); + expect(avlTree._root._left._left._height).toBe(1); + + expect(avlTree._root._left._right.value).toBe(26); + expect(avlTree._root._left._right._height).toBe(2); + + expect(avlTree._root._right._left.value).toBe(52); + expect(avlTree._root._right._left._height).toBe(1); + // depth 4 + expect(avlTree._root._left._right._left.value).toBe(24); + expect(avlTree._root._left._right._left._height).toBe(1); + + expect(avlTree._root._left._right._right.value).toBe(27); + expect(avlTree._root._left._right._right._height).toBe(1); + }); +}); From 01f46fb78ea6f345e70d28b2d7d87b48f1b16c1d Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 27 Feb 2015 09:42:53 -0800 Subject: [PATCH 405/613] Update the contributors list --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 239e9256..4bdc682c 100644 --- a/readme.md +++ b/readme.md @@ -71,9 +71,9 @@ If the build is not successful fix your code in order the tests and jshint valid ## Contributors -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[pvoznenko](https://github.com/pvoznenko) |[secrettriangle](https://github.com/secrettriangle) |[Jakehp](https://github.com/Jakehp) |[Microfed](https://github.com/Microfed) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[pvoznenko](https://github.com/pvoznenko) |[Jakehp](https://github.com/Jakehp) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) | :---: |:---: |:---: |:---: |:---: |:---: | -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[pvoznenko](https://github.com/pvoznenko) |[secrettriangle](https://github.com/secrettriangle) |[Jakehp](https://github.com/Jakehp) |[Microfed](https://github.com/Microfed) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[pvoznenko](https://github.com/pvoznenko) |[Jakehp](https://github.com/Jakehp) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) | [contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | :---: |:---: | From 136c3fb2442eb6efabe94152ef4332183d3a3ab4 Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Fri, 27 Feb 2015 23:21:48 -0600 Subject: [PATCH 406/613] AVL Tree balance on removal. Added remove specs. --- src/data-structures/avl-tree.js | 137 +++++++++++++++++++------- test/data-structures/avl-tree.spec.js | 38 +++++++ 2 files changed, 142 insertions(+), 33 deletions(-) diff --git a/src/data-structures/avl-tree.js b/src/data-structures/avl-tree.js index 4e6aa075..7e911a94 100644 --- a/src/data-structures/avl-tree.js +++ b/src/data-structures/avl-tree.js @@ -93,6 +93,76 @@ return true; }; + exports.AVLTree.prototype._getNodesToRestructureRemove = + function (traveledNodes) { + // z is last traveled node - imbalance found at z + var zIndex = traveledNodes.length; + zIndex -= 1; + var z = traveledNodes[zIndex]; + // y should be child of z with larger height + // (cannot be ancestor of removed node) + var y; + if (z._left !== null && z._right !== null){ + y = (z._left === y) ? z._right : z._left; + }else if (z._left !== null && z._right === null){ + y = z._left; + }else if (z._right !== null && z._left === null){ + y = z._right; + } + // x should be tallest child of y. + // If children same height, x should be child of y + // that has same orientation as z to y. + var x; + if (y._left !== null && y._right !== null){ + if (y._left._height > y._right._height){ + x = y._left; + }else if (y._left._height < y._right._height){ + x = y._right; + }else if (y._left._height === y._right._height){ + x = (z._left === y) ? y._left : y._right; + } + }else if (y._left !== null && y._right === null){ + x = y._left; + }else if (y._right !== null && y._left === null){ + x = y._right; + } + return [x, y, z]; + }; + + exports.AVLTree.prototype._getNodesToRestructureInsert = + function (traveledNodes) { + // z is last traveled node - imbalance found at z + var zIndex = traveledNodes.length; + zIndex -= 1; + var z = traveledNodes[zIndex]; + // y should be child of z with larger height + // (must be ancestor of inserted node) + // therefore, last traveled node is correct. + var yIndex = traveledNodes.length; + yIndex -= 2; + var y = traveledNodes[yIndex]; + // x should be tallest child of y. + // If children same height, x should be ancestor + // of inserted node (in traveled path). + var x; + if (y._left !== null && y._right !== null){ + if (y._left._height > y._right._height){ + x = y._left; + }else if (y._left._height < y._right._height){ + x = y._right; + }else if (y._left._height === y._right._height){ + var xIndex = traveledNodes.length; + xIndex -= 3; + x = traveledNodes[xIndex]; + } + }else if (y._left !== null && y._right === null){ + x = y._left; + }else if (y._right !== null && y._left === null){ + x = y._right; + } + return [x, y, z]; + }; + /** * Maintains the height balance property by * walking to root and checking for invalid height @@ -102,21 +172,20 @@ * @public * @method * @param {Node} node Started node. + * @param {Boolean} isRemove Represents if method was called after remove. */ - exports.AVLTree.prototype._maintainHeightBalanceProperty = function (node) { + exports.AVLTree.prototype._maintainHeightBalanceProperty = + function (node, isRemove) { var current = node; - var path = []; //During restructure, use last 3 nodes traveled. + var traveledNodes = []; while (current !== null){ - path.push(current); + traveledNodes.push(current); current._height = this._getHeightAtNode(current); if (!this._isBalancedAtNode(current)){ - if (path.length >= 3){ - var nodesToRestructure = path.slice(0, 3); - var x = nodesToRestructure[0]; - var y = nodesToRestructure[1]; - var z = nodesToRestructure[2]; - this._restructure(x, y, z); - } + var nodesToBeRestructured = (isRemove) + ? this._getNodesToRestructureRemove(traveledNodes) + : this._getNodesToRestructureInsert(traveledNodes); + this._restructure(nodesToBeRestructured); } current = current._parent; } @@ -128,11 +197,13 @@ * * @public * @method - * @param {Node} x node with lowest height to be restructured. - * @param {Node} y parent of x parameter. - * @param {Node} z grandparent of x, largest height. + * @param {Array} nodesToBeRestructured + * array of nodes, in format, [x, y, z], to be restructured */ - exports.AVLTree.prototype._restructure = function (x, y, z) { + exports.AVLTree.prototype._restructure = function (nodesToBeRestructured) { + var x = nodesToBeRestructured[0]; + var y = nodesToBeRestructured[1]; + var z = nodesToBeRestructured[2]; //Determine Rotation Pattern if (z._right === y && y._right === x){ this._rightRight(x, y, z); @@ -337,7 +408,7 @@ } if (!current[insertKey]) { current[insertKey] = new exports.Node(value, null, null, current); - this._maintainHeightBalanceProperty(current[insertKey]); + this._maintainHeightBalanceProperty(current[insertKey], false); } else { this.insert(value, current[insertKey]); } @@ -481,9 +552,11 @@ */ exports.AVLTree.prototype._replaceChild = function (parent, oldChild, newChild) { - if (!parent) { + if (parent === null) { this._root = newChild; - this._root._parent = null; + if (this._root !== null){ + this._root._parent = null; + } } else { if (parent._left === oldChild) { parent._left = newChild; @@ -501,33 +574,31 @@ * Average runtime complexity: O(log N). * * @public - * @param {Node} node to be removed + * @param {Number|String} value of node to be removed * @returns {Boolean} True/false depending * on whether the given node is removed. */ - exports.AVLTree.prototype.remove = function (node) { + exports.AVLTree.prototype.remove = function (value) { + var node = this.find(value); if (!node) { return false; } - if (node._left && node._right) { var min = this._findMin(node._right); var temp = node.value; - node.value = min.value; min.value = temp; return this.remove(min); } else { - if (node._parent !== null) { - if (node._left) { - this._replaceChild(node._parent, node, node._left); - } else if (node._right) { - this._replaceChild(node._parent, node, node._right); - } else { - this._replaceChild(node._parent, node, null); - } - }else { - this._root = null; + if (node._left) { + this._replaceChild(node._parent, node, node._left); + this._maintainHeightBalanceProperty(node._left, true); + } else if (node._right) { + this._replaceChild(node._parent, node, node._right); + this._maintainHeightBalanceProperty(node._right, true); + } else { + this._replaceChild(node._parent, node, null); + this._maintainHeightBalanceProperty(node._parent, true); } return true; } @@ -656,12 +727,12 @@ * @returns {Node} The lowest common ancestor of the two nodes or null. */ exports.AVLTree.prototype.lowestCommonAncestor = - function (firstNode, secondNode) { + function (firstNode, secondNode) { return this._lowestCommonAncestor(firstNode, secondNode, this._root); }; exports.AVLTree.prototype._lowestCommonAncestor = - function (firstNode, secondNode, current) { + function (firstNode, secondNode, current) { var firstNodeInLeft = this._existsInSubtree(firstNode, current._left); var secondNodeInLeft = this._existsInSubtree(secondNode, current._left); var firstNodeInRight = this._existsInSubtree(firstNode, current._right); diff --git a/test/data-structures/avl-tree.spec.js b/test/data-structures/avl-tree.spec.js index 3345e52e..19b8c9bb 100644 --- a/test/data-structures/avl-tree.spec.js +++ b/test/data-structures/avl-tree.spec.js @@ -123,4 +123,42 @@ describe('AVL Tree', function () { expect(avlTree._root._left._right._right.value).toBe(27); expect(avlTree._root._left._right._right._height).toBe(1); }); + it('should remove nodes and balance properly (1)', function () { + var avlTree = new AVLTree(); + avlTree.insert(30); + avlTree.insert(15); + avlTree.insert(60); + avlTree.insert(90); + avlTree.insert(100); + avlTree.remove(15); + // depth 1 + expect(avlTree._root.value).toBe(90); + expect(avlTree._root._height).toBe(3); + // depth 2 + expect(avlTree._root._left.value).toBe(30); + expect(avlTree._root._left._height).toBe(2); + + expect(avlTree._root._right.value).toBe(100); + expect(avlTree._root._right._height).toBe(1); + // depth 3 + expect(avlTree._root._left._right.value).toBe(60); + expect(avlTree._root._left._right._height).toBe(1); + }); + it('should remove nodes and balance properly (2)', function () { + var avlTree = new AVLTree(); + avlTree.insert(55); + avlTree.insert(25); + avlTree.insert(11); + avlTree.insert(1); + avlTree.remove(55); + // depth 1 + expect(avlTree._root.value).toBe(11); + expect(avlTree._root._height).toBe(2); + // depth 2 + expect(avlTree._root._left.value).toBe(1); + expect(avlTree._root._left._height).toBe(1); + + expect(avlTree._root._right.value).toBe(25); + expect(avlTree._root._right._height).toBe(1); + }); }); From 6613e2d56bcc6ca9b471ea67b899358aba163e34 Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Sun, 1 Mar 2015 12:59:02 -0600 Subject: [PATCH 407/613] BST remove root with children bug fix. --- src/data-structures/binary-search-tree.js | 22 ++++++++----------- .../binary-search-tree.spec.js | 9 ++++++++ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 9aa08f28..c6dd09f0 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -225,7 +225,9 @@ function (parent, oldChild, newChild) { if (!parent) { this._root = newChild; - this._root._parent = null; + if (this._root !== null){ + this._root._parent = null; + } } else { if (parent._left === oldChild) { parent._left = newChild; @@ -251,25 +253,19 @@ if (!node) { return false; } - if (node._left && node._right) { var min = this._findMin(node._right); var temp = node.value; - node.value = min.value; min.value = temp; return this.remove(min); } else { - if (node._parent !== null) { - if (node._left) { - this._replaceChild(node._parent, node, node._left); - } else if (node._right) { - this._replaceChild(node._parent, node, node._right); - } else { - this._replaceChild(node._parent, node, null); - } - }else { - this._root = null; + if (node._left) { + this._replaceChild(node._parent, node, node._left); + } else if (node._right) { + this._replaceChild(node._parent, node, node._right); + } else { + this._replaceChild(node._parent, node, null); } return true; } diff --git a/test/data-structures/binary-search-tree.spec.js b/test/data-structures/binary-search-tree.spec.js index f889dcdd..fc90744b 100644 --- a/test/data-structures/binary-search-tree.spec.js +++ b/test/data-structures/binary-search-tree.spec.js @@ -24,6 +24,15 @@ describe('Binary Tree', function () { bTree.remove(node); expect(bTree._root).toBe(null); }); + it('should remove root and replace with valid child', function () { + var bTree = new BinaryTree(); + bTree.insert(15); + bTree.insert(30); + bTree.insert(45); + var node = bTree.find(15); + bTree.remove(node); + expect(bTree._root.value).toBe(30); + }); it('should insert multiple nodes properly', function () { var bTree = new BinaryTree(); bTree.insert(10); From d679da5899dc58e44bacaab0593bc817d685e0d8 Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Mon, 2 Mar 2015 19:25:32 -0600 Subject: [PATCH 408/613] Basic heap specs. typo in heap. --- src/data-structures/heap.js | 2 +- test/data-structures/heap.spec.js | 61 +++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 test/data-structures/heap.spec.js diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index c654f815..b2e167b3 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -47,7 +47,7 @@ * * @public * @constructor - * @param {Function} cmp Function used for comparition between the elements. + * @param {Function} cmp Function used for comparison between the elements. */ exports.Heap = function (cmp) { this._heap = []; diff --git a/test/data-structures/heap.spec.js b/test/data-structures/heap.spec.js new file mode 100644 index 00000000..d6de8ecb --- /dev/null +++ b/test/data-structures/heap.spec.js @@ -0,0 +1,61 @@ +'use strict'; + +var mod = require('../../src/data-structures/heap.js'); +var Heap = mod.Heap; + +describe('Heap', function () { + it('should be a constructor function', function () { + expect(typeof Heap).toBe('function'); + }); + it('should have default comparison function', function () { + var heap = new Heap(); + expect(typeof heap._cmp).toBe('function'); + }); + it('should add an object properly', function () { + var heap = new Heap(); + heap.add(1); + expect(heap._heap[0]).toBe(1); + }); + it('should remove an object properly', function () { + var heap = new Heap(); + heap.add(1); + var res = heap.extract(); + expect(res).toBe(1); + expect(heap._heap.length).toBe(0); + }); + it('should add multiple nodes properly', function () { + var heap = new Heap(); + heap.add(55); + heap.add(11); + heap.add(66); + expect(heap._heap.indexOf(55)).toBeGreaterThan(-1); + expect(heap._heap.indexOf(11)).toBeGreaterThan(-1); + expect(heap._heap.indexOf(66)).toBeGreaterThan(-1); + }); + it('should remove multiple nodes properly (max heap)', function () { + var heap = new Heap(); + heap.add(55); + heap.add(11); + heap.add(66); + var res = heap.extract(); + expect(res).toBe(66); + res = heap.extract(); + expect(res).toBe(55); + res = heap.extract(); + expect(res).toBe(11); + }); + it('should remove multiple nodes properly (min heap)', function () { + var heap = new Heap(function (a, b) { + return b - a; + }); + heap.add(55); + heap.add(11); + heap.add(66); + var res = heap.extract(); + expect(res).toBe(11); + res = heap.extract(); + expect(res).toBe(55); + res = heap.extract(); + expect(res).toBe(66); + }); +}); \ No newline at end of file From 53a6405c1b11e1912ee8222befdc4925e7476155 Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Mon, 2 Mar 2015 21:56:34 -0600 Subject: [PATCH 409/613] added new line. --- test/data-structures/heap.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/data-structures/heap.spec.js b/test/data-structures/heap.spec.js index d6de8ecb..e26b2f45 100644 --- a/test/data-structures/heap.spec.js +++ b/test/data-structures/heap.spec.js @@ -58,4 +58,4 @@ describe('Heap', function () { res = heap.extract(); expect(res).toBe(66); }); -}); \ No newline at end of file +}); From 7bebda62d952459c4cf89fd16cd22d0b13354e5c Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Tue, 3 Mar 2015 17:38:52 -0600 Subject: [PATCH 410/613] Added linked list spec. --- src/data-structures/linked-list.js | 2 +- test/data-structures/linked-list.spec.js | 140 +++++++++++++++++++++++ 2 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 test/data-structures/linked-list.spec.js diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index 9f997893..f7390d81 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -165,7 +165,7 @@ }; /** - * Check or linked list contains cycle. + * Check if linked list contains cycle. * * @public * @method diff --git a/test/data-structures/linked-list.spec.js b/test/data-structures/linked-list.spec.js new file mode 100644 index 00000000..67f1faea --- /dev/null +++ b/test/data-structures/linked-list.spec.js @@ -0,0 +1,140 @@ +'use strict'; + +var mod = require('../../src/data-structures/linked-list.js'); +var Node = mod.Node; +var LinkedList = mod.LinkedList; + +describe('Node', function () { + it('should be a constructor function', function () { + expect(typeof Node).toBe('function'); + }); + it('should construct properly', function () { + var node = new Node("data"); + expect(node.data).toBe("data"); + expect(node.next).toBe(null); + expect(node.prev).toBe(null); + }); +}); + +describe('Linked List', function () { + it('should be a constructor function', function () { + expect(typeof LinkedList).toBe('function'); + }); + it('should push properly', function () { + var linkedList = new LinkedList(); + linkedList.push(1); + linkedList.push(2); + linkedList.push(3); + linkedList.push(4); + linkedList.push(5); + expect(linkedList.first.data).toBe(1); + expect(linkedList.first.next.data).toBe(2); + expect(linkedList.first.next.next.data).toBe(3); + expect(linkedList.first.next.next.next.data).toBe(4); + expect(linkedList.first.next.next.next.next.data).toBe(5); + expect(linkedList.last.data).toBe(5); + }); + it('should pop properly', function () { + var linkedList = new LinkedList(); + linkedList.push(1); + linkedList.push(2); + linkedList.push(3); + linkedList.push(4); + linkedList.push(5); + expect(linkedList.pop().data).toBe(5); + expect(linkedList.pop().data).toBe(4); + expect(linkedList.pop().data).toBe(3); + expect(linkedList.pop().data).toBe(2); + expect(linkedList.pop().data).toBe(1); + }); + it('should shift properly', function () { + var linkedList = new LinkedList(); + linkedList.push(1); + linkedList.push(2); + linkedList.push(3); + linkedList.push(4); + linkedList.push(5); + expect(linkedList.shift().data).toBe(1); + expect(linkedList.shift().data).toBe(2); + expect(linkedList.shift().data).toBe(3); + expect(linkedList.shift().data).toBe(4); + expect(linkedList.shift().data).toBe(5); + }); + it('should reverse properly', function () { + var linkedList = new LinkedList(); + linkedList.push(1); + linkedList.push(2); + linkedList.push(3); + linkedList.push(4); + linkedList.push(5); + linkedList.reverse(); + expect(linkedList.shift().data).toBe(5); + expect(linkedList.shift().data).toBe(4); + expect(linkedList.shift().data).toBe(3); + expect(linkedList.shift().data).toBe(2); + expect(linkedList.shift().data).toBe(1); + }); + it('should recursive reverse properly', function () { + var linkedList = new LinkedList(); + linkedList.push(1); + linkedList.push(2); + linkedList.push(3); + linkedList.push(4); + linkedList.push(5); + linkedList.recursiveReverse(); + expect(linkedList.shift().data).toBe(5); + expect(linkedList.shift().data).toBe(4); + expect(linkedList.shift().data).toBe(3); + expect(linkedList.shift().data).toBe(2); + expect(linkedList.shift().data).toBe(1); + }); + it('should unshift properly', function () { + var linkedList = new LinkedList(); + linkedList.push(1); + linkedList.push(2); + linkedList.push(3); + linkedList.push(4); + linkedList.push(5); + linkedList.unshift(3); + expect(linkedList.shift().data).toBe(3); + expect(linkedList.shift().data).toBe(1); + expect(linkedList.shift().data).toBe(2); + expect(linkedList.shift().data).toBe(3); + expect(linkedList.shift().data).toBe(4); + expect(linkedList.shift().data).toBe(5); + }); + it('should properly check for existing cycle', function () { + var linkedList = new LinkedList(); + var last = new Node(2); + var first = new Node(1); + last.next = first; + last.prev = first; + first.next = last; + first.prev = last; + linkedList.first = first; + linkedList.last = last; + expect(linkedList.hasCycle()).toBe(true); + }); + it('should properly check for non existing cycle', function () { + var linkedList = new LinkedList(); + linkedList.push(1); + linkedList.push(2); + linkedList.push(3); + linkedList.push(4); + linkedList.push(5); + expect(linkedList.hasCycle()).toBe(false); + }); + it('should inorder properly', function () { + var linkedList = new LinkedList(); + linkedList.push(1); + linkedList.push(2); + linkedList.push(3); + linkedList.push(4); + linkedList.push(5); + var pushedValue = 1; + function callback(node){ + expect(node.data).toBe(pushedValue++); + } + linkedList.inorder(callback); + }); +}); From a9868099d9a02b8ff69dddb64c290de527813d49 Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Wed, 4 Mar 2015 16:44:33 -0600 Subject: [PATCH 411/613] Added more docs for datastructures. --- src/data-structures/avl-tree.js | 18 +++++++++++ src/data-structures/binary-search-tree.js | 37 ++++++++++++++++++++++ src/data-structures/linked-list.js | 12 +++++++ src/data-structures/splay-tree.js | 38 ++++++++++++++++++++--- src/sorting/heapsort.js | 3 ++ 5 files changed, 104 insertions(+), 4 deletions(-) diff --git a/src/data-structures/avl-tree.js b/src/data-structures/avl-tree.js index 7e911a94..8694246d 100644 --- a/src/data-structures/avl-tree.js +++ b/src/data-structures/avl-tree.js @@ -93,6 +93,15 @@ return true; }; + /** + * Gets the nodes to be restructured during an AVL restructure + * after a remove/delete takes place. + * + * @public + * @method + * @param {Array} traveledNodes Array of previously traveled nodes + * that are used to help determine the nodes to be restructured. + */ exports.AVLTree.prototype._getNodesToRestructureRemove = function (traveledNodes) { // z is last traveled node - imbalance found at z @@ -129,6 +138,15 @@ return [x, y, z]; }; + /** + * Gets the nodes to be restructured during an AVL restructure + * after an insert takes place. + * + * @public + * @method + * @param {Array} traveledNodes Array of previously traveled nodes + * that are used to help determine the nodes to be restructured. + */ exports.AVLTree.prototype._getNodesToRestructureInsert = function (traveledNodes) { // z is last traveled node - imbalance found at z diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index c6dd09f0..5d332218 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -330,6 +330,13 @@ return this._findMax(this._root); }; + /** + * Checks if a given node is balanced. + * + * @private + * @param {Node} current Node to have balance checked. + * @returns {Boolean} Boolean of whether or not provided node is balanced. + */ exports.BinaryTree.prototype._isBalanced = function (current) { if (!current) { return true; @@ -379,6 +386,13 @@ return this._getHeight(this._root); }; + /** + * Recursive worker function for getHeight() + * + * @private + * @param {Node} node Node at current recursive frame. + * @returns {Number} Height of the Node in the parameter. + */ exports.BinaryTree.prototype._getHeight = function (node) { if (!node) { return 0; @@ -391,6 +405,10 @@ * Finds the lowest common ancestor of two nodes. * * @public + * @param {Node} firstNode First node to be considered when checking + * for ancestor. + * @param {Node} secondNode Second node to be considered when checking + * for ancestor. * @returns {Node} The lowest common ancestor of the two nodes or null. */ exports.BinaryTree.prototype.lowestCommonAncestor = @@ -398,6 +416,17 @@ return this._lowestCommonAncestor(firstNode, secondNode, this._root); }; + /** + * Obtains the lowest common ancestor for the given nodes. + * + * @private + * @param {Node} firstNode First node to be considered when checking + * for ancestor. + * @param {Node} secondNode Second node to be considered when checking + * for ancestor. + * @param {Node} current Current node. + * @returns {Node} The lowest common ancestor of the two nodes or null. + */ exports.BinaryTree.prototype._lowestCommonAncestor = function (firstNode, secondNode, current) { var firstNodeInLeft = this._existsInSubtree(firstNode, current._left); @@ -417,6 +446,14 @@ return null; }; + /** + * Checks if a given node exists in a subtree. + * + * @private + * @param {Node} node Node to check for. + * @param {Node} root Root node of a given subtree. + * @returns {Node} The lowest common ancestor of the two nodes or null. + */ exports.BinaryTree.prototype._existsInSubtree = function (node, root) { if (!root) { return false; diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index f7390d81..14e9a23e 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -222,6 +222,12 @@ return temp; }; + /** + * Reverses the linked list recursively + * + * @public + * @method + */ exports.LinkedList.prototype.recursiveReverse = function () { function inverse(current, next) { @@ -242,6 +248,12 @@ this.last = temp; }; + /** + * Reverses the linked list iteratively + * + * @public + * @method + */ exports.LinkedList.prototype.reverse = function () { if (!this.first || !this.first.next) { return; diff --git a/src/data-structures/splay-tree.js b/src/data-structures/splay-tree.js index b7aff748..dfadb1ee 100644 --- a/src/data-structures/splay-tree.js +++ b/src/data-structures/splay-tree.js @@ -58,6 +58,7 @@ * @private * @method * @param {Node} node Node to be splayed. + * @returns {Node} The same node from the parameter, post splayed. */ exports.SplayTree.prototype._splay = function (node) { while (this._root !== node) { @@ -87,6 +88,7 @@ * @private * @method * @param {Node} node Node to be zig-zig'd. + * @returns {Node} The same node from the parameter, post splayed. */ exports.SplayTree.prototype._zigZig = function (node) { @@ -136,6 +138,7 @@ * @private * @method * @param {Node} node Node to be zig-zag'd. + * @returns {Node} The same node from the parameter, post splayed. */ exports.SplayTree.prototype._zigZag = function (node) { @@ -185,6 +188,7 @@ * @private * @method * @param {Node} node Node to be zig'd. + * @returns {Node} The same node from the parameter, post splayed. */ exports.SplayTree.prototype._zig = function (node) { @@ -334,7 +338,7 @@ * Average time complexity: O(log N). * * @public - * @param {Number|String} Value of the node which should be found. + * @param {Number|String} value of the node which should be found. */ exports.SplayTree.prototype.search = function (value) { var node = this._search(value, this._root); @@ -346,7 +350,7 @@ * Average time complexity: O(log N). * * @public - * @param {Number|String} Value of the node which should be found. + * @param {Number|String} value of the node which should be found. */ exports.SplayTree.prototype._splaylessSearch = function (value) { return this._search(value, this._root); @@ -357,8 +361,8 @@ * Average time complexity: O(log N). * * @private - * @param {Number|String} Value of the node which should be found. - * @param {Node} Current node to be checked. + * @param {Number|String} value of the node which should be found. + * @param {Node} current node to be checked. */ exports.SplayTree.prototype._search = function (value, current) { if (!current) { @@ -512,6 +516,13 @@ return this._getHeight(this._root); }; + /** + * Recursive worker function for getHeight() + * + * @public + * @param {Node} node The node of the current recursive frame. + * @returns {Number} The height of the tree. + */ exports.SplayTree.prototype._getHeight = function (node) { if (!node) { return 0; @@ -531,6 +542,17 @@ return this._lowestCommonAncestor(firstNode, secondNode, this._root); }; + /** + * Obtains the lowest common ancestor for the given nodes. + * + * @private + * @param {Node} firstNode First node to be considered when checking + * for ancestor. + * @param {Node} secondNode Second node to be considered when checking + * for ancestor. + * @param {Node} current Current node. + * @returns {Node} The lowest common ancestor of the two nodes or null. + */ exports.SplayTree.prototype._lowestCommonAncestor = function (firstNode, secondNode, current) { var firstNodeInLeft = this._existsInSubtree(firstNode, current._left); @@ -551,6 +573,14 @@ return null; }; + /** + * Checks if a given node exists in a subtree. + * + * @private + * @param {Node} node Node to check for. + * @param {Node} root Root node of a given subtree. + * @returns {Node} The lowest common ancestor of the two nodes or null. + */ exports.SplayTree.prototype._existsInSubtree = function (node, root) { if (!root) { return false; diff --git a/src/sorting/heapsort.js b/src/sorting/heapsort.js index b661a827..765adc3a 100644 --- a/src/sorting/heapsort.js +++ b/src/sorting/heapsort.js @@ -14,6 +14,8 @@ * @param {Array} array Array. * @param {Number} index Index of the element which palce in * the max heap should be found. + * @param {Number} heapSize Size of the heap. + * @param {function} cmp Comparison function. */ function heapify(array, index, heapSize, cmp) { var left = 2 * index + 1; @@ -41,6 +43,7 @@ * * @private * @param {Array} array Array which should be turned into max heap. + * @param {function} cmp Comparison function. * @return {Array} array Array turned into max heap. */ function buildMaxHeap(array, cmp) { From 4a2d98ec0942d788fca61445404a4386ce7ed7d6 Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Thu, 5 Mar 2015 20:09:52 -0600 Subject: [PATCH 412/613] more doc fixes. --- src/graphics/bresenham-line-drawing.js | 1 + src/graphs/shortest-path/dijkstra.js | 1 + src/graphs/shortest-path/floyd-warshall.js | 4 ++-- src/others/hanoi.js | 4 ++-- src/searching/quickselect.js | 2 +- src/searching/recursive-binarysearch.js | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/graphics/bresenham-line-drawing.js b/src/graphics/bresenham-line-drawing.js index d8f79c7e..099cd694 100644 --- a/src/graphics/bresenham-line-drawing.js +++ b/src/graphics/bresenham-line-drawing.js @@ -8,6 +8,7 @@ * @param {number} y1 The second coordinate of the beginning of the line * @param {number} x2 The first coordinate of the end of the line * @param {number} y2 The second coordinate of the end of the line + * @param {function} draw Optional custom drawing function. */ function drawLine(x1, y1, x2, y2, draw) { drawPoint = draw || drawPoint; diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index 38b7aa30..0f5d30bd 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -39,6 +39,7 @@ * * @private * @param {number} src Start node. + * @param {Array} graph A distance matrix of the graph. */ function init(src, graph) { var currentTemp; diff --git a/src/graphs/shortest-path/floyd-warshall.js b/src/graphs/shortest-path/floyd-warshall.js index 4e97fd12..6c25b804 100644 --- a/src/graphs/shortest-path/floyd-warshall.js +++ b/src/graphs/shortest-path/floyd-warshall.js @@ -12,8 +12,8 @@ * Initialize the distance matrix. * * @private - * @param {array} graph Distance matrix of the array. - * @return {array} Distance matrix used for the algorithm. + * @param {Array} graph Distance matrix of the array. + * @return {Array} Distance matrix used for the algorithm. */ function init(graph) { var dist = []; diff --git a/src/others/hanoi.js b/src/others/hanoi.js index bbd6b052..613ff98a 100644 --- a/src/others/hanoi.js +++ b/src/others/hanoi.js @@ -25,8 +25,8 @@ * * @param {Number} count Count of the plates/stones. * @param {String|Number} source Identifier of the 1st peg. - * @param {String|Number} source Identifier of the 2nd peg. - * @param {String|Number} source Identifier of the 3rd peg. + * @param {String|Number} intermediate Identifier of the 2nd peg. + * @param {String|Number} goal Identifier of the 3rd peg. * @return Array which contains all the moves required * in order to place all the plates onto the last peg. */ diff --git a/src/searching/quickselect.js b/src/searching/quickselect.js index 6a16457f..ba068ea9 100644 --- a/src/searching/quickselect.js +++ b/src/searching/quickselect.js @@ -18,7 +18,7 @@ * @param {Array} arr Input array. * @param {Number} n A number of an element. * @param {Number} lo Low index. - * @param {Number} lo High index. + * @param {Number} hi High index. * @return Returns n-th smallest element. */ function quickselect(arr, n, lo, hi) { diff --git a/src/searching/recursive-binarysearch.js b/src/searching/recursive-binarysearch.js index 8eb4d2f5..1344bacd 100644 --- a/src/searching/recursive-binarysearch.js +++ b/src/searching/recursive-binarysearch.js @@ -26,7 +26,7 @@ /** * Recursive version of binary search. - * Searchs for specific element in a given array using + * Searches for specific element in a given array using * the binary search algorithm.

* Time complexity: O(log N). * From ecc523c9b5687b3e47f4f7ba9073f0ace00316a4 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 10 Mar 2015 11:51:50 -0700 Subject: [PATCH 413/613] Update contrib list --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 4bdc682c..0b95fa29 100644 --- a/readme.md +++ b/readme.md @@ -71,9 +71,9 @@ If the build is not successful fix your code in order the tests and jshint valid ## Contributors -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[pvoznenko](https://github.com/pvoznenko) |[Jakehp](https://github.com/Jakehp) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) | :---: |:---: |:---: |:---: |:---: |:---: | -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[pvoznenko](https://github.com/pvoznenko) |[Jakehp](https://github.com/Jakehp) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) | [contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | :---: |:---: | From 6ac898570c55272c83d9741dd765feacf02eaf20 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 17 Mar 2015 21:15:49 -0700 Subject: [PATCH 414/613] Add min change problem --- src/others/min-coins-change.js | 50 +++++++++++++++++++++++++++++++ test/others/min-coins-sum.spec.js | 30 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 src/others/min-coins-change.js create mode 100644 test/others/min-coins-sum.spec.js diff --git a/src/others/min-coins-change.js b/src/others/min-coins-change.js new file mode 100644 index 00000000..239f99e5 --- /dev/null +++ b/src/others/min-coins-change.js @@ -0,0 +1,50 @@ +(function (exports) { + 'use strict'; + + /** + * Returns the minimum number of coins from given set, + * which sum equals to given change. This is famous + * problem from the dymanic programming: + * https://en.wikipedia.org/wiki/Change-making_problem + * + * @public + * @module others/minCoinsChange + * + * @example + * + * var minCoinsChange = + * require('path-to-algorithms/src/others/min-coins-change') + * .minCoinsChange; + * var coins = minCoinsChange([1, 2, 3], 5); // [ 2, 3 ] + * + * @param {Array} coins The sorted list of the coins used for the change. + * @param {Number} change The change, which should be returned. + * @return Array which contains the minimum coins from the given + * list, required for the change. + */ + function minCoinsChange(coins, change) { + var minChange = [[0]]; + if (coins.indexOf(change) >= 0) { + return [change]; + } + for (var i = 1; i <= change; i += 1) { + var current = null; + for (var j = 0; j < coins.length && coins[j] <= change; j += 1) { + for (var k = 0; k < minChange.length; k += 1) { + if (k + coins[j] === i && + (!current || minChange[k].length + 1 < current.length)) { + minChange[i] = minChange[k].concat([coins[j]]); + } + } + } + } + var result = minChange[change]; + if (!result) { + return undefined; + } + return result.slice(1); + } + + exports.minCoinsChange = minCoinsChange; + +})(typeof window === 'undefined' ? module.exports : window); diff --git a/test/others/min-coins-sum.spec.js b/test/others/min-coins-sum.spec.js new file mode 100644 index 00000000..7a5004d1 --- /dev/null +++ b/test/others/min-coins-sum.spec.js @@ -0,0 +1,30 @@ +'use strict'; + +var minCoinsChange = + require('../../src/others/min-coins-change.js').minCoinsChange; + +describe('Change making problem', function () { + it('should be defined', function () { + expect(minCoinsChange).toBeDefined(); + }); + + it('should work for 0 change', function () { + expect(minCoinsChange([1, 2], 0)).toEqual([]); + }); + + it('should work for change equals to array element', function () { + expect(minCoinsChange([1, 2], 1)).toEqual([1]); + }); + + it('should return the minimum amount of coins', function () { + expect(minCoinsChange([1], 2)).toEqual([1, 1]); + expect(minCoinsChange([1, 2], 3)).toEqual([1, 2]); + // [2, 3, 2, 3] or [1, 3, 3, 3] + expect(minCoinsChange([1, 2, 3], 10).length).toEqual(4); + }); + + it('should return undefined for combination, which is not possible', + function () { + expect(minCoinsChange([1, 2, 3], 0.5)).not.toBeDefined(); + }); +}); From 8da32f37a416aaadc9c459c3797cd0e5629d7732 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 19 Mar 2015 10:05:41 -0700 Subject: [PATCH 415/613] Add credits to Robert Sedgewick, closes #53 --- src/sets/quickfind.js | 4 ++++ src/sets/quickunion.js | 3 +++ src/sets/weightquickunion.js | 3 +++ 3 files changed, 10 insertions(+) diff --git a/src/sets/quickfind.js b/src/sets/quickfind.js index 15ab2fa7..272dd72c 100644 --- a/src/sets/quickfind.js +++ b/src/sets/quickfind.js @@ -2,6 +2,10 @@ * Keeps track of a set of elements partitioned into a * number of disjoint (nonoverlapping) subsets. * Allows to check whether the path between two nodes exists. + * The algorithm is inspired by Robert Sedgewick's Java implementation. + *
+ * The algorithm is inspired by Robert Sedgewick's Java implementation. + * For further reading http://algs4.cs.princeton.edu/home/. * * @example * diff --git a/src/sets/quickunion.js b/src/sets/quickunion.js index 21f6b8d8..ecb88327 100644 --- a/src/sets/quickunion.js +++ b/src/sets/quickunion.js @@ -2,6 +2,9 @@ * Keeps track of a set of elements partitioned into a * number of disjoint (nonoverlapping) subsets. * Allows to check whether the path between two nodes exists. + *
+ * The algorithm is inspired by Robert Sedgewick's Java implementation. + * For further reading http://algs4.cs.princeton.edu/home/. * * @example * diff --git a/src/sets/weightquickunion.js b/src/sets/weightquickunion.js index 765fcb85..57c5b1d2 100644 --- a/src/sets/weightquickunion.js +++ b/src/sets/weightquickunion.js @@ -2,6 +2,9 @@ * Keeps track of a set of elements partitioned into a * number of disjoint (nonoverlapping) subsets. * Allows to check whether the path between two nodes exists. + *
+ * The algorithm is inspired by Robert Sedgewick's Java implementation. + * For further reading http://algs4.cs.princeton.edu/home/. * * @example * From 129de26b8dc009082216463fcab89f79672fbb7d Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 13 Apr 2015 10:32:47 +0300 Subject: [PATCH 416/613] Add recursive binary search spec --- test/searching/recursive-binarysearch.spec.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/searching/recursive-binarysearch.spec.js diff --git a/test/searching/recursive-binarysearch.spec.js b/test/searching/recursive-binarysearch.spec.js new file mode 100644 index 00000000..3678ef10 --- /dev/null +++ b/test/searching/recursive-binarysearch.spec.js @@ -0,0 +1,29 @@ +'use strict'; + +var binarySearch = + require('../../src/searching/recursive-binarysearch').binarySearch; + +describe('Binary search', function () { + + it('should find the element at position 0 ', function () { + expect(binarySearch([1, 2, 3, 4, 6, 8], 1)).toBe(0); + }); + + it('should find the eleent in position arr.length', function () { + expect(binarySearch([1, 2, 3, 4, 6, 8], 1)).toBe(0); + }); + + it('should work with arrays with 2 elements', function () { + expect(binarySearch([1, 8], 1)).toBe(0); + expect(binarySearch([1, 8], 8)).toBe(1); + }); + + it('should return a negative number for missing elements', function () { + expect(binarySearch([1, 2, 3], 4)).toBeLessThan(0); + }); + + it('should work with empty arrays', function () { + expect(binarySearch([], 4)).toBe(-1); + }); + +}); From 2dbfc5d9eed5bb74303695004782a1f61eb58a60 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 13 Apr 2015 10:40:35 +0300 Subject: [PATCH 417/613] Fix quick select return values --- src/searching/quickselect.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/searching/quickselect.js b/src/searching/quickselect.js index ba068ea9..7ba9790c 100644 --- a/src/searching/quickselect.js +++ b/src/searching/quickselect.js @@ -41,7 +41,7 @@ } if (arr.length <= n) { - return NaN; + return undefined; } lo = lo || 0; hi = hi || arr.length - 1; @@ -60,7 +60,7 @@ lo = pivotIdx + 1; } } - return NaN; + return undefined; } exports.quickselect = quickselect; From 2f80d345907a5da15dd0a034d8c626672a0fa95d Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 13 Apr 2015 10:40:52 +0300 Subject: [PATCH 418/613] Add tests for quick select --- test/searching/quickselect.spec.js | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/searching/quickselect.spec.js diff --git a/test/searching/quickselect.spec.js b/test/searching/quickselect.spec.js new file mode 100644 index 00000000..e48f0532 --- /dev/null +++ b/test/searching/quickselect.spec.js @@ -0,0 +1,31 @@ +var quickselect = require('../../src/searching/quickselect').quickselect; + +describe('quickselect', function () { + 'use strict'; + + it('should be defined as function', function () { + expect(typeof quickselect).toBe('function'); + }); + + it('should work with empty array', function () { + expect(quickselect([], 1)).toBe(undefined); + }); + + it('should find the only element in the list', function () { + expect(quickselect([1], 0)).toBe(1); + }); + + it('should return undefined if the list is smaller than the index', + function () { + expect(quickselect([2, 1], 3)).toBeUndefined(); + }); + + it('should find the element if in sorted order', function () { + expect(quickselect([1, 2], 0)).toBe(1); + expect(quickselect([1, 2], 1)).toBe(2); + }); + + it('should fine the element if not in sorted order', function () { + expect(quickselect([2, 1, 9, 6], 3)).toBe(9); + }); +}); From 2b168965283cb2d4e0d85aa8391a36482f1f7c25 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 13 Apr 2015 10:43:45 +0300 Subject: [PATCH 419/613] Fix indentation --- src/combinatorics/permutations.js | 2 +- src/data-structures/suffix-tree.js | 25 ------------------- .../longest-increasing-subsequence.js | 10 ++++---- src/sets/weightquickunion.js | 8 +++--- 4 files changed, 10 insertions(+), 35 deletions(-) diff --git a/src/combinatorics/permutations.js b/src/combinatorics/permutations.js index 915acea1..0ab94b77 100644 --- a/src/combinatorics/permutations.js +++ b/src/combinatorics/permutations.js @@ -21,7 +21,7 @@ } } - /** + /** * Finds all the permutations of given array.

* Permutation relates to the act of rearranging, or permuting, * all the members of a set into some sequence or order. diff --git a/src/data-structures/suffix-tree.js b/src/data-structures/suffix-tree.js index 7fe73109..e6b917c4 100644 --- a/src/data-structures/suffix-tree.js +++ b/src/data-structures/suffix-tree.js @@ -66,31 +66,6 @@ } }; -// function isSubstr(tree, str) { -// if (!tree) { -// return false; -// } -// if (tree.nodes[str[0]]) { -// return isSubstr(tree, str.substr(1, str.length)); -// } -// var match = ''; -// for (var i = 0; i < Math.min(tree.value.length, str.length); i += 1) { -// if (tree.value[i] === str[i]) { -// match += str[i]; -// } else { -// break; -// } -// } -// if (match.length === str.length) { -// return true; -// } -// return false; -// } - - // var suffix = new SuffixTree(); - // suffix.build('banana'); - // console.log(suffix); - exports.Node = Node; exports.SuffixTree = SuffixTree; diff --git a/src/searching/longest-increasing-subsequence.js b/src/searching/longest-increasing-subsequence.js index 54129632..a0a95412 100644 --- a/src/searching/longest-increasing-subsequence.js +++ b/src/searching/longest-increasing-subsequence.js @@ -3,7 +3,7 @@ exports.longestSubsequence = (function () { - /** + /** * Find the index of the first largest element in array. * Complexity: O(N). * @@ -29,7 +29,7 @@ return maxIdx; } - /** + /** * Default comparison method. * @private */ @@ -37,7 +37,7 @@ return a.distance - b.distance; } - /** + /** * Creates directed graph from given array. * Each element's neighbours are the elements which can be * after the element in the resulting sequence.

@@ -59,7 +59,7 @@ return result; } - /** + /** * Finds the longest sub-sequence for given node.

* Complexity: O(N^N). * @private @@ -98,7 +98,7 @@ return result; } - /** + /** * Algorithm from dynamic programming. It finds the longest * sub-sequence of increasing numbers. It is not required * the numbers to be neighboring. For example for 1, 5, 2 diff --git a/src/sets/weightquickunion.js b/src/sets/weightquickunion.js index 57c5b1d2..410245b2 100644 --- a/src/sets/weightquickunion.js +++ b/src/sets/weightquickunion.js @@ -28,7 +28,7 @@ (function (exports) { 'use strict'; - /** + /** * Initialization.

* Time complexity: O(N). * @@ -45,7 +45,7 @@ } }; - /** + /** * Finds the root of given node.

* Time complexity: O(log N). * @private @@ -60,7 +60,7 @@ return i; }; - /** + /** * Checks whether two nodes are connected.

* Time complexity: O(log N). * @@ -72,7 +72,7 @@ return this._root(p) === this._root(q); }; - /** + /** * Connects two nodes - p and q.

* Time complexity: O(log N). * From e59c2d964f7dae2d27f118ce816a470c0ed97a4a Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 13 Apr 2015 10:49:22 +0300 Subject: [PATCH 420/613] Fix indentation --- .../longest-increasing-subsequence.js | 32 ++++----- src/sets/weightquickunion.js | 66 +++++++++---------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/searching/longest-increasing-subsequence.js b/src/searching/longest-increasing-subsequence.js index a0a95412..7ee8b232 100644 --- a/src/searching/longest-increasing-subsequence.js +++ b/src/searching/longest-increasing-subsequence.js @@ -98,22 +98,22 @@ return result; } - /** - * Algorithm from dynamic programming. It finds the longest - * sub-sequence of increasing numbers. It is not required - * the numbers to be neighboring. For example for 1, 5, 2 - * sequence the longest sub-sequence is 1, 2. - * - * @example - * var subsequence = require('path-to-algorithms/src/searching/'+ - * 'longest-increasing-subsequence').longestSubsequence; - * console.log(subsequence([1, 0, 4, 3, 5])); // 1, 4, 5 - * - * @public - * @module searching/longest-increasing-subsequence - * @param {Array} array Input sequence. - * @return {Array} Longest increasing subsequence. - */ + /** + * Algorithm from dynamic programming. It finds the longest + * sub-sequence of increasing numbers. It is not required + * the numbers to be neighboring. For example for 1, 5, 2 + * sequence the longest sub-sequence is 1, 2. + * + * @example + * var subsequence = require('path-to-algorithms/src/searching/'+ + * 'longest-increasing-subsequence').longestSubsequence; + * console.log(subsequence([1, 0, 4, 3, 5])); // 1, 4, 5 + * + * @public + * @module searching/longest-increasing-subsequence + * @param {Array} array Input sequence. + * @return {Array} Longest increasing subsequence. + */ return function (array) { var results = []; var dag = buildDag(array); diff --git a/src/sets/weightquickunion.js b/src/sets/weightquickunion.js index 410245b2..47079193 100644 --- a/src/sets/weightquickunion.js +++ b/src/sets/weightquickunion.js @@ -28,14 +28,14 @@ (function (exports) { 'use strict'; - /** - * Initialization.

- * Time complexity: O(N). - * - * @public - * @constructor - * @param {Numner} size Count of the nodes. - */ + /** + * Initialization.

+ * Time complexity: O(N). + * + * @public + * @constructor + * @param {Numner} size Count of the nodes. + */ exports.QuickUnion = function (n) { this._ids = []; this._size = []; @@ -45,42 +45,42 @@ } }; - /** - * Finds the root of given node.

- * Time complexity: O(log N). - * @private - * @param {Number} i The given node. - * @return {Number} Root of the given node. - */ + /** + * Finds the root of given node.

+ * Time complexity: O(log N). + * @private + * @param {Number} i The given node. + * @return {Number} Root of the given node. + */ exports.QuickUnion.prototype._root = function (i) { while (i !== this._ids[i]) { - // this._ids[i] = this._ids[this._ids[i]]; //enables the path compression + // this._ids[i] = this._ids[this._ids[i]]; //enables the path compression i = this._ids[i]; } return i; }; - /** - * Checks whether two nodes are connected.

- * Time complexity: O(log N). - * - * @param {Number} p The first node. - * @param {Number} q The second node. - * @return {Boolean} True/false depending on whether the nodes are connected. - */ + /** + * Checks whether two nodes are connected.

+ * Time complexity: O(log N). + * + * @param {Number} p The first node. + * @param {Number} q The second node. + * @return {Boolean} True/false depending on whether the nodes are connected. + */ exports.QuickUnion.prototype.connected = function (p, q) { return this._root(p) === this._root(q); }; - /** - * Connects two nodes - p and q.

- * Time complexity: O(log N). - * - * @public - * @method - * @param {Number} p The first node. - * @param {Number} q The second node. - */ + /** + * Connects two nodes - p and q.

+ * Time complexity: O(log N). + * + * @public + * @method + * @param {Number} p The first node. + * @param {Number} q The second node. + */ exports.QuickUnion.prototype.union = function (p, q) { var pf = this._root(p); var qf = this._root(q); From ecd99c91d157ca53d1a97caf54102854d5327e27 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 26 Apr 2015 17:48:02 +0200 Subject: [PATCH 421/613] Fix issue in dijkstra for empty matrix --- src/graphs/shortest-path/dijkstra.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index 0f5d30bd..e271b6d5 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -112,7 +112,10 @@ visited[current.node] = true; current = unvisited.extract(); } - return distance[dest].distance; + if (distance[dest]) { + return distance[dest].distance || Infinity; + } + return Infinity; }; })(); From 911d563071f6876a49336694dd36c50189ac8304 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 26 Apr 2015 17:48:24 +0200 Subject: [PATCH 422/613] Add basic tests for dijkstra --- test/graphs/shortest-path/dijkstra.spec.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 test/graphs/shortest-path/dijkstra.spec.js diff --git a/test/graphs/shortest-path/dijkstra.spec.js b/test/graphs/shortest-path/dijkstra.spec.js new file mode 100644 index 00000000..c5658463 --- /dev/null +++ b/test/graphs/shortest-path/dijkstra.spec.js @@ -0,0 +1,15 @@ +var dijkstra = + require('../../../src/graphs/shortest-path/dijkstra').dijkstra; + +describe('dijkstra', function () { + 'use strict'; + it('should define a function', function () { + expect(dijkstra).toBeDefined(); + expect(typeof dijkstra).toBe('function'); + }); + + it('should work with empty graph', function () { + expect(dijkstra(0, 0, [])).toBe(Infinity); + }); + +}); From 60f2983ebc42fd64a851ae2ad64a040e9309f232 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 26 Apr 2015 17:53:32 +0200 Subject: [PATCH 423/613] Add basic tests for dijkstra --- src/graphs/shortest-path/dijkstra.js | 2 +- test/graphs/shortest-path/dijkstra.spec.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index e271b6d5..2b08fc1e 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -113,7 +113,7 @@ current = unvisited.extract(); } if (distance[dest]) { - return distance[dest].distance || Infinity; + return distance[dest].distance; } return Infinity; }; diff --git a/test/graphs/shortest-path/dijkstra.spec.js b/test/graphs/shortest-path/dijkstra.spec.js index c5658463..ca13b147 100644 --- a/test/graphs/shortest-path/dijkstra.spec.js +++ b/test/graphs/shortest-path/dijkstra.spec.js @@ -12,4 +12,15 @@ describe('dijkstra', function () { expect(dijkstra(0, 0, [])).toBe(Infinity); }); + it('should work when the src and dest are the same', function () { + expect(dijkstra(0, 0, [[0]])).toBe(0); + }); + + it('should work when there\'s no path', function () { + expect(dijkstra(0, 1, [[0, Infinity], [Infinity, 0]])).toBe(Infinity); + }); + + it('should find the shortest path', function () { + expect(dijkstra(0, 2, [[0, 1, 4], [1, 0, 1], [4, 1, 0]])).toBe(2); + }); }); From 9280db2f759e6687250195b2a488c9ccbe34c7c2 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 1 May 2015 18:19:04 +0300 Subject: [PATCH 424/613] Add tests for topological sort --- test/graphs/others/topological-sort.spec.js | 40 +++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 test/graphs/others/topological-sort.spec.js diff --git a/test/graphs/others/topological-sort.spec.js b/test/graphs/others/topological-sort.spec.js new file mode 100644 index 00000000..019804b7 --- /dev/null +++ b/test/graphs/others/topological-sort.spec.js @@ -0,0 +1,40 @@ +var ts = require('../../../src/graphs/others/topological-sort').topologicalSort; + +describe('Topological sort', function () { + 'use strict'; + it('should be defined', function () { + expect(typeof ts).toBe('function'); + }); + + it('should work with empty graphs', function () { + expect(ts({})).toEqual([]); + }); + + it('should give the proper topological order', function () { + expect(ts({ v1: [] })).toEqual(['v1']); + var graph = { + v1: ['v2'], + v2: ['v3'], + v3: [] + }; + expect(ts(graph)).toEqual(['v1', 'v2', 'v3']); + graph = { + v1: ['v2', 'v5'], + v2: [], + v3: ['v1', 'v2', 'v4', 'v5'], + v4: [], + v5: [] + }; + expect(ts(graph)).toEqual(['v3', 'v4', 'v1', 'v5', 'v2']); + }); + + it('should throw an error on cycle', function () { + function runTs() { + ts({ + v1: ['v2'], + v2: ['v1'] + }); + } + expect(runTs).toThrow(); + }); +}); From 95f879a4705b6d720d27dec8e1c9cf8d726d18f8 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 7 May 2015 17:12:11 -0700 Subject: [PATCH 425/613] Update bellman-ford's jsdocs --- src/graphs/shortest-path/bellman-ford.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/graphs/shortest-path/bellman-ford.js b/src/graphs/shortest-path/bellman-ford.js index 47f05b85..a2d283be 100644 --- a/src/graphs/shortest-path/bellman-ford.js +++ b/src/graphs/shortest-path/bellman-ford.js @@ -47,7 +47,8 @@ * @param {Array} edges Edges of the graph. * @param {Number} source Start vertex. * @returns {Object} Object with two arrays (parents and distances) - * with shortest-path information. + * with shortest-path information or undefined if the graph + * has a negative cycle. */ exports.bellmanFord = function (vertexes, edges, source) { var distances = {}; From 28b5d0f67b51898a771edc7b8894fa16985860d1 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 7 May 2015 17:25:34 -0700 Subject: [PATCH 426/613] Fix Bellman-Ford implementation --- src/graphs/shortest-path/bellman-ford.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/graphs/shortest-path/bellman-ford.js b/src/graphs/shortest-path/bellman-ford.js index a2d283be..4429553d 100644 --- a/src/graphs/shortest-path/bellman-ford.js +++ b/src/graphs/shortest-path/bellman-ford.js @@ -12,7 +12,13 @@ * var Edge = BellmanFord.Edge; * var bellmanFord = BellmanFord.bellmanFord; * var edges = []; - * var vertexes = [0, 1, 2, 3, 4]; + * var vertexes = [ + * new Vertex(0), + * new Vertex(1), + * new Vertex(2), + * new Vertex(3), + * new Vertex(4) + * ]; * * edges.push(new Edge(0, 1, -1)); * edges.push(new Edge(0, 2, 4)); @@ -55,23 +61,23 @@ var parents = {}; var c; for (var i = 0; i < vertexes.length; i += 1) { - distances[vertexes[i]] = Infinity; - parents[vertexes[i]] = null; + distances[vertexes[i].id] = Infinity; + parents[vertexes[i].id] = null; } distances[source] = 0; for (i = 0; i < vertexes.length - 1; i += 1) { for (var j = 0; j < edges.length; j += 1) { c = edges[j]; - if (distances[c.from] + c.weight < distances[c.to]) { - distances[c.to] = distances[c.from] + c.weight; - parents[c.to] = c.from; + if (distances[c.from.id] + c.distance < distances[c.to.id]) { + distances[c.to.id] = distances[c.from.id] + c.distance; + parents[c.to.id] = c.from.id; } } } for (i = 0; i < edges.length; i += 1) { c = edges[i]; - if (distances[c.from] + c.weight < distances[c.to]) { + if (distances[c.from.id] + c.distance < distances[c.to.id]) { return undefined; } } From d0a1358dbc2c4553cf718a596126b2ef4de8c24a Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 7 May 2015 17:41:51 -0700 Subject: [PATCH 427/613] Add basic tests for bellman ford --- .../graphs/shortest-path/bellman-ford.spec.js | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/graphs/shortest-path/bellman-ford.spec.js diff --git a/test/graphs/shortest-path/bellman-ford.spec.js b/test/graphs/shortest-path/bellman-ford.spec.js new file mode 100644 index 00000000..ab9a7f2d --- /dev/null +++ b/test/graphs/shortest-path/bellman-ford.spec.js @@ -0,0 +1,33 @@ +var exported = + require('../../../src/graphs/shortest-path/bellman-ford'), + bellmanFord = exported.bellmanFord, + Vertex = exported.Vertex, + Edge = exported.Edge; + +describe('Bellman-Ford', function () { + 'use strict'; + it('should exports a method called bellmanFord', function () { + expect(typeof bellmanFord).toBe('function'); + }); + + it('should work for an empty graph', function () { + var vs = []; + var e = []; + expect(bellmanFord(vs, e, undefined)) + .toEqual({ parents: {}, distances: { undefined: 0 } }); + }); + + it('should work for a graph with a single vertex', function () { + var vs = [new Vertex(1)]; + var e = []; + expect(bellmanFord(vs, e, 1)) + .toEqual({ parents: { '1': null }, distances: { '1': 0 }}); + }); + + it('should work in the general case', function () { + var vs = [new Vertex(1), new Vertex(2), new Vertex(3)]; + var e = []; + expect(bellmanFord(vs, e, 1)) + .toEqual({ parents: { '1': null }, distances: { '1': 0 }}); + }); +}); From 7ca316264c544a1b0e8efb19e71909d3f5f23cd9 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 7 May 2015 17:56:08 -0700 Subject: [PATCH 428/613] Update bellman ford, edge and spec --- src/data-structures/edge.js | 4 +-- src/graphs/shortest-path/bellman-ford.js | 34 ++++++++++--------- .../graphs/shortest-path/bellman-ford.spec.js | 13 ++++--- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/data-structures/edge.js b/src/data-structures/edge.js index 48fe5ec7..e16e343a 100644 --- a/src/data-structures/edge.js +++ b/src/data-structures/edge.js @@ -12,8 +12,8 @@ * @module data-structures/edge */ exports.Edge = function (e, v, distance) { - this.e = e; - this.v = v; + this.from = e; + this.to = v; this.distance = distance; }; diff --git a/src/graphs/shortest-path/bellman-ford.js b/src/graphs/shortest-path/bellman-ford.js index 4429553d..d7fcf45b 100644 --- a/src/graphs/shortest-path/bellman-ford.js +++ b/src/graphs/shortest-path/bellman-ford.js @@ -60,25 +60,27 @@ var distances = {}; var parents = {}; var c; - for (var i = 0; i < vertexes.length; i += 1) { - distances[vertexes[i].id] = Infinity; - parents[vertexes[i].id] = null; - } - distances[source] = 0; - for (i = 0; i < vertexes.length - 1; i += 1) { - for (var j = 0; j < edges.length; j += 1) { - c = edges[j]; - if (distances[c.from.id] + c.distance < distances[c.to.id]) { - distances[c.to.id] = distances[c.from.id] + c.distance; - parents[c.to.id] = c.from.id; + if (source) { + for (var i = 0; i < vertexes.length; i += 1) { + distances[vertexes[i].id] = Infinity; + parents[vertexes[i].id] = null; + } + distances[source.id] = 0; + for (i = 0; i < vertexes.length - 1; i += 1) { + for (var j = 0; j < edges.length; j += 1) { + c = edges[j]; + if (distances[c.from.id] + c.distance < distances[c.to.id]) { + distances[c.to.id] = distances[c.from.id] + c.distance; + parents[c.to.id] = c.from.id; + } } } - } - for (i = 0; i < edges.length; i += 1) { - c = edges[i]; - if (distances[c.from.id] + c.distance < distances[c.to.id]) { - return undefined; + for (i = 0; i < edges.length; i += 1) { + c = edges[i]; + if (distances[c.from.id] + c.distance < distances[c.to.id]) { + return undefined; + } } } diff --git a/test/graphs/shortest-path/bellman-ford.spec.js b/test/graphs/shortest-path/bellman-ford.spec.js index ab9a7f2d..1481788d 100644 --- a/test/graphs/shortest-path/bellman-ford.spec.js +++ b/test/graphs/shortest-path/bellman-ford.spec.js @@ -14,20 +14,23 @@ describe('Bellman-Ford', function () { var vs = []; var e = []; expect(bellmanFord(vs, e, undefined)) - .toEqual({ parents: {}, distances: { undefined: 0 } }); + .toEqual({ parents: {}, distances: {} }); }); it('should work for a graph with a single vertex', function () { var vs = [new Vertex(1)]; var e = []; - expect(bellmanFord(vs, e, 1)) + expect(bellmanFord(vs, e, vs[0])) .toEqual({ parents: { '1': null }, distances: { '1': 0 }}); }); it('should work in the general case', function () { var vs = [new Vertex(1), new Vertex(2), new Vertex(3)]; - var e = []; - expect(bellmanFord(vs, e, 1)) - .toEqual({ parents: { '1': null }, distances: { '1': 0 }}); + var e = [new Edge(vs[0], vs[1], 2), + new Edge(vs[0], vs[2], 10), + new Edge(vs[1], vs[2], 1) + ]; + var output = bellmanFord(vs, e, vs[0]); + expect(output.distances['3']).toBe(3); }); }); From f62871d62a07644275d7cfe8bce85e696c659e21 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 7 May 2015 18:00:49 -0700 Subject: [PATCH 429/613] Update bellman ford specs --- test/graphs/shortest-path/bellman-ford.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/graphs/shortest-path/bellman-ford.spec.js b/test/graphs/shortest-path/bellman-ford.spec.js index 1481788d..3910c0b8 100644 --- a/test/graphs/shortest-path/bellman-ford.spec.js +++ b/test/graphs/shortest-path/bellman-ford.spec.js @@ -21,7 +21,7 @@ describe('Bellman-Ford', function () { var vs = [new Vertex(1)]; var e = []; expect(bellmanFord(vs, e, vs[0])) - .toEqual({ parents: { '1': null }, distances: { '1': 0 }}); + .toEqual({ parents: { 1: null }, distances: { 1: 0 }}); }); it('should work in the general case', function () { From 9a437b13ebac2f7854484deb3fed4342979db640 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 7 May 2015 18:01:45 -0700 Subject: [PATCH 430/613] Fix build --- test/graphs/shortest-path/bellman-ford.spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/graphs/shortest-path/bellman-ford.spec.js b/test/graphs/shortest-path/bellman-ford.spec.js index 3910c0b8..79a55d4e 100644 --- a/test/graphs/shortest-path/bellman-ford.spec.js +++ b/test/graphs/shortest-path/bellman-ford.spec.js @@ -1,8 +1,8 @@ var exported = - require('../../../src/graphs/shortest-path/bellman-ford'), - bellmanFord = exported.bellmanFord, - Vertex = exported.Vertex, - Edge = exported.Edge; + require('../../../src/graphs/shortest-path/bellman-ford'); +var bellmanFord = exported.bellmanFord; +var Vertex = exported.Vertex; +var Edge = exported.Edge; describe('Bellman-Ford', function () { 'use strict'; From 25dc6aabe5e16ac0a563d69817eb8a1e4b5b8968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Falc=C3=A3o?= Date: Mon, 11 May 2015 01:31:22 -0300 Subject: [PATCH 431/613] LZW Encoding/Decoding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lempel–Ziv–Welch (LZW) is a universal lossless data compression algorithm. It is an improved implementation of the LZ78 algorithm. --- src/compression/LZW/LZW.js | 95 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src/compression/LZW/LZW.js diff --git a/src/compression/LZW/LZW.js b/src/compression/LZW/LZW.js new file mode 100644 index 00000000..9c1f9c06 --- /dev/null +++ b/src/compression/LZW/LZW.js @@ -0,0 +1,95 @@ +/** + * LZW Encoding/Decoding + * + * Lempel–Ziv–Welch (LZW) is a universal lossless data + * compression algorithm. It is an improved implementation + * of the LZ78 algorithm. + * + * @example + * var lzwModule = require('path-to-algorithms/src/compression'+ + * '/LZW/LZW'); + * var lzw = new lzwModule.LZW(); + * + * var compressed = lzw.compress("ABCABCABCABCABCABC"); + * console.log(compressed); + * + * var decompressed = lzw.decompress(compressed); + * console.log(decompressed); + * + * @module compression/LZW/LZW + */ +(function (exports) { + 'use strict'; + + exports.LZW = function () { + this.dictionarySize = 256; + }; + + exports.LZW.compress = function (data) { + var i; + var dictionary = {}; + var character; + var wc; + var w = ''; + var result = []; + + for (i = 0; i < this.dictionarySize; i = i + 1) { + dictionary[String.fromCharCode(i)] = i; + } + + for (i = 0; i < data.length; i = i + 1) { + character = data.charAt(i); + wc = w + character; + if (dictionary.hasOwnProperty(wc)) { + w = wc; + } else { + result.push(dictionary[w]); + dictionary[wc] = this.dictionarySize; + this.dictionarySize = this.dictionarySize + 1; + w = String(character); + } + } + + if (w !== '') { + result.push(dictionary[w]); + } + + return result; + }; + + exports.LZW.decompress = function (compressedData) { + var i; + var dictionary = []; + var w; + var result; + var key; + var entry = ''; + + for (i = 0; i < this.dictionarySize; i = i + 1) { + dictionary[i] = String.fromCharCode(i); + } + + w = String.fromCharCode(compressedData[0]); + result = w; + + for (i = 1; i < compressedData.length; i = i + 1) { + key = compressedData[i]; + if (dictionary[key]) { + entry = dictionary[key]; + } else { + if (key === this.dictionarySize) { + entry = w + w.charAt(0); + } else { + return null; + } + } + + result += entry; + dictionary[this.dictionarySize] = w + entry.charAt(0); + this.dictionarySize = this.dictionarySize + 1; + w = entry; + } + + return result; + }; +})(typeof window === 'undefined' ? module.exports : window); From df075adb7dfb9e0e60d9b1992820d65dead22a5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Falc=C3=A3o?= Date: Fri, 15 May 2015 22:39:11 -0300 Subject: [PATCH 432/613] Fibonacci algorithm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An algorithm to find the nth number in fibonacci’s sequence --- src/others/fibonacci.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/others/fibonacci.js diff --git a/src/others/fibonacci.js b/src/others/fibonacci.js new file mode 100644 index 00000000..6ce98d06 --- /dev/null +++ b/src/others/fibonacci.js @@ -0,0 +1,37 @@ +/** + * Nth number of fibonacci's sequence + * + * Returns the nth number of fibonacci's sequence. + * + * @public + * + * @example + * var fibonacci = require('path-to-algorithms/src/others/fibonacci').fibonacci; + * var nth = fibonacci(20); + * + * console.log(nth); // 6765 + * + * @param {Number} n The nth position in fibonacci's sequence + * + * @module others/fibonacci +*/ +(function (exports) { + 'use strict'; + + function fibonacci (n) { + var n1 = 0; + var n2 = 1; + var aux; + + while (n > 0) { + aux = n1; + n1 = n2; + n2 += aux; + n = n - 1; + } + + return n1; + } + + exports.fibonacci = fibonacci; +})(typeof window === 'undefined' ? module.exports : window); From 2664ca56349a4cd1fa8ce9807cc4d460f6f017a5 Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Sat, 16 May 2015 10:25:56 -0500 Subject: [PATCH 433/613] fibonacci spec and throw on too large of input. --- src/others/fibonacci.js | 3 +++ test/others/fibonacci.spec.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 test/others/fibonacci.spec.js diff --git a/src/others/fibonacci.js b/src/others/fibonacci.js index 6ce98d06..1b56562e 100644 --- a/src/others/fibonacci.js +++ b/src/others/fibonacci.js @@ -19,6 +19,9 @@ 'use strict'; function fibonacci (n) { + if (n > 97) { + throw 'Input too large, results in inaccurate fibonacci value.'; + } var n1 = 0; var n2 = 1; var aux; diff --git a/test/others/fibonacci.spec.js b/test/others/fibonacci.spec.js new file mode 100644 index 00000000..02cbddd8 --- /dev/null +++ b/test/others/fibonacci.spec.js @@ -0,0 +1,28 @@ +'use strict'; + +var mod = require('../../src/others/fibonacci.js'); +var fibonacci = mod.fibonacci; + +describe('fibonacci algorithm', function () { + it('should return value 1 with input 1.', function () { + expect(fibonacci(1)).toBe(1); + }); + it('should return value 1 with input 2.', function () { + expect(fibonacci(2)).toBe(1); + }); + it('should return value 2 with input 3.', function () { + expect(fibonacci(3)).toBe(2); + }); + it('should return value 3 with input 4.', function () { + expect(fibonacci(4)).toBe(3); + }); + it('should return value 5 with input 5.', function () { + expect(fibonacci(5)).toBe(5); + }); + it('should be 83621143489848422977 with input 97.', function () { + expect(fibonacci(97)).toBe(83621143489848422977); + }); + it('should throw when input is too large.', function () { + expect(function () {fibonacci(98)}).toThrow('Input too large, results in inaccurate fibonacci value.'); + }); +}); From 3baa3b689e0cc8362f0780eb93a8a3063f4b47d9 Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Sun, 17 May 2015 07:58:54 -0500 Subject: [PATCH 434/613] use https instead of ssh --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 0b95fa29..ff653a9c 100644 --- a/readme.md +++ b/readme.md @@ -23,7 +23,7 @@ npm install - Go to the parent directory of the `javascript-algorithms` folder and call: ```bash -git clone git@github.com:mgechev/javascript-algorithms.git javascript-algorithms-docs +git clone https://github.com/mgechev/javascript-algorithms.git javascript-algorithms-docs ``` - Go to the `javascript-algorithms-docs` folder and change current branch to `gh-pages`: @@ -81,4 +81,4 @@ If the build is not successful fix your code in order the tests and jshint valid ## License -The code in this repository is distributed under the terms of the MIT license. \ No newline at end of file +The code in this repository is distributed under the terms of the MIT license. From f34b55a25b2f2827875abbef348873cedfe67c1a Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 18 May 2015 11:12:04 +0300 Subject: [PATCH 435/613] Update contributors list --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 0b95fa29..759569cb 100644 --- a/readme.md +++ b/readme.md @@ -71,9 +71,9 @@ If the build is not successful fix your code in order the tests and jshint valid ## Contributors -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) | :---: |:---: |:---: |:---: |:---: |:---: | -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) | [contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | :---: |:---: | From 19105e2eaafa65b7bbd2200448a22cdaa1d0a8bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Falc=C3=A3o?= Date: Tue, 19 May 2015 14:52:20 -0300 Subject: [PATCH 436/613] Hash Table data structure A hash table is a data structure used to implement an associative array, that can map keys to values. A hash table uses a hash function to compute an index into an array of buckets or slots, from which the correct value can be found. The idea is to access a value in O(1). --- src/data-structures/hash-table.js | 65 +++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/data-structures/hash-table.js diff --git a/src/data-structures/hash-table.js b/src/data-structures/hash-table.js new file mode 100644 index 00000000..18a327f4 --- /dev/null +++ b/src/data-structures/hash-table.js @@ -0,0 +1,65 @@ +/** + * Hash Table + * + * An associative array, that can map keys + * (strings and numbers) to values in O(1). + * + * @example + * var hash = require('path-to-algorithms/src/data-structures'+ + * '/hash-table'); + * var HashTable = new hash.HashTable(); + * + * HashTable.put(10, 'value'); + * HashTable.put('key', 10); + * + * console.log(HashTable.get(10)); // 'value' + * console.log(HashTable.get('key')); // 10 + * + * HashTable.remove(10); + * HashTable.remove('key'); + * + * console.log(HashTable.get(10)); // 'undefined' + * console.log(HashTable.get('key')); // 'undefined' + * + * @module data-structures/hash-table +*/ +(function (exports) { + 'use strict'; + + exports.HashTable = function () { + this.elements = []; + }; + + exports.HashTable.prototype.hashCode = function (str) { + var i; + var hashCode = 0; + var character; + + if (str.length === 0) { + return hashCode; + } + + for (i = 0; i < str.length; i += 1) { + character = str.charCodeAt(i); + hashCode = ((hashCode << 5) - hashCode) + character; + hashCode = hashCode & hashCode; + } + + return hashCode; + }; + + exports.HashTable.prototype.put = function (key, value) { + var hashCode = this.hashCode(key); + this.elements[hashCode] = value; + }; + + exports.HashTable.prototype.get = function (key) { + var hashCode = this.hashCode(key); + return this.elements[hashCode]; + }; + + exports.HashTable.prototype.remove = function (key) { + var hashCode = this.hashCode(key); + this.elements.splice(hashCode, 1); + }; +})(typeof window === 'undefined' ? module.exports : window); From 3ec53d63937d9c28c8c3df79002bded20c87dcd8 Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Tue, 19 May 2015 21:53:49 -0500 Subject: [PATCH 437/613] Ignore <<, & jshint warnings --- src/data-structures/hash-table.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/data-structures/hash-table.js b/src/data-structures/hash-table.js index 18a327f4..a7210149 100644 --- a/src/data-structures/hash-table.js +++ b/src/data-structures/hash-table.js @@ -41,8 +41,10 @@ for (i = 0; i < str.length; i += 1) { character = str.charCodeAt(i); + /*jshint -W016 */ hashCode = ((hashCode << 5) - hashCode) + character; hashCode = hashCode & hashCode; + /*jshint -W016 */ } return hashCode; From 2217e286fc358ab0be87cd72369396777717f957 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 20 May 2015 10:22:00 +0300 Subject: [PATCH 438/613] Fix #64 --- src/data-structures/hash-table.js | 2 +- test/data-structures/hash-table.spec.js | 28 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 test/data-structures/hash-table.spec.js diff --git a/src/data-structures/hash-table.js b/src/data-structures/hash-table.js index a7210149..1afead26 100644 --- a/src/data-structures/hash-table.js +++ b/src/data-structures/hash-table.js @@ -26,7 +26,7 @@ (function (exports) { 'use strict'; - exports.HashTable = function () { + exports.HashTable = function HashTable() { this.elements = []; }; diff --git a/test/data-structures/hash-table.spec.js b/test/data-structures/hash-table.spec.js new file mode 100644 index 00000000..29fa3336 --- /dev/null +++ b/test/data-structures/hash-table.spec.js @@ -0,0 +1,28 @@ +var HashTable = require('../../src/data-structures/hash-table').HashTable; + +describe('HashTable', function () { + 'use strict'; + it('should be defined as constructor function', function () { + expect(typeof HashTable).toBe('function'); + var hash = new HashTable(); + expect(hash instanceof HashTable).toBeTruthy(); + expect(hash.constructor.name).toBe('HashTable'); + }); + + describe('methods', function () { + it('should define a put and get methods', function () { + var hash = new HashTable(); + expect(typeof hash.put).toBe('function'); + expect(typeof hash.get).toBe('function'); + hash.put('key', 'value'); + expect(hash.get('key')).toBe('value'); + hash.put('key', 'foo'); + expect(hash.get('key')).toBe('foo'); + hash.put('bar', 'baz'); + expect(hash.get('bar')).toBe('baz'); + }); + + it('should define a remove method', function () { + }); + }); +}); From cac4e536e661903616270854a8effbae2f838e07 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 20 May 2015 17:49:32 +0300 Subject: [PATCH 439/613] Add contributor manually --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 675aad9d..ce04c448 100644 --- a/readme.md +++ b/readme.md @@ -75,9 +75,9 @@ If the build is not successful fix your code in order the tests and jshint valid :---: |:---: |:---: |:---: |:---: |:---: | [mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) | -[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | +[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | [pvoznenko](https://github.com/pvoznenko) | :---: |:---: | -[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | +[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | [pvoznenko](https://github.com/pvoznenko)| ## License From a7498dfba2e130e1f1903b3d71b6412595b2c119 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 20 May 2015 17:50:29 +0300 Subject: [PATCH 440/613] Fix the readme contrib list table --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index ce04c448..37cab38a 100644 --- a/readme.md +++ b/readme.md @@ -75,8 +75,8 @@ If the build is not successful fix your code in order the tests and jshint valid :---: |:---: |:---: |:---: |:---: |:---: | [mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) | -[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | [pvoznenko](https://github.com/pvoznenko) | -:---: |:---: | +[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) |[pvoznenko](https://github.com/pvoznenko) | +:---: |:---: |:---: | [contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | [pvoznenko](https://github.com/pvoznenko)| ## License From 99d3f4c02cd02d50863d71303f48f517a66b1101 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 21 May 2015 00:30:17 +0300 Subject: [PATCH 441/613] Update readme --- readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index 37cab38a..8c7413cd 100644 --- a/readme.md +++ b/readme.md @@ -71,13 +71,13 @@ If the build is not successful fix your code in order the tests and jshint valid ## Contributors -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) |[secrettriangle](https://github.com/secrettriangle) | :---: |:---: |:---: |:---: |:---: |:---: | -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[secrettriangle](https://github.com/secrettriangle) |[Microfed](https://github.com/Microfed) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) |[secrettriangle](https://github.com/secrettriangle) | -[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) |[pvoznenko](https://github.com/pvoznenko) | +[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | :---: |:---: |:---: | -[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | [pvoznenko](https://github.com/pvoznenko)| +[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | ## License From 2eca98c9c216805bec717d62bfb37979bd05cbaa Mon Sep 17 00:00:00 2001 From: CJJ Date: Fri, 22 May 2015 10:22:18 -0700 Subject: [PATCH 442/613] Trying to fix issues raised at build #100 --- src/primes/prime-factor-tree.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/primes/prime-factor-tree.js b/src/primes/prime-factor-tree.js index b5f1a9de..b803ff02 100644 --- a/src/primes/prime-factor-tree.js +++ b/src/primes/prime-factor-tree.js @@ -18,19 +18,29 @@ * console.log(primeFactorTree(600851475143)); // [71, 839, 1471, 6857] */ exports.primeFactorTree = function (number) { - var div = 2; var array = []; - - while (number > 1) { - if (number % div === 0) { - number /= div; - - array.push(div); - } else { - div += 1; + var s = 6; + while (number > 1 && number % 2 === 0) { + number /= 2; + array.push(2); + } + while (number > 2 && number % 3 === 0) { + number /= 3; + array.push(3); + } + while (number > 4) { + var p = s - 1; + var q = s + 1; + while (number > 4 && number % p === 0) { + number /= p; + array.push(p); + } + while (number > 4 && number % q === 0) { + number /= q; + array.push(q); } + s += 6; } - return array; }; From 686c8a9d32850604cb5f0a734680d1be55778773 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 2 Jun 2015 18:19:08 +0300 Subject: [PATCH 443/613] Fix #70 --- test/searching/binarysearch.spec.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/searching/binarysearch.spec.js b/test/searching/binarysearch.spec.js index ef12ea45..99eeb059 100644 --- a/test/searching/binarysearch.spec.js +++ b/test/searching/binarysearch.spec.js @@ -9,8 +9,9 @@ describe('Binary search', function () { expect(binarySearch([1, 2, 3, 4, 6, 8], 1)).toBe(0); }); - it('should find the eleent in position arr.length', function () { - expect(binarySearch([1, 2, 3, 4, 6, 8], 1)).toBe(0); + it('should find the element in position arr.length - 1', function () { + var arr = [1, 2, 3, 4, 6, 8]; + expect(binarySearch(arr, 8)).toBe(arr.length - 1); }); it('should work with arrays with 2 elements', function () { @@ -31,6 +32,7 @@ describe('Binary search', function () { }); it('should work with a key function', function () { - expect(binarySearch([{ x: 1 }, { x: 2 }, { x: 3 }], { x: 2 }, function (o) { return o.x; })).toBe(1); + expect(binarySearch([{ x: 1 }, { x: 2 }, { x: 3 }], + { x: 2 }, function (o) { return o.x; })).toBe(1); }); }); From 788f0bc459abc55c46b02d5930ed16c93f323099 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 4 Jun 2015 11:05:28 +0300 Subject: [PATCH 444/613] Fix #71 --- src/data-structures/binary-search-tree.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 5d332218..b6605590 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -128,11 +128,11 @@ if (!current) { return; } + this._postorder(current._left, callback); + this._postorder(current._right, callback); if (typeof callback === 'function') { callback(current); } - this._postorder(current._left, callback); - this._postorder(current._right, callback); }; /** From 6ff46479bf4ffa65e0680d7d2e60e00b70acd5b1 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 7 Jun 2015 17:34:49 +0300 Subject: [PATCH 445/613] Fix #72 --- src/data-structures/hash-table.js | 67 ------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 src/data-structures/hash-table.js diff --git a/src/data-structures/hash-table.js b/src/data-structures/hash-table.js deleted file mode 100644 index 1afead26..00000000 --- a/src/data-structures/hash-table.js +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Hash Table - * - * An associative array, that can map keys - * (strings and numbers) to values in O(1). - * - * @example - * var hash = require('path-to-algorithms/src/data-structures'+ - * '/hash-table'); - * var HashTable = new hash.HashTable(); - * - * HashTable.put(10, 'value'); - * HashTable.put('key', 10); - * - * console.log(HashTable.get(10)); // 'value' - * console.log(HashTable.get('key')); // 10 - * - * HashTable.remove(10); - * HashTable.remove('key'); - * - * console.log(HashTable.get(10)); // 'undefined' - * console.log(HashTable.get('key')); // 'undefined' - * - * @module data-structures/hash-table -*/ -(function (exports) { - 'use strict'; - - exports.HashTable = function HashTable() { - this.elements = []; - }; - - exports.HashTable.prototype.hashCode = function (str) { - var i; - var hashCode = 0; - var character; - - if (str.length === 0) { - return hashCode; - } - - for (i = 0; i < str.length; i += 1) { - character = str.charCodeAt(i); - /*jshint -W016 */ - hashCode = ((hashCode << 5) - hashCode) + character; - hashCode = hashCode & hashCode; - /*jshint -W016 */ - } - - return hashCode; - }; - - exports.HashTable.prototype.put = function (key, value) { - var hashCode = this.hashCode(key); - this.elements[hashCode] = value; - }; - - exports.HashTable.prototype.get = function (key) { - var hashCode = this.hashCode(key); - return this.elements[hashCode]; - }; - - exports.HashTable.prototype.remove = function (key) { - var hashCode = this.hashCode(key); - this.elements.splice(hashCode, 1); - }; -})(typeof window === 'undefined' ? module.exports : window); From fa8b1e1fa0a7c0f5146dbff442ef7145b9cad471 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 7 Jun 2015 18:16:35 +0300 Subject: [PATCH 446/613] Remove hash table spec --- test/data-structures/hash-table.spec.js | 28 ------------------------- 1 file changed, 28 deletions(-) delete mode 100644 test/data-structures/hash-table.spec.js diff --git a/test/data-structures/hash-table.spec.js b/test/data-structures/hash-table.spec.js deleted file mode 100644 index 29fa3336..00000000 --- a/test/data-structures/hash-table.spec.js +++ /dev/null @@ -1,28 +0,0 @@ -var HashTable = require('../../src/data-structures/hash-table').HashTable; - -describe('HashTable', function () { - 'use strict'; - it('should be defined as constructor function', function () { - expect(typeof HashTable).toBe('function'); - var hash = new HashTable(); - expect(hash instanceof HashTable).toBeTruthy(); - expect(hash.constructor.name).toBe('HashTable'); - }); - - describe('methods', function () { - it('should define a put and get methods', function () { - var hash = new HashTable(); - expect(typeof hash.put).toBe('function'); - expect(typeof hash.get).toBe('function'); - hash.put('key', 'value'); - expect(hash.get('key')).toBe('value'); - hash.put('key', 'foo'); - expect(hash.get('key')).toBe('foo'); - hash.put('bar', 'baz'); - expect(hash.get('bar')).toBe('baz'); - }); - - it('should define a remove method', function () { - }); - }); -}); From c75e494d24302668db26fddc200dc22f6d7cd549 Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Sun, 12 Jul 2015 22:24:27 -0500 Subject: [PATCH 447/613] Implemented Hash table and spec. --- src/data-structures/hash-table.js | 213 ++++++++++++++++++++++++ test/data-structures/hash-table.spec.js | 129 ++++++++++++++ 2 files changed, 342 insertions(+) create mode 100644 src/data-structures/hash-table.js create mode 100644 test/data-structures/hash-table.spec.js diff --git a/src/data-structures/hash-table.js b/src/data-structures/hash-table.js new file mode 100644 index 00000000..2b7dff44 --- /dev/null +++ b/src/data-structures/hash-table.js @@ -0,0 +1,213 @@ +/** + * Hash Table + * + * An associative array, that can map keys + * (strings and numbers) to values in O(1). + * + * @example + * var hash = require('path-to-algorithms/src/data-structures'+ + * '/hash-table'); + * var hashTable = new hash.Hashtable(); + * + * hashTable.put(10, 'value'); + * hashTable.put('key', 10); + * + * console.log(hashTable.get(10)); // 'value' + * console.log(hashTable.get('key')); // 10 + * + * hashTable.remove(10); + * hashTable.remove('key'); + * + * console.log(hashTable.get(10)); // undefined + * console.log(hashTable.get('key')); // undefined + * + * @module data-structures/hash-table +*/ +(function (exports) { + 'use strict'; + + exports.Node = function (key, data) { + this.key = key; + this.data = data; + this.next = undefined; + this.prev = undefined; + }; + + exports.Hashtable = function () { + this.buckets = []; + // The higher the bucket count; less likely for collisions. + this.maxBucketCount = 100; + }; + + /* + Using simple non-crypto x->integer based hash. + */ + exports.Hashtable.prototype.hashCode = function (val) { + var i; + var hashCode = 0; + var character; + + // If value to be hashed is already an integer, return it. + if (val.length === 0 || val.length === undefined) { + return val; + } + + for (i = 0; i < val.length; i += 1) { + character = val.charCodeAt(i); + /*jshint -W016 */ + hashCode = ((hashCode << 5) - hashCode) + character; + hashCode = hashCode & hashCode; + /*jshint -W016 */ + } + + return hashCode; + }; + + exports.Hashtable.prototype.put = function (key, data, hashCode) { + /* + Make collision testing easy with optional hashCode parameter. + That should not be used! Only by spec/tests. + */ + if (hashCode === undefined) { + // Typical use + hashCode = this.hashCode(key); + } else if (hashCode.length > 0) { + // Testing/Spec - String hash passed, convert to int based hash. + hashCode = this.hashCode(hashCode); + } + // Adjust hash to fit within buckets. + hashCode = hashCode % this.maxBucketCount; + + var newNode = new exports.Node(key, data); + + // No element exists at hash/index for given key -> put in table. + if (this.buckets[hashCode] === undefined) { + this.buckets[hashCode] = newNode; + return; + } + + // Element exists at hash/index for given key, but, same key -> overwrite. + if (this.buckets[hashCode].key === key) { + this.buckets[hashCode].data = data; + return; + } + + /* + Item exists at hash/index for key, but different key. + Handle collision. + */ + var first = this.buckets[hashCode]; + while (first.next !== undefined) { + first = first.next; + } + first.next = newNode; + newNode.prev = first; + }; + + exports.Hashtable.prototype.get = function (key, hashCode) { + /* + Make collision testing easy with optional hashCode parameter. + That should not be used! Only by spec/tests. + */ + if (hashCode === undefined) { + // Typical use + hashCode = this.hashCode(key); + } else if (hashCode.length > 0) { + // Testing/Spec - String hash passed, convert to int based hash. + hashCode = this.hashCode(hashCode); + } + hashCode = hashCode % this.maxBucketCount; + + if (this.buckets[hashCode] === undefined) { + return undefined; + } else if ( + this.buckets[hashCode].next === undefined && + this.buckets[hashCode].key === key + ) { + return this.buckets[hashCode].data; + } else { + var first = this.buckets[hashCode]; + while ( + first !== undefined && + first.next !== undefined && + first.key !== key + ) { + first = first.next; + } + + if (first.key === key) { + return first.data; + } else { + return undefined; + } + } + }; + + exports.Hashtable.prototype.remove = function (key, hashCode) { + /* + Make collision testing easy with optional hashCode parameter. + That should not be used! Only by spec/tests. + */ + if (hashCode === undefined) { + // Typical use + hashCode = this.hashCode(key); + } else if (hashCode.length > 0) { + // Testing/Spec - String hash passed, convert to int based hash. + hashCode = this.hashCode(hashCode); + } + hashCode = hashCode % this.maxBucketCount; + + if (this.buckets[hashCode] === undefined) { + return undefined; + } else if (this.buckets[hashCode].next === undefined) { + this.buckets[hashCode] = undefined; + } else { + var first = this.buckets[hashCode]; + + while ( + first !== undefined && + first.next !== undefined && + first.key !== key + ) { + first = first.next; + } + + var removedValue = first.data; + + // Removing (B) + // (B) : only item in bucket + if (first.prev === undefined && first.next === undefined) { + first = undefined; + return removedValue; + } + + // (B) - A - C: start link in bucket + if (first.prev === undefined && first.next !== undefined) { + first.data = first.next.data; + first.key = first.next.key; + if (first.next.next !== undefined) { + first.next = first.next.next; + } else { + first.next = undefined; + } + return removedValue; + } + + // A - (B) : end link in bucket + if (first.prev !== undefined && first.next === undefined) { + first.prev.next = undefined; + first = undefined; + return removedValue; + } + + // A - (B) - C : middle link in bucket + if (first.prev !== undefined && first.next !== undefined) { + first.prev.next = first.next; + first.next.prev = first.prev; + first = undefined; + return removedValue; + } + + } + }; +})(typeof window === 'undefined' ? module.exports : window); diff --git a/test/data-structures/hash-table.spec.js b/test/data-structures/hash-table.spec.js new file mode 100644 index 00000000..03959822 --- /dev/null +++ b/test/data-structures/hash-table.spec.js @@ -0,0 +1,129 @@ +'use strict'; + +var mod = require('../../src/data-structures/hash-table.js'); +var Node = mod.Node; +var Hashtable = mod.Hashtable; + +describe('Node', function () { + it('should be a constructor function', function () { + expect(typeof Node).toBe('function'); + }); +}); + +describe('Hash table', function () { + it('should be a constructor function.', function () { + expect(typeof Hashtable).toBe('function'); + }); + it('should start with empty table.', function () { + expect(new Hashtable().buckets.length).toBe(0); + }); + it('should put() K(int):V in table properly.', function () { + var hashTable = new Hashtable(); + hashTable.put(10, 'value'); + expect(hashTable.buckets[10].data).toBe('value'); + }); + it('should put() K(str):V in table properly.', function () { + var hashTable = new Hashtable(); + hashTable.put('key', 'value'); + /* + 'key' hashCode()'s to 106079. Then the hash is adjusted to fit + the number of configurable buckets (array size). + 106079 % 100 (100 is default maxBucketCount) + result is 79. + This is done to avoid using get() since it's untested at this point. + */ + expect(hashTable.buckets[79].data).toBe('value'); + }); + it('should put() multiple K(int):Vs with hash collisions in properly (1).', function () { + var hashTable = new Hashtable(); + // Same hash so going to same bucket, but different keys. Collision. + hashTable.put(10, 'value', 'someHash'); + hashTable.put(35, 'anotherValue', 'someHash'); + /* + 'someHash' hashCode()'s to 1504481314. Then the hash is adjusted to fit + the number of configurable buckets (array size). + 1504481314 % 100 (100 is default maxBucketCount) + result is 14. + This is done to avoid using get() since it's untested at this point. + */ + expect(hashTable.buckets[14].data).toBe('value'); + expect(hashTable.buckets[14].next.data).toBe('anotherValue'); + }); + it('should put() multiple K:Vs with hash collisions in properly (2).', function () { + var hashTable = new Hashtable(); + hashTable.put(10, 'value', 'someHash'); + hashTable.put(35, 'anotherValue', 'someHash'); + hashTable.put(77, 'lastValue', 'someHash'); + expect(hashTable.buckets[14].data).toBe('value'); + expect(hashTable.buckets[14].next.data).toBe('anotherValue'); + expect(hashTable.buckets[14].next.next.data).toBe('lastValue'); + }); + it('should get() a k:v from table properly.', function () { + var hashTable = new Hashtable(); + hashTable.put(10, 'value'); + expect(hashTable.get(10)).toBe('value'); + }); + it('should get() a k:v with collisions from table properly (1).', function () { + var hashTable = new Hashtable(); + hashTable.put(10, 'value', 'someHash'); + hashTable.put(35, 'anotherValue', 'someHash'); + expect(hashTable.get(35, 'someHash')).toBe('anotherValue'); + }); + it('should get() a k:v with collisions from table properly (2).', function () { + var hashTable = new Hashtable(); + hashTable.put(10, 'value', 'someHash'); + hashTable.put(35, 'anotherValue', 'someHash'); + hashTable.put(77, 'lastValue', 'someHash'); + expect(hashTable.get(77, 'someHash')).toBe('lastValue'); + }); + it('should get() a k:v with collisions from table properly (3).', function () { + var hashTable = new Hashtable(); + hashTable.put(10, 'value', 'someHash'); + hashTable.put(35, 'anotherValue', 'someHash'); + hashTable.put(77, 'lastValue', 'someHash'); + expect(hashTable.get(35, 'someHash')).toBe('anotherValue'); + }); + it('should get() a k:v with collisions from table properly (4).', function () { + var hashTable = new Hashtable(); + hashTable.put(10, 'value', 'someHash'); + hashTable.put(35, 'anotherValue', 'someHash'); + hashTable.put(77, 'lastValue', 'someHash'); + expect(hashTable.get(10, 'someHash')).toBe('value'); + }); + it('should remove() a k:v from table properly.', function () { + // remove only node/link in bucket : (B) + var hashTable = new Hashtable(); + hashTable.put(10, 'value'); + hashTable.remove(10); + expect(hashTable.get(10)).toBe(undefined); + }); + it('should remove() a k:v with collisions from table properly (2).', function () { + // remove start node/link in bucket : (B) - A + var hashTable = new Hashtable(); + hashTable.put(10, 'value', 'someHash'); + hashTable.put(35, 'anotherValue', 'someHash'); + expect(hashTable.remove(10, 'someHash')).toBe('value'); + expect(hashTable.get(35, 'someHash')).toBe('anotherValue'); + expect(hashTable.get(10, 'someHash')).toBe(undefined); + }); + it('should remove() a k:v with collisions from table properly (3).', function () { + // remove start node/link in bucket : (B) - A - C + var hashTable = new Hashtable(); + hashTable.put(10, 'value', 'someHash'); + hashTable.put(35, 'anotherValue', 'someHash'); + hashTable.put(66, 'lastValue', 'someHash'); + expect(hashTable.remove(10, 'someHash')).toBe('value'); + expect(hashTable.get(35, 'someHash')).toBe('anotherValue'); + expect(hashTable.get(66, 'someHash')).toBe('lastValue'); + }); + it('should remove() a k:v with collisions from table properly (4).', function () { + // remove middle node/link in bucket : A - (B) - C + var hashTable = new Hashtable(); + hashTable.put(10, 'value', 'someHash'); + hashTable.put(35, 'anotherValue', 'someHash'); + hashTable.put(66, 'lastValue', 'someHash'); + expect(hashTable.remove(35, 'someHash')).toBe('anotherValue'); + expect(hashTable.get(10, 'someHash')).toBe('value'); + expect(hashTable.get(66, 'someHash')).toBe('lastValue'); + }); +}); From 49d594a3c24a54513872cba2ae7614c496c87a32 Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Mon, 13 Jul 2015 20:59:38 -0500 Subject: [PATCH 448/613] Added docs to Hash table. --- src/data-structures/hash-table.js | 48 +++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/src/data-structures/hash-table.js b/src/data-structures/hash-table.js index 2b7dff44..079845d7 100644 --- a/src/data-structures/hash-table.js +++ b/src/data-structures/hash-table.js @@ -26,6 +26,14 @@ (function (exports) { 'use strict'; + /** + * Constructs a Node to store data and next/prev nodes in Hash table. + * + * @public + * @constructor + * @param {Number|String} key Key of the node. + * @param {Number|String} data Data to be stored in hash table. + */ exports.Node = function (key, data) { this.key = key; this.data = data; @@ -33,15 +41,27 @@ this.prev = undefined; }; + /** + * Construct a Hash table.. + * + * @public + * @constructor + */ exports.Hashtable = function () { this.buckets = []; // The higher the bucket count; less likely for collisions. this.maxBucketCount = 100; }; - /* - Using simple non-crypto x->integer based hash. - */ + /** + * Simple non-crypto hash used to hash keys, which determines + * while bucket the value will be placed in. + * A javascript implementation of Java's 32bitint hash. + * + * @public + * @method + * @param {Number|String} val Key to be hashed. + */ exports.Hashtable.prototype.hashCode = function (val) { var i; var hashCode = 0; @@ -63,6 +83,14 @@ return hashCode; }; + /** + * Puts data into the table based on hashed key value. + * + * @public + * @method + * @param {Number|String} key Key for data. + * @param {Number|String} data Data to be stored in table. + */ exports.Hashtable.prototype.put = function (key, data, hashCode) { /* Make collision testing easy with optional hashCode parameter. @@ -104,6 +132,13 @@ newNode.prev = first; }; + /** + * Get's data from the table based on key. + * + * @public + * @method + * @param {Number|String} key Key for data to be retrieved. + */ exports.Hashtable.prototype.get = function (key, hashCode) { /* Make collision testing easy with optional hashCode parameter. @@ -143,6 +178,13 @@ } }; + /** + * Removes data from the table based on key. + * + * @public + * @method + * @param {Number|String} key Key of the data to be removed. + */ exports.Hashtable.prototype.remove = function (key, hashCode) { /* Make collision testing easy with optional hashCode parameter. From a8cfc5c19e6143ad48219d14c5ca3d6d487c6c94 Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Tue, 14 Jul 2015 17:29:46 -0500 Subject: [PATCH 449/613] Clarified key types in spec descriptions. --- test/data-structures/hash-table.spec.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/data-structures/hash-table.spec.js b/test/data-structures/hash-table.spec.js index 03959822..535ff2d2 100644 --- a/test/data-structures/hash-table.spec.js +++ b/test/data-structures/hash-table.spec.js @@ -49,7 +49,7 @@ describe('Hash table', function () { expect(hashTable.buckets[14].data).toBe('value'); expect(hashTable.buckets[14].next.data).toBe('anotherValue'); }); - it('should put() multiple K:Vs with hash collisions in properly (2).', function () { + it('should put() multiple K(int):Vs with hash collisions in properly (2).', function () { var hashTable = new Hashtable(); hashTable.put(10, 'value', 'someHash'); hashTable.put(35, 'anotherValue', 'someHash'); @@ -58,46 +58,46 @@ describe('Hash table', function () { expect(hashTable.buckets[14].next.data).toBe('anotherValue'); expect(hashTable.buckets[14].next.next.data).toBe('lastValue'); }); - it('should get() a k:v from table properly.', function () { + it('should get() a K(int):V from table properly.', function () { var hashTable = new Hashtable(); hashTable.put(10, 'value'); expect(hashTable.get(10)).toBe('value'); }); - it('should get() a k:v with collisions from table properly (1).', function () { + it('should get() a K(int):V with collisions from table properly (1).', function () { var hashTable = new Hashtable(); hashTable.put(10, 'value', 'someHash'); hashTable.put(35, 'anotherValue', 'someHash'); expect(hashTable.get(35, 'someHash')).toBe('anotherValue'); }); - it('should get() a k:v with collisions from table properly (2).', function () { + it('should get() a K(int):V with collisions from table properly (2).', function () { var hashTable = new Hashtable(); hashTable.put(10, 'value', 'someHash'); hashTable.put(35, 'anotherValue', 'someHash'); hashTable.put(77, 'lastValue', 'someHash'); expect(hashTable.get(77, 'someHash')).toBe('lastValue'); }); - it('should get() a k:v with collisions from table properly (3).', function () { + it('should get() a K(int):V with collisions from table properly (3).', function () { var hashTable = new Hashtable(); hashTable.put(10, 'value', 'someHash'); hashTable.put(35, 'anotherValue', 'someHash'); hashTable.put(77, 'lastValue', 'someHash'); expect(hashTable.get(35, 'someHash')).toBe('anotherValue'); }); - it('should get() a k:v with collisions from table properly (4).', function () { + it('should get() a K(int):V with collisions from table properly (4).', function () { var hashTable = new Hashtable(); hashTable.put(10, 'value', 'someHash'); hashTable.put(35, 'anotherValue', 'someHash'); hashTable.put(77, 'lastValue', 'someHash'); expect(hashTable.get(10, 'someHash')).toBe('value'); }); - it('should remove() a k:v from table properly.', function () { + it('should remove() a K(int):V from table properly.', function () { // remove only node/link in bucket : (B) var hashTable = new Hashtable(); hashTable.put(10, 'value'); hashTable.remove(10); expect(hashTable.get(10)).toBe(undefined); }); - it('should remove() a k:v with collisions from table properly (2).', function () { + it('should remove() a K(int):V with collisions from table properly (2).', function () { // remove start node/link in bucket : (B) - A var hashTable = new Hashtable(); hashTable.put(10, 'value', 'someHash'); @@ -106,7 +106,7 @@ describe('Hash table', function () { expect(hashTable.get(35, 'someHash')).toBe('anotherValue'); expect(hashTable.get(10, 'someHash')).toBe(undefined); }); - it('should remove() a k:v with collisions from table properly (3).', function () { + it('should remove() a K(int):V with collisions from table properly (3).', function () { // remove start node/link in bucket : (B) - A - C var hashTable = new Hashtable(); hashTable.put(10, 'value', 'someHash'); @@ -116,7 +116,7 @@ describe('Hash table', function () { expect(hashTable.get(35, 'someHash')).toBe('anotherValue'); expect(hashTable.get(66, 'someHash')).toBe('lastValue'); }); - it('should remove() a k:v with collisions from table properly (4).', function () { + it('should remove() a K(int):V with collisions from table properly (4).', function () { // remove middle node/link in bucket : A - (B) - C var hashTable = new Hashtable(); hashTable.put(10, 'value', 'someHash'); From 90ff3f13f95ce8846f7778e0e0518935f666fa22 Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Tue, 14 Jul 2015 17:38:02 -0500 Subject: [PATCH 450/613] Added string based key specs. --- test/data-structures/hash-table.spec.js | 96 ++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 2 deletions(-) diff --git a/test/data-structures/hash-table.spec.js b/test/data-structures/hash-table.spec.js index 535ff2d2..8a598226 100644 --- a/test/data-structures/hash-table.spec.js +++ b/test/data-structures/hash-table.spec.js @@ -22,7 +22,7 @@ describe('Hash table', function () { hashTable.put(10, 'value'); expect(hashTable.buckets[10].data).toBe('value'); }); - it('should put() K(str):V in table properly.', function () { + it('should put() K(string):V in table properly.', function () { var hashTable = new Hashtable(); hashTable.put('key', 'value'); /* @@ -58,11 +58,40 @@ describe('Hash table', function () { expect(hashTable.buckets[14].next.data).toBe('anotherValue'); expect(hashTable.buckets[14].next.next.data).toBe('lastValue'); }); + it('should put() multiple K(string):Vs with hash collisions in properly (1).', function () { + var hashTable = new Hashtable(); + // Same hash so going to same bucket, but different keys. Collision. + hashTable.put('keyA', 'value', 'someHash'); + hashTable.put('keyB', 'anotherValue', 'someHash'); + /* + 'someHash' hashCode()'s to 1504481314. Then the hash is adjusted to fit + the number of configurable buckets (array size). + 1504481314 % 100 (100 is default maxBucketCount) + result is 14. + This is done to avoid using get() since it's untested at this point. + */ + expect(hashTable.buckets[14].data).toBe('value'); + expect(hashTable.buckets[14].next.data).toBe('anotherValue'); + }); + it('should put() multiple K(string):Vs with hash collisions in properly (2).', function () { + var hashTable = new Hashtable(); + hashTable.put('keyA', 'value', 'someHash'); + hashTable.put('keyB', 'anotherValue', 'someHash'); + hashTable.put('keyC', 'lastValue', 'someHash'); + expect(hashTable.buckets[14].data).toBe('value'); + expect(hashTable.buckets[14].next.data).toBe('anotherValue'); + expect(hashTable.buckets[14].next.next.data).toBe('lastValue'); + }); it('should get() a K(int):V from table properly.', function () { var hashTable = new Hashtable(); hashTable.put(10, 'value'); expect(hashTable.get(10)).toBe('value'); }); + it('should get() a K(string):V from table properly.', function () { + var hashTable = new Hashtable(); + hashTable.put('keyA', 'value'); + expect(hashTable.get('keyA')).toBe('value'); + }); it('should get() a K(int):V with collisions from table properly (1).', function () { var hashTable = new Hashtable(); hashTable.put(10, 'value', 'someHash'); @@ -90,7 +119,34 @@ describe('Hash table', function () { hashTable.put(77, 'lastValue', 'someHash'); expect(hashTable.get(10, 'someHash')).toBe('value'); }); - it('should remove() a K(int):V from table properly.', function () { + it('should get() a K(string):V with collisions from table properly (1).', function () { + var hashTable = new Hashtable(); + hashTable.put('keyA', 'value', 'someHash'); + hashTable.put('keyB', 'anotherValue', 'someHash'); + expect(hashTable.get('keyB', 'someHash')).toBe('anotherValue'); + }); + it('should get() a K(string):V with collisions from table properly (2).', function () { + var hashTable = new Hashtable(); + hashTable.put('keyA', 'value', 'someHash'); + hashTable.put('keyB', 'anotherValue', 'someHash'); + hashTable.put('keyC', 'lastValue', 'someHash'); + expect(hashTable.get('keyC', 'someHash')).toBe('lastValue'); + }); + it('should get() a K(string):V with collisions from table properly (3).', function () { + var hashTable = new Hashtable(); + hashTable.put('keyA', 'value', 'someHash'); + hashTable.put('keyB', 'anotherValue', 'someHash'); + hashTable.put('keyC', 'lastValue', 'someHash'); + expect(hashTable.get('keyB', 'someHash')).toBe('anotherValue'); + }); + it('should get() a K(string):V with collisions from table properly (4).', function () { + var hashTable = new Hashtable(); + hashTable.put('keyA', 'value', 'someHash'); + hashTable.put('keyB', 'anotherValue', 'someHash'); + hashTable.put('keyC', 'lastValue', 'someHash'); + expect(hashTable.get('keyA', 'someHash')).toBe('value'); + }); + it('should remove() a K(int):V from table properly (1).', function () { // remove only node/link in bucket : (B) var hashTable = new Hashtable(); hashTable.put(10, 'value'); @@ -126,4 +182,40 @@ describe('Hash table', function () { expect(hashTable.get(10, 'someHash')).toBe('value'); expect(hashTable.get(66, 'someHash')).toBe('lastValue'); }); + it('should remove() a K(string):V from table properly (1).', function () { + // remove only node/link in bucket : (B) + var hashTable = new Hashtable(); + hashTable.put('keyA', 'value'); + hashTable.remove('keyA'); + expect(hashTable.get('keyA')).toBe(undefined); + }); + it('should remove() a K(string):V with collisions from table properly (2).', function () { + // remove start node/link in bucket : (B) - A + var hashTable = new Hashtable(); + hashTable.put('keyA', 'value', 'someHash'); + hashTable.put('keyB', 'anotherValue', 'someHash'); + expect(hashTable.remove('keyA', 'someHash')).toBe('value'); + expect(hashTable.get('keyB', 'someHash')).toBe('anotherValue'); + expect(hashTable.get('keyA', 'someHash')).toBe(undefined); + }); + it('should remove() a K(string):V with collisions from table properly (3).', function () { + // remove start node/link in bucket : (B) - A - C + var hashTable = new Hashtable(); + hashTable.put('keyA', 'value', 'someHash'); + hashTable.put('keyB', 'anotherValue', 'someHash'); + hashTable.put('keyC', 'lastValue', 'someHash'); + expect(hashTable.remove('keyA', 'someHash')).toBe('value'); + expect(hashTable.get('keyB', 'someHash')).toBe('anotherValue'); + expect(hashTable.get('keyC', 'someHash')).toBe('lastValue'); + }); + it('should remove() a K(string):V with collisions from table properly (4).', function () { + // remove middle node/link in bucket : A - (B) - C + var hashTable = new Hashtable(); + hashTable.put('keyA', 'value', 'someHash'); + hashTable.put('keyB', 'anotherValue', 'someHash'); + hashTable.put('keyC', 'lastValue', 'someHash'); + expect(hashTable.remove('keyB', 'someHash')).toBe('anotherValue'); + expect(hashTable.get('keyA', 'someHash')).toBe('value'); + expect(hashTable.get('keyC', 'someHash')).toBe('lastValue'); + }); }); From 43be733d902c9187136b7ab54c02c0580f3c9f58 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 20 Jul 2015 11:20:39 +0300 Subject: [PATCH 451/613] Fix #77 --- gulpfile.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gulpfile.js b/gulpfile.js index 57841253..75f37af9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,8 +5,11 @@ var jshint = require('gulp-jshint'); var jasmine = require('gulp-jasmine'); var stylish = require('jshint-stylish'); var jscs = require('gulp-jscs'); +var isWin = /^win/.test(process.platform); gulp.task('jsdoc', shell.task([ + (isWin) ? + '"node_modules/.bin/jsdoc.cmd" -c ./doc-config.json' : './node_modules/.bin/jsdoc -c ./doc-config.json' ])); From 30254674de23e5f6b9cc3638f49065a68e4a9fac Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 6 Aug 2015 17:46:10 +0300 Subject: [PATCH 452/613] Update readme --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 8c7413cd..35bdaa4c 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,7 @@ -![](https://travis-ci.org/mgechev/javascript-algorithms.svg?branch=master) - ## About +![](https://travis-ci.org/mgechev/javascript-algorithms.svg?branch=master) + This repository contains JavaScript implementations of different famous Computer Science algorithms. API reference with usage examples available
here. From 51228e073559a5fcd2fdacf2c8ed0d6d67172451 Mon Sep 17 00:00:00 2001 From: Robert Eisele Date: Fri, 14 Aug 2015 14:08:43 +0200 Subject: [PATCH 453/613] Improved prime factor check --- src/primes/is-prime.js | 97 +++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 57 deletions(-) diff --git a/src/primes/is-prime.js b/src/primes/is-prime.js index 38ec9afe..6f80c7ab 100644 --- a/src/primes/is-prime.js +++ b/src/primes/is-prime.js @@ -1,61 +1,44 @@ (function (exports) { - 'use strict'; - - /** - * Advanced (optimised) method for checking if provided number is prime. - * For example for number 104743 it should return true, for 104744 - false. - * - * @module primes/is-prime - * @param {Number} number - Number that we check on prime. - * @returns {Boolean} Will return true if provided number is prime. - * - * @example - * var isPrime = require('path-to-algorithms/src/is-prime').isPrime; - * - * console.log(isPrime(7)); // true - * console.log(isPrime(18)); // false - */ - exports.isPrime = function (number) { - if (number === 1) { - return false; - - } else if (number < 4) { - /** - * 2 and 3 are prime - */ - return true; - - } else if (number % 2 === 0) { - return false; - - } else if (number < 9) { - /** - * We have already excluded 4,6 and 8 - */ - return true; - - } else if (number % 3 === 0) { - return false; - - } else { - /** - * 'number' rounded to the greatest integer 'rounded' so that: - * rounded * rounded <= number - */ - var rounded = Math.floor(Math.sqrt(number)); - var factor = 5; - while (factor <= rounded) { - if (number % factor === 0) { - return false; + 'use strict'; + + /** + * Advanced (optimised) method for checking if provided number is prime. + * For example for number 104743 it should return true, for 104744 - false. + * + * @module primes/is-prime + * @param {Number} number - Number that we check on prime. + * @returns {Boolean} Will return true if provided number is prime. + * + * @example + * var isPrime = require('path-to-algorithms/src/is-prime').isPrime; + * + * console.log(isPrime(7)); // true + * console.log(isPrime(18)); // false + */ + exports.isPrime = function (number) { + + if (number < 2) + return false; + + if (number % 2 === 0) + return (number === 2); + if (number % 3 === 0) + return (number === 3); + + var horizon = Math.floor(Math.sqrt(number)); + var factor = 5; + + while (factor <= horizon) { + + if (number % factor === 0) + return false; + + if (number % (factor + 2) === 0) + return false; + + factor += 6; } - if (number % (factor + 2) === 0) { - return false; - } - factor += 6; - } - } - - return true; - }; + return true; + }; }(typeof exports === 'undefined' ? window : exports)); From 88b545497842ad6bcfbf05c44d55aa964796ca51 Mon Sep 17 00:00:00 2001 From: Robert Eisele Date: Fri, 14 Aug 2015 14:12:03 +0200 Subject: [PATCH 454/613] Fixed fisheryates algorithm --- src/shuffle/fisheryates.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shuffle/fisheryates.js b/src/shuffle/fisheryates.js index 75721e04..2951ff0a 100644 --- a/src/shuffle/fisheryates.js +++ b/src/shuffle/fisheryates.js @@ -21,8 +21,8 @@ var size = array.length; var rand; var temp; - for (var i = 1; i < size; i += 1) { - rand = Math.round(Math.random() * i); + for (var i = 0; i < size; i += 1) { + rand = Math.floor(i + Math.random() * (size - i)); temp = array[rand]; array[rand] = array[i]; array[i] = temp; From 50663769a7481ca082b3310bc9323d230b87edae Mon Sep 17 00:00:00 2001 From: Robert Eisele Date: Fri, 14 Aug 2015 17:01:19 +0200 Subject: [PATCH 455/613] Mess with linter --- src/primes/is-prime.js | 87 ++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 41 deletions(-) diff --git a/src/primes/is-prime.js b/src/primes/is-prime.js index 6f80c7ab..ca954fe0 100644 --- a/src/primes/is-prime.js +++ b/src/primes/is-prime.js @@ -1,44 +1,49 @@ (function (exports) { - 'use strict'; - - /** - * Advanced (optimised) method for checking if provided number is prime. - * For example for number 104743 it should return true, for 104744 - false. - * - * @module primes/is-prime - * @param {Number} number - Number that we check on prime. - * @returns {Boolean} Will return true if provided number is prime. - * - * @example - * var isPrime = require('path-to-algorithms/src/is-prime').isPrime; - * - * console.log(isPrime(7)); // true - * console.log(isPrime(18)); // false - */ - exports.isPrime = function (number) { - - if (number < 2) - return false; - - if (number % 2 === 0) - return (number === 2); - if (number % 3 === 0) - return (number === 3); - - var horizon = Math.floor(Math.sqrt(number)); - var factor = 5; - - while (factor <= horizon) { - - if (number % factor === 0) - return false; - - if (number % (factor + 2) === 0) - return false; - - factor += 6; - } - return true; - }; + 'use strict'; + + /** + * Advanced (optimised) method for checking if provided number is prime. + * For example for number 104743 it should return true, for 104744 - false. + * + * @module primes/is-prime + * @param {Number} number - Number that we check on prime. + * @returns {Boolean} Will return true if provided number is prime. + * + * @example + * var isPrime = require('path-to-algorithms/src/is-prime').isPrime; + * + * console.log(isPrime(7)); // true + * console.log(isPrime(18)); // false + */ + exports.isPrime = function (number) { + + if (number < 2) { + return false; + } + + if (number % 2 === 0) { + return (number === 2); + } + + if (number % 3 === 0) { + return (number === 3); + } + + var horizon = Math.floor(Math.sqrt(number)); + var factor = 5; + + while (factor <= horizon) { + + if (number % factor === 0) { + return false; + } + + if (number % (factor + 2) === 0) { + return false; + } + factor += 6; + } + return true; + }; }(typeof exports === 'undefined' ? window : exports)); From e6150b4bb529ae08bb44aafc08be2820c1a6eff1 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 15 Aug 2015 18:19:07 +0300 Subject: [PATCH 456/613] Update contributors list --- readme.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index 35bdaa4c..08e5e2e8 100644 --- a/readme.md +++ b/readme.md @@ -71,14 +71,13 @@ If the build is not successful fix your code in order the tests and jshint valid ## Contributors -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) |[secrettriangle](https://github.com/secrettriangle) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) |[infusion](https://github.com/infusion) | :---: |:---: |:---: |:---: |:---: |:---: | -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) |[secrettriangle](https://github.com/secrettriangle) | - -[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | -:---: |:---: |:---: | -[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) |[infusion](https://github.com/infusion) | +[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) |[ysharplanguage](https://github.com/ysharplanguage) |[fanixk](https://github.com/fanixk) | +:---: |:---: |:---: |:---: | +[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) |[ysharplanguage](https://github.com/ysharplanguage) |[fanixk](https://github.com/fanixk) | ## License The code in this repository is distributed under the terms of the MIT license. From 66eab6e7550c5cf6acd705edfca52befe66c7824 Mon Sep 17 00:00:00 2001 From: Kostas Lekkas Date: Thu, 20 Aug 2015 21:40:27 +0300 Subject: [PATCH 457/613] mergesort: Use queues to efficiently merge left and right sub-arrays. --- src/sorting/mergesort.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/sorting/mergesort.js b/src/sorting/mergesort.js index e4e0557d..ab7c2a0c 100644 --- a/src/sorting/mergesort.js +++ b/src/sorting/mergesort.js @@ -4,6 +4,8 @@ */ 'use strict'; + var ll = require('../data-structures/linked-list.js'); + function compare(a, b) { return a - b; } @@ -61,8 +63,9 @@ * }, 0, 4, 7); */ mergeSort.merge = function (array, cmp, start, middle, end) { - var left = []; - var right = []; + var left = new ll.LinkedList(); + var right = new ll.LinkedList(); + var leftSize = middle - start; var rightSize = end - middle; var maxSize = Math.max(leftSize, rightSize); @@ -71,24 +74,24 @@ for (i = 0; i < maxSize; i += 1) { if (i < leftSize) { - left[i] = array[start + i]; + left.push(array[start + i]); } if (i < rightSize) { - right[i] = array[middle + i]; + right.push(array[middle + i]); } } i = 0; while (i < size) { - if (left.length && right.length) { - if (cmp(left[0], right[0]) > 0) { - array[start + i] = right.shift(); + if (left.first && right.first) { + if (cmp(left.first.data, right.first.data) > 0) { + array[start + i] = right.shift().data; } else { - array[start + i] = left.shift(); + array[start + i] = left.shift().data; } - } else if (left.length) { - array[start + i] = left.shift(); + } else if (left.first) { + array[start + i] = left.shift().data; } else { - array[start + i] = right.shift(); + array[start + i] = right.shift().data; } i += 1; } From f4b8566d938b4eb3d2288b0f325e2fe35ffa952f Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 1 Sep 2015 16:50:44 +0300 Subject: [PATCH 458/613] Update contributors list --- readme.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 08e5e2e8..a3677c77 100644 --- a/readme.md +++ b/readme.md @@ -75,9 +75,10 @@ If the build is not successful fix your code in order the tests and jshint valid :---: |:---: |:---: |:---: |:---: |:---: | [mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) |[infusion](https://github.com/infusion) | -[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) |[ysharplanguage](https://github.com/ysharplanguage) |[fanixk](https://github.com/fanixk) | -:---: |:---: |:---: |:---: | -[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) |[ysharplanguage](https://github.com/ysharplanguage) |[fanixk](https://github.com/fanixk) | +[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) |[ysharplanguage](https://github.com/ysharplanguage) |[lekkas](https://github.com/lekkas) |[fanixk](https://github.com/fanixk) | +:---: |:---: |:---: |:---: |:---: | +[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) |[ysharplanguage](https://github.com/ysharplanguage) |[lekkas](https://github.com/lekkas) |[fanixk](https://github.com/fanixk) | + ## License The code in this repository is distributed under the terms of the MIT license. From 0f4d8cb453d8357b87368ed3095ae68ccc4c43f0 Mon Sep 17 00:00:00 2001 From: Kostas Lekkas Date: Tue, 1 Sep 2015 23:38:50 +0300 Subject: [PATCH 459/613] Add radix sort algorithm A non comparative, stable integer sorting algorithm. --- src/sorting/radixsort.js | 100 +++++++++++++++++++++++++++++++++ test/sorting/radixsort.spec.js | 18 ++++++ 2 files changed, 118 insertions(+) create mode 100644 src/sorting/radixsort.js create mode 100644 test/sorting/radixsort.spec.js diff --git a/src/sorting/radixsort.js b/src/sorting/radixsort.js new file mode 100644 index 00000000..94d3bfbd --- /dev/null +++ b/src/sorting/radixsort.js @@ -0,0 +1,100 @@ +(function (exports) { + 'use strict'; + + var radixSort = (function() { + + /** + * Returns the digit of a number that is 'lsdOffset' + * places from the least significant digit. + * + * @private + * @param {Number} number Number + * @param {Number} lsdOffset Offset of the digit to return, counting + * from the position of the least significant digit (e.g. lsdOffset = 0 + * will return the least significant digit itself) + * @return {String} digit The specified number digit. Returns 'undefined' + * if lsdOffset is bigger or equal to the number of digits of the 'number' + * argument. + */ + var getDigit = function(number, lsdOffset) { + var numStr = ''+number; + var size = numStr.length; + var digit; + + if (lsdOffset >= 0 && lsdOffset < size) { + digit = numStr[size - 1 - lsdOffset]; + } + + return digit; + }; + + /** + * Least significant digit (LSD) Radix sort. A non-comparative, + * stable integer sorting algorithm.

+ * Worst-case time complexity is O(N K) for N keys with K being + * the average key length, measured in number of digits. + * + * @example + * var sort = require('path-to-algorithms/src/' + + * 'sorting/radixsort').radixSort; + * console.log(sort([2, 5, 1, 3, 4])); // [ 1, 2, 3, 4, 5 ] + * + * @public + * @module sorting/radixsort + * @param {Array} array Input integer array + * @return {Array} Sorted array + */ + return function(array) { + var size = array.length; + var R = 10; /* Alphabet size ([0-9] for integers) */ + var count; + var digit; + var i, j; + + /* Find maximum key size */ + var maxKeySize = ('' + array[0]).length; + for (i = 1; i < size; i += 1) { + var numStr = '' + array[i]; + if (numStr.length > maxKeySize) { + maxKeySize = numStr.length; + } + } + + for (i = 0; i < maxKeySize; i += 1) { + /* Initialize count */ + count = []; + for (j = 0; j < R; j += 1) { + count[j] = 0; + } + + /* Count frequency of each array element */ + for (j = 0; j < array.length; j += 1) { + digit = getDigit(array[j], i) || 0; + count[digit] += 1; + } + + /* Compute cumulates */ + for (j = 1; j < R; j += 1) { + count[j] += count[j - 1]; + } + + /* Move elements to auxilary array */ + var aux = []; + for (j = array.length - 1; j >= 0; j -= 1) { + digit = getDigit(array[j], i) || 0; + count[digit] -= 1; + aux[count[digit]] = array[j]; + } + + /* Copy elements back from auxilary array */ + for (j = 0; j < array.length; j += 1) { + array[j] = aux[j]; + } + } + return array; + }; + })(); + + exports.radixSort = radixSort; + +})(typeof window === 'undefined' ? module.exports : window); diff --git a/test/sorting/radixsort.spec.js b/test/sorting/radixsort.spec.js new file mode 100644 index 00000000..4197be94 --- /dev/null +++ b/test/sorting/radixsort.spec.js @@ -0,0 +1,18 @@ +var rx = + require('../../src/sorting/radixsort.js').radixSort; + +describe('radixsort', function () { + 'use strict'; + + it('should sort the empty array', function () { + expect(rx([])).toEqual([]); + }); + + it('should return array with the same count of elements', function () { + expect(rx([2, 3, 4]).length).toBe(3); + }); + + it('should sort the given array in ascending order', function () { + expect(rx([42, 3, 10])).toEqual([3, 10, 42]); + }); +}); From 4405e249202af3197183e79c297bca12bbbfc415 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Wed, 2 Sep 2015 15:04:08 +0300 Subject: [PATCH 460/613] Revert "Add radix sort algorithm" --- src/sorting/radixsort.js | 100 --------------------------------- test/sorting/radixsort.spec.js | 18 ------ 2 files changed, 118 deletions(-) delete mode 100644 src/sorting/radixsort.js delete mode 100644 test/sorting/radixsort.spec.js diff --git a/src/sorting/radixsort.js b/src/sorting/radixsort.js deleted file mode 100644 index 94d3bfbd..00000000 --- a/src/sorting/radixsort.js +++ /dev/null @@ -1,100 +0,0 @@ -(function (exports) { - 'use strict'; - - var radixSort = (function() { - - /** - * Returns the digit of a number that is 'lsdOffset' - * places from the least significant digit. - * - * @private - * @param {Number} number Number - * @param {Number} lsdOffset Offset of the digit to return, counting - * from the position of the least significant digit (e.g. lsdOffset = 0 - * will return the least significant digit itself) - * @return {String} digit The specified number digit. Returns 'undefined' - * if lsdOffset is bigger or equal to the number of digits of the 'number' - * argument. - */ - var getDigit = function(number, lsdOffset) { - var numStr = ''+number; - var size = numStr.length; - var digit; - - if (lsdOffset >= 0 && lsdOffset < size) { - digit = numStr[size - 1 - lsdOffset]; - } - - return digit; - }; - - /** - * Least significant digit (LSD) Radix sort. A non-comparative, - * stable integer sorting algorithm.

- * Worst-case time complexity is O(N K) for N keys with K being - * the average key length, measured in number of digits. - * - * @example - * var sort = require('path-to-algorithms/src/' + - * 'sorting/radixsort').radixSort; - * console.log(sort([2, 5, 1, 3, 4])); // [ 1, 2, 3, 4, 5 ] - * - * @public - * @module sorting/radixsort - * @param {Array} array Input integer array - * @return {Array} Sorted array - */ - return function(array) { - var size = array.length; - var R = 10; /* Alphabet size ([0-9] for integers) */ - var count; - var digit; - var i, j; - - /* Find maximum key size */ - var maxKeySize = ('' + array[0]).length; - for (i = 1; i < size; i += 1) { - var numStr = '' + array[i]; - if (numStr.length > maxKeySize) { - maxKeySize = numStr.length; - } - } - - for (i = 0; i < maxKeySize; i += 1) { - /* Initialize count */ - count = []; - for (j = 0; j < R; j += 1) { - count[j] = 0; - } - - /* Count frequency of each array element */ - for (j = 0; j < array.length; j += 1) { - digit = getDigit(array[j], i) || 0; - count[digit] += 1; - } - - /* Compute cumulates */ - for (j = 1; j < R; j += 1) { - count[j] += count[j - 1]; - } - - /* Move elements to auxilary array */ - var aux = []; - for (j = array.length - 1; j >= 0; j -= 1) { - digit = getDigit(array[j], i) || 0; - count[digit] -= 1; - aux[count[digit]] = array[j]; - } - - /* Copy elements back from auxilary array */ - for (j = 0; j < array.length; j += 1) { - array[j] = aux[j]; - } - } - return array; - }; - })(); - - exports.radixSort = radixSort; - -})(typeof window === 'undefined' ? module.exports : window); diff --git a/test/sorting/radixsort.spec.js b/test/sorting/radixsort.spec.js deleted file mode 100644 index 4197be94..00000000 --- a/test/sorting/radixsort.spec.js +++ /dev/null @@ -1,18 +0,0 @@ -var rx = - require('../../src/sorting/radixsort.js').radixSort; - -describe('radixsort', function () { - 'use strict'; - - it('should sort the empty array', function () { - expect(rx([])).toEqual([]); - }); - - it('should return array with the same count of elements', function () { - expect(rx([2, 3, 4]).length).toBe(3); - }); - - it('should sort the given array in ascending order', function () { - expect(rx([42, 3, 10])).toEqual([3, 10, 42]); - }); -}); From 795a4701a430119e2ccbb1ea7e55f38c7106a634 Mon Sep 17 00:00:00 2001 From: Kostas Lekkas Date: Tue, 1 Sep 2015 23:38:50 +0300 Subject: [PATCH 461/613] Add radix sort algorithm A non comparative, stable integer sorting algorithm. - [Pull Request v2] Fix reported jscs errors. --- src/sorting/radixsort.js | 100 +++++++++++++++++++++++++++++++++ test/sorting/radixsort.spec.js | 18 ++++++ 2 files changed, 118 insertions(+) create mode 100644 src/sorting/radixsort.js create mode 100644 test/sorting/radixsort.spec.js diff --git a/src/sorting/radixsort.js b/src/sorting/radixsort.js new file mode 100644 index 00000000..caf58cc6 --- /dev/null +++ b/src/sorting/radixsort.js @@ -0,0 +1,100 @@ +(function (exports) { + 'use strict'; + + var radixSort = (function () { + + /** + * Returns the digit of a number that is 'lsdOffset' + * places from the least significant digit. + * + * @private + * @param {Number} number Number + * @param {Number} lsdOffset Offset of the digit to return, counting + * from the position of the least significant digit (e.g. lsdOffset = 0 + * will return the least significant digit itself) + * @return {String} digit The specified number digit. Returns 'undefined' + * if lsdOffset is bigger or equal to the number of digits of the 'number' + * argument. + */ + var getDigit = function (number, lsdOffset) { + var size = number.toString().length; + var digit; + + if (lsdOffset >= 0 && lsdOffset < size) { + digit = number.toString()[size - 1 - lsdOffset]; + } + + return digit; + }; + + /** + * Least significant digit (LSD) Radix sort. A non-comparative, + * stable integer sorting algorithm.

+ * Worst-case time complexity is O(N K) for N keys with K being + * the average key length, measured in number of digits. + * + * @example + * var sort = require('path-to-algorithms/src/' + + * 'sorting/radixsort').radixSort; + * console.log(sort([2, 5, 1, 3, 4])); // [ 1, 2, 3, 4, 5 ] + * + * @public + * @module sorting/radixsort + * @param {Array} array Input integer array + * @return {Array} Sorted array + */ + return function (array) { + var size = array.length; + var R = 10; /* Alphabet size ([0-9] for integers) */ + var count; + var digit; + var i; + var j; + + /* Find maximum key size */ + var maxKeySize = (array[0] || '').toString().length; + for (i = 1; i < size; i += 1) { + var numStr = array[i].toString(); + if (numStr.length > maxKeySize) { + maxKeySize = numStr.length; + } + } + + for (i = 0; i < maxKeySize; i += 1) { + /* Initialize count */ + count = []; + for (j = 0; j < R; j += 1) { + count[j] = 0; + } + + /* Count frequency of each array element */ + for (j = 0; j < array.length; j += 1) { + digit = getDigit(array[j], i) || 0; + count[digit] += 1; + } + + /* Compute cumulates */ + for (j = 1; j < R; j += 1) { + count[j] += count[j - 1]; + } + + /* Move elements to auxilary array */ + var aux = []; + for (j = array.length - 1; j >= 0; j -= 1) { + digit = getDigit(array[j], i) || 0; + count[digit] -= 1; + aux[count[digit]] = array[j]; + } + + /* Copy elements back from auxilary array */ + for (j = 0; j < array.length; j += 1) { + array[j] = aux[j]; + } + } + return array; + }; + })(); + + exports.radixSort = radixSort; + +})(typeof window === 'undefined' ? module.exports : window); diff --git a/test/sorting/radixsort.spec.js b/test/sorting/radixsort.spec.js new file mode 100644 index 00000000..4197be94 --- /dev/null +++ b/test/sorting/radixsort.spec.js @@ -0,0 +1,18 @@ +var rx = + require('../../src/sorting/radixsort.js').radixSort; + +describe('radixsort', function () { + 'use strict'; + + it('should sort the empty array', function () { + expect(rx([])).toEqual([]); + }); + + it('should return array with the same count of elements', function () { + expect(rx([2, 3, 4]).length).toBe(3); + }); + + it('should sort the given array in ascending order', function () { + expect(rx([42, 3, 10])).toEqual([3, 10, 42]); + }); +}); From b5351887f9858f39da3fefc81dcede5cbad4a642 Mon Sep 17 00:00:00 2001 From: deniskyashif Date: Sat, 5 Sep 2015 11:36:52 +0300 Subject: [PATCH 462/613] added tests for levenshtein distance algorithm --- test/others/levenshtein-distance.spec.js | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/others/levenshtein-distance.spec.js diff --git a/test/others/levenshtein-distance.spec.js b/test/others/levenshtein-distance.spec.js new file mode 100644 index 00000000..d0bc9ce4 --- /dev/null +++ b/test/others/levenshtein-distance.spec.js @@ -0,0 +1,42 @@ +'use strict'; + +var mod = require('../../src/others/levenshtein-distance.js'); +var levenshteinDistance = mod.levenshteinDistance; + +describe('Levenstein\'s minimum edit distance algorithm', function () { + it('"" -> "" should return 0.', function () { + expect(levenshteinDistance('', '')).toBe(0); + }); + + it('"T" -> "" should return 1.', function () { + expect(levenshteinDistance('T', '')).toBe(1); + }); + + it('"cake" -> "rake" should return 1.', function () { + expect(levenshteinDistance('cake', 'rake')).toBe(1); + }); + + it('"Sofia" -> "Sof" should return 2.', function () { + expect(levenshteinDistance('Sofia', 'Sof')).toBe(2); + }); + + it('"google" -> "lookat" should return 4.', function () { + expect(levenshteinDistance('google', 'lookat')).toBe(4); + }); + + it('"emacs" -> "vim" should return 5.', function () { + expect(levenshteinDistance('emacs', 'vim')).toBe(5); + }); + + it('"coffee" -> "cocoa" should return 4.', function () { + expect(levenshteinDistance('coffee', 'cocoa')).toBe(4); + }); + + it('"Munich" -> "Muenchen" should return 4.', function () { + expect(levenshteinDistance('Munich', 'Muenchen')).toBe(4); + }); + + it('"rosebud" -> "budrose" should return 6.', function () { + expect(levenshteinDistance('rosebud', 'budrose')).toBe(6); + }); +}); From a26cf93ed887ee62bfa12365ae9e157d4c11ea5a Mon Sep 17 00:00:00 2001 From: deniskyashif Date: Sat, 5 Sep 2015 13:16:35 +0300 Subject: [PATCH 463/613] optimized levenstein distance algorithm... - replaced the recursive implementation with iterative - used one-dimensional array for memoizing single row(the previous one) of the distance matrix at iteration --- src/others/levenshtein-distance.js | 38 +++++++++++++++++++----------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/others/levenshtein-distance.js b/src/others/levenshtein-distance.js index c9fe2e81..e3f34811 100644 --- a/src/others/levenshtein-distance.js +++ b/src/others/levenshtein-distance.js @@ -3,22 +3,31 @@ var levenshteinDistance = (function () { - function levenshteinDistance(s, ls, t, lt) { - if (ls === 0) { - return lt; - } - if (lt === 0) { - return ls; + function levenshteinDistance (s, ls, t, lt) { + var memo = []; + var currRowMemo; + var i; + var k; + + for (k = 0; k <= lt; k += 1) { + memo[k] = k; } - var cost; - if (s[ls - 1] === t[lt - 1]) { - cost = 0; - } else { - cost = 1; + + for (i = 1; i <= ls; i += 1) { + currRowMemo = [i]; + + for (k = 1; k <= lt; k += 1) { + currRowMemo[k] = Math.min( + currRowMemo[k - 1] + 1, + memo[k] + 1, + memo[k - 1] + (s[i - 1] !== t[k - 1] ? 1 : 0) + ); + } + + memo = currRowMemo; } - return Math.min(levenshteinDistance(s, ls - 1, t, lt) + 1, - levenshteinDistance(s, ls, t, lt - 1) + 1, - levenshteinDistance(s, ls - 1, t, lt - 1) + cost); + + return memo[lt]; } /** @@ -49,3 +58,4 @@ exports.levenshteinDistance = levenshteinDistance; }(typeof exports === 'undefined' ? window : exports)); + From 9f2c410a53477d02c108de5360a5ace375095676 Mon Sep 17 00:00:00 2001 From: deniskyashif Date: Sat, 5 Sep 2015 13:36:20 +0300 Subject: [PATCH 464/613] added few more tests for levenshtein distance --- test/others/levenshtein-distance.spec.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/others/levenshtein-distance.spec.js b/test/others/levenshtein-distance.spec.js index d0bc9ce4..705a3f90 100644 --- a/test/others/levenshtein-distance.spec.js +++ b/test/others/levenshtein-distance.spec.js @@ -4,6 +4,10 @@ var mod = require('../../src/others/levenshtein-distance.js'); var levenshteinDistance = mod.levenshteinDistance; describe('Levenstein\'s minimum edit distance algorithm', function () { + it('should be defined', function () { + expect(levenshteinDistance).toBeDefined(); + }); + it('"" -> "" should return 0.', function () { expect(levenshteinDistance('', '')).toBe(0); }); @@ -20,6 +24,10 @@ describe('Levenstein\'s minimum edit distance algorithm', function () { expect(levenshteinDistance('Sofia', 'Sof')).toBe(2); }); + it('"kitten" -> "sitting" should return 3', function () { + expect(levenshteinDistance('kitten', 'sitting')).toBe(3); + }); + it('"google" -> "lookat" should return 4.', function () { expect(levenshteinDistance('google', 'lookat')).toBe(4); }); @@ -39,4 +47,12 @@ describe('Levenstein\'s minimum edit distance algorithm', function () { it('"rosebud" -> "budrose" should return 6.', function () { expect(levenshteinDistance('rosebud', 'budrose')).toBe(6); }); + + it('"decided" -> "decisive" should return 4.', function () { + expect(levenshteinDistance('decided', 'decisive')).toBe(4); + }); + + it('"similar" -> "simile" should return 2.', function () { + expect(levenshteinDistance('similar', 'simile')).toBe(2); + }); }); From 43f6cd1e44e8f43cb02eb267a18e31c59990cb3f Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 5 Sep 2015 17:48:16 +0300 Subject: [PATCH 465/613] Update contributors list --- readme.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index a3677c77..fbe1e4b4 100644 --- a/readme.md +++ b/readme.md @@ -71,13 +71,13 @@ If the build is not successful fix your code in order the tests and jshint valid ## Contributors -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) |[infusion](https://github.com/infusion) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) |[lekkas](https://github.com/lekkas) | :---: |:---: |:---: |:---: |:---: |:---: | -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) |[infusion](https://github.com/infusion) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) |[lekkas](https://github.com/lekkas) | -[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) |[ysharplanguage](https://github.com/ysharplanguage) |[lekkas](https://github.com/lekkas) |[fanixk](https://github.com/fanixk) | -:---: |:---: |:---: |:---: |:---: | -[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) |[ysharplanguage](https://github.com/ysharplanguage) |[lekkas](https://github.com/lekkas) |[fanixk](https://github.com/fanixk) | +[deniskyashif](https://github.com/deniskyashif) |[infusion](https://github.com/infusion) |[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) |[ysharplanguage](https://github.com/ysharplanguage) |[fanixk](https://github.com/fanixk) | +:---: |:---: |:---: |:---: |:---: |:---: | +[deniskyashif](https://github.com/deniskyashif) |[infusion](https://github.com/infusion) |[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) |[ysharplanguage](https://github.com/ysharplanguage) |[fanixk](https://github.com/fanixk) | ## License From d2f065ac97bf47b11eb0542375795c2a0f26de93 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 23 Sep 2015 02:16:48 +0800 Subject: [PATCH 466/613] Add size-balanced-tree.js now. --- src/data-structures/size-balanced-tree.js | 284 ++++++++++++++++++++++ 1 file changed, 284 insertions(+) create mode 100644 src/data-structures/size-balanced-tree.js diff --git a/src/data-structures/size-balanced-tree.js b/src/data-structures/size-balanced-tree.js new file mode 100644 index 00000000..36d473cc --- /dev/null +++ b/src/data-structures/size-balanced-tree.js @@ -0,0 +1,284 @@ +/** + * Size balanced tree is a data structure which is + * a type of self-balancing binary search tree that use + * the tree size attribute for re-balancing the tree. + * + * @example + * + * var SBTree = require('../src/data-structures/size-balanced-tree').SBTree; + * var sbTree = new SBTree(); + * + * var treeNode = sbTree.push({ + * name: 'John', + * surname: 'Smith' + * }); + * sbTree.insert(0, { + * name: 'Pavlo', + * surname: 'Popov' + * }); + * sbTree.insert(1, { + * name: 'Garry', + * surname: 'Fisher' + * }); + * sbTree.insert(0, { + * name: 'Derek', + * surname: 'Anderson' + * }); + * + * console.log(sbTree.get(0)); // { name: 'Derek', surname: 'Anderson' } + * + * @module data-structures/size-balanced-tree + */ +(function (exports) { + + 'use strict'; + + var Nil = { + parent: Nil, + left: Nil, + right: Nil, + size: 0, + }; + + exports.Nil = Nil; + + /** + * Node of the Size-Balanced tree. + * + * @private + * @constructor + * @param {Object} value Value assigned to the node. + * @param {Node} parent Parent node. + * @param {Node} left Left node. + * @param {Node} right Right node. + * @param {Number} size Node's, means the Node count of this subtree. + */ + function Node(value, parent, left, right, size) { + this.value = value; + this.parent = parent; + this.left = left; + this.right = right; + this.size = size; + } + + /** + * Update node's size. + * + * @private + * @method + */ + Node.prototype.updateSize = function () { + this.size = this.left.size + this.right.size + 1; + }; + + exports.Node = Node; + + function updateChild(node, newChild) { + let parent = node.parent; + if (parent !== Nil) { + if (parent.right === node) { + parent.right = newChild; + newChild.parent = parent; + } else { + parent.left = newChild; + newChild.parent = parent; + } + return parent; + } + return newChild; + } + + function LeftRotate(node, childNode) { + /* + Before rotate: + node + / \ + NL childNode + / \ + CL CR + After rotate: + + childNode + / \ + node CR + / \ + NL CL + */ + node.right = childNode.left; + node.right.parent = node; + childNode.left = node; + childNode.left.parent = childNode; + updateChild(node, childNode) + node.updateSize(); + return childNode; + } + + function RightRotate(node, childNode) { + /* + Before rotate: + node + / \ + childNode NR + / \ + CL CR + After rotate: + + childNode + / \ + CL node + / \ + CR NR + */ + node.left = childNode.right; + node.left.parent = node; + childNode.right = node; + childNode.right.parent = childNode; + updateChild(node, childNode) + node.updateSize(); + return childNode; + } + + function maintainSizeBalancedTree(node) { + while (node.parent !== Nil) { + let childNode = node; + node = node.parent; + if (node.right === childNode) { + if (childNode.right.size > node.left.size) { + node = LeftRotate(node, childNode); + } + } else { + if (childNode.left.size > node.right.size) { + node = RightRotate(node, childNode); + } + } + node.updateSize(); + } + return node; + } + + function findRightMost = function(node) { + while (node.right !== Nil) { + node = node.right; + } + return node; + } + + function findNodeAtPos = function(node, pos) { + while (pos != node.left.size) { + if (pos < node.left.size) { + node = node.left; + } else { + pos -= node.left.size; + node = node.right; + } + } + return node; + } + + /** + * Red-Black Tree. + * + * @public + * @constructor + */ + exports.SBTree = function () { + this._root = Nil; + }; + + /** + * Push a value to the end of tree.

+ * Complexity: O(log N). + * + * @public + * @method + * @param {Object} value Value. + */ + exports.SBTree.prototype.push = function (value) { + let node = findRightMost(this._root); + let newNode = new Node(value, node, Nil, Nil, 1); + if (node !== Nil) node.right = newNode; + this._root = maintainSizeBalancedTree(newNode); + return newNode; + }; + + exports.SBTree.prototype.get = function(pos) { + if (pos >= this._root.size) { + return Nil; + } + return findNodeAtPos(this._root, pos); + }, + + exports.SBTree.prototype.insert = function(pos, value) { + if (pos >= this._root.size) { + return this.push(value) + } + let node = findNodeAtPos(this._root, pos); + let newNode + if (node.left === Nil) { + newNode = new Node(value, node, Nil, Nil, 1); + node.left = newNode; + } else { + node = findRightMost(node); + newNode = new Node(value, node, Nil, Nil, 1); + node.right = newNode; + } + this._root = maintainSizeBalancedTree(newNode); + return newNode; + }; + + exports.SBTree.prototype.remove = function(pos) { + if (pos >= this._root.size) { + return Nil; // There is no element to remove + } + let node = findNodeAtPos(this._root, pos); + let removedNode = node; + let maintainNode; + if (node.right === Nil) { + maintainNode = updateChild(node, node.left) + } else if (node.left === Nil) { + maintainNode = updateChild(node, node.right) + } else { + /* + Before remove: + P(node's parent, be notices, N either be left child or right child of P) + | + N(node) + / \ + L R + \ + \ + LRM(Left-Rightmost) + \ + Nil + After remove node N: + P(node's parent) + / + L + \ + \ + LRM(Left-Rightmost) + \ + R + + N(node) is wild node that was removed + + */ + let LRM = findRightMost(node.left); + updateChild(node, node.left) + LRM.right = node.right + LRM.right.parent = LRM; + maintainNode = LRM; + } + if (maintainNode !== Nil) { + maintainNode.updateSize(); + } + + this._root = maintainSizeBalancedTree(maintainNode); + return removedNode; + }; + + exports.SBTree.prototype.size = function() { + return this._root.size; + } + +})(typeof window === 'undefined' ? module.exports : window); From fe9fd72706f25fc662898cf520e89a03bb8610b8 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 23 Sep 2015 02:27:26 +0800 Subject: [PATCH 467/613] Getting the maintainNode to be the leaf-most node, so that the updateSize would always be right and the rotate always working. --- src/data-structures/size-balanced-tree.js | 26 ++++++++++------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/data-structures/size-balanced-tree.js b/src/data-structures/size-balanced-tree.js index 36d473cc..1e1574c6 100644 --- a/src/data-structures/size-balanced-tree.js +++ b/src/data-structures/size-balanced-tree.js @@ -75,17 +75,17 @@ function updateChild(node, newChild) { let parent = node.parent; - if (parent !== Nil) { - if (parent.right === node) { - parent.right = newChild; - newChild.parent = parent; - } else { - parent.left = newChild; - newChild.parent = parent; - } - return parent; + if (parent.right === node) { + parent.right = newChild; + newChild.parent = parent; + } else if (parent.left === node) { + parent.left = newChild; + newChild.parent = parent; + } + if (newChild !== Nil) { + return newChild; } - return newChild; + return parent; } function LeftRotate(node, childNode) { @@ -267,12 +267,8 @@ updateChild(node, node.left) LRM.right = node.right LRM.right.parent = LRM; - maintainNode = LRM; + maintainNode = node.right; } - if (maintainNode !== Nil) { - maintainNode.updateSize(); - } - this._root = maintainSizeBalancedTree(maintainNode); return removedNode; }; From 46f29d48e45f0b21f043249246b4e395370d4e11 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 23 Sep 2015 03:45:57 +0800 Subject: [PATCH 468/613] Fixes updateChild and the usage of updateChild --- src/data-structures/size-balanced-tree.js | 50 ++++++----- .../size-balanced-tree.spec.js | 85 +++++++++++++++++++ 2 files changed, 113 insertions(+), 22 deletions(-) create mode 100644 test/data-structures/size-balanced-tree.spec.js diff --git a/src/data-structures/size-balanced-tree.js b/src/data-structures/size-balanced-tree.js index 1e1574c6..0381a820 100644 --- a/src/data-structures/size-balanced-tree.js +++ b/src/data-structures/size-balanced-tree.js @@ -33,14 +33,7 @@ 'use strict'; - var Nil = { - parent: Nil, - left: Nil, - right: Nil, - size: 0, - }; - exports.Nil = Nil; /** * Node of the Size-Balanced tree. @@ -72,21 +65,30 @@ }; exports.Node = Node; + var Nil = new Node(null, null, null, null, 0); + Nil.parent = Nil; + Nil.left = Nil; + Nil.right = Nil; + exports.Nil = Nil; function updateChild(node, newChild) { let parent = node.parent; + if (parent === Nil) { + newChild.parent = parent; + return newChild; + } if (parent.right === node) { parent.right = newChild; - newChild.parent = parent; - } else if (parent.left === node) { + } else { parent.left = newChild; - newChild.parent = parent; } - if (newChild !== Nil) { - return newChild; + if (newChild === Nil) { + return parent; } - return parent; + newChild.parent = parent; + return newChild; } + exports.updateChild = updateChild; function LeftRotate(node, childNode) { /* @@ -107,8 +109,8 @@ node.right = childNode.left; node.right.parent = node; childNode.left = node; - childNode.left.parent = childNode; - updateChild(node, childNode) + updateChild(node, childNode) //Access node.parent + node.parent = childNode; node.updateSize(); return childNode; } @@ -132,8 +134,8 @@ node.left = childNode.right; node.left.parent = node; childNode.right = node; - childNode.right.parent = childNode; - updateChild(node, childNode) + updateChild(node, childNode) //Access node.parent + node.parent = childNode; node.updateSize(); return childNode; } @@ -156,14 +158,14 @@ return node; } - function findRightMost = function(node) { + function findRightMost(node) { while (node.right !== Nil) { node = node.right; } return node; } - function findNodeAtPos = function(node, pos) { + function findNodeAtPos(node, pos) { while (pos != node.left.size) { if (pos < node.left.size) { node = node.left; @@ -185,6 +187,13 @@ this._root = Nil; }; + + exports.SBTree.prototype = { + get size() { + return this._root.size; + }, + } + /** * Push a value to the end of tree.

* Complexity: O(log N). @@ -273,8 +282,5 @@ return removedNode; }; - exports.SBTree.prototype.size = function() { - return this._root.size; - } })(typeof window === 'undefined' ? module.exports : window); diff --git a/test/data-structures/size-balanced-tree.spec.js b/test/data-structures/size-balanced-tree.spec.js new file mode 100644 index 00000000..f98a3041 --- /dev/null +++ b/test/data-structures/size-balanced-tree.spec.js @@ -0,0 +1,85 @@ +'use strict'; + +var mod = require('../../src/data-structures/size-balanced-tree.js'); +var Node = mod.Node; +var Nil = mod.Nil; +var SBTree = mod.SBTree; +var updateChild = mod.updateChild; + +describe('Node', function () { + it('should be a constructor function', function () { + expect(typeof Node).toBe('function'); + }); + it('should be a construct properly', function () { + var node = new Node(10, Nil, Nil, Nil, 1); + expect(node.value).toBe(10); + expect(node.left).toBe(Nil); + expect(node.right).toBe(Nil); + expect(node.parent).toBe(Nil); + expect(node.size).toBe(1); + }); + it('should reference children/parent properly', function () { + var root = new Node(10, Nil, Nil, Nil, 1); + var left = new Node(5, root, Nil, Nil, 1); + var right = new Node(15, root, Nil, Nil, 1); + root.left = left; + root.right = right; + expect(root.value).toBe(10); + expect(root.left).toBe(left); + expect(root.right).toBe(right); + expect(root.parent).toBe(Nil); + expect(right.parent).toBe(root); + expect(left.parent).toBe(root); + expect(right.size).toBe(1); + expect(left.size).toBe(1); + expect(root.size).toBe(1); + root.updateSize(); + expect(root.size).toBe(3); + }); +}); + +describe('SBTree', function () { + it('should be a constructor function', function () { + expect(typeof SBTree).toBe('function'); + }); + it('should start with null root', function () { + expect(new SBTree()._root).toBe(Nil); + }); + it('should insert and remove correctly', function () { + var sTree = new SBTree(); + expect(sTree.size).toBe(0); + sTree.insert(0, 10); + expect(sTree.size).toBe(1); + sTree.remove(0); + expect(sTree.size).toBe(0); + expect(sTree._root).toBe(Nil); + }); + + function checkNil() { + expect(Nil.size).toBe(0); + expect(Nil.left).toBe(Nil); + expect(Nil.right).toBe(Nil); + expect(Nil.parent).toBe(Nil); + expect(Nil.value).toBe(null); + } + it('test updateChild', function() { + var e = updateChild(Nil, Nil); + checkNil(); + expect(e).toBe(Nil); + var root = new Node(10, Nil, Nil, Nil, 1); + var left = new Node(5, root, Nil, Nil, 1); + var right = new Node(15, root, Nil, Nil, 1); + var leftLeft = new Node(10, left, Nil, Nil, 1); + left.left = leftLeft; + root.left = left; + root.right = right; + updateChild(left, leftLeft); + expect(leftLeft.parent).toBe(root); + expect(root.left).toBe(leftLeft); + updateChild(leftLeft, Nil); + checkNil(); + expect(root.left).toBe(Nil); + updateChild(Nil, right); + expect(right.parent).toBe(Nil); + }); +}); From 19a12da558cf6dc7af8e30c29c20b0ec5ff33515 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 23 Sep 2015 04:03:48 +0800 Subject: [PATCH 469/613] Fixes of the Nil pointer problem, testing push 10000 elements at the end and get the 10000 elements and check it. --- src/data-structures/size-balanced-tree.js | 5 +++-- test/data-structures/size-balanced-tree.spec.js | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/data-structures/size-balanced-tree.js b/src/data-structures/size-balanced-tree.js index 0381a820..1f5d9882 100644 --- a/src/data-structures/size-balanced-tree.js +++ b/src/data-structures/size-balanced-tree.js @@ -107,7 +107,7 @@ NL CL */ node.right = childNode.left; - node.right.parent = node; + if (node.right !== Nil) node.right.parent = node; childNode.left = node; updateChild(node, childNode) //Access node.parent node.parent = childNode; @@ -132,7 +132,7 @@ CR NR */ node.left = childNode.right; - node.left.parent = node; + if (node.left !== Nil) node.left.parent = node; childNode.right = node; updateChild(node, childNode) //Access node.parent node.parent = childNode; @@ -171,6 +171,7 @@ node = node.left; } else { pos -= node.left.size; + --pos; //The node element should be decrement by 1 node = node.right; } } diff --git a/test/data-structures/size-balanced-tree.spec.js b/test/data-structures/size-balanced-tree.spec.js index f98a3041..91d29c51 100644 --- a/test/data-structures/size-balanced-tree.spec.js +++ b/test/data-structures/size-balanced-tree.spec.js @@ -81,5 +81,17 @@ describe('SBTree', function () { expect(root.left).toBe(Nil); updateChild(Nil, right); expect(right.parent).toBe(Nil); + checkNil(); + }); + + it('push and get 100000 elements', function () { + var sTree = new SBTree(); + for (var i = 0; i < 100000; ++i) { + sTree.push(i); + } + checkNil(); + for (var i = 0; i < 100000; ++i) { + expect(sTree.get(i).value).toBe(i); + } }); }); From b201487a00b7db5e87ed150e1c49eb4e1cf82a91 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 23 Sep 2015 04:28:04 +0800 Subject: [PATCH 470/613] Fixes updateChild with updateSize when the newChild is Nil and the parent is not Nil. --- src/data-structures/size-balanced-tree.js | 3 ++- .../size-balanced-tree.spec.js | 24 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/data-structures/size-balanced-tree.js b/src/data-structures/size-balanced-tree.js index 1f5d9882..d47708c1 100644 --- a/src/data-structures/size-balanced-tree.js +++ b/src/data-structures/size-balanced-tree.js @@ -83,6 +83,7 @@ parent.left = newChild; } if (newChild === Nil) { + parent.updateSize(); return parent; } newChild.parent = parent; @@ -277,7 +278,7 @@ updateChild(node, node.left) LRM.right = node.right LRM.right.parent = LRM; - maintainNode = node.right; + maintainNode = LRM.right; } this._root = maintainSizeBalancedTree(maintainNode); return removedNode; diff --git a/test/data-structures/size-balanced-tree.spec.js b/test/data-structures/size-balanced-tree.spec.js index 91d29c51..f17f7d62 100644 --- a/test/data-structures/size-balanced-tree.spec.js +++ b/test/data-structures/size-balanced-tree.spec.js @@ -71,20 +71,25 @@ describe('SBTree', function () { var right = new Node(15, root, Nil, Nil, 1); var leftLeft = new Node(10, left, Nil, Nil, 1); left.left = leftLeft; + left.updateSize(); root.left = left; root.right = right; + root.updateSize(); + expect(root.size).toBe(4); + updateChild(left, leftLeft); expect(leftLeft.parent).toBe(root); expect(root.left).toBe(leftLeft); updateChild(leftLeft, Nil); checkNil(); expect(root.left).toBe(Nil); + expect(root.size).toBe(2); updateChild(Nil, right); expect(right.parent).toBe(Nil); checkNil(); }); - it('push and get 100000 elements', function () { + it('push and get 100000 elements, remove the array by always remove the first/last element', function () { var sTree = new SBTree(); for (var i = 0; i < 100000; ++i) { sTree.push(i); @@ -93,5 +98,22 @@ describe('SBTree', function () { for (var i = 0; i < 100000; ++i) { expect(sTree.get(i).value).toBe(i); } + for (var i = 0; i < 100000; ++i) { + expect(sTree.get(0).value).toBe(i); + var node = sTree.remove(0); // Always remove the first element; + expect(node.value).toBe(i); + } + checkNil(); + expect(sTree._root).toBe(Nil); + var count = 10000; + for (var i = 0; i < count; ++i) { + sTree.push(i); + } + for (var i = 0; i < count; ++i) { + var node = sTree.remove(count - i - 1); // Always remove the last element; + expect(node.value).toBe(count - i - 1); + expect(sTree.size).toBe(count - i - 1); + } + checkNil(); }); }); From 62700e15dcd123f4a2f7baa868836c5a9b96022a Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 23 Sep 2015 04:48:13 +0800 Subject: [PATCH 471/613] Testing insert properly. --- test/data-structures/size-balanced-tree.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/data-structures/size-balanced-tree.spec.js b/test/data-structures/size-balanced-tree.spec.js index f17f7d62..a8736175 100644 --- a/test/data-structures/size-balanced-tree.spec.js +++ b/test/data-structures/size-balanced-tree.spec.js @@ -107,11 +107,11 @@ describe('SBTree', function () { expect(sTree._root).toBe(Nil); var count = 10000; for (var i = 0; i < count; ++i) { - sTree.push(i); + sTree.insert(0, i); } for (var i = 0; i < count; ++i) { var node = sTree.remove(count - i - 1); // Always remove the last element; - expect(node.value).toBe(count - i - 1); + expect(node.value).toBe(i); expect(sTree.size).toBe(count - i - 1); } checkNil(); From 9832fb6af2bbafe3acae5dc342e799efb4f97896 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 23 Sep 2015 10:41:49 +0800 Subject: [PATCH 472/613] Checking the maxHeight properly. --- src/data-structures/size-balanced-tree.js | 2 ++ test/data-structures/size-balanced-tree.spec.js | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/data-structures/size-balanced-tree.js b/src/data-structures/size-balanced-tree.js index d47708c1..9390c6e1 100644 --- a/src/data-structures/size-balanced-tree.js +++ b/src/data-structures/size-balanced-tree.js @@ -52,6 +52,7 @@ this.left = left; this.right = right; this.size = size; + this.height = 0; } /** @@ -62,6 +63,7 @@ */ Node.prototype.updateSize = function () { this.size = this.left.size + this.right.size + 1; + this.height = Math.max(this.left.height, this.right.height) + 1; }; exports.Node = Node; diff --git a/test/data-structures/size-balanced-tree.spec.js b/test/data-structures/size-balanced-tree.spec.js index a8736175..3ca3b295 100644 --- a/test/data-structures/size-balanced-tree.spec.js +++ b/test/data-structures/size-balanced-tree.spec.js @@ -91,14 +91,18 @@ describe('SBTree', function () { it('push and get 100000 elements, remove the array by always remove the first/last element', function () { var sTree = new SBTree(); - for (var i = 0; i < 100000; ++i) { + for (var i = 0; i < 2000000; ++i) { sTree.push(i); } checkNil(); - for (var i = 0; i < 100000; ++i) { - expect(sTree.get(i).value).toBe(i); + let maxHeight = 0; + for (var i = 0; i < 2000000; ++i) { + var node = sTree.get(i); + maxHeight = Math.max(maxHeight, node.height); + expect(node.value).toBe(i); } - for (var i = 0; i < 100000; ++i) { + expect(maxHeight).toBe(21); + for (var i = 0; i < 2000000; ++i) { expect(sTree.get(0).value).toBe(i); var node = sTree.remove(0); // Always remove the first element; expect(node.value).toBe(i); From aa997d38608bcdbe156f346a81d20128859c40f9 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 23 Sep 2015 11:12:53 +0800 Subject: [PATCH 473/613] Testing random insert properly. --- src/data-structures/size-balanced-tree.js | 2 +- .../size-balanced-tree.spec.js | 38 ++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/data-structures/size-balanced-tree.js b/src/data-structures/size-balanced-tree.js index 9390c6e1..974ec793 100644 --- a/src/data-structures/size-balanced-tree.js +++ b/src/data-structures/size-balanced-tree.js @@ -231,7 +231,7 @@ newNode = new Node(value, node, Nil, Nil, 1); node.left = newNode; } else { - node = findRightMost(node); + node = findRightMost(node.left); newNode = new Node(value, node, Nil, Nil, 1); node.right = newNode; } diff --git a/test/data-structures/size-balanced-tree.spec.js b/test/data-structures/size-balanced-tree.spec.js index 3ca3b295..a04f8ddb 100644 --- a/test/data-structures/size-balanced-tree.spec.js +++ b/test/data-structures/size-balanced-tree.spec.js @@ -88,6 +88,16 @@ describe('SBTree', function () { expect(right.parent).toBe(Nil); checkNil(); }); + // Returns a random integer between min (included) and max (excluded) + // Using Math.round() will give you a non-uniform distribution! + function getRandomInt(min, max) { + return Math.floor(Math.random() * (max - min)) + min; + } + // Returns a random integer between min (included) and max (included) + // Using Math.round() will give you a non-uniform distribution! + function getRandomIntInclusive(min, max) { + return Math.floor(Math.random() * (max - min + 1)) + min; + } it('push and get 100000 elements, remove the array by always remove the first/last element', function () { var sTree = new SBTree(); @@ -95,7 +105,7 @@ describe('SBTree', function () { sTree.push(i); } checkNil(); - let maxHeight = 0; + var maxHeight = 0; for (var i = 0; i < 2000000; ++i) { var node = sTree.get(i); maxHeight = Math.max(maxHeight, node.height); @@ -119,5 +129,31 @@ describe('SBTree', function () { expect(sTree.size).toBe(count - i - 1); } checkNil(); + var expectedArray = []; + for (var i = 0; i < 10000; ++i) { + var isAdded = sTree.size === 0; + if (!isAdded) { + isAdded = getRandomIntInclusive(0, 3) < 3; + } + if (isAdded) { + var newPos = getRandomIntInclusive(0, sTree.size); + sTree.insert(newPos, i); + expectedArray.splice(newPos, 0, i); + } else { + var removedPos = getRandomInt(0, sTree.size); + // sTree.remove(removedPos); + //expectedArray.splice(removedPos, 1); + } + } + expect(sTree.size).toBe(expectedArray.length); + maxHeight = 0; + for (var i = 0; i < sTree.size; ++i) { + var node = sTree.get(i); + maxHeight = Math.max(maxHeight, node.height); + expect(node.value).toBe(expectedArray[i]); + //console.log(node.value, expectedArray[i]); + } + console.log(maxHeight); + checkNil(); }); }); From 61807b01f7e485202129ad975a2926629ac1b80d Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 23 Sep 2015 11:19:32 +0800 Subject: [PATCH 474/613] Testing random remove properly. --- .../size-balanced-tree.spec.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/test/data-structures/size-balanced-tree.spec.js b/test/data-structures/size-balanced-tree.spec.js index a04f8ddb..d4096c89 100644 --- a/test/data-structures/size-balanced-tree.spec.js +++ b/test/data-structures/size-balanced-tree.spec.js @@ -130,20 +130,10 @@ describe('SBTree', function () { } checkNil(); var expectedArray = []; - for (var i = 0; i < 10000; ++i) { - var isAdded = sTree.size === 0; - if (!isAdded) { - isAdded = getRandomIntInclusive(0, 3) < 3; - } - if (isAdded) { - var newPos = getRandomIntInclusive(0, sTree.size); - sTree.insert(newPos, i); - expectedArray.splice(newPos, 0, i); - } else { - var removedPos = getRandomInt(0, sTree.size); - // sTree.remove(removedPos); - //expectedArray.splice(removedPos, 1); - } + for (var i = 0; i < 100000; ++i) { + var newPos = getRandomIntInclusive(0, sTree.size); + sTree.insert(newPos, i); + expectedArray.splice(newPos, 0, i); } expect(sTree.size).toBe(expectedArray.length); maxHeight = 0; @@ -151,7 +141,17 @@ describe('SBTree', function () { var node = sTree.get(i); maxHeight = Math.max(maxHeight, node.height); expect(node.value).toBe(expectedArray[i]); - //console.log(node.value, expectedArray[i]); + } + console.log(maxHeight); + for (var i = 0; i < 50000; ++i) { + var removedPos = getRandomInt(0, sTree.size); + sTree.remove(removedPos); + expectedArray.splice(removedPos, 1); + } + for (var i = 0; i < sTree.size; ++i) { + var node = sTree.get(i); + maxHeight = Math.max(maxHeight, node.height); + expect(node.value).toBe(expectedArray[i]); } console.log(maxHeight); checkNil(); From 160fdef9e61edb5597d9954602f40b7b4aafdbe9 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 23 Sep 2015 11:54:02 +0800 Subject: [PATCH 475/613] Using standard maintain, and the delete operation have problems. --- src/data-structures/size-balanced-tree.js | 42 +++++++++++++++---- .../size-balanced-tree.spec.js | 2 +- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/data-structures/size-balanced-tree.js b/src/data-structures/size-balanced-tree.js index 974ec793..e05beff4 100644 --- a/src/data-structures/size-balanced-tree.js +++ b/src/data-structures/size-balanced-tree.js @@ -143,20 +143,46 @@ return childNode; } + function maintain(node, leftChild) { + if (node === Nil) { + return node; + } + var savedNode = node; + if (leftChild) { + if (node.left.left.size > node.right.size) { + node = RightRotate(node, node.left); + } else if (node.left.right.size > node.right.size) { + LeftRotate(node.left, node.left.right); + node = RightRotate(node, node.left); + } + } else { + if (node.right.right.size > node.left.size) { + node = LeftRotate(node, node.right); + } else if (node.right.left.size > node.left.size) { + RightRotate(node.right, node.right.left); + node = LeftRotate(node, node.right); + } + } + node.updateSize(); + if (node === savedNode) { + return node; + } + maintain(node.left, false); + maintain(node.right, true); + node = maintain(node, true); + node = maintain(node, false); + return node; + } + function maintainSizeBalancedTree(node) { while (node.parent !== Nil) { let childNode = node; node = node.parent; - if (node.right === childNode) { - if (childNode.right.size > node.left.size) { - node = LeftRotate(node, childNode); - } + if (node.left == childNode) { + node = maintain(node, true); } else { - if (childNode.left.size > node.right.size) { - node = RightRotate(node, childNode); - } + node = maintain(node, false); } - node.updateSize(); } return node; } diff --git a/test/data-structures/size-balanced-tree.spec.js b/test/data-structures/size-balanced-tree.spec.js index d4096c89..17663741 100644 --- a/test/data-structures/size-balanced-tree.spec.js +++ b/test/data-structures/size-balanced-tree.spec.js @@ -143,7 +143,7 @@ describe('SBTree', function () { expect(node.value).toBe(expectedArray[i]); } console.log(maxHeight); - for (var i = 0; i < 50000; ++i) { + for (var i = 0; i < 90000; ++i) { var removedPos = getRandomInt(0, sTree.size); sTree.remove(removedPos); expectedArray.splice(removedPos, 1); From 628cc1195402c9c9ecf752fcb594c2a390425db2 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 23 Sep 2015 12:22:59 +0800 Subject: [PATCH 476/613] Do not check return of updateChild --- test/data-structures/size-balanced-tree.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/data-structures/size-balanced-tree.spec.js b/test/data-structures/size-balanced-tree.spec.js index 17663741..7e75daa2 100644 --- a/test/data-structures/size-balanced-tree.spec.js +++ b/test/data-structures/size-balanced-tree.spec.js @@ -63,9 +63,8 @@ describe('SBTree', function () { expect(Nil.value).toBe(null); } it('test updateChild', function() { - var e = updateChild(Nil, Nil); + updateChild(Nil, Nil); checkNil(); - expect(e).toBe(Nil); var root = new Node(10, Nil, Nil, Nil, 1); var left = new Node(5, root, Nil, Nil, 1); var right = new Node(15, root, Nil, Nil, 1); From 0079d4d8f7eb191c9bdcf4dea627b81c91af280e Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 23 Sep 2015 12:24:13 +0800 Subject: [PATCH 477/613] Consistence the delete operation. --- src/data-structures/size-balanced-tree.js | 100 +++++++++++++--------- 1 file changed, 58 insertions(+), 42 deletions(-) diff --git a/src/data-structures/size-balanced-tree.js b/src/data-structures/size-balanced-tree.js index e05beff4..e59d0666 100644 --- a/src/data-structures/size-balanced-tree.js +++ b/src/data-structures/size-balanced-tree.js @@ -75,21 +75,17 @@ function updateChild(node, newChild) { let parent = node.parent; - if (parent === Nil) { - newChild.parent = parent; - return newChild; - } - if (parent.right === node) { - parent.right = newChild; - } else { - parent.left = newChild; - } - if (newChild === Nil) { + if (parent !== Nil) { + if (parent.right === node) { + parent.right = newChild; + } else { + parent.left = newChild; + } parent.updateSize(); - return parent; } - newChild.parent = parent; - return newChild; + if (newChild !== Nil) { + newChild.parent = parent; + } } exports.updateChild = updateChild; @@ -194,6 +190,13 @@ return node; } + function findLeftMost(node) { + while (node.left !== Nil) { + node = node.left; + } + return node; + } + function findNodeAtPos(node, pos) { while (pos != node.left.size) { if (pos < node.left.size) { @@ -270,46 +273,59 @@ return Nil; // There is no element to remove } let node = findNodeAtPos(this._root, pos); - let removedNode = node; let maintainNode; - if (node.right === Nil) { - maintainNode = updateChild(node, node.left) - } else if (node.left === Nil) { - maintainNode = updateChild(node, node.right) - } else { - /* - Before remove: - P(node's parent, be notices, N either be left child or right child of P) - | - N(node) - / \ - L R + + /* + Before remove: + P(node's parent, be notices, N either be left child or right child of P) + | + N(node) + / \ + L R + \ + \ + LRM(Left-Rightmost) + \ + Nil + After remove node N: + P(node's parent) + / + L \ \ LRM(Left-Rightmost) \ - Nil - After remove node N: - P(node's parent) - / - L - \ - \ - LRM(Left-Rightmost) - \ - R + R - N(node) is wild node that was removed - - */ + N(node) is wild node that was removed + + */ + if (node.left !== Nil){ let LRM = findRightMost(node.left); updateChild(node, node.left) LRM.right = node.right - LRM.right.parent = LRM; - maintainNode = LRM.right; + if (LRM.right === Nil) { + maintainNode = LRM; + } else { + LRM.right.parent = LRM; + maintainNode = LRM.right; + } + } else if (node.right !== Nil) { + let RLM = findLeftMost(node.right); + updateChild(node, node.right) + RLM.left = node.left + if (RLM.left === Nil) { + maintainNode = RLM; + } else { + RLM.left.parent = RLM; + maintainNode = RLM.left; + } + } else { + updateChild(node, Nil) + maintainNode = node.parent; } this._root = maintainSizeBalancedTree(maintainNode); - return removedNode; + return node; }; From 819d6f9d6730a3d90f70a415eaea8ae5e5b15a17 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Thu, 24 Sep 2015 01:04:19 +0800 Subject: [PATCH 478/613] No need the maxHeight --- test/data-structures/size-balanced-tree.spec.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/test/data-structures/size-balanced-tree.spec.js b/test/data-structures/size-balanced-tree.spec.js index 7e75daa2..34fcf733 100644 --- a/test/data-structures/size-balanced-tree.spec.js +++ b/test/data-structures/size-balanced-tree.spec.js @@ -104,13 +104,11 @@ describe('SBTree', function () { sTree.push(i); } checkNil(); - var maxHeight = 0; for (var i = 0; i < 2000000; ++i) { var node = sTree.get(i); - maxHeight = Math.max(maxHeight, node.height); expect(node.value).toBe(i); } - expect(maxHeight).toBe(21); + expect(sTree._root.height).toBe(21); for (var i = 0; i < 2000000; ++i) { expect(sTree.get(0).value).toBe(i); var node = sTree.remove(0); // Always remove the first element; @@ -135,13 +133,11 @@ describe('SBTree', function () { expectedArray.splice(newPos, 0, i); } expect(sTree.size).toBe(expectedArray.length); - maxHeight = 0; for (var i = 0; i < sTree.size; ++i) { var node = sTree.get(i); - maxHeight = Math.max(maxHeight, node.height); expect(node.value).toBe(expectedArray[i]); } - console.log(maxHeight); + console.log(sTree._root.height); for (var i = 0; i < 90000; ++i) { var removedPos = getRandomInt(0, sTree.size); sTree.remove(removedPos); @@ -149,10 +145,9 @@ describe('SBTree', function () { } for (var i = 0; i < sTree.size; ++i) { var node = sTree.get(i); - maxHeight = Math.max(maxHeight, node.height); expect(node.value).toBe(expectedArray[i]); } - console.log(maxHeight); + console.log(sTree._root.height); checkNil(); }); }); From 180ac8e0ff5ce1e122807029eb6e764e55e6fa97 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 7 Oct 2015 07:27:28 +0300 Subject: [PATCH 479/613] Update gulp-jasmine --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b85713a..ecff0768 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ }, "devDependencies": { "gulp": "^3.8.10", - "gulp-jasmine": "^1.0.1", + "gulp-jasmine": "^2.0.1", "gulp-jscs": "^1.4.0", "gulp-jshint": "^1.9.0", "gulp-shell": "^0.2.11", From de706f1a54dd8cc56e75a0c250cf44621c10e499 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 7 Oct 2015 07:31:53 +0300 Subject: [PATCH 480/613] Update recursive insertion sort --- src/sorting/recursive-insertionsort.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sorting/recursive-insertionsort.js b/src/sorting/recursive-insertionsort.js index 87c564c2..b34135c4 100644 --- a/src/sorting/recursive-insertionsort.js +++ b/src/sorting/recursive-insertionsort.js @@ -27,12 +27,12 @@ */ function recursiveInsertionSort(array, cmp, max) { cmp = cmp || compare; - if (max <= 0) { - return array; - } if (max === undefined) { max = array.length - 1; } + if (max <= 0) { + return array; + } recursiveInsertionSort(array, cmp, max - 1); for (var i = max - 1, current = array[max]; i >= 0 && cmp(current, array[i]) < 0; i -= 1) { From f9299a515dc8108d96088c8703aaf5a5718e773a Mon Sep 17 00:00:00 2001 From: Denis Savenok Date: Thu, 22 Oct 2015 16:07:48 +0400 Subject: [PATCH 481/613] array.length -> size --- src/sorting/radixsort.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sorting/radixsort.js b/src/sorting/radixsort.js index caf58cc6..4c2c4a45 100644 --- a/src/sorting/radixsort.js +++ b/src/sorting/radixsort.js @@ -68,7 +68,7 @@ } /* Count frequency of each array element */ - for (j = 0; j < array.length; j += 1) { + for (j = 0; j < size; j += 1) { digit = getDigit(array[j], i) || 0; count[digit] += 1; } @@ -80,14 +80,14 @@ /* Move elements to auxilary array */ var aux = []; - for (j = array.length - 1; j >= 0; j -= 1) { + for (j = size - 1; j >= 0; j -= 1) { digit = getDigit(array[j], i) || 0; count[digit] -= 1; aux[count[digit]] = array[j]; } /* Copy elements back from auxilary array */ - for (j = 0; j < array.length; j += 1) { + for (j = 0; j < size; j += 1) { array[j] = aux[j]; } } From 1e8f60d022885b1d41f1fc433e7d996b5f824522 Mon Sep 17 00:00:00 2001 From: Denis Savenok Date: Thu, 22 Oct 2015 16:08:49 +0400 Subject: [PATCH 482/613] auxiliary typo --- src/sorting/radixsort.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sorting/radixsort.js b/src/sorting/radixsort.js index 4c2c4a45..ef8325c4 100644 --- a/src/sorting/radixsort.js +++ b/src/sorting/radixsort.js @@ -78,7 +78,7 @@ count[j] += count[j - 1]; } - /* Move elements to auxilary array */ + /* Move elements to auxiliary array */ var aux = []; for (j = size - 1; j >= 0; j -= 1) { digit = getDigit(array[j], i) || 0; From 3c0f1d60205fec1643a1a586f3bfffeb7533415b Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Tue, 27 Oct 2015 23:29:43 +0800 Subject: [PATCH 483/613] Switch module & window. --- src/data-structures/size-balanced-tree.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data-structures/size-balanced-tree.js b/src/data-structures/size-balanced-tree.js index e59d0666..e078fd0b 100644 --- a/src/data-structures/size-balanced-tree.js +++ b/src/data-structures/size-balanced-tree.js @@ -329,4 +329,4 @@ }; -})(typeof window === 'undefined' ? module.exports : window); +})(typeof module === 'undefined' ? window : module.exports); From a4c3a4434d17604540a962e13264b5f913a35e53 Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 29 Oct 2015 14:34:12 +0200 Subject: [PATCH 484/613] Update contributors' list --- readme.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index fbe1e4b4..a26a6052 100644 --- a/readme.md +++ b/readme.md @@ -75,9 +75,13 @@ If the build is not successful fix your code in order the tests and jshint valid :---: |:---: |:---: |:---: |:---: |:---: | [mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) |[lekkas](https://github.com/lekkas) | -[deniskyashif](https://github.com/deniskyashif) |[infusion](https://github.com/infusion) |[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) |[ysharplanguage](https://github.com/ysharplanguage) |[fanixk](https://github.com/fanixk) | +[deniskyashif](https://github.com/deniskyashif) |[infusion](https://github.com/infusion) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[ysharplanguage](https://github.com/ysharplanguage) |[contra](https://github.com/contra) | :---: |:---: |:---: |:---: |:---: |:---: | -[deniskyashif](https://github.com/deniskyashif) |[infusion](https://github.com/infusion) |[Microfed](https://github.com/Microfed) |[contra](https://github.com/contra) |[ysharplanguage](https://github.com/ysharplanguage) |[fanixk](https://github.com/fanixk) | +[deniskyashif](https://github.com/deniskyashif) |[infusion](https://github.com/infusion) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[ysharplanguage](https://github.com/ysharplanguage) |[contra](https://github.com/contra) | + +[fanixk](https://github.com/fanixk) | +:---: | +[fanixk](https://github.com/fanixk) | ## License From 03f482004d2ecb1f74111092fb1f2a357b05e9d0 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Sat, 14 Nov 2015 01:31:16 +0800 Subject: [PATCH 485/613] Test index. --- src/data-structures/size-balanced-tree.js | 14 ++++++++++- .../size-balanced-tree.spec.js | 24 ++++++++++++++----- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/data-structures/size-balanced-tree.js b/src/data-structures/size-balanced-tree.js index e078fd0b..1bb55315 100644 --- a/src/data-structures/size-balanced-tree.js +++ b/src/data-structures/size-balanced-tree.js @@ -248,7 +248,19 @@ return Nil; } return findNodeAtPos(this._root, pos); - }, + }; + + exports.SBTree.prototype.getIndex = function(node) { + let index = node.left.size; + while (node != this._root) { + let parent = node.parent; + if (parent.right === node) { + index += parent.left.size + 1; + } + node = parent; + } + return index; + }; exports.SBTree.prototype.insert = function(pos, value) { if (pos >= this._root.size) { diff --git a/test/data-structures/size-balanced-tree.spec.js b/test/data-structures/size-balanced-tree.spec.js index 34fcf733..d1280bd0 100644 --- a/test/data-structures/size-balanced-tree.spec.js +++ b/test/data-structures/size-balanced-tree.spec.js @@ -100,16 +100,16 @@ describe('SBTree', function () { it('push and get 100000 elements, remove the array by always remove the first/last element', function () { var sTree = new SBTree(); - for (var i = 0; i < 2000000; ++i) { + for (var i = 0; i < 200000; ++i) { sTree.push(i); } checkNil(); - for (var i = 0; i < 2000000; ++i) { + for (var i = 0; i < 200000; ++i) { var node = sTree.get(i); expect(node.value).toBe(i); } - expect(sTree._root.height).toBe(21); - for (var i = 0; i < 2000000; ++i) { + expect(sTree._root.height).toBe(18); + for (var i = 0; i < 200000; ++i) { expect(sTree.get(0).value).toBe(i); var node = sTree.remove(0); // Always remove the first element; expect(node.value).toBe(i); @@ -137,7 +137,6 @@ describe('SBTree', function () { var node = sTree.get(i); expect(node.value).toBe(expectedArray[i]); } - console.log(sTree._root.height); for (var i = 0; i < 90000; ++i) { var removedPos = getRandomInt(0, sTree.size); sTree.remove(removedPos); @@ -147,7 +146,20 @@ describe('SBTree', function () { var node = sTree.get(i); expect(node.value).toBe(expectedArray[i]); } - console.log(sTree._root.height); checkNil(); }); + + it('test getIndex', function(){ + var sTree = new SBTree(); + for (let i = 0; i < 10000; ++i) { + let key = i.toString(); + sTree.push(key); + } + + for (let i=0; i<100; ++i) { + let item = sTree.get(i); + expect(item.value).toBe(i.toString()); + expect(sTree.getIndex(item)).toBe(i); + } + }); }); From 2854031afb64c42ff5e113b074df90a7d864825f Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Sat, 14 Nov 2015 01:32:28 +0800 Subject: [PATCH 486/613] Replace let with var --- src/data-structures/size-balanced-tree.js | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/data-structures/size-balanced-tree.js b/src/data-structures/size-balanced-tree.js index 1bb55315..e4ac88d3 100644 --- a/src/data-structures/size-balanced-tree.js +++ b/src/data-structures/size-balanced-tree.js @@ -74,7 +74,7 @@ exports.Nil = Nil; function updateChild(node, newChild) { - let parent = node.parent; + var parent = node.parent; if (parent !== Nil) { if (parent.right === node) { parent.right = newChild; @@ -172,7 +172,7 @@ function maintainSizeBalancedTree(node) { while (node.parent !== Nil) { - let childNode = node; + var childNode = node; node = node.parent; if (node.left == childNode) { node = maintain(node, true); @@ -236,8 +236,8 @@ * @param {Object} value Value. */ exports.SBTree.prototype.push = function (value) { - let node = findRightMost(this._root); - let newNode = new Node(value, node, Nil, Nil, 1); + var node = findRightMost(this._root); + var newNode = new Node(value, node, Nil, Nil, 1); if (node !== Nil) node.right = newNode; this._root = maintainSizeBalancedTree(newNode); return newNode; @@ -251,9 +251,9 @@ }; exports.SBTree.prototype.getIndex = function(node) { - let index = node.left.size; + var index = node.left.size; while (node != this._root) { - let parent = node.parent; + var parent = node.parent; if (parent.right === node) { index += parent.left.size + 1; } @@ -266,8 +266,8 @@ if (pos >= this._root.size) { return this.push(value) } - let node = findNodeAtPos(this._root, pos); - let newNode + var node = findNodeAtPos(this._root, pos); + var newNode if (node.left === Nil) { newNode = new Node(value, node, Nil, Nil, 1); node.left = newNode; @@ -284,8 +284,8 @@ if (pos >= this._root.size) { return Nil; // There is no element to remove } - let node = findNodeAtPos(this._root, pos); - let maintainNode; + var node = findNodeAtPos(this._root, pos); + var maintainNode; /* Before remove: @@ -313,7 +313,7 @@ */ if (node.left !== Nil){ - let LRM = findRightMost(node.left); + var LRM = findRightMost(node.left); updateChild(node, node.left) LRM.right = node.right if (LRM.right === Nil) { @@ -323,7 +323,7 @@ maintainNode = LRM.right; } } else if (node.right !== Nil) { - let RLM = findLeftMost(node.right); + var RLM = findLeftMost(node.right); updateChild(node, node.right) RLM.left = node.left if (RLM.left === Nil) { From d3673b0bb9e7e2e098ed99742770dbea5e81e985 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Sat, 14 Nov 2015 01:50:04 +0800 Subject: [PATCH 487/613] Pass the whole gulp build. --- src/data-structures/size-balanced-tree.js | 66 ++++++++++--------- .../size-balanced-tree.spec.js | 13 ++-- 2 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/data-structures/size-balanced-tree.js b/src/data-structures/size-balanced-tree.js index e4ac88d3..314a1ca4 100644 --- a/src/data-structures/size-balanced-tree.js +++ b/src/data-structures/size-balanced-tree.js @@ -30,11 +30,8 @@ * @module data-structures/size-balanced-tree */ (function (exports) { - 'use strict'; - - /** * Node of the Size-Balanced tree. * @@ -101,14 +98,16 @@ childNode / \ - node CR + node CR / \ NL CL */ node.right = childNode.left; - if (node.right !== Nil) node.right.parent = node; + if (node.right !== Nil) { + node.right.parent = node; + } childNode.left = node; - updateChild(node, childNode) //Access node.parent + updateChild(node, childNode); //Access node.parent node.parent = childNode; node.updateSize(); return childNode; @@ -126,14 +125,16 @@ childNode / \ - CL node + CL node / \ CR NR */ node.left = childNode.right; - if (node.left !== Nil) node.left.parent = node; + if (node.left !== Nil) { + node.left.parent = node; + } childNode.right = node; - updateChild(node, childNode) //Access node.parent + updateChild(node, childNode); //Access node.parent node.parent = childNode; node.updateSize(); return childNode; @@ -174,7 +175,7 @@ while (node.parent !== Nil) { var childNode = node; node = node.parent; - if (node.left == childNode) { + if (node.left === childNode) { node = maintain(node, true); } else { node = maintain(node, false); @@ -198,12 +199,12 @@ } function findNodeAtPos(node, pos) { - while (pos != node.left.size) { + while (pos !== node.left.size) { if (pos < node.left.size) { node = node.left; } else { pos -= node.left.size; - --pos; //The node element should be decrement by 1 + pos -= 1; //The node element should be decrement by 1 node = node.right; } } @@ -220,13 +221,12 @@ this._root = Nil; }; - exports.SBTree.prototype = { get size() { return this._root.size; }, - } - + }; + /** * Push a value to the end of tree.

* Complexity: O(log N). @@ -238,21 +238,23 @@ exports.SBTree.prototype.push = function (value) { var node = findRightMost(this._root); var newNode = new Node(value, node, Nil, Nil, 1); - if (node !== Nil) node.right = newNode; + if (node !== Nil) { + node.right = newNode; + } this._root = maintainSizeBalancedTree(newNode); return newNode; }; - exports.SBTree.prototype.get = function(pos) { + exports.SBTree.prototype.get = function (pos) { if (pos >= this._root.size) { return Nil; } return findNodeAtPos(this._root, pos); }; - exports.SBTree.prototype.getIndex = function(node) { + exports.SBTree.prototype.getIndex = function (node) { var index = node.left.size; - while (node != this._root) { + while (node !== this._root) { var parent = node.parent; if (parent.right === node) { index += parent.left.size + 1; @@ -262,12 +264,12 @@ return index; }; - exports.SBTree.prototype.insert = function(pos, value) { + exports.SBTree.prototype.insert = function (pos, value) { if (pos >= this._root.size) { - return this.push(value) + return this.push(value); } var node = findNodeAtPos(this._root, pos); - var newNode + var newNode; if (node.left === Nil) { newNode = new Node(value, node, Nil, Nil, 1); node.left = newNode; @@ -280,7 +282,7 @@ return newNode; }; - exports.SBTree.prototype.remove = function(pos) { + exports.SBTree.prototype.remove = function (pos) { if (pos >= this._root.size) { return Nil; // There is no element to remove } @@ -289,7 +291,8 @@ /* Before remove: - P(node's parent, be notices, N either be left child or right child of P) + P (node's parent, be notices, + | N either be left child or right child of P) | N(node) / \ @@ -302,7 +305,7 @@ After remove node N: P(node's parent) / - L + L \ \ LRM(Left-Rightmost) @@ -310,12 +313,12 @@ R N(node) is wild node that was removed - + */ if (node.left !== Nil){ var LRM = findRightMost(node.left); - updateChild(node, node.left) - LRM.right = node.right + updateChild(node, node.left); + LRM.right = node.right; if (LRM.right === Nil) { maintainNode = LRM; } else { @@ -324,8 +327,8 @@ } } else if (node.right !== Nil) { var RLM = findLeftMost(node.right); - updateChild(node, node.right) - RLM.left = node.left + updateChild(node, node.right); + RLM.left = node.left; if (RLM.left === Nil) { maintainNode = RLM; } else { @@ -333,12 +336,11 @@ maintainNode = RLM.left; } } else { - updateChild(node, Nil) + updateChild(node, Nil); maintainNode = node.parent; } this._root = maintainSizeBalancedTree(maintainNode); return node; }; - })(typeof module === 'undefined' ? window : module.exports); diff --git a/test/data-structures/size-balanced-tree.spec.js b/test/data-structures/size-balanced-tree.spec.js index d1280bd0..1f3f07f6 100644 --- a/test/data-structures/size-balanced-tree.spec.js +++ b/test/data-structures/size-balanced-tree.spec.js @@ -62,7 +62,8 @@ describe('SBTree', function () { expect(Nil.parent).toBe(Nil); expect(Nil.value).toBe(null); } - it('test updateChild', function() { + + it('test updateChild', function () { updateChild(Nil, Nil); checkNil(); var root = new Node(10, Nil, Nil, Nil, 1); @@ -149,15 +150,15 @@ describe('SBTree', function () { checkNil(); }); - it('test getIndex', function(){ + it('test getIndex', function () { var sTree = new SBTree(); - for (let i = 0; i < 10000; ++i) { - let key = i.toString(); + for (var i = 0; i < 10000; ++i) { + var key = i.toString(); sTree.push(key); } - for (let i=0; i<100; ++i) { - let item = sTree.get(i); + for (var i = 0; i < 100; ++i) { + var item = sTree.get(i); expect(item.value).toBe(i.toString()); expect(sTree.getIndex(item)).toBe(i); } From 521904fdb3b99ae34b432307ff51a73c4edeb59b Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 14 Nov 2015 11:10:01 +0200 Subject: [PATCH 488/613] Update node versions in travis --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 207c6cac..a9ff642d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: node_js node_js: - - "0.11" - - "0.10" + - "0.12" before_script: - npm install -g gulp script: gulp build \ No newline at end of file From 51b9215911dc5e9e90bb64733b9cebfafdcedfc6 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Sat, 14 Nov 2015 01:56:36 +0800 Subject: [PATCH 489/613] Use node 0.12 --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 207c6cac..a9ff642d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: node_js node_js: - - "0.11" - - "0.10" + - "0.12" before_script: - npm install -g gulp script: gulp build \ No newline at end of file From efeda272b54b81ea642cdd10756d7be911a4f4f0 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Tue, 5 Jan 2016 22:33:14 +0800 Subject: [PATCH 490/613] Add binarySearch function. --- src/data-structures/size-balanced-tree.js | 147 +++++++++++------- .../size-balanced-tree.spec.js | 15 ++ 2 files changed, 110 insertions(+), 52 deletions(-) diff --git a/src/data-structures/size-balanced-tree.js b/src/data-structures/size-balanced-tree.js index 314a1ca4..073fbfc0 100644 --- a/src/data-structures/size-balanced-tree.js +++ b/src/data-structures/size-balanced-tree.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Size balanced tree is a data structure which is * a type of self-balancing binary search tree that use @@ -29,47 +31,8 @@ * * @module data-structures/size-balanced-tree */ -(function (exports) { - 'use strict'; - - /** - * Node of the Size-Balanced tree. - * - * @private - * @constructor - * @param {Object} value Value assigned to the node. - * @param {Node} parent Parent node. - * @param {Node} left Left node. - * @param {Node} right Right node. - * @param {Number} size Node's, means the Node count of this subtree. - */ - function Node(value, parent, left, right, size) { - this.value = value; - this.parent = parent; - this.left = left; - this.right = right; - this.size = size; - this.height = 0; - } - - /** - * Update node's size. - * - * @private - * @method - */ - Node.prototype.updateSize = function () { - this.size = this.left.size + this.right.size + 1; - this.height = Math.max(this.left.height, this.right.height) + 1; - }; - - exports.Node = Node; - var Nil = new Node(null, null, null, null, 0); - Nil.parent = Nil; - Nil.left = Nil; - Nil.right = Nil; - exports.Nil = Nil; +function CreateSBTreeClass (Node, Nil) { function updateChild(node, newChild) { var parent = node.parent; if (parent !== Nil) { @@ -84,7 +47,6 @@ newChild.parent = parent; } } - exports.updateChild = updateChild; function LeftRotate(node, childNode) { /* @@ -212,30 +174,49 @@ } /** - * Red-Black Tree. + * Size Balanced Tree. * * @public * @constructor */ - exports.SBTree = function () { - this._root = Nil; - }; + var SBTree = function () {}; - exports.SBTree.prototype = { + SBTree.prototype = { + _root: Nil, + updateChild: updateChild, get size() { return this._root.size; }, + + get root() { + return this._root; + }, + + binarySearch: function (cmp, value) { + var left = -1; + var right = this.size; + while (left + 1 < right) { + var middle = (left + right) >> 1; // jshint ignore:line + var result = cmp(this.get(middle).value, value); + if (result <= 0) { + left = middle; + } else { + right = middle; + } + } + return left + 1; + }, }; /** - * Push a value to the end of tree.

+ * Push a value to the end of tree. * Complexity: O(log N). * * @public * @method * @param {Object} value Value. */ - exports.SBTree.prototype.push = function (value) { + SBTree.prototype.push = function (value) { var node = findRightMost(this._root); var newNode = new Node(value, node, Nil, Nil, 1); if (node !== Nil) { @@ -245,14 +226,14 @@ return newNode; }; - exports.SBTree.prototype.get = function (pos) { + SBTree.prototype.get = function (pos) { if (pos >= this._root.size) { return Nil; } return findNodeAtPos(this._root, pos); }; - exports.SBTree.prototype.getIndex = function (node) { + SBTree.prototype.getIndex = function (node) { var index = node.left.size; while (node !== this._root) { var parent = node.parent; @@ -264,7 +245,7 @@ return index; }; - exports.SBTree.prototype.insert = function (pos, value) { + SBTree.prototype.insert = function (pos, value) { if (pos >= this._root.size) { return this.push(value); } @@ -282,7 +263,7 @@ return newNode; }; - exports.SBTree.prototype.remove = function (pos) { + SBTree.prototype.remove = function (pos) { if (pos >= this._root.size) { return Nil; // There is no element to remove } @@ -343,4 +324,66 @@ return node; }; + return SBTree; +} + +(function (exports) { + + /** + * Node constructor of the Size-Balanced tree. + * + * @private + * @constructor + * @param {Object} value Value assigned to the node. + * @param {Node} parent Parent node. + * @param {Node} left Left node. + * @param {Node} right Right node. + * @param {Number} size Node's, means the Node count of this . + */ + var NodeConstructor = function (value, parent, left, right, size) { + this.value = value; + this.parent = parent; + this.left = left; + this.right = right; + this.size = size; + this.height = 0; + }; + + /** + * Update node's size. + * + * @private + * @method + */ + var updateSize = function () { + this.size = this.left.size + this.right.size + 1; + this.height = Math.max(this.left.height, this.right.height) + 1; + }; + + var createNil = function (Node, value) { + var Nil = new Node(value, null, null, null, 0); + Nil.parent = Nil; + Nil.left = Nil; + Nil.right = Nil; + return Nil; + }; + + var Node = function () { + NodeConstructor.apply(this, arguments); + }; + + Node.prototype.updateSize = updateSize; + + var Nil = createNil(Node, null); + + exports.NodeConstructor = NodeConstructor; + exports.createNil = createNil; + exports.updateSize = updateSize; + exports.CreateSBTreeClass = CreateSBTreeClass; + + exports.Node = Node; + exports.Nil = Nil; + exports.SBTree = CreateSBTreeClass(Node, Nil); + exports.updateChild = exports.SBTree.prototype.updateChild; + })(typeof module === 'undefined' ? window : module.exports); diff --git a/test/data-structures/size-balanced-tree.spec.js b/test/data-structures/size-balanced-tree.spec.js index 1f3f07f6..ac41c70f 100644 --- a/test/data-structures/size-balanced-tree.spec.js +++ b/test/data-structures/size-balanced-tree.spec.js @@ -163,4 +163,19 @@ describe('SBTree', function () { expect(sTree.getIndex(item)).toBe(i); } }); + + it('test binary search', function () { + var sTree = new SBTree(); + for (var i = 0; i < 10000; ++i) { + sTree.push(i); + } + var cmp = function (a, b) { + return a - b; + } + expect(sTree.binarySearch(cmp, 10.5)).toBe(11) + expect(sTree.binarySearch(cmp, 0)).toBe(1) + expect(sTree.binarySearch(cmp, -1)).toBe(0) + expect(sTree.binarySearch(cmp, 9999)).toBe(10000) + expect(sTree.binarySearch(cmp, 10000)).toBe(10000) + }); }); From bddeca7579f1f748d68dbbf2c43359489679c7f7 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 6 Jan 2016 16:25:48 +0800 Subject: [PATCH 491/613] Now the updateChild could be able override by external code. and along with insertLeafNode & removeLeafNode --- src/data-structures/size-balanced-tree.js | 241 ++++++++---------- .../size-balanced-tree.spec.js | 8 +- 2 files changed, 112 insertions(+), 137 deletions(-) diff --git a/src/data-structures/size-balanced-tree.js b/src/data-structures/size-balanced-tree.js index 073fbfc0..93ccd198 100644 --- a/src/data-structures/size-balanced-tree.js +++ b/src/data-structures/size-balanced-tree.js @@ -32,22 +32,7 @@ * @module data-structures/size-balanced-tree */ -function CreateSBTreeClass (Node, Nil) { - function updateChild(node, newChild) { - var parent = node.parent; - if (parent !== Nil) { - if (parent.right === node) { - parent.right = newChild; - } else { - parent.left = newChild; - } - parent.updateSize(); - } - if (newChild !== Nil) { - newChild.parent = parent; - } - } - +function CreateSBTreeClass (Node, Nil, updateChild) { function LeftRotate(node, childNode) { /* Before rotate: @@ -69,9 +54,8 @@ function CreateSBTreeClass (Node, Nil) { node.right.parent = node; } childNode.left = node; - updateChild(node, childNode); //Access node.parent - node.parent = childNode; - node.updateSize(); + // setting childNode's parent to node's parent + updateChild(node, childNode); return childNode; } @@ -96,9 +80,8 @@ function CreateSBTreeClass (Node, Nil) { node.left.parent = node; } childNode.right = node; - updateChild(node, childNode); //Access node.parent - node.parent = childNode; - node.updateSize(); + // setting childNode's parent to node's parent + updateChild(node, childNode); return childNode; } @@ -122,7 +105,6 @@ function CreateSBTreeClass (Node, Nil) { node = LeftRotate(node, node.right); } } - node.updateSize(); if (node === savedNode) { return node; } @@ -146,20 +128,6 @@ function CreateSBTreeClass (Node, Nil) { return node; } - function findRightMost(node) { - while (node.right !== Nil) { - node = node.right; - } - return node; - } - - function findLeftMost(node) { - while (node.left !== Nil) { - node = node.left; - } - return node; - } - function findNodeAtPos(node, pos) { while (pos !== node.left.size) { if (pos < node.left.size) { @@ -183,7 +151,6 @@ function CreateSBTreeClass (Node, Nil) { SBTree.prototype = { _root: Nil, - updateChild: updateChild, get size() { return this._root.size; }, @@ -208,26 +175,8 @@ function CreateSBTreeClass (Node, Nil) { }, }; - /** - * Push a value to the end of tree. - * Complexity: O(log N). - * - * @public - * @method - * @param {Object} value Value. - */ - SBTree.prototype.push = function (value) { - var node = findRightMost(this._root); - var newNode = new Node(value, node, Nil, Nil, 1); - if (node !== Nil) { - node.right = newNode; - } - this._root = maintainSizeBalancedTree(newNode); - return newNode; - }; - SBTree.prototype.get = function (pos) { - if (pos >= this._root.size) { + if (pos >= this.size) { return Nil; } return findNodeAtPos(this._root, pos); @@ -245,83 +194,97 @@ function CreateSBTreeClass (Node, Nil) { return index; }; - SBTree.prototype.insert = function (pos, value) { - if (pos >= this._root.size) { - return this.push(value); + SBTree.prototype.shiftDown = function (node) { + var direction = 0; + while (true) { + if (node.left !== Nil && node.right !== Nil) { + switch (direction) { + case 0: + RightRotate(node, node.left); + break; + case 1: + LeftRotate(node, node.right); + break; + } + direction = 1 - direction; + } else if (node.left !== Nil) { + RightRotate(node, node.left); + } else if (node.right !== Nil) { + LeftRotate(node, node.right); + } else { + break; // The node could be able to removed + } } - var node = findNodeAtPos(this._root, pos); - var newNode; - if (node.left === Nil) { - newNode = new Node(value, node, Nil, Nil, 1); - node.left = newNode; + }; + + SBTree.prototype.insertLeafNode = function (node) { + var parent = node.parent; + while (parent !== Nil) { + parent.size = parent.size + 1; + parent = parent.parent; + } + }; + + SBTree.prototype.removeLeafNode = function (node) { + var parent = node.parent; + while (parent !== Nil) { + parent.size = parent.size - 1; + parent = parent.parent; + } + }; + + SBTree.prototype.insert = function (pos, value) { + var node = Nil; + var newNode = new Node(value, Nil, Nil, Nil, 1); + if (pos === this.size) { + if (pos > 0) { + node = findNodeAtPos(this._root, pos - 1); + node.right = newNode; + } } else { - node = findRightMost(node.left); - newNode = new Node(value, node, Nil, Nil, 1); - node.right = newNode; + node = findNodeAtPos(this._root, pos); + if (node.left !== Nil) { + this.shiftDown(node); + } + node.left = newNode; } + newNode.parent = node; + this.insertLeafNode(newNode); this._root = maintainSizeBalancedTree(newNode); return newNode; }; + /** + * Push a value to the end of tree. + * Complexity: O(log N). + * + * @public + * @method + * @param {Object} value Value. + */ + SBTree.prototype.push = function (value) { + this.insert(this.size, value); + }; + + SBTree.prototype.removeNode = function (node) { + this.shiftDown(node); + var maintainNode = node.parent; + if (maintainNode.left === node) { + maintainNode.left = Nil; + } else if (maintainNode.right === node) { + maintainNode.right = Nil; + } + this.removeLeafNode(node); + this._root = maintainSizeBalancedTree(maintainNode); + return node; + }; + SBTree.prototype.remove = function (pos) { if (pos >= this._root.size) { return Nil; // There is no element to remove } var node = findNodeAtPos(this._root, pos); - var maintainNode; - - /* - Before remove: - P (node's parent, be notices, - | N either be left child or right child of P) - | - N(node) - / \ - L R - \ - \ - LRM(Left-Rightmost) - \ - Nil - After remove node N: - P(node's parent) - / - L - \ - \ - LRM(Left-Rightmost) - \ - R - - N(node) is wild node that was removed - - */ - if (node.left !== Nil){ - var LRM = findRightMost(node.left); - updateChild(node, node.left); - LRM.right = node.right; - if (LRM.right === Nil) { - maintainNode = LRM; - } else { - LRM.right.parent = LRM; - maintainNode = LRM.right; - } - } else if (node.right !== Nil) { - var RLM = findLeftMost(node.right); - updateChild(node, node.right); - RLM.left = node.left; - if (RLM.left === Nil) { - maintainNode = RLM; - } else { - RLM.left.parent = RLM; - maintainNode = RLM.left; - } - } else { - updateChild(node, Nil); - maintainNode = node.parent; - } - this._root = maintainSizeBalancedTree(maintainNode); - return node; + return this.removeNode(node); }; return SBTree; @@ -349,6 +312,14 @@ function CreateSBTreeClass (Node, Nil) { this.height = 0; }; + var createNil = function (Node, value) { + var Nil = new Node(value, null, null, null, 0); + Nil.parent = Nil; + Nil.left = Nil; + Nil.right = Nil; + return Nil; + }; + /** * Update node's size. * @@ -360,12 +331,22 @@ function CreateSBTreeClass (Node, Nil) { this.height = Math.max(this.left.height, this.right.height) + 1; }; - var createNil = function (Node, value) { - var Nil = new Node(value, null, null, null, 0); - Nil.parent = Nil; - Nil.left = Nil; - Nil.right = Nil; - return Nil; + // node, childNode must not be Nil, + // if the childNode turn out to be the root, the parent should be Nil + var updateChild = function (node, childNode) { + var parent = node.parent; + node.parent = childNode; + childNode.parent = parent; + + node.updateSize(); + childNode.updateSize(); + if (parent.right === node) { + parent.right = childNode; + parent.updateSize(); + } else if (parent.left === node) { + parent.left = childNode; + parent.updateSize(); + } // otherwise parent is Nil }; var Node = function () { @@ -379,11 +360,11 @@ function CreateSBTreeClass (Node, Nil) { exports.NodeConstructor = NodeConstructor; exports.createNil = createNil; exports.updateSize = updateSize; + exports.updateChild = updateChild; exports.CreateSBTreeClass = CreateSBTreeClass; exports.Node = Node; exports.Nil = Nil; - exports.SBTree = CreateSBTreeClass(Node, Nil); - exports.updateChild = exports.SBTree.prototype.updateChild; + exports.SBTree = CreateSBTreeClass(Node, Nil, updateChild); })(typeof module === 'undefined' ? window : module.exports); diff --git a/test/data-structures/size-balanced-tree.spec.js b/test/data-structures/size-balanced-tree.spec.js index ac41c70f..5d55dfa4 100644 --- a/test/data-structures/size-balanced-tree.spec.js +++ b/test/data-structures/size-balanced-tree.spec.js @@ -64,7 +64,6 @@ describe('SBTree', function () { } it('test updateChild', function () { - updateChild(Nil, Nil); checkNil(); var root = new Node(10, Nil, Nil, Nil, 1); var left = new Node(5, root, Nil, Nil, 1); @@ -80,12 +79,7 @@ describe('SBTree', function () { updateChild(left, leftLeft); expect(leftLeft.parent).toBe(root); expect(root.left).toBe(leftLeft); - updateChild(leftLeft, Nil); - checkNil(); - expect(root.left).toBe(Nil); - expect(root.size).toBe(2); - updateChild(Nil, right); - expect(right.parent).toBe(Nil); + expect(root.left.size).toBe(1); checkNil(); }); // Returns a random integer between min (included) and max (excluded) From 3d9d535d210852af596e1bddffe393d2b756b881 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 6 Jan 2016 16:58:39 +0800 Subject: [PATCH 492/613] Do not check height. --- src/data-structures/size-balanced-tree.js | 2 -- test/data-structures/size-balanced-tree.spec.js | 1 - 2 files changed, 3 deletions(-) diff --git a/src/data-structures/size-balanced-tree.js b/src/data-structures/size-balanced-tree.js index 93ccd198..2eb60c58 100644 --- a/src/data-structures/size-balanced-tree.js +++ b/src/data-structures/size-balanced-tree.js @@ -309,7 +309,6 @@ function CreateSBTreeClass (Node, Nil, updateChild) { this.left = left; this.right = right; this.size = size; - this.height = 0; }; var createNil = function (Node, value) { @@ -328,7 +327,6 @@ function CreateSBTreeClass (Node, Nil, updateChild) { */ var updateSize = function () { this.size = this.left.size + this.right.size + 1; - this.height = Math.max(this.left.height, this.right.height) + 1; }; // node, childNode must not be Nil, diff --git a/test/data-structures/size-balanced-tree.spec.js b/test/data-structures/size-balanced-tree.spec.js index 5d55dfa4..dff072e7 100644 --- a/test/data-structures/size-balanced-tree.spec.js +++ b/test/data-structures/size-balanced-tree.spec.js @@ -103,7 +103,6 @@ describe('SBTree', function () { var node = sTree.get(i); expect(node.value).toBe(i); } - expect(sTree._root.height).toBe(18); for (var i = 0; i < 200000; ++i) { expect(sTree.get(0).value).toBe(i); var node = sTree.remove(0); // Always remove the first element; From bbfebd0084a69441596068d904cf4e230509e120 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 3 Feb 2016 10:53:55 +0200 Subject: [PATCH 493/613] Fix linting errors --- src/data-structures/interval-tree.js | 10 ++++---- src/graphics/bresenham-line-drawing.js | 18 +++++++-------- src/graphs/spanning-trees/prim.js | 18 +++++++-------- src/searching/binarysearch.js | 5 ++-- src/sorting/quicksort.js | 32 +++++++++++++------------- 5 files changed, 42 insertions(+), 41 deletions(-) diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index bd247188..9f5c1835 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -151,6 +151,11 @@ return contains(point, this.root); }; + function intersects(a, b) { + return (a[0] <= b[0] && a[1] >= b[0]) || (a[0] <= b[1] && a[1] >= b[1]) || + (b[0] <= a[0] && b[1] >= a[0]) || (b[0] <= a[1] && b[1] >= a[1]); + } + function intersectsHelper(interval, node) { if (!node) { return false; @@ -169,11 +174,6 @@ return result; } - function intersects(a, b) { - return (a[0] <= b[0] && a[1] >= b[0]) || (a[0] <= b[1] && a[1] >= b[1]) || - (b[0] <= a[0] && b[1] >= a[0]) || (b[0] <= a[1] && b[1] >= a[1]); - } - /** * Checks or interval belongs to at least one intarval from the tree.

* Complexity: O(log N). diff --git a/src/graphics/bresenham-line-drawing.js b/src/graphics/bresenham-line-drawing.js index 099cd694..2317b70c 100644 --- a/src/graphics/bresenham-line-drawing.js +++ b/src/graphics/bresenham-line-drawing.js @@ -1,6 +1,15 @@ (function (exports) { 'use strict'; + /** + * Draws (prints) the given coordinates + * @param {number} x The first coordinate of the point + * @param {number} y The second coordinate of the point + */ + function drawPoint(x, y) { + console.log(x, y); + } + /** * Bresenham's line drawing algorithm. * It has complexity O(n) @@ -33,15 +42,6 @@ } } - /** - * Draws (prints) the given coordinates - * @param {number} x The first coordinate of the point - * @param {number} y The second coordinate of the point - */ - function drawPoint(x, y) { - console.log(x, y); - } - exports.drawLine = drawLine; }(typeof exports === 'undefined' ? window : exports)); diff --git a/src/graphs/spanning-trees/prim.js b/src/graphs/spanning-trees/prim.js index f0bb9bc4..cd915d48 100644 --- a/src/graphs/spanning-trees/prim.js +++ b/src/graphs/spanning-trees/prim.js @@ -71,15 +71,6 @@ exports.Graph.prototype.prim = (function () { var queue; - /** - * Initialize the algorithm. - * - * @private - */ - function init() { - queue = new Heap(compareEdges); - } - /** * Used for comparitions in the heap * @@ -94,6 +85,15 @@ return b.distance - a.distance; } + /** + * Initialize the algorithm. + * + * @private + */ + function init() { + queue = new Heap(compareEdges); + } + return function () { init.call(this); var inTheTree = {}; diff --git a/src/searching/binarysearch.js b/src/searching/binarysearch.js index d871ee56..1536acc6 100644 --- a/src/searching/binarysearch.js +++ b/src/searching/binarysearch.js @@ -1,6 +1,9 @@ (function (exports) { 'use strict'; + function id (val) { return val; } + function get (key) { return function (val) { return val[key]; }; } + /** * Searchs for specific element in a given array using * the binary search algorithm.

@@ -37,8 +40,6 @@ } return -middle - 1; } - function id (val) { return val; } - function get (key) { return function (val) { return val[key]; }; } exports.binarySearch = binarySearch; diff --git a/src/sorting/quicksort.js b/src/sorting/quicksort.js index 8a645323..b54a84df 100644 --- a/src/sorting/quicksort.js +++ b/src/sorting/quicksort.js @@ -13,6 +13,22 @@ return a - b; } + /** + * Swap the places of two elements + * + * @private + * @param {array} array The array which contains the elements + * @param {number} i The index of the first element + * @param {number} j The index of the second element + * @returns {array} array The array with swaped elements + */ + function swap(array, i, j) { + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + return array; + } + /** * Partitions given subarray using Lomuto's partitioning algorithm. * @@ -35,22 +51,6 @@ return minEnd; } - /** - * Swap the places of two elements - * - * @private - * @param {array} array The array which contains the elements - * @param {number} i The index of the first element - * @param {number} j The index of the second element - * @returns {array} array The array with swaped elements - */ - function swap(array, i, j) { - var temp = array[i]; - array[i] = array[j]; - array[j] = temp; - return array; - } - /** * Sorts given array. * From f63c6d31dc4ff8bb46690d9f2180adeacbcc014f Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 3 Feb 2016 11:02:00 +0200 Subject: [PATCH 494/613] Fix linting errors --- src/graphics/bresenham-line-drawing.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/graphics/bresenham-line-drawing.js b/src/graphics/bresenham-line-drawing.js index 2317b70c..73267f32 100644 --- a/src/graphics/bresenham-line-drawing.js +++ b/src/graphics/bresenham-line-drawing.js @@ -20,7 +20,7 @@ * @param {function} draw Optional custom drawing function. */ function drawLine(x1, y1, x2, y2, draw) { - drawPoint = draw || drawPoint; + var drawPointStrategy = draw || drawPoint; var dx = Math.abs(x2 - x1); var dy = Math.abs(y2 - y1); var cx = (x1 < x2) ? 1 : -1; @@ -29,7 +29,7 @@ var doubledError; while (x1 !== x2 || y1 !== y2) { - drawPoint(x1, y1); + drawPointStrategy(x1, y1); doubledError = error + error; if (doubledError > -dy) { error -= dy; From aa9beea701783f12011448d7bfda620a4768e449 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 9 Apr 2016 13:27:50 +0300 Subject: [PATCH 495/613] docs(contributors): update the list of contributors --- readme.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/readme.md b/readme.md index a26a6052..6464dc3f 100644 --- a/readme.md +++ b/readme.md @@ -71,17 +71,17 @@ If the build is not successful fix your code in order the tests and jshint valid ## Contributors -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) |[lekkas](https://github.com/lekkas) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[pvoznenko](https://github.com/pvoznenko) |[filipefalcaos](https://github.com/filipefalcaos) | :---: |:---: |:---: |:---: |:---: |:---: | -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[pvoznenko](https://github.com/pvoznenko) |[FilipeFalcaoBatista](https://github.com/FilipeFalcaoBatista) |[lekkas](https://github.com/lekkas) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[pvoznenko](https://github.com/pvoznenko) |[filipefalcaos](https://github.com/filipefalcaos) | -[deniskyashif](https://github.com/deniskyashif) |[infusion](https://github.com/infusion) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[ysharplanguage](https://github.com/ysharplanguage) |[contra](https://github.com/contra) | +[lekkas](https://github.com/lekkas) |[deniskyashif](https://github.com/deniskyashif) |[infusion](https://github.com/infusion) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[ysharplanguage](https://github.com/ysharplanguage) | :---: |:---: |:---: |:---: |:---: |:---: | -[deniskyashif](https://github.com/deniskyashif) |[infusion](https://github.com/infusion) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[ysharplanguage](https://github.com/ysharplanguage) |[contra](https://github.com/contra) | +[lekkas](https://github.com/lekkas) |[deniskyashif](https://github.com/deniskyashif) |[infusion](https://github.com/infusion) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[ysharplanguage](https://github.com/ysharplanguage) | -[fanixk](https://github.com/fanixk) | -:---: | -[fanixk](https://github.com/fanixk) | +[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | +:---: |:---: | +[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | ## License From 49b3857f4d4b6f835af47689a11257f3db03d95b Mon Sep 17 00:00:00 2001 From: Lukas Liesis Date: Sat, 9 Apr 2016 14:04:05 +0300 Subject: [PATCH 496/613] Create readme.md (#94) * Create readme.md starting comparison table * Update readme.md * Update readme.md updated bubblesort complexity --- src/sorting/readme.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/sorting/readme.md diff --git a/src/sorting/readme.md b/src/sorting/readme.md new file mode 100644 index 00000000..3d9d00f0 --- /dev/null +++ b/src/sorting/readme.md @@ -0,0 +1,21 @@ +# Comparison of all sorting algorithms + +| Algorithm | Complexity | When to use? | +|----------------------------|-----------------------------------------------------|--------------| +| 3-way-string-quicksort.js | O(N^2) | | +| bubblesort.js | O(N^2) | | +| bucketsort.js | O(N) | | +| countingsort.js | O(N) | | +| heapsort.js | O(N log N) | | +| insertion-binary-sort.js | O(N^2) | | +| insertionsort.js | O(N^2) | | +| lsd.js | O(N*M) for N keys which have M or fewer digits | | +| mergesort.js | O(n log(n)) | | +| msd.js | O(N*M) for N keys which have M or fewer digits | | +| oddeven-sort.js | O(N^2) | | +| quicksort-middle.js | O(N log(N)) | | +| quicksort.js | O(nlog n) | | +| radixsort.js | O(N K) for N keys with K being | | +| recursive-insertionsort.js | O(N^2) | | +| selectionsort.js | O(N^2) | | +| shellsort.js | O((nlog(n))^2) | | From b21b5e5dbfe5b010b5371ef9080b39e82ad58866 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 18 May 2016 11:18:50 +0300 Subject: [PATCH 497/613] test(longestIncreasingSubsequence): update tests --- test/searching/longest-increasing-subsequence.spec.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/searching/longest-increasing-subsequence.spec.js b/test/searching/longest-increasing-subsequence.spec.js index ae72a3a0..7e42ec55 100644 --- a/test/searching/longest-increasing-subsequence.spec.js +++ b/test/searching/longest-increasing-subsequence.spec.js @@ -12,6 +12,15 @@ describe('longest subsequence', function () { sequence = [5, 2, 8, 6, 3, 6, 9, 7, 11]; }); + it('should work with empty array', function () { + expect(longestSubsequence([]).length).toBe(0); + }); + + it('should return the only element in a single element array', function () { + let array = [1]; + expect(longestSubsequence(array)).toEqual([1]); + }); + it('should give the right length', function () { expect(longestSubsequence(sequence).length).toBe(5); }); From ba6645a3a2f3e6c4e4b7e9c86cdb0593ac288661 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 18 May 2016 11:33:48 +0300 Subject: [PATCH 498/613] refactor(longestSubSeq): add cmp and change name --- ...-subsequence.js => longest-subsequence.js} | 26 +++++++++---------- ...ce.spec.js => longest-subsequence.spec.js} | 13 +++++++++- 2 files changed, 24 insertions(+), 15 deletions(-) rename src/searching/{longest-increasing-subsequence.js => longest-subsequence.js} (86%) rename test/searching/{longest-increasing-subsequence.spec.js => longest-subsequence.spec.js} (74%) diff --git a/src/searching/longest-increasing-subsequence.js b/src/searching/longest-subsequence.js similarity index 86% rename from src/searching/longest-increasing-subsequence.js rename to src/searching/longest-subsequence.js index 7ee8b232..b326f9f0 100644 --- a/src/searching/longest-increasing-subsequence.js +++ b/src/searching/longest-subsequence.js @@ -10,19 +10,15 @@ * @private * @param {Array} array The array in which the largest * element should be found. - * @param {Function} cmp Function used for comparison. * @return {Number} index of the first largest element */ - function max(array, cmp) { + function max(array) { if (!array || !array.length) { return -1; } - if (!cmp) { - cmp = function (a, b) { return a - b; }; - } var maxIdx = 0; for (var i = 1; i < array.length; i += 1) { - if (cmp(array[maxIdx], array[i]) < 0) { + if (array[maxIdx].distance < array[i].distance) { maxIdx = i; } } @@ -33,8 +29,8 @@ * Default comparison method. * @private */ - function cmp(a, b) { - return a.distance - b.distance; + function asc(a, b) { + return a - b; } /** @@ -46,12 +42,12 @@ * @param {Array} array The input array. * @return {Object} Graph represented with list of neighbours. */ - function buildDag(array) { + function buildDag(array, cmp) { var result = []; for (var i = 0; i < array.length; i += 1) { result[i] = []; for (var j = i + 1; j < array.length; j += 1) { - if (array[i] < array[j]) { + if (cmp(array[i], array[j]) < 0) { result[i].push(j); } } @@ -87,7 +83,7 @@ neighboursDistance[i] = find(dag, neighbours[i]); } - maxDist = max(neighboursDistance, cmp); + maxDist = max(neighboursDistance); maxNode = neighbours[maxDist]; distance = 1 + neighboursDistance[maxDist].distance; find.memo[node] = result = { @@ -114,15 +110,16 @@ * @param {Array} array Input sequence. * @return {Array} Longest increasing subsequence. */ - return function (array) { + return function (array, cmp) { + cmp = cmp || asc; var results = []; - var dag = buildDag(array); + var dag = buildDag(array, cmp); var maxPath; find.memo = []; for (var i = 0; i < array.length; i += 1) { results.push(find(dag, i)); } - maxPath = results[max(results, cmp)]; + maxPath = results[max(results)]; results = []; while (maxPath) { results.push(array[maxPath.node]); @@ -133,3 +130,4 @@ })(); })(typeof window === 'undefined' ? module.exports : window); + diff --git a/test/searching/longest-increasing-subsequence.spec.js b/test/searching/longest-subsequence.spec.js similarity index 74% rename from test/searching/longest-increasing-subsequence.spec.js rename to test/searching/longest-subsequence.spec.js index 7e42ec55..5a068aa7 100644 --- a/test/searching/longest-increasing-subsequence.spec.js +++ b/test/searching/longest-subsequence.spec.js @@ -2,7 +2,7 @@ var longestSubsequence = require('../../src/searching/' + - 'longest-increasing-subsequence') + 'longest-subsequence') .longestSubsequence; describe('longest subsequence', function () { @@ -33,4 +33,15 @@ describe('longest subsequence', function () { expect(longestSubsequence(sequence).toString()) .toBe([2, 3, 6, 9, 11].toString()); }); + + it('should work with a custom comparator', function () { + var cmp = function (a, b) { + return b - a; + }; + var seq = [1, 2, -1]; + var result = longestSubsequence(seq, cmp); + expect(result.length).toBe(2); + expect(result).toEqual([1, -1]); + }); }); + From ea06d3413f952273916038a0431e0499f449b17a Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 18 May 2016 11:35:01 +0300 Subject: [PATCH 499/613] docs(subSeq): update parameters --- src/searching/longest-subsequence.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/searching/longest-subsequence.js b/src/searching/longest-subsequence.js index b326f9f0..10335535 100644 --- a/src/searching/longest-subsequence.js +++ b/src/searching/longest-subsequence.js @@ -40,6 +40,7 @@ * Complexity: O(N^2). * @private * @param {Array} array The input array. + * @param {Function} cmp Comparator. * @return {Object} Graph represented with list of neighbours. */ function buildDag(array, cmp) { @@ -108,6 +109,7 @@ * @public * @module searching/longest-increasing-subsequence * @param {Array} array Input sequence. + * @param {Function} cmp Comparator. * @return {Array} Longest increasing subsequence. */ return function (array, cmp) { From b155d899563c34674a262ef76a424cd119653145 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 18 May 2016 11:40:10 +0300 Subject: [PATCH 500/613] fix(build): use var instead of let --- test/searching/longest-subsequence.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/searching/longest-subsequence.spec.js b/test/searching/longest-subsequence.spec.js index 5a068aa7..f32efd06 100644 --- a/test/searching/longest-subsequence.spec.js +++ b/test/searching/longest-subsequence.spec.js @@ -17,7 +17,7 @@ describe('longest subsequence', function () { }); it('should return the only element in a single element array', function () { - let array = [1]; + var array = [1]; expect(longestSubsequence(array)).toEqual([1]); }); From a4759dd71e98c9eddbc65a81c856976b9155ea1e Mon Sep 17 00:00:00 2001 From: Xie Dezhuo Date: Tue, 31 May 2016 18:53:58 +0800 Subject: [PATCH 501/613] Update binarysearch.js --- src/searching/binarysearch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/searching/binarysearch.js b/src/searching/binarysearch.js index 1536acc6..d8f874e0 100644 --- a/src/searching/binarysearch.js +++ b/src/searching/binarysearch.js @@ -38,7 +38,7 @@ } middle = Math.floor((left + right) / 2); } - return -middle - 1; + return -1; } exports.binarySearch = binarySearch; From be84808abee53624f27203997059b8f7d034e9b9 Mon Sep 17 00:00:00 2001 From: Amila Welihinda Date: Thu, 9 Jun 2016 17:33:35 -0700 Subject: [PATCH 502/613] Updated travis ci to test modern node version --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a9ff642d..bce32da8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - "0.12" + - "4" before_script: - npm install -g gulp -script: gulp build \ No newline at end of file +script: gulp build From c1a1b2f0dda86e1ee531a1c952908cc20d406ebb Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 8 Jul 2016 16:31:41 +0300 Subject: [PATCH 503/613] feat(graphs): add Tarjan's algorithm for SCC Fix #98 --- package.json | 2 +- .../others/tarjan-connected-components.js | 70 +++++++++++++++++++ src/graphs/others/topological-sort.js | 3 +- .../tarjan-connected-components.spec.js | 38 ++++++++++ 4 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 src/graphs/others/tarjan-connected-components.js create mode 100644 test/graphs/others/tarjan-connected-components.spec.js diff --git a/package.json b/package.json index ecff0768..e7b6b150 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "jshint-stylish": "^1.0.0" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "gulp test" }, "repository": { "type": "git", diff --git a/src/graphs/others/tarjan-connected-components.js b/src/graphs/others/tarjan-connected-components.js new file mode 100644 index 00000000..f39ff848 --- /dev/null +++ b/src/graphs/others/tarjan-connected-components.js @@ -0,0 +1,70 @@ +(function (exports) { + + /** + * Tarjan's algorithm for finding the connected components in a graph.

+ * Time complexity: O(|E| + |V|) where E is a number of edges and |V| + * is the number of nodes. + * + * @public + * @module graphs/others/tarjan-connected-components + * @param {Array} graph Adjacency list, which represents the graph. + * @returns {Array} Connected components. + * + * @example + * var tarjanConnectedComponents = + * require('path-to-algorithms/src/graphs/' + + * 'others/tarjan-connected-components').tarjanConnectedComponents; + * var graph = { + * v1: ['v2', 'v5'], + * v2: [], + * v3: ['v1', 'v2', 'v4', 'v5'], + * v4: [], + * v5: [] + * }; + * var vertices = topsort(graph); // ['v3', 'v4', 'v1', 'v5', 'v2'] + */ + function tarjanConnectedComponents(graph) { + graph = graph || {}; + const indexes = {}; + const lowIndexes = {}; + const onStack = {}; + const result = []; + const stack = []; + let index = 1; + + const connectedComponent = node => { + stack.push(node); + onStack[node] = true; + indexes[node] = index; + lowIndexes[node] = index; + index += 1; + graph[node].forEach(n => { + if (indexes[n] === undefined) { + connectedComponent(n); + lowIndexes[node] = Math.min(lowIndexes[n], lowIndexes[node]); + } else if (onStack[n]) { + lowIndexes[node] = Math.min(lowIndexes[node], indexes[n]); + } + }); + // This is a "root" node + const cc = []; + if (indexes[node] === lowIndexes[node]) { + let current; + do { + current = stack.pop(); + onStack[current] = false; + cc.push(current); + } while (stack.length > 0 && node !== current); + result.push(cc); + } + }; + + Object.keys(graph) + .forEach(n => !indexes[n] && connectedComponent(n)); + + return result; + } + + exports.tarjanConnectedComponents = tarjanConnectedComponents; + +}(typeof exports === 'undefined' ? window : exports)); diff --git a/src/graphs/others/topological-sort.js b/src/graphs/others/topological-sort.js index b793d5a5..f32ee48a 100644 --- a/src/graphs/others/topological-sort.js +++ b/src/graphs/others/topological-sort.js @@ -22,7 +22,8 @@ /** * Topological sort algorithm of a directed acyclic graph.

- * Time complexity: O(|E|) where E is a number of edges. + * Time complexity: O(|E| + |V|) where E is a number of edges + * and |V| is the number of nodes. * * @public * @module graphs/others/topological-sort diff --git a/test/graphs/others/tarjan-connected-components.spec.js b/test/graphs/others/tarjan-connected-components.spec.js new file mode 100644 index 00000000..4b2c45c8 --- /dev/null +++ b/test/graphs/others/tarjan-connected-components.spec.js @@ -0,0 +1,38 @@ +var tj = require('../../../src/graphs/others/tarjan-connected-components').tarjanConnectedComponents; + +var nonConnected = { + v1: [], + v2: [], + v3: [], + v4: [], + v5: [] +}; + +var cyclicGraph = { + v1: ['v2'], + v2: ['v3'], + v3: ['v4'], + v4: ['v5'], + v5: ['v1'] +}; + + +describe('Tarjan\'s algorithm for finding connected components', function () { + 'use strict'; + it('should be defined', function () { + expect(typeof tj).toBe('function'); + }); + + it('should return an array', function () { + expect(tj() instanceof Array).toBeTruthy(); + }); + + it('should work with non-connected graphs', function () { + expect(tj(nonConnected)).toEqual([['v1'], ['v2'], ['v3'], ['v4'], ['v5']]); + }); + + it('should workw ith cycles', () => { + expect(tj(cyclicGraph)).toEqual([['v5', 'v4', 'v3', 'v2', 'v1']]); + }); + +}); From 0ecc1515fb983235b3b526ba40af3fdb91274369 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 8 Jul 2016 16:40:51 +0300 Subject: [PATCH 504/613] fix(build): handle jscs errors --- .../others/tarjan-connected-components.js | 17 +++++++++++------ .../others/tarjan-connected-components.spec.js | 4 +--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/graphs/others/tarjan-connected-components.js b/src/graphs/others/tarjan-connected-components.js index f39ff848..c131f6dc 100644 --- a/src/graphs/others/tarjan-connected-components.js +++ b/src/graphs/others/tarjan-connected-components.js @@ -1,6 +1,7 @@ (function (exports) { + 'use strict'; - /** + /** * Tarjan's algorithm for finding the connected components in a graph.

* Time complexity: O(|E| + |V|) where E is a number of edges and |V| * is the number of nodes. @@ -30,15 +31,15 @@ const onStack = {}; const result = []; const stack = []; - let index = 1; + var index = 1; - const connectedComponent = node => { + const connectedComponent = function (node) { stack.push(node); onStack[node] = true; indexes[node] = index; lowIndexes[node] = index; index += 1; - graph[node].forEach(n => { + graph[node].forEach(function (n) { if (indexes[n] === undefined) { connectedComponent(n); lowIndexes[node] = Math.min(lowIndexes[n], lowIndexes[node]); @@ -49,7 +50,7 @@ // This is a "root" node const cc = []; if (indexes[node] === lowIndexes[node]) { - let current; + var current; do { current = stack.pop(); onStack[current] = false; @@ -60,7 +61,11 @@ }; Object.keys(graph) - .forEach(n => !indexes[n] && connectedComponent(n)); + .forEach(function (n) { + if (!indexes[n]) { + connectedComponent(n); + } + }); return result; } diff --git a/test/graphs/others/tarjan-connected-components.spec.js b/test/graphs/others/tarjan-connected-components.spec.js index 4b2c45c8..e24ecbef 100644 --- a/test/graphs/others/tarjan-connected-components.spec.js +++ b/test/graphs/others/tarjan-connected-components.spec.js @@ -16,7 +16,6 @@ var cyclicGraph = { v5: ['v1'] }; - describe('Tarjan\'s algorithm for finding connected components', function () { 'use strict'; it('should be defined', function () { @@ -31,8 +30,7 @@ describe('Tarjan\'s algorithm for finding connected components', function () { expect(tj(nonConnected)).toEqual([['v1'], ['v2'], ['v3'], ['v4'], ['v5']]); }); - it('should workw ith cycles', () => { + it('should workw ith cycles', function () { expect(tj(cyclicGraph)).toEqual([['v5', 'v4', 'v3', 'v2', 'v1']]); }); - }); From 8cc32315e14e07b3fceec6aca228bd128a79089c Mon Sep 17 00:00:00 2001 From: krzysztof-grzybek Date: Mon, 18 Jul 2016 22:29:25 +0200 Subject: [PATCH 505/613] Add tests to heap "update" method --- test/data-structures/heap.spec.js | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/data-structures/heap.spec.js b/test/data-structures/heap.spec.js index e26b2f45..8de81f23 100644 --- a/test/data-structures/heap.spec.js +++ b/test/data-structures/heap.spec.js @@ -58,4 +58,38 @@ describe('Heap', function () { res = heap.extract(); expect(res).toBe(66); }); + it('should update top node properly', function () { + var heap = new Heap(function (a, b) { + return a.val - b.val; + }); + var objectToUpdate = { val: 66 }; + heap.add(objectToUpdate); + heap.add({ val: 11 }); + heap.add({ val: 55 }); + objectToUpdate.val = 0; + heap.update(objectToUpdate); + var res = heap.extract(); + expect(res.val).toBe(55); + res = heap.extract(); + expect(res.val).toBe(11); + res = heap.extract(); + expect(res.val).toBe(0); + }); + it('should update bottom node properly', function () { + var heap = new Heap(function (a, b) { + return a.val - b.val; + }); + var objectToUpdate = { val: 0 }; + heap.add(objectToUpdate); + heap.add({ val: 11 }); + heap.add({ val: 55 }); + objectToUpdate.val = 66; + heap.update(objectToUpdate); + var res = heap.extract(); + expect(res.val).toBe(66); + res = heap.extract(); + expect(res.val).toBe(55); + res = heap.extract(); + expect(res.val).toBe(11); + }); }); From c8228753cc1ebace7bd678a0100c21feaf3afb62 Mon Sep 17 00:00:00 2001 From: krzysztof-grzybek Date: Mon, 18 Jul 2016 22:29:43 +0200 Subject: [PATCH 506/613] Fix heap "update" method --- src/data-structures/heap.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/data-structures/heap.js b/src/data-structures/heap.js index b2e167b3..cb936575 100644 --- a/src/data-structures/heap.js +++ b/src/data-structures/heap.js @@ -82,7 +82,8 @@ } if (right < this._heap.length && - this._cmp(this._heap[right], this._heap[index]) > 0) { + this._cmp(this._heap[right], this._heap[index]) > 0 && + this._cmp(this._heap[right], this._heap[left]) > 0) { extr = right; } @@ -116,6 +117,7 @@ index = parent; parent = Math.floor(parent / 2); } + this._heapify(index); } return parent; }; From ce8f53afad9df63369c9438d888c83204944a956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Bregu=C5=82a?= Date: Sun, 25 Sep 2016 20:29:25 +0200 Subject: [PATCH 507/613] Make link clickable See: http://usejsdoc.org/tags-inline-link.html --- src/others/min-coins-change.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/others/min-coins-change.js b/src/others/min-coins-change.js index 239f99e5..d4120d3a 100644 --- a/src/others/min-coins-change.js +++ b/src/others/min-coins-change.js @@ -5,7 +5,7 @@ * Returns the minimum number of coins from given set, * which sum equals to given change. This is famous * problem from the dymanic programming: - * https://en.wikipedia.org/wiki/Change-making_problem + * {@link https://en.wikipedia.org/wiki/Change-making_problem} * * @public * @module others/minCoinsChange From b0d8bc994e8812b6a9c820a632f3182ac2ad97a3 Mon Sep 17 00:00:00 2001 From: mik-laj Date: Sun, 25 Sep 2016 20:57:11 +0200 Subject: [PATCH 508/613] Make link clickable --- src/data-structures/splay-tree.js | 2 +- src/sets/quickfind.js | 2 +- src/sets/quickunion.js | 2 +- src/sets/weightquickunion.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/data-structures/splay-tree.js b/src/data-structures/splay-tree.js index dfadb1ee..20b80716 100644 --- a/src/data-structures/splay-tree.js +++ b/src/data-structures/splay-tree.js @@ -44,7 +44,7 @@ /** * Splay tree. - * http://en.wikipedia.org/wiki/Splay_tree + * {@link http://en.wikipedia.org/wiki/Splay_tree} * @public * @constructor */ diff --git a/src/sets/quickfind.js b/src/sets/quickfind.js index 272dd72c..a5a465b1 100644 --- a/src/sets/quickfind.js +++ b/src/sets/quickfind.js @@ -5,7 +5,7 @@ * The algorithm is inspired by Robert Sedgewick's Java implementation. *
* The algorithm is inspired by Robert Sedgewick's Java implementation. - * For further reading http://algs4.cs.princeton.edu/home/. + * {@link http://algs4.cs.princeton.edu/home/} * * @example * diff --git a/src/sets/quickunion.js b/src/sets/quickunion.js index ecb88327..0d8bb402 100644 --- a/src/sets/quickunion.js +++ b/src/sets/quickunion.js @@ -4,7 +4,7 @@ * Allows to check whether the path between two nodes exists. *
* The algorithm is inspired by Robert Sedgewick's Java implementation. - * For further reading http://algs4.cs.princeton.edu/home/. + * {@link http://algs4.cs.princeton.edu/home/} * * @example * diff --git a/src/sets/weightquickunion.js b/src/sets/weightquickunion.js index 47079193..2fc9b099 100644 --- a/src/sets/weightquickunion.js +++ b/src/sets/weightquickunion.js @@ -4,7 +4,7 @@ * Allows to check whether the path between two nodes exists. *
* The algorithm is inspired by Robert Sedgewick's Java implementation. - * For further reading http://algs4.cs.princeton.edu/home/. + * {@link http://algs4.cs.princeton.edu/home/} * * @example * From 9a15f58aef29bce7ef3790d719afd3bce2de6ac6 Mon Sep 17 00:00:00 2001 From: Rachel Miller Date: Sat, 1 Oct 2016 15:56:21 -0500 Subject: [PATCH 509/613] Fixed two spelling errors --- readme.md | 2 +- src/searching/binarysearch.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 6464dc3f..0c47c952 100644 --- a/readme.md +++ b/readme.md @@ -56,7 +56,7 @@ and all `*.spec.js` files will be executed. ## Contributions -Fork the repo and make requred changes. After that push your changes in branch, which is named according to the changes you did. +Fork the repo and make required changes. After that push your changes in branch, which is named according to the changes you did. Initiate the PR. Make sure you're editor makes validations according to the `.jshintrc` in the root directory of the repository. diff --git a/src/searching/binarysearch.js b/src/searching/binarysearch.js index d8f874e0..efe6e28c 100644 --- a/src/searching/binarysearch.js +++ b/src/searching/binarysearch.js @@ -5,7 +5,7 @@ function get (key) { return function (val) { return val[key]; }; } /** - * Searchs for specific element in a given array using + * Searches for specific element in a given array using * the binary search algorithm.

* Time complexity: O(log N). * From 7bd9f56387145ad60453adb2048d1658f44ebc92 Mon Sep 17 00:00:00 2001 From: Xuefeng Zhu Date: Thu, 27 Oct 2016 23:12:21 -0500 Subject: [PATCH 510/613] minor optimize runlength --- src/compression/runlength/runlength.js | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/compression/runlength/runlength.js b/src/compression/runlength/runlength.js index 2a5f7942..a530448d 100644 --- a/src/compression/runlength/runlength.js +++ b/src/compression/runlength/runlength.js @@ -14,19 +14,15 @@ * This takes O(n). */ function convertToAscii(str) { - var result = ''; + var result = []; var currentChar = ''; var i = 0; for (; i < str.length; i += 1) { currentChar = str[i].charCodeAt(0).toString(2); - if (currentChar.length < 8) { - while (8 - currentChar.length) { - currentChar = '0' + currentChar; - } - } - result += currentChar; + currentChar = new Array(9 - currentChar.length).join('0') + currentChar; + result.push(currentChar); } - return result; + return result.join(''); } /** @@ -34,26 +30,21 @@ * Takes O(n^2). */ function runLength(vector) { - var result = ''; + var result = []; var zeros = 0; var zerosTemp = ''; - var wordLength = 0; var i = 0; for (; i < vector.length; i += 1) { if (vector[i] === '0') { zeros += 1; } else { zerosTemp = zeros.toString(2); - wordLength = zerosTemp.length - 1; - while (wordLength) { - result = result + '1'; - wordLength -= 1; - } - result += '0' + zerosTemp; + result.push(new Array(zerosTemp.length).join('1')); + result.push('0' + zerosTemp); zeros = 0; } } - return result; + return result.join(''); } /** From 583ffe6eb34ce2352f1564f562551eb2d4325804 Mon Sep 17 00:00:00 2001 From: Xuefeng Zhu Date: Sat, 29 Oct 2016 23:31:19 -0500 Subject: [PATCH 511/613] remove unused current in min-coins-change.js --- src/others/min-coins-change.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/others/min-coins-change.js b/src/others/min-coins-change.js index d4120d3a..f0f07933 100644 --- a/src/others/min-coins-change.js +++ b/src/others/min-coins-change.js @@ -28,11 +28,9 @@ return [change]; } for (var i = 1; i <= change; i += 1) { - var current = null; for (var j = 0; j < coins.length && coins[j] <= change; j += 1) { for (var k = 0; k < minChange.length; k += 1) { - if (k + coins[j] === i && - (!current || minChange[k].length + 1 < current.length)) { + if (k + coins[j] === i) { minChange[i] = minChange[k].concat([coins[j]]); } } From c5486fcae517ff27dd799f5153dbfc801d79d6b2 Mon Sep 17 00:00:00 2001 From: Krzysztof Grzybek Date: Thu, 15 Dec 2016 20:33:22 +0100 Subject: [PATCH 512/613] Rename longest-subsequence to longest-increasing-subsequence. --- ...e.js => longest-increasing-subsequence.js} | 8 ++++---- ...=> longest-increasing-subsequence.spec.js} | 20 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) rename src/searching/{longest-subsequence.js => longest-increasing-subsequence.js} (92%) rename test/searching/{longest-subsequence.spec.js => longest-increasing-subsequence.spec.js} (58%) diff --git a/src/searching/longest-subsequence.js b/src/searching/longest-increasing-subsequence.js similarity index 92% rename from src/searching/longest-subsequence.js rename to src/searching/longest-increasing-subsequence.js index 10335535..81d969cf 100644 --- a/src/searching/longest-subsequence.js +++ b/src/searching/longest-increasing-subsequence.js @@ -1,7 +1,7 @@ (function (exports) { 'use strict'; - exports.longestSubsequence = (function () { + exports.longestIncreasingSubsequence = (function () { /** * Find the index of the first largest element in array. @@ -57,12 +57,12 @@ } /** - * Finds the longest sub-sequence for given node.

+ * Finds the longest increasing sub-sequence for given node.

* Complexity: O(N^N). * @private * @param {Object} dag Graph represented with list of neighbours. * @param {number} node The current node. - * @return {object} The longest sub-sequence for given node. + * @return {object} The longest increasing sub-sequence for given node. */ function find(dag, node) { node = node || 0; @@ -103,7 +103,7 @@ * * @example * var subsequence = require('path-to-algorithms/src/searching/'+ - * 'longest-increasing-subsequence').longestSubsequence; + * 'longest-increasing-subsequence').longestIncreasingSubsequence; * console.log(subsequence([1, 0, 4, 3, 5])); // 1, 4, 5 * * @public diff --git a/test/searching/longest-subsequence.spec.js b/test/searching/longest-increasing-subsequence.spec.js similarity index 58% rename from test/searching/longest-subsequence.spec.js rename to test/searching/longest-increasing-subsequence.spec.js index f32efd06..8c764fa7 100644 --- a/test/searching/longest-subsequence.spec.js +++ b/test/searching/longest-increasing-subsequence.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var longestSubsequence = +var longestIncreasingSubsequence = require('../../src/searching/' + - 'longest-subsequence') - .longestSubsequence; + 'longest-increasing-subsequence') + .longestIncreasingSubsequence; -describe('longest subsequence', function () { +describe('longest increasing subsequence', function () { var sequence; beforeEach(function () { @@ -13,24 +13,24 @@ describe('longest subsequence', function () { }); it('should work with empty array', function () { - expect(longestSubsequence([]).length).toBe(0); + expect(longestIncreasingSubsequence([]).length).toBe(0); }); it('should return the only element in a single element array', function () { var array = [1]; - expect(longestSubsequence(array)).toEqual([1]); + expect(longestIncreasingSubsequence(array)).toEqual([1]); }); it('should give the right length', function () { - expect(longestSubsequence(sequence).length).toBe(5); + expect(longestIncreasingSubsequence(sequence).length).toBe(5); }); it('should work with empty arrays', function () { - expect(longestSubsequence([]).length).toBe(0); + expect(longestIncreasingSubsequence([]).length).toBe(0); }); it('should return the correct path', function () { - expect(longestSubsequence(sequence).toString()) + expect(longestIncreasingSubsequence(sequence).toString()) .toBe([2, 3, 6, 9, 11].toString()); }); @@ -39,7 +39,7 @@ describe('longest subsequence', function () { return b - a; }; var seq = [1, 2, -1]; - var result = longestSubsequence(seq, cmp); + var result = longestIncreasingSubsequence(seq, cmp); expect(result.length).toBe(2); expect(result).toEqual([1, -1]); }); From 440c7deee26ff2c339510d42e98ae9d219df3156 Mon Sep 17 00:00:00 2001 From: Peter Kerpedjiev Date: Thu, 22 Dec 2016 16:09:44 -0500 Subject: [PATCH 513/613] New nodes should be added with a max value --- src/data-structures/interval-tree.js | 2 + test/data-structures/interval-tree.spec.js | 48 ++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 test/data-structures/interval-tree.spec.js diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index 9f5c1835..6d3da17d 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -76,6 +76,7 @@ function addNode(node, side, interval) { var child = new exports.Node(interval[0], interval[1]); + child.max = interval[1]; child.parentNode = node; node[side] = child; if (node.max < interval[1]) { @@ -113,6 +114,7 @@ exports.IntervalTree.prototype.add = function (interval) { if (!this.root) { this.root = new exports.Node(interval[0], interval[1]); + this.root.max = interval[1]; return; } addHelper(this.root, interval); diff --git a/test/data-structures/interval-tree.spec.js b/test/data-structures/interval-tree.spec.js new file mode 100644 index 00000000..15fec119 --- /dev/null +++ b/test/data-structures/interval-tree.spec.js @@ -0,0 +1,48 @@ +'use strict'; + +var mod = require('../../src/data-structures/interval-tree.js'); +var IntervalTree = mod.IntervalTree; + +describe('IntervalTree', function () { + it('should correctly detect intersections', function () { + var it = new IntervalTree(); + + it.add([10383734, 10594186]) + it.add([10383734, 10594186]) + it.add([8891125, 9095610]) + it.add([9495571, 9677853]) + it.add([10093457, 10257167]) + it.add([9303743, 9404967]) + it.intersects([9303743, 9303744]) + expect(it.intersects([9303743, 9303744])).toBe(true) + expect(it.intersects([10383734, 10383734])).toBe(true); + + it.add([9495571, 9677853]) + it.add([9303743, 9404967]) + + expect(it.intersects([9303743, 9303744])).toBe(true) + expect(it.intersects([9303742, 9303742])).toBe(false) + + expect(it.intersects([9404967,9404967 ])).toBe(true) + expect(it.intersects([9404968,9404969 ])).toBe(false) + + it = new IntervalTree(); + + expect(it.intersects([1,2])).toBe(false); + + it.add([1,2]); + expect(it.contains(0.4)).toBe(false); + expect(it.contains(1.4)).toBe(true); + + expect(it.intersects([0,3])).toBe(true); + expect(it.intersects([1.5,1.6])).toBe(true); + expect(it.intersects([2.1,3.0])).toBe(false); + + it.add([1.4,2.1]); + + expect(it.intersects([0,3])).toBe(true); + expect(it.intersects([1.5,1.6])).toBe(true); + + expect(it.intersects([2.1,3.0])).toBe(true); + }); +}); From 5870065287198ab8fd304854e6af0cebef43431d Mon Sep 17 00:00:00 2001 From: Peter Kerpedjiev Date: Thu, 22 Dec 2016 16:15:54 -0500 Subject: [PATCH 514/613] Fix spacing --- test/data-structures/interval-tree.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/data-structures/interval-tree.spec.js b/test/data-structures/interval-tree.spec.js index 15fec119..a6d79099 100644 --- a/test/data-structures/interval-tree.spec.js +++ b/test/data-structures/interval-tree.spec.js @@ -23,8 +23,8 @@ describe('IntervalTree', function () { expect(it.intersects([9303743, 9303744])).toBe(true) expect(it.intersects([9303742, 9303742])).toBe(false) - expect(it.intersects([9404967,9404967 ])).toBe(true) - expect(it.intersects([9404968,9404969 ])).toBe(false) + expect(it.intersects([9404967,9404967])).toBe(true) + expect(it.intersects([9404968,9404969])).toBe(false) it = new IntervalTree(); From f839af2efbe02905aa35b797df37b59e260e1047 Mon Sep 17 00:00:00 2001 From: Krzysztof Grzybek Date: Fri, 23 Dec 2016 20:57:52 +0100 Subject: [PATCH 515/613] Add tests to longest common subsequence algorithm --- .../longest-common-subsequence.spec.js | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/searching/longest-common-subsequence.spec.js diff --git a/test/searching/longest-common-subsequence.spec.js b/test/searching/longest-common-subsequence.spec.js new file mode 100644 index 00000000..4adaa080 --- /dev/null +++ b/test/searching/longest-common-subsequence.spec.js @@ -0,0 +1,49 @@ +'use strict'; + +var longestCommonSubsequence = + require('../../src/searching/' + + 'longest-common-subsequence') + .longestCommonSubsequence; + +describe('longest common subsequence', function () { + + it('should work with empty strings', function () { + expect(longestCommonSubsequence('', '')).toBe(''); + }); + + it('should work with first string empty', function () { + expect(longestCommonSubsequence('', 'abcd')).toBe(''); + }); + + it('should work with second string empty', function () { + expect(longestCommonSubsequence('abcd', '')).toBe(''); + }); + + it('should work if there is no lcs', function () { + expect(longestCommonSubsequence('qtwer', 'zvxcv')).toBe(''); + }); + + it('should work if lcs is whole first string', function () { + expect(longestCommonSubsequence('abc', 'abcdefghi')).toBe('abc'); + }); + + it('should work if lcs is whole second string', function () { + expect(longestCommonSubsequence('qwerty', 'rty')).toBe('rty'); + }); + + it('should work with repeated letter', function () { + expect(longestCommonSubsequence('AAATC', 'GGTAGGC')).toBe('AC'); + }); + + it('should work with custom characters', function () { + expect(longestCommonSubsequence(':-)', 'B-)')).toBe('-)'); + }); + + it('should work with long strings', function () { + expect(longestCommonSubsequence('this is the first string', 'that is second')).toBe('tht is sn'); + }); + + it('should work with very long strings', function () { + expect(longestCommonSubsequence('giiiiiiit1huuuuuu2bbb', 'zzxxcvasdfgmntplpliiggggu2b222')).toBe('giiu2b'); + }); +}); From b589f9bb6115752ab12ef93a9076303882f06354 Mon Sep 17 00:00:00 2001 From: Krzysztof Grzybek Date: Fri, 23 Dec 2016 21:03:35 +0100 Subject: [PATCH 516/613] Implement longest common subsequence algorithm --- src/searching/longest-common-subsequence.js | 44 +++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/searching/longest-common-subsequence.js diff --git a/src/searching/longest-common-subsequence.js b/src/searching/longest-common-subsequence.js new file mode 100644 index 00000000..e0286944 --- /dev/null +++ b/src/searching/longest-common-subsequence.js @@ -0,0 +1,44 @@ +(function (exports) { + 'use strict'; + + exports.longestCommonSubsequence = (function () { + + function getLcsLengths(str1, str2) { + var result = []; + for (var i = -1; i < str1.length; i = i + 1) { + result[i] = []; + for (var j = -1; j < str2.length; j = j + 1) { + if (i === -1 || j === -1) { + result[i][j] = 0; + } else if (str1[i] === str2[j]) { + result[i][j] = result[i - 1][j - 1] + 1; + } else { + result[i][j] = Math.max(result[i - 1][j], result[i][j - 1]); + } + } + } + return result; + } + + function getLcs(str1, str2, lcsLengthsMatrix) { + var execute = function (i, j) { + if (!lcsLengthsMatrix[i][j]) { + return ''; + } else if (str1[i] === str2[j]) { + return execute(i - 1, j - 1) + str1[i]; + } else if (lcsLengthsMatrix[i][j - 1] > lcsLengthsMatrix[i - 1][j]) { + return execute(i, j - 1); + } else { + return execute(i - 1, j); + } + }; + return execute(str1.length - 1, str2.length - 1); + } + + return function (str1, str2) { + var lcsLengthsMatrix = getLcsLengths(str1, str2); + return getLcs(str1, str2, lcsLengthsMatrix); + }; + })(); + +})(typeof window === 'undefined' ? module.exports : window); From 57989d5a010610338ce5cdfc3aca0504ebd1f08b Mon Sep 17 00:00:00 2001 From: Krzysztof Grzybek Date: Fri, 23 Dec 2016 21:40:24 +0100 Subject: [PATCH 517/613] Add docs for longest common subsequence algorithm --- src/searching/longest-common-subsequence.js | 42 +++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/searching/longest-common-subsequence.js b/src/searching/longest-common-subsequence.js index e0286944..01361142 100644 --- a/src/searching/longest-common-subsequence.js +++ b/src/searching/longest-common-subsequence.js @@ -3,6 +3,19 @@ exports.longestCommonSubsequence = (function () { + /** + * Find the lengths of longest common sub-sequences + * of two strings and their substrings. + * + * Complexity: O(MN). + * + * @private + * @param {String} first string + * @param {String} second string + * @return {Array} two dimensional array with LCS + * lengths of input strings and their substrings. + * + */ function getLcsLengths(str1, str2) { var result = []; for (var i = -1; i < str1.length; i = i + 1) { @@ -20,6 +33,19 @@ return result; } + /** + * Find longest common sub-sequences of two strings. + * + * Complexity: O(M + N). + * + * @private + * @param {String} first string + * @param {String} second string + * @return {Array} two dimensional array with LCS + * lengths of input strings and their substrings + * returned from 'getLcsLengths' function. + * + */ function getLcs(str1, str2, lcsLengthsMatrix) { var execute = function (i, j) { if (!lcsLengthsMatrix[i][j]) { @@ -35,6 +61,22 @@ return execute(str1.length - 1, str2.length - 1); } + /** + * Algorithm from dynamic programming. It finds the longest + * common sub-sequence of two strings. For example for strings 'abcd' + * and 'axxcda' the longest common sub-sequence is 'acd'. + * + * @example + * var subsequence = require('path-to-algorithms/src/searching/'+ + * 'longest-common-subsequence').longestCommonSubsequence; + * console.log(subsequence('abcd', 'axxcda'); // 'acd' + * + * @public + * @module searching/longest-common-subsequence + * @param {String} first input string. + * @param {String} second input string. + * @return {Array} Longest common subsequence. + */ return function (str1, str2) { var lcsLengthsMatrix = getLcsLengths(str1, str2); return getLcs(str1, str2, lcsLengthsMatrix); From eba273b314456c7e0447d30755db9b259e9609ad Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 5 Jan 2017 11:46:32 +0200 Subject: [PATCH 518/613] docs: update the list of contributors --- readme.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/readme.md b/readme.md index 0c47c952..58f6cd1e 100644 --- a/readme.md +++ b/readme.md @@ -71,17 +71,21 @@ If the build is not successful fix your code in order the tests and jshint valid ## Contributors -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[pvoznenko](https://github.com/pvoznenko) |[filipefalcaos](https://github.com/filipefalcaos) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) | :---: |:---: |:---: |:---: |:---: |:---: | -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[pvoznenko](https://github.com/pvoznenko) |[filipefalcaos](https://github.com/filipefalcaos) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) | -[lekkas](https://github.com/lekkas) |[deniskyashif](https://github.com/deniskyashif) |[infusion](https://github.com/infusion) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[ysharplanguage](https://github.com/ysharplanguage) | +[filipefalcaos](https://github.com/filipefalcaos) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) | :---: |:---: |:---: |:---: |:---: |:---: | -[lekkas](https://github.com/lekkas) |[deniskyashif](https://github.com/deniskyashif) |[infusion](https://github.com/infusion) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[ysharplanguage](https://github.com/ysharplanguage) | +[filipefalcaos](https://github.com/filipefalcaos) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) | -[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | -:---: |:---: | -[contra](https://github.com/contra) |[fanixk](https://github.com/fanixk) | +[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[mik-laj](https://github.com/mik-laj) |[amilajack](https://github.com/amilajack) |[ysharplanguage](https://github.com/ysharplanguage) |[contra](https://github.com/contra) | +:---: |:---: |:---: |:---: |:---: |:---: | +[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[mik-laj](https://github.com/mik-laj) |[amilajack](https://github.com/amilajack) |[ysharplanguage](https://github.com/ysharplanguage) |[contra](https://github.com/contra) | + +[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) | +:---: |:---: |:---: | +[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) | ## License From 34217fff31436c30a9c1c076bed3822eff070f6e Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 10 Feb 2017 16:31:53 -0800 Subject: [PATCH 519/613] feat(DataStructures): add segment tree --- src/data-structures/segment-tree.js | 105 ++++++++++++++++++++++ test/data-structures/segment-tree.spec.js | 89 ++++++++++++++++++ 2 files changed, 194 insertions(+) create mode 100644 src/data-structures/segment-tree.js create mode 100644 test/data-structures/segment-tree.spec.js diff --git a/src/data-structures/segment-tree.js b/src/data-structures/segment-tree.js new file mode 100644 index 00000000..4acc1f60 --- /dev/null +++ b/src/data-structures/segment-tree.js @@ -0,0 +1,105 @@ +/** + * Implementation of a segment tree. + * + * @example + * var SegmentTree = require('path-to-algorithms/src/data-structures'+ + * '/segment-tree').SegmentTree; + * + * var tree = SegmentTree.indexArray([-1, 2, 4, 0], Infinity, function (a, b) { + * return Math.min(a, b); + * }); + * + * @public + * @constructor + * @param {any} placeholder A placeholder value dpendent on the aggregate. + * @param {Function} aggregate Generates the values for the intermediate nodes. + * @module data-structures/segment-tree + */ +(function (exports) { + + 'use strict'; + + /** + * SegmentTree constructor. + * + * @public + * @constructor + * @param {any} invalidValue Invalid value to be returned depending + * on the aggregate. + * @param {Function} aggregate Function to generate the intermediate + * values in the tree. + */ + function SegmentTree(invalidValue, aggregate) { + this._data = []; + this._original = null; + this._invalidValue = invalidValue; + this._aggregate = aggregate; + } + + /** + * Creates a segment tree using an array passed as element. + * + * @static + * @public + * @param {Array} array Array to be indexed. + * @param {Function} aggregate Function used for generation of + * intermediate nodes. + */ + SegmentTree.indexArray = function (array, placeholder, aggregate) { + var segmentize = function (original, data, lo, hi, idx) { + if (lo === hi) { + data[idx] = original[lo]; + } else { + var mid = Math.floor((lo + hi) / 2); + var left = 2 * idx + 1; + var right = 2 * idx + 2; + segmentize(original, data, lo, mid, left); + segmentize(original, data, mid + 1, hi, right); + data[idx] = aggregate(data[left], data[right]); + } + }; + var result = []; + if (array && array.length) { + segmentize(array, result, 0, array.length - 1, 0); + } + var tree = new SegmentTree(placeholder, aggregate); + tree._data = result; + tree._original = array; + return tree; + }; + + /** + * Queries the SegmentTree in given range based on the set aggregate. + * + * @param {Number} start The start index of the interval. + * @param {Number} end The end index of the interval. + */ + SegmentTree.prototype.query = function (start, end) { + if (start > end) { + throw new Error('The start index should be smaller by the end index'); + } + var findEl = function (originalArrayStart, originalArrayEnd, current) { + if (start > originalArrayEnd) { + return this._invalidValue; + } + if (end < originalArrayStart) { + return this._invalidValue; + } + if (start === originalArrayStart && end === originalArrayEnd || + originalArrayStart === originalArrayEnd) { + return this._data[current]; + } + var originalArrayMid = + Math.floor((originalArrayStart + originalArrayEnd) / 2); + return this._aggregate( + findEl(originalArrayStart, originalArrayMid, 2 * current + 1), + findEl(originalArrayMid + 1, originalArrayEnd, 2 * current + 2) + ); + }.bind(this); + return findEl(0, this._original.length - 1, 0, this._aggregate); + }; + + exports.SegmentTree = SegmentTree; + +}(typeof window === 'undefined' ? module.exports : window)); + diff --git a/test/data-structures/segment-tree.spec.js b/test/data-structures/segment-tree.spec.js new file mode 100644 index 00000000..4679d5cd --- /dev/null +++ b/test/data-structures/segment-tree.spec.js @@ -0,0 +1,89 @@ +'use strict'; + +var SegmentTree = require('../../src/data-structures/segment-tree.js') + .SegmentTree; + +var defaultAggregate = function (a, b) { + return Math.min(a, b); +}; + +describe('Segment Tree', function () { + + describe('indexing', function () { + + it('should be a constructor function', function () { + expect(typeof SegmentTree).toBe('function'); + }); + + it('should start with null original array', function () { + expect(new SegmentTree()._original).toBe(null); + }); + + it('should start with empty array as data', function () { + expect(new SegmentTree()._data).not.toBe(null); + expect(new SegmentTree()._data.length).toBe(0); + }); + + it('should work with empty arrays', function () { + var tree = SegmentTree.indexArray([], Infinity, defaultAggregate); + expect(tree._data).toBeTruthy(); + expect(tree._data.length).toBe(0); + }); + + it('should index arrays with one element', function () { + var tree = SegmentTree.indexArray([1], Infinity, defaultAggregate); + expect(tree._data).toBeTruthy(); + expect(tree._data.length).toBe(1); + }); + + it('should index any array', function () { + var tree = SegmentTree.indexArray([1, 2, 3], Infinity, defaultAggregate); + expect(tree._data).toEqual([1, 1, 3, 1, 2]); + + tree = SegmentTree.indexArray([1, 2, 3, 6], Infinity, defaultAggregate); + expect(tree._data).toEqual([1, 1, 3, 1, 2, 3, 6]); + }); + + }); + + describe('should find the proper value at given interval', function () { + + it('should properly find the minimum when in range', function () { + var tree = SegmentTree.indexArray([1], Infinity, defaultAggregate); + expect(tree.query(0, 0)).toBe(1); + + tree = SegmentTree.indexArray([1, 2], Infinity, defaultAggregate); + expect(tree.query(0, 0)).toBe(1); + expect(tree.query(0, 1)).toBe(1); + expect(tree.query(1, 1)).toBe(2); + + tree = SegmentTree.indexArray([1, -1, 2], Infinity, defaultAggregate); + expect(tree.query(0, 2)).toBe(-1); + expect(tree.query(0, 1)).toBe(-1); + expect(tree.query(1, 1)).toBe(-1); + expect(tree.query(1, 2)).toBe(-1); + expect(tree.query(2, 2)).toBe(2); + }); + + it('should properly find the minimum when outside range', function () { + var tree = SegmentTree.indexArray([1], Infinity, defaultAggregate); + expect(tree.query(0, 2)).toBe(1); + + tree = SegmentTree.indexArray([1, 2, 3], Infinity, defaultAggregate); + expect(tree.query(0, 20)).toBe(1); + expect(tree.query(2, 20)).toBe(3); + expect(Number.isFinite(tree.query(20, 25))).toBe(false); + }); + + it('should throw when the start index is bigger than end', function () { + var tree = SegmentTree.indexArray([1], Infinity, defaultAggregate); + expect(function () { + tree.query(2, 1); + }).toThrow(); + expect(function () { + tree.query(1, 1); + }).not.toThrow(); + }); + }); +}); + From 8369dca78cbfc04fdddbd360e1d13fc90440f0c8 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 27 Feb 2017 20:14:32 -0800 Subject: [PATCH 520/613] docs: update readme --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 58f6cd1e..50b3aaa8 100644 --- a/readme.md +++ b/readme.md @@ -90,3 +90,4 @@ If the build is not successful fix your code in order the tests and jshint valid ## License The code in this repository is distributed under the terms of the MIT license. + From 40b0658968be46a3b4c5087b8032d2088b826ee5 Mon Sep 17 00:00:00 2001 From: shaunak Date: Wed, 22 Mar 2017 15:06:30 +0530 Subject: [PATCH 521/613] Level Order Traversal for red black tree using queue. --- src/data-structures/red-black-tree.js | 30 +++++++++++++++++++++ test/data-structures/red-black-tree.spec.js | 16 +++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index 2a6c487d..997dc8cd 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -266,4 +266,34 @@ } }; + /** + * Get Level Order Traversal for the given Red Black Tree, + * returns 'Tree is empty' string when tree has no Nodes. + * Complexity: O(N). + * + * @public + * @return {String} The keys of the tree in level order traversal. + * + */ + exports.RBTree.prototype.levelOrderTraversal = function () { + var queue = []; + var levelOrderString = ''; + if (this._root){ + queue.push(this._root); + }else { + levelOrderString = ' Tree is empty'; + } + while (queue.length !== 0){ + var tempNode = queue.shift(); + levelOrderString += ' ' + tempNode.getKey(); + if (tempNode.getLeft() !== null){ + queue.push(tempNode.getLeft()); + } + if (tempNode.getRight() !== null){ + queue.push(tempNode.getRight()); + } + } + return 'Level Order Traversal -:' + levelOrderString; + }; + })(typeof window === 'undefined' ? module.exports : window); diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index ca2ab9bd..085de6a8 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -97,4 +97,20 @@ describe('RBTree', function () { }); }); + describe('levelOrderTraversal method', function () { + it('should be able to traverse tree in level order', function () { + var tree = new RBTree(); + expect(tree.levelOrderTraversal()).toBe('Level Order Traversal -: Tree is empty'); + tree.put(10); + tree.put(20); + expect(tree.levelOrderTraversal()).toBe('Level Order Traversal -: 20 10'); + tree.put(30); + expect(tree.levelOrderTraversal()).toBe('Level Order Traversal -: 20 10 30'); + tree.put(45); + expect(tree.levelOrderTraversal()).toBe('Level Order Traversal -: 20 10 45 30'); + tree.put(5); + expect(tree.levelOrderTraversal()).toBe('Level Order Traversal -: 20 10 45 5 30'); + }); + }); + }); From 26c4f33a06d21fc4d48672c04bd444fe6dda1b3d Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 2 May 2017 23:50:52 -0700 Subject: [PATCH 522/613] docs: update the list of contributors --- readme.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index 50b3aaa8..7e5e212a 100644 --- a/readme.md +++ b/readme.md @@ -71,21 +71,21 @@ If the build is not successful fix your code in order the tests and jshint valid ## Contributors -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) | :---: |:---: |:---: |:---: |:---: |:---: | [mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) | -[filipefalcaos](https://github.com/filipefalcaos) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) | +[filipefalcaos](https://github.com/filipefalcaos) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) | :---: |:---: |:---: |:---: |:---: |:---: | [filipefalcaos](https://github.com/filipefalcaos) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) | -[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[mik-laj](https://github.com/mik-laj) |[amilajack](https://github.com/amilajack) |[ysharplanguage](https://github.com/ysharplanguage) |[contra](https://github.com/contra) | +[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[mik-laj](https://github.com/mik-laj) |[amilajack](https://github.com/amilajack) |[ysharplanguage](https://github.com/ysharplanguage) |[contra](https://github.com/contra) | :---: |:---: |:---: |:---: |:---: |:---: | [pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[mik-laj](https://github.com/mik-laj) |[amilajack](https://github.com/amilajack) |[ysharplanguage](https://github.com/ysharplanguage) |[contra](https://github.com/contra) | -[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) | -:---: |:---: |:---: | -[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) | +[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[shaunak1111](https://github.com/shaunak1111) | +:---: |:---: |:---: |:---: | +[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[shaunak1111](https://github.com/shaunak1111) | ## License From 6da97dd53bf1b784888cba671c9cea073462b534 Mon Sep 17 00:00:00 2001 From: Kado Date: Fri, 12 May 2017 10:53:45 +0200 Subject: [PATCH 523/613] Swap the two using es6 deconstruction --- src/shuffle/fisheryates.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/shuffle/fisheryates.js b/src/shuffle/fisheryates.js index 2951ff0a..ccb26734 100644 --- a/src/shuffle/fisheryates.js +++ b/src/shuffle/fisheryates.js @@ -20,12 +20,9 @@ function shuffle(array) { var size = array.length; var rand; - var temp; for (var i = 0; i < size; i += 1) { rand = Math.floor(i + Math.random() * (size - i)); - temp = array[rand]; - array[rand] = array[i]; - array[i] = temp; + [array[rand], array[i]] = [array[i], array[rand]]; } return array; } From 61ca87e1046d709b4aefcbfd89c31584de5b9c8e Mon Sep 17 00:00:00 2001 From: Kado Date: Fri, 12 May 2017 11:36:23 +0200 Subject: [PATCH 524/613] Update readme.md --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 7e5e212a..18369f48 100644 --- a/readme.md +++ b/readme.md @@ -83,9 +83,9 @@ If the build is not successful fix your code in order the tests and jshint valid :---: |:---: |:---: |:---: |:---: |:---: | [pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[mik-laj](https://github.com/mik-laj) |[amilajack](https://github.com/amilajack) |[ysharplanguage](https://github.com/ysharplanguage) |[contra](https://github.com/contra) | -[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[shaunak1111](https://github.com/shaunak1111) | +[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[shaunak1111](https://github.com/shaunak1111) | |[kdamball](https://github.com/kdamball) | :---: |:---: |:---: |:---: | -[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[shaunak1111](https://github.com/shaunak1111) | +[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[shaunak1111](https://github.com/shaunak1111) |[kdamball](https://github.com/kdamball) | ## License From 47e36a4723a321936667bb4bab2b1212e67fa5e8 Mon Sep 17 00:00:00 2001 From: Kado Date: Fri, 12 May 2017 11:48:25 +0200 Subject: [PATCH 525/613] fix Contributions table layout --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 18369f48..e20eeea0 100644 --- a/readme.md +++ b/readme.md @@ -83,8 +83,8 @@ If the build is not successful fix your code in order the tests and jshint valid :---: |:---: |:---: |:---: |:---: |:---: | [pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[mik-laj](https://github.com/mik-laj) |[amilajack](https://github.com/amilajack) |[ysharplanguage](https://github.com/ysharplanguage) |[contra](https://github.com/contra) | -[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[shaunak1111](https://github.com/shaunak1111) | |[kdamball](https://github.com/kdamball) | -:---: |:---: |:---: |:---: | +[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[shaunak1111](https://github.com/shaunak1111)|[kdamball](https://github.com/kdamball) | +:---: |:---: |:---: |:---: |:---: | [liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[shaunak1111](https://github.com/shaunak1111) |[kdamball](https://github.com/kdamball) | ## License From e2abe6b898c81359daf8752f17c5dc85aa9b7efb Mon Sep 17 00:00:00 2001 From: Jett Calleja Date: Fri, 12 May 2017 18:23:39 +0800 Subject: [PATCH 526/613] add Minkowski Distance --- src/others/minkowski-distance.js | 84 ++++++++++++++++++++++++++ test/others/minkowski-distance.spec.js | 42 +++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 src/others/minkowski-distance.js create mode 100644 test/others/minkowski-distance.spec.js diff --git a/src/others/minkowski-distance.js b/src/others/minkowski-distance.js new file mode 100644 index 00000000..caf662fb --- /dev/null +++ b/src/others/minkowski-distance.js @@ -0,0 +1,84 @@ +(function (exports) { + 'use strict'; + + var minkowskiDistance = (function () { + + function chebyshevDistance (x, y, lx, p, mathfn) { + var ret = -p; + var i; + + for (i = 0; i < lx; i++) { + ret = mathfn(ret, Math.abs(x[i] - y[i])); + } + + return ret; + } + + function minkowskiDistance (x, lx, y, ly, p) { + var d; + var i; + + if (lx !== ly) { + throw '2 points must have same array length'; + } + + if (isNaN(p)) { + throw 'p must be a number'; + } + + if (p === Number.POSITIVE_INFINITY) { + return chebyshevDistance(x, y, lx, p, Math.max); + } + else if (p === Number.NEGATIVE_INFINITY) { + return chebyshevDistance(x, y, lx, p, Math.min); + } + else if (p < 1) { + throw 'p less than 1 will violate triangle inequality'; + } + else { + d = 0; + + for (i = 0; i < lx; i++) { + d += Math.pow(Math.abs(x[i] - y[i]), p); + } + + return isNaN(d) + ? 0 + : Math.pow(d, 1/p); + } + + } + + + /** + * The Minkowski distance between two points gets generalized + * metric distance + * + * when p === 1, this becomes same as Manhattan Distance + * when p === 2, this becomes same as Euclidean Distance + * when p === Positive or Negative Infinity, + * this becomes chebyshev distance + * + * @public + * @module others/minkowski-distance + * + * @example + * var dist = require('path-to-algorithms/src/others/' + + * 'minkowski-distance').minkowskiDistance; + * console.log(dist([0, 1], [1, 1], 2)); // 1 + * + * @param {Array} x source point + * @param {Array} y target point + * @param {Number} p order of Minkowski distance + * @returns {Number} distance between two points, if distance + * is NaN, then this returns 0 + */ + return function (x, y, p) { + return minkowskiDistance (x, x.length, y, y.length, p); + } + }()); + + + exports.minkowskiDistance = minkowskiDistance; + +}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file diff --git a/test/others/minkowski-distance.spec.js b/test/others/minkowski-distance.spec.js new file mode 100644 index 00000000..cd97f3fe --- /dev/null +++ b/test/others/minkowski-distance.spec.js @@ -0,0 +1,42 @@ +'use strict'; + +var mod = require('../../src/others/minkowski-distance.js'); +var minkowskiDistance = mod.minkowskiDistance; + +describe('Minkowski Distance', function () { + it('should return 1 with points (0, 1), (1, 1) in order 1.', function () { + expect(minkowskiDistance([0, 1], [1, 1], 1)).toBe(1); + }); + it('should return 2 with points (0, 1), (1, 1) in order 2.', function () { + expect(minkowskiDistance([0, 1], [1, 1], 2)).toBe(1); + }); + it('should return 2 with points (0, 1, 4), (1, 1, 6) in order Positive Infinity.', function () { + expect(minkowskiDistance([0, 1, 4], [1, 1, 6], Number.POSITIVE_INFINITY)).toBe(2); + }); + it('should return 0 with points (0, 1, 4), (1, 1, 6) in order Negative Infinity.', function () { + expect(minkowskiDistance([0, 1, 4], [1, 1, 6], Number.NEGATIVE_INFINITY)).toBe(0); + }); + it('should return 8.372966759705923 with points (0, 3, 4, 5), (7, 6, 3, -1) in order 3.', function () { + expect(minkowskiDistance([0, 1, 4], [1, 1, 6], Number.NEGATIVE_INFINITY)).toBe(0); + }); + it('should throw when 2 points are not in equal length', function () { + expect( function () { + minkowskiDistance([1, 2], [1], 1) + }).toThrow('2 points must have same array length'); + }); + it('should throw when p is not defined', function () { + expect( function () { + minkowskiDistance([1, 2], [1, 2]) + }).toThrow('p must be a number'); + }); + it('should throw when p is not a number', function () { + expect( function () { + minkowskiDistance([1, 2], [1, 2], NaN) + }).toThrow('p must be a number'); + }); + it('should throw when p is less than 1', function () { + expect( function () { + minkowskiDistance([1, 2], [1, 2], 0) + }).toThrow('p less than 1 will violate triangle inequality'); + }); +}); From 5ec5a9bd043daff88bda5851b90c9c35ba732ead Mon Sep 17 00:00:00 2001 From: Jett Calleja Date: Fri, 12 May 2017 18:48:40 +0800 Subject: [PATCH 527/613] JsLint --- src/others/minkowski-distance.js | 31 +++++++++++--------------- test/others/minkowski-distance.spec.js | 8 +++---- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/others/minkowski-distance.js b/src/others/minkowski-distance.js index caf662fb..bccecd85 100644 --- a/src/others/minkowski-distance.js +++ b/src/others/minkowski-distance.js @@ -6,10 +6,10 @@ function chebyshevDistance (x, y, lx, p, mathfn) { var ret = -p; var i; - - for (i = 0; i < lx; i++) { + + for (i = 0; i < lx; i += 1) { ret = mathfn(ret, Math.abs(x[i] - y[i])); - } + } return ret; } @@ -28,32 +28,28 @@ if (p === Number.POSITIVE_INFINITY) { return chebyshevDistance(x, y, lx, p, Math.max); - } - else if (p === Number.NEGATIVE_INFINITY) { + } else if (p === Number.NEGATIVE_INFINITY) { return chebyshevDistance(x, y, lx, p, Math.min); - } - else if (p < 1) { + } else if (p < 1) { throw 'p less than 1 will violate triangle inequality'; - } - else { + } else { d = 0; - for (i = 0; i < lx; i++) { + for (i = 0; i < lx; i += 1) { d += Math.pow(Math.abs(x[i] - y[i]), p); } return isNaN(d) ? 0 - : Math.pow(d, 1/p); + : Math.pow(d, 1 / p); + } } - /** - * The Minkowski distance between two points gets generalized + * The Minkowski distance between two points gets generalized * metric distance - * * when p === 1, this becomes same as Manhattan Distance * when p === 2, this becomes same as Euclidean Distance * when p === Positive or Negative Infinity, @@ -66,7 +62,7 @@ * var dist = require('path-to-algorithms/src/others/' + * 'minkowski-distance').minkowskiDistance; * console.log(dist([0, 1], [1, 1], 2)); // 1 - * + * * @param {Array} x source point * @param {Array} y target point * @param {Number} p order of Minkowski distance @@ -75,10 +71,9 @@ */ return function (x, y, p) { return minkowskiDistance (x, x.length, y, y.length, p); - } + }; }()); - exports.minkowskiDistance = minkowskiDistance; -}(typeof exports === 'undefined' ? window : exports)); \ No newline at end of file +}(typeof exports === 'undefined' ? window : exports)); diff --git a/test/others/minkowski-distance.spec.js b/test/others/minkowski-distance.spec.js index cd97f3fe..9a5089cb 100644 --- a/test/others/minkowski-distance.spec.js +++ b/test/others/minkowski-distance.spec.js @@ -20,22 +20,22 @@ describe('Minkowski Distance', function () { expect(minkowskiDistance([0, 1, 4], [1, 1, 6], Number.NEGATIVE_INFINITY)).toBe(0); }); it('should throw when 2 points are not in equal length', function () { - expect( function () { + expect(function () { minkowskiDistance([1, 2], [1], 1) }).toThrow('2 points must have same array length'); }); it('should throw when p is not defined', function () { - expect( function () { + expect(function () { minkowskiDistance([1, 2], [1, 2]) }).toThrow('p must be a number'); }); it('should throw when p is not a number', function () { - expect( function () { + expect(function () { minkowskiDistance([1, 2], [1, 2], NaN) }).toThrow('p must be a number'); }); it('should throw when p is less than 1', function () { - expect( function () { + expect(function () { minkowskiDistance([1, 2], [1, 2], 0) }).toThrow('p less than 1 will violate triangle inequality'); }); From f789338a64744d5609b94b5c9d815a276ae06158 Mon Sep 17 00:00:00 2001 From: Jett Calleja Date: Sat, 13 May 2017 11:33:54 +0800 Subject: [PATCH 528/613] update requested changes --- src/others/minkowski-distance.js | 6 +++--- test/others/minkowski-distance.spec.js | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/others/minkowski-distance.js b/src/others/minkowski-distance.js index bccecd85..e917bf80 100644 --- a/src/others/minkowski-distance.js +++ b/src/others/minkowski-distance.js @@ -19,11 +19,11 @@ var i; if (lx !== ly) { - throw '2 points must have same array length'; + throw 'Both vectors should have same dimension'; } if (isNaN(p)) { - throw 'p must be a number'; + throw 'The order "p" must be a number'; } if (p === Number.POSITIVE_INFINITY) { @@ -31,7 +31,7 @@ } else if (p === Number.NEGATIVE_INFINITY) { return chebyshevDistance(x, y, lx, p, Math.min); } else if (p < 1) { - throw 'p less than 1 will violate triangle inequality'; + throw 'Order less than 1 will violate the triangle inequality'; } else { d = 0; diff --git a/test/others/minkowski-distance.spec.js b/test/others/minkowski-distance.spec.js index 9a5089cb..fad96dff 100644 --- a/test/others/minkowski-distance.spec.js +++ b/test/others/minkowski-distance.spec.js @@ -17,26 +17,26 @@ describe('Minkowski Distance', function () { expect(minkowskiDistance([0, 1, 4], [1, 1, 6], Number.NEGATIVE_INFINITY)).toBe(0); }); it('should return 8.372966759705923 with points (0, 3, 4, 5), (7, 6, 3, -1) in order 3.', function () { - expect(minkowskiDistance([0, 1, 4], [1, 1, 6], Number.NEGATIVE_INFINITY)).toBe(0); + expect(minkowskiDistance([0, 3, 4, 5], [7, 6, 3, -1], 3)).toBe(8.372966759705923); }); - it('should throw when 2 points are not in equal length', function () { + it('should throw when both vectors don\'t have same dimension', function () { expect(function () { minkowskiDistance([1, 2], [1], 1) - }).toThrow('2 points must have same array length'); + }).toThrow('Both vectors should have same dimension'); }); it('should throw when p is not defined', function () { expect(function () { minkowskiDistance([1, 2], [1, 2]) - }).toThrow('p must be a number'); + }).toThrow('The order "p" must be a number'); }); it('should throw when p is not a number', function () { expect(function () { minkowskiDistance([1, 2], [1, 2], NaN) - }).toThrow('p must be a number'); + }).toThrow('The order "p" must be a number'); }); it('should throw when p is less than 1', function () { expect(function () { minkowskiDistance([1, 2], [1, 2], 0) - }).toThrow('p less than 1 will violate triangle inequality'); + }).toThrow('Order less than 1 will violate the triangle inequality'); }); }); From 8f39577eb3d74e90127b80cd32d4ff111e915ca6 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 13 May 2017 09:50:10 -0700 Subject: [PATCH 529/613] docs: update the list of contributors --- readme.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/readme.md b/readme.md index 7e5e212a..bfa865b3 100644 --- a/readme.md +++ b/readme.md @@ -75,17 +75,17 @@ If the build is not successful fix your code in order the tests and jshint valid :---: |:---: |:---: |:---: |:---: |:---: | [mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) | -[filipefalcaos](https://github.com/filipefalcaos) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) | +[jettcalleja](https://github.com/jettcalleja) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[filipefalcaos](https://github.com/filipefalcaos) | :---: |:---: |:---: |:---: |:---: |:---: | -[filipefalcaos](https://github.com/filipefalcaos) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) | +[jettcalleja](https://github.com/jettcalleja) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[filipefalcaos](https://github.com/filipefalcaos) | -[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[mik-laj](https://github.com/mik-laj) |[amilajack](https://github.com/amilajack) |[ysharplanguage](https://github.com/ysharplanguage) |[contra](https://github.com/contra) | +[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[mik-laj](https://github.com/mik-laj) |[amilajack](https://github.com/amilajack) | :---: |:---: |:---: |:---: |:---: |:---: | -[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[mik-laj](https://github.com/mik-laj) |[amilajack](https://github.com/amilajack) |[ysharplanguage](https://github.com/ysharplanguage) |[contra](https://github.com/contra) | +[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[mik-laj](https://github.com/mik-laj) |[amilajack](https://github.com/amilajack) | -[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[shaunak1111](https://github.com/shaunak1111) | -:---: |:---: |:---: |:---: | -[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[shaunak1111](https://github.com/shaunak1111) | +[ysharplanguage](https://github.com/ysharplanguage) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[shaunak1111](https://github.com/shaunak1111) | +:---: |:---: |:---: |:---: |:---: |:---: | +[ysharplanguage](https://github.com/ysharplanguage) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[shaunak1111](https://github.com/shaunak1111) | ## License From fbd2d69803a26cc42305aa71b296e6ff7d79f522 Mon Sep 17 00:00:00 2001 From: zouyun Date: Wed, 17 May 2017 18:23:55 +0800 Subject: [PATCH 530/613] update dijkstra --- src/graphs/shortest-path/dijkstra.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index 2b08fc1e..a2daf924 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -92,7 +92,7 @@ * var shortestDist = dijkstra(0, 2, distMatrix); // 9 */ return function (src, dest, graph) { - var tempDistance = 0; + var tempDistance = 0; init(src, graph); while (current.node !== dest && isFinite(current.distance)) { for (var i = 0; i < graph.length; i += 1) { @@ -100,11 +100,10 @@ !visited[i] && //and if we haven't visited this node //and this node is sibling of the current... Number.isFinite(graph[i][current.node])) { - + tempDistance = current.distance + graph[i][current.node]; if (tempDistance < distance[i].distance) { distance[i].distance = tempDistance; - current.distance = tempDistance; unvisited.update(current); } } From 684eb10883a2ce7875c7b0288c1a4d68b738959d Mon Sep 17 00:00:00 2001 From: zouyun Date: Wed, 17 May 2017 18:25:45 +0800 Subject: [PATCH 531/613] delete trailing space --- src/graphs/shortest-path/dijkstra.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphs/shortest-path/dijkstra.js b/src/graphs/shortest-path/dijkstra.js index a2daf924..ea4a38e0 100644 --- a/src/graphs/shortest-path/dijkstra.js +++ b/src/graphs/shortest-path/dijkstra.js @@ -100,7 +100,7 @@ !visited[i] && //and if we haven't visited this node //and this node is sibling of the current... Number.isFinite(graph[i][current.node])) { - + tempDistance = current.distance + graph[i][current.node]; if (tempDistance < distance[i].distance) { distance[i].distance = tempDistance; From fe7e23550fc39cf76ee3829594be53b0c448500d Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 6 Jun 2017 23:17:00 -0400 Subject: [PATCH 532/613] build(lint): use eslint --- .eslintrc.json | 144 + .jscsrc | 3 +- gulpfile.js | 19 +- package-lock.json | 2343 +++++++++++++++++ package.json | 5 +- src/data-structures/avl-tree.js | 58 +- src/data-structures/binary-search-tree.js | 9 +- src/data-structures/interval-tree.js | 3 +- src/data-structures/red-black-tree.js | 2 +- src/data-structures/size-balanced-tree.js | 5 +- src/graphs/spanning-trees/prim.js | 67 +- .../longest-increasing-subsequence.js | 4 +- test/data-structures/avl-tree.spec.js | 6 +- .../binary-search-tree.spec.js | 6 +- test/data-structures/hash-table.spec.js | 6 +- test/data-structures/heap.spec.js | 4 +- test/data-structures/interval-tree.spec.js | 4 +- test/data-structures/linked-list.spec.js | 13 +- test/data-structures/red-black-tree.spec.js | 5 +- test/data-structures/segment-tree.spec.js | 4 +- .../size-balanced-tree.spec.js | 30 +- test/data-structures/splay-tree.spec.js | 6 +- test/graphs/searching/bfs.spec.js | 3 +- test/graphs/searching/dfs.spec.js | 28 +- test/others/fibonacci.spec.js | 4 +- test/others/levenshtein-distance.spec.js | 4 +- test/others/min-coins-sum.spec.js | 11 +- test/others/minkowski-distance.spec.js | 4 +- test/primes/is-prime.spec.js | 7 +- test/primes/prime-factor-tree.spec.js | 8 +- test/primes/sieve-of-eratosthenes.spec.js | 11 +- test/searching/binarysearch.spec.js | 3 +- .../longest-common-subsequence.spec.js | 3 +- .../longest-increasing-subsequence.spec.js | 3 +- ...aximum-subarray-divide-and-conquer.spec.js | 3 +- test/searching/recursive-binarysearch.spec.js | 3 +- 36 files changed, 2656 insertions(+), 185 deletions(-) create mode 100644 .eslintrc.json create mode 100644 package-lock.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..0c7a9c7b --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,144 @@ +{ + "env": { + "browser": true, + "jquery": true, + "node": true + }, + "globals": { + "expect": true, + "it": true, + "describe": true, + "beforeEach": true, + "afterEach": true + }, + "parserOptions": { + "ecmaVersion": 6 + }, + "rules": { + + "camelcase": 2, + "curly": 2, + "eqeqeq": 2, + "indent": [ + 2, + 2, + { + "SwitchCase": 1 + } + ], + "no-use-before-define": [ + 2, + { + "functions": false + } + ], + "no-caller": 2, + "new-cap": 0, + "quotes": [ + 2, + "single" + ], + "no-unused-vars": 2, + "strict": [ + 2, + "function" + ], + "no-extend-native": 2, + "wrap-iife": [ + 2, + "any" + ], + "no-empty": 2, + "no-plusplus": 2, + "no-undef": 2, + "linebreak-style": 2, + "max-depth": [ + 2, + 4 + ], + "no-loop-func": 2, + "complexity": [ + 2, + 13 + ], + "max-len": [ + 2, + { + "code": 120, + "ignoreComments": true + } + ], + "max-params": [ + 2, + 5 + ], + + + "curly": [ + 2, + "all" + ], + "keyword-spacing": [ + 2, + {} + ], + "one-var": [ + 2, + "never" + ], + "array-bracket-spacing": [ + 2, + "never", + {} + ], + "space-in-parens": [ + 2, + "never" + ], + "key-spacing": [ + 2, + { + "beforeColon": false, + "afterColon": true + } + ], + "quote-props": [ + 2, + "as-needed" + ], + "space-infix-ops": 2, + "space-unary-ops": [ + 2, + { + "words": false, + "nonwords": false + } + ], + "no-implicit-coercion": [ + 2, + { + "boolean": false, + "string": true, + "number": true + } + ], + "no-with": 2, + "no-multiple-empty-lines": 2, + "brace-style": [ + 2, + "1tbs", + { + "allowSingleLine": true + } + ], + "eol-last": 2, + "no-trailing-spaces": 2, + "indent": [ + 2, + 2, + { + "SwitchCase": 1 + } + ] + } +} diff --git a/.jscsrc b/.jscsrc index 847fc3ee..c45cd225 100644 --- a/.jscsrc +++ b/.jscsrc @@ -5,7 +5,6 @@ "beforeOpeningCurlyBrace": true }, "disallowMultipleVarDecl": true, - "requireSpacesInsideObjectBrackets": "allButNested", "disallowSpacesInsideArrayBrackets": true, "disallowSpacesInsideParentheses": true, "disallowSpaceAfterObjectKeys": true, @@ -26,4 +25,4 @@ "disallowTrailingWhitespace": true, "excludeFiles": ["node_modules/**", "bower_components/**"], "validateIndentation": 2 -} \ No newline at end of file +} diff --git a/gulpfile.js b/gulpfile.js index 75f37af9..95f2a2c0 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,10 +1,8 @@ 'use strict'; var gulp = require('gulp'); var shell = require('gulp-shell'); -var jshint = require('gulp-jshint'); +var eslint = require('gulp-eslint'); var jasmine = require('gulp-jasmine'); -var stylish = require('jshint-stylish'); -var jscs = require('gulp-jscs'); var isWin = /^win/.test(process.platform); gulp.task('jsdoc', shell.task([ @@ -13,21 +11,16 @@ gulp.task('jsdoc', shell.task([ './node_modules/.bin/jsdoc -c ./doc-config.json' ])); -gulp.task('lint', function () { - return gulp.src(['./src/**/*.js'], ['./test/**/*.js']) - .pipe(jshint()) - .pipe(jshint.reporter(stylish)) - .pipe(jshint.reporter('fail')); -}); - gulp.task('test', function () { return gulp.src('test/**/*.spec.js') .pipe(jasmine()); }); -gulp.task('jscs', function () { +gulp.task('lint', function () { return gulp.src(['src/**/*.js', 'test/**/*.js']) - .pipe(jscs()); + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failAfterError()); }); -gulp.task('build', ['lint', 'jscs', 'test']); +gulp.task('build', ['lint', 'test']); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..0fbe7a4c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,2343 @@ +{ + "name": "javascript-algorithms", + "version": "0.0.0", + "lockfileVersion": 1, + "dependencies": { + "acorn": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.0.3.tgz", + "integrity": "sha1-xGDfCEkUY/AozLguqzcwvwEIez0=", + "dev": true + }, + "acorn-jsx": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", + "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", + "dev": true, + "dependencies": { + "acorn": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", + "dev": true + } + } + }, + "ajv": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", + "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", + "dev": true + }, + "ajv-keywords": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz", + "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=", + "dev": true + }, + "ansi-escapes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", + "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", + "dev": true + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "archy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", + "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", + "dev": true + }, + "argparse": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz", + "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=", + "dev": true + }, + "arr-diff": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", + "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", + "dev": true + }, + "arr-flatten": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.0.3.tgz", + "integrity": "sha1-onTthawIhJtr14R8RYB0XcUa37E=", + "dev": true + }, + "array-differ": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", + "integrity": "sha1-7/UuN1gknTO+QCuLuOVkuytdQDE=", + "dev": true + }, + "array-union": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", + "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "dev": true + }, + "array-uniq": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "dev": true + }, + "array-unique": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", + "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", + "dev": true + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", + "dev": true + }, + "async": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", + "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=", + "dev": true + }, + "babel-code-frame": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.22.0.tgz", + "integrity": "sha1-AnYgvuVnqIwyVhV05/0IAdMxGOQ=", + "dev": true + }, + "balanced-match": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz", + "integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=", + "dev": true + }, + "beeper": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/beeper/-/beeper-1.1.1.tgz", + "integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.7.tgz", + "integrity": "sha1-Pv/DxQ4ABTH7cg6v+A8K6O8jz1k=", + "dev": true + }, + "braces": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", + "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", + "dev": true + }, + "bufferstreams": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/bufferstreams/-/bufferstreams-1.1.1.tgz", + "integrity": "sha1-AWE3MGCsWYjv+ZBYcxEU9uGV1R4=", + "dev": true, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.2.11", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.11.tgz", + "integrity": "sha512-h+8+r3MKEhkiVrwdKL8aWs1oc1VvBu33ueshOvS26RsZQ3Amhx/oO3TKe4lApSV9ueY6as8EAh7mtuFjdlhg9Q==", + "dev": true + }, + "string_decoder": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.2.tgz", + "integrity": "sha1-sp4fThEl+pehA4K4pTNze3SR4Xk=", + "dev": true + } + } + }, + "caller-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", + "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", + "dev": true + }, + "callsites": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", + "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", + "dev": true + }, + "catharsis": { + "version": "0.8.8", + "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.8.tgz", + "integrity": "sha1-aTR59DqsVJ2Aa9c+kkzQ2USVGgY=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true + }, + "circular-json": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.1.tgz", + "integrity": "sha1-vos2rvzN6LPKeqLWr8B6NyQsDS0=", + "dev": true + }, + "cli-cursor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", + "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", + "dev": true + }, + "cli-table": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.1.tgz", + "integrity": "sha1-9TsFJmqLGguTSz0IIebi3FkUriM=", + "dev": true + }, + "cli-width": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.1.0.tgz", + "integrity": "sha1-sjTKIJsp72b8UY2bmNWEewDt8Ao=", + "dev": true + }, + "clone": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.2.tgz", + "integrity": "sha1-Jgt6meux7f4kdTgXX3gyQ8sZ0Uk=", + "dev": true + }, + "clone-stats": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", + "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=", + "dev": true + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "dev": true + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true + }, + "colors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", + "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=", + "dev": true + }, + "commander": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.6.0.tgz", + "integrity": "sha1-nfflL7Kgyw+4kFjugMMQQiXzfh0=", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "concat-stream": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", + "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", + "dev": true, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.2.11", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.11.tgz", + "integrity": "sha512-h+8+r3MKEhkiVrwdKL8aWs1oc1VvBu33ueshOvS26RsZQ3Amhx/oO3TKe4lApSV9ueY6as8EAh7mtuFjdlhg9Q==", + "dev": true + }, + "string_decoder": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.2.tgz", + "integrity": "sha1-sp4fThEl+pehA4K4pTNze3SR4Xk=", + "dev": true + } + } + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "cycle": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz", + "integrity": "sha1-IegLK+hYD5i0aPN5QwZisEbDStI=", + "dev": true + }, + "d": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", + "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", + "dev": true + }, + "dateformat": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.0.0.tgz", + "integrity": "sha1-J0Pjq7XD/CRi5SfcpEXgTp9N7hc=", + "dev": true + }, + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "dev": true + }, + "deep-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", + "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", + "dev": true + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, + "defaults": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", + "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", + "dev": true + }, + "del": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", + "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", + "dev": true, + "dependencies": { + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + } + } + }, + "deprecated": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/deprecated/-/deprecated-0.0.1.tgz", + "integrity": "sha1-+cmvVGSvoeepcUWKi97yqpTVuxk=", + "dev": true + }, + "detect-file": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-0.1.0.tgz", + "integrity": "sha1-STXe39lIhkjgBrASlWbpOGcR6mM=", + "dev": true + }, + "doctrine": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.0.tgz", + "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=", + "dev": true, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + } + } + }, + "duplexer2": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", + "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", + "dev": true + }, + "end-of-stream": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-0.1.5.tgz", + "integrity": "sha1-jhdyBsPICDfYVjLouTWd/osvbq8=", + "dev": true + }, + "es5-ext": { + "version": "0.10.23", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.23.tgz", + "integrity": "sha1-dXi1G+l0IHpUh4IbVlOMIk5Oezg=", + "dev": true + }, + "es6-iterator": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.1.tgz", + "integrity": "sha1-jjGcnwRTv1ddN0lAplWSDlnKVRI=", + "dev": true + }, + "es6-map": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/es6-map/-/es6-map-0.1.5.tgz", + "integrity": "sha1-kTbgUD3MBqMBaQ8LsU/042TpSfA=", + "dev": true + }, + "es6-set": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", + "integrity": "sha1-0rPsXU2ADO2BjbU40ol02wpzzLE=", + "dev": true + }, + "es6-symbol": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", + "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", + "dev": true + }, + "es6-weak-map": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz", + "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "escope": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/escope/-/escope-3.6.0.tgz", + "integrity": "sha1-4Bl16BJ4GhY6ba392AOY3GTIicM=", + "dev": true + }, + "eslint": { + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-3.19.0.tgz", + "integrity": "sha1-yPxiAcf0DdCJQbh8CFdnOGpnmsw=", + "dev": true, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, + "user-home": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", + "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=", + "dev": true + } + } + }, + "espree": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/espree/-/espree-3.4.3.tgz", + "integrity": "sha1-KRC1zNSc6JPC//+qtP2LOjG4I3Q=", + "dev": true + }, + "esprima": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", + "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=", + "dev": true + }, + "esprima-harmony-jscs": { + "version": "1.1.0-bin", + "resolved": "https://registry.npmjs.org/esprima-harmony-jscs/-/esprima-harmony-jscs-1.1.0-bin.tgz", + "integrity": "sha1-B8sFcdlD7tS8e/6ecmN8Zj/hUe0=", + "dev": true + }, + "esquery": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.0.tgz", + "integrity": "sha1-z7qLV9f7qT8XKYqKAGoEzaE9gPo=", + "dev": true + }, + "esrecurse": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.1.0.tgz", + "integrity": "sha1-RxO2U2rffyrE8yfVWed1a/9kgiA=", + "dev": true, + "dependencies": { + "estraverse": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.1.1.tgz", + "integrity": "sha1-9srKcokzqFDvkGYdDheYK6RxEaI=", + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + } + } + }, + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true + }, + "event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", + "dev": true + }, + "exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", + "dev": true + }, + "exit-hook": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz", + "integrity": "sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=", + "dev": true + }, + "expand-brackets": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", + "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", + "dev": true + }, + "expand-range": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", + "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", + "dev": true + }, + "expand-tilde": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-1.2.2.tgz", + "integrity": "sha1-C4HrqJflo9MdHD0QL48BRB5VlEk=", + "dev": true + }, + "extend": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", + "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", + "dev": true + }, + "extglob": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", + "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", + "dev": true + }, + "eyes": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", + "integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A=", + "dev": true + }, + "fancy-log": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.0.tgz", + "integrity": "sha1-Rb4X0Cu5kX1gzP/UmVyZnmyMmUg=", + "dev": true + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "figures": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", + "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", + "dev": true, + "dependencies": { + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + } + } + }, + "file-entry-cache": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", + "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "dev": true, + "dependencies": { + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + } + } + }, + "filename-regex": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", + "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=", + "dev": true + }, + "fill-range": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz", + "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", + "dev": true + }, + "find-index": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/find-index/-/find-index-0.1.1.tgz", + "integrity": "sha1-Z101iyyjiS15Whq0cjL4tuLg3eQ=", + "dev": true + }, + "findup-sync": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.4.3.tgz", + "integrity": "sha1-QAQ5Kee8YK3wt/SCfExudaDeyhI=", + "dev": true + }, + "fined": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/fined/-/fined-1.0.2.tgz", + "integrity": "sha1-WyhCS3YNdZiWC374SA3/itNmDpc=", + "dev": true + }, + "first-chunk-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz", + "integrity": "sha1-Wb+1DNkF9g18OUzT2ayqtOatk04=", + "dev": true + }, + "flagged-respawn": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-0.3.2.tgz", + "integrity": "sha1-/xke3c1wiKZ1smEP/8l2vpuAdLU=", + "dev": true + }, + "flat-cache": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.2.2.tgz", + "integrity": "sha1-+oZxTnLCHbiGAXYezy9VXRq8a5Y=", + "dev": true, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + } + } + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "dev": true + }, + "for-own": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", + "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", + "dev": true + }, + "fs-exists-sync": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz", + "integrity": "sha1-mC1ok6+RjnLQjeyehnP/K1qNat0=", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "gaze": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz", + "integrity": "sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8=", + "dev": true + }, + "generate-function": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", + "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=", + "dev": true + }, + "generate-object-property": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", + "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", + "dev": true + }, + "get-stdin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", + "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", + "dev": true + }, + "glob": { + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", + "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", + "dev": true + }, + "glob-base": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", + "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", + "dev": true + }, + "glob-parent": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", + "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", + "dev": true + }, + "glob-stream": { + "version": "3.1.18", + "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-3.1.18.tgz", + "integrity": "sha1-kXCl8St5Awb9/lmPMT+PeVT9FDs=", + "dev": true, + "dependencies": { + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true + }, + "through2": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "dev": true + } + } + }, + "glob-watcher": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.6.tgz", + "integrity": "sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs=", + "dev": true + }, + "glob2base": { + "version": "0.0.12", + "resolved": "https://registry.npmjs.org/glob2base/-/glob2base-0.0.12.tgz", + "integrity": "sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY=", + "dev": true + }, + "global-modules": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-0.2.3.tgz", + "integrity": "sha1-6lo77ULG1s6ZWk+KEmm12uIjgo0=", + "dev": true + }, + "global-prefix": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-0.1.5.tgz", + "integrity": "sha1-jTvGuNo8qBEqFg2NSW/wRiv+948=", + "dev": true + }, + "globals": { + "version": "9.17.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-9.17.0.tgz", + "integrity": "sha1-DAymltm5u2lNLlRwvTd3fKrVAoY=", + "dev": true + }, + "globby": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", + "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", + "dev": true, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + } + } + }, + "globule": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/globule/-/globule-0.1.0.tgz", + "integrity": "sha1-2cjt3h2nnRJaFRt5UzuXhnY0auU=", + "dev": true, + "dependencies": { + "glob": { + "version": "3.1.21", + "resolved": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz", + "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", + "dev": true + }, + "graceful-fs": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz", + "integrity": "sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=", + "dev": true + }, + "inherits": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-1.0.2.tgz", + "integrity": "sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js=", + "dev": true + }, + "minimatch": { + "version": "0.2.14", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", + "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", + "dev": true + } + } + }, + "glogg": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.0.tgz", + "integrity": "sha1-f+DxmfV6yQbPUS/urY+Q7kooT8U=", + "dev": true + }, + "graceful-fs": { + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", + "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", + "dev": true + }, + "gulp": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/gulp/-/gulp-3.9.1.tgz", + "integrity": "sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ=", + "dev": true + }, + "gulp-eslint": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/gulp-eslint/-/gulp-eslint-3.0.1.tgz", + "integrity": "sha1-BOV+PhjGl0JnwSz2hV3HF9SjE70=", + "dev": true + }, + "gulp-jasmine": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/gulp-jasmine/-/gulp-jasmine-2.4.2.tgz", + "integrity": "sha1-Wn9H4nNww2GawKKkQr45lnFAnbM=", + "dev": true + }, + "gulp-jscs": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/gulp-jscs/-/gulp-jscs-1.6.0.tgz", + "integrity": "sha1-sV7lJgH391pyXTQdHaFhsBJ9Z6A=", + "dev": true, + "dependencies": { + "object-assign": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-2.1.1.tgz", + "integrity": "sha1-Q8NuXVaf+OSBbE76i+AtJpZ8GKo=", + "dev": true + }, + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true + }, + "through2": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "dev": true + } + } + }, + "gulp-shell": { + "version": "0.2.11", + "resolved": "https://registry.npmjs.org/gulp-shell/-/gulp-shell-0.2.11.tgz", + "integrity": "sha1-GbpoC2WoZvYELt4LDjS2LbcfITk=", + "dev": true, + "dependencies": { + "async": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", + "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=", + "dev": true + }, + "lodash": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", + "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=", + "dev": true + }, + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true + }, + "through2": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "dev": true + } + } + }, + "gulp-util": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", + "dev": true + }, + "gulplog": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz", + "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=", + "dev": true + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true + }, + "has-gulplog": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz", + "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=", + "dev": true + }, + "homedir-polyfill": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", + "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", + "dev": true + }, + "i": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/i/-/i-0.3.5.tgz", + "integrity": "sha1-HSuFQVjsgWkRPGy39raAHpniEdU=", + "dev": true + }, + "ignore": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.3.tgz", + "integrity": "sha1-QyNS5XrM2HqzEQ6C0/6g5HgSFW0=", + "dev": true + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "indent-string": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", + "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "ini": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", + "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=", + "dev": true + }, + "inquirer": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz", + "integrity": "sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=", + "dev": true, + "dependencies": { + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "dev": true + } + } + }, + "interpret": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.0.3.tgz", + "integrity": "sha1-y8NcYu7uc/Gat7EKgBURQBr8D5A=", + "dev": true + }, + "is-absolute": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-0.2.6.tgz", + "integrity": "sha1-IN5p89uULvLYe5wto28XIjWxtes=", + "dev": true + }, + "is-buffer": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", + "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", + "dev": true + }, + "is-dotfile": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", + "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=", + "dev": true + }, + "is-equal-shallow": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", + "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", + "dev": true + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "dev": true + }, + "is-extglob": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", + "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", + "dev": true + }, + "is-finite": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", + "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true + }, + "is-glob": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", + "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", + "dev": true + }, + "is-my-json-valid": { + "version": "2.16.0", + "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.16.0.tgz", + "integrity": "sha1-8Hndm/2uZe4gOKrorLyGqxCeNpM=", + "dev": true + }, + "is-number": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", + "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", + "dev": true + }, + "is-path-cwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", + "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=", + "dev": true + }, + "is-path-in-cwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz", + "integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=", + "dev": true + }, + "is-path-inside": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.0.tgz", + "integrity": "sha1-/AbloWg/vaE95mev9xe7wQpI838=", + "dev": true + }, + "is-posix-bracket": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", + "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=", + "dev": true + }, + "is-primitive": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", + "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", + "dev": true + }, + "is-property": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", + "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", + "dev": true + }, + "is-relative": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-0.2.1.tgz", + "integrity": "sha1-0n9MfVFtF1+2ENuEu+7yPDvJeqU=", + "dev": true + }, + "is-resolvable": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.0.tgz", + "integrity": "sha1-jfV8YeouPFAUCNEA+wE8+NbgzGI=", + "dev": true + }, + "is-unc-path": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-0.1.2.tgz", + "integrity": "sha1-arBTpyVzwQJQ/0FqOBTDUXivObk=", + "dev": true + }, + "is-utf8": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", + "dev": true + }, + "is-windows": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-0.2.0.tgz", + "integrity": "sha1-3hqm1j6indJIc3tp8f+LgALSEIw=", + "dev": true + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + } + } + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "dev": true + }, + "jasmine": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-2.6.0.tgz", + "integrity": "sha1-ayLnCIPo5YnUVjRhU7TSBt2+IX8=", + "dev": true, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true + } + } + }, + "jasmine-core": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.6.2.tgz", + "integrity": "sha1-dOoffPQoaRryARB9YxI0AnoJ2qs=", + "dev": true + }, + "jasmine-terminal-reporter": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/jasmine-terminal-reporter/-/jasmine-terminal-reporter-1.0.3.tgz", + "integrity": "sha1-iW8eyP30v2rs3UHFA+2nNH9hUms=", + "dev": true + }, + "js-tokens": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.1.tgz", + "integrity": "sha1-COnxMkhKLEWjCQfp3E1VZ7fxFNc=", + "dev": true + }, + "js-yaml": { + "version": "3.8.4", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.8.4.tgz", + "integrity": "sha1-UgtFZPhlc7qWZir4Woyvp7S1pvY=", + "dev": true + }, + "js2xmlparser": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-0.1.9.tgz", + "integrity": "sha1-LFFniOCUYGN/mkA9/te5JfcdI54=", + "dev": true + }, + "jscs": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/jscs/-/jscs-1.13.1.tgz", + "integrity": "sha1-fdRuGG8PzgcSzQMerMCkXvfc/rA=", + "dev": true, + "dependencies": { + "ansi-regex": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-1.1.1.tgz", + "integrity": "sha1-QchHGUZGN15qGl0Qw8oFTvn8mA0=", + "dev": true + }, + "chalk": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.0.0.tgz", + "integrity": "sha1-s89O0P9Tl8mcdbj2edsvUoMfltw=", + "dev": true + }, + "esprima": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.5.tgz", + "integrity": "sha1-CZNQL+r2aBODJXVvMPmlH+7sEek=", + "dev": true + }, + "estraverse": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.9.3.tgz", + "integrity": "sha1-r2fy3JIlgkFZUJJgkaQAXSnJu0Q=", + "dev": true + }, + "glob": { + "version": "5.0.15", + "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", + "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", + "dev": true + }, + "has-ansi": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-1.0.3.tgz", + "integrity": "sha1-wLWxYV2eOCsP9nFp2We0JeSMpTg=", + "dev": true + }, + "strip-ansi": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-2.0.1.tgz", + "integrity": "sha1-32LBqpTtLxFOHQ8h/R1QSCt5pg4=", + "dev": true + }, + "strip-json-comments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", + "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", + "dev": true + }, + "supports-color": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.3.1.tgz", + "integrity": "sha1-FXWN8J2P87SswwdTn6vicJXhBC0=", + "dev": true + } + } + }, + "jsdoc": { + "version": "3.3.0-alpha13", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.3.0-alpha13.tgz", + "integrity": "sha1-rWS5iaT2++8xEqse6AkIMopOv9I=", + "dev": true, + "dependencies": { + "async": { + "version": "0.1.22", + "resolved": "https://registry.npmjs.org/async/-/async-0.1.22.tgz", + "integrity": "sha1-D8GqoIig4+8Ovi2IMbqw3PiEUGE=", + "dev": true + }, + "esprima": { + "version": "https://github.com/ariya/esprima/tarball/49a2eccb243f29bd653b11e9419241a9d726af7c", + "integrity": "sha1-oD6sqD7BElqj1Kzd0mNrTdcH22c=", + "dev": true + }, + "strip-json-comments": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-0.1.3.tgz", + "integrity": "sha1-Fkxk43Coo8wAyeAbU55WmCPw7lQ=", + "dev": true + } + } + }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dev": true + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "dev": true + }, + "jsonpointer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", + "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", + "dev": true + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true + }, + "liftoff": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-2.3.0.tgz", + "integrity": "sha1-qY8v9nGD2Lp8+soQVIvX/wVQs4U=", + "dev": true + }, + "lodash": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-1.0.2.tgz", + "integrity": "sha1-j1dWDIO1n8JwvT1WG2kAQ0MOJVE=", + "dev": true + }, + "lodash._baseassign": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", + "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", + "dev": true + }, + "lodash._basecopy": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", + "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", + "dev": true + }, + "lodash._basetostring": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", + "integrity": "sha1-0YYdh3+CSlL2aYMtyvPuFVZqB9U=", + "dev": true + }, + "lodash._basevalues": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz", + "integrity": "sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc=", + "dev": true + }, + "lodash._bindcallback": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz", + "integrity": "sha1-5THCdkTPi1epnhftlbNcdIeJOS4=", + "dev": true + }, + "lodash._createassigner": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz", + "integrity": "sha1-g4pbri/aymOsIt7o4Z+k5taXCxE=", + "dev": true + }, + "lodash._getnative": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", + "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", + "dev": true + }, + "lodash._isiterateecall": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", + "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", + "dev": true + }, + "lodash._reescape": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reescape/-/lodash._reescape-3.0.0.tgz", + "integrity": "sha1-Kx1vXf4HyKNVdT5fJ/rH8c3hYWo=", + "dev": true + }, + "lodash._reevaluate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz", + "integrity": "sha1-WLx0xAZklTrgsSTYBpltrKQx4u0=", + "dev": true + }, + "lodash._reinterpolate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", + "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", + "dev": true + }, + "lodash._root": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._root/-/lodash._root-3.0.1.tgz", + "integrity": "sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI=", + "dev": true + }, + "lodash.assign": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-3.0.0.tgz", + "integrity": "sha1-93SdFYCkEgJzo3H1SmaxTJ1yJvo=", + "dev": true + }, + "lodash.assignwith": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.assignwith/-/lodash.assignwith-4.2.0.tgz", + "integrity": "sha1-EnqX8CrcQXUalU0ksN4X4QDgOOs=", + "dev": true + }, + "lodash.escape": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", + "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", + "dev": true + }, + "lodash.isarguments": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", + "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", + "dev": true + }, + "lodash.isarray": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", + "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", + "dev": true + }, + "lodash.isempty": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.isempty/-/lodash.isempty-4.4.0.tgz", + "integrity": "sha1-b4bL7di+TsmHvpqvM8loTbGzHn4=", + "dev": true + }, + "lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=", + "dev": true + }, + "lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=", + "dev": true + }, + "lodash.keys": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", + "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", + "dev": true + }, + "lodash.mapvalues": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.mapvalues/-/lodash.mapvalues-4.6.0.tgz", + "integrity": "sha1-G6+lAF3p3W9PJmaMMMo3IwzJaJw=", + "dev": true + }, + "lodash.pick": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz", + "integrity": "sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM=", + "dev": true + }, + "lodash.restparam": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", + "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=", + "dev": true + }, + "lodash.template": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz", + "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", + "dev": true + }, + "lodash.templatesettings": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz", + "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=", + "dev": true + }, + "lru-cache": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", + "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", + "dev": true + }, + "map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "dev": true + }, + "marked": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.6.tgz", + "integrity": "sha1-ssbGGPzOzk74bE/Gy4p8v1rtqNc=", + "dev": true + }, + "micromatch": { + "version": "2.3.11", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", + "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", + "dev": true + }, + "minimatch": { + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", + "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", + "dev": true + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + } + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "multipipe": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", + "integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=", + "dev": true + }, + "mute-stream": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", + "integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=", + "dev": true + }, + "natives": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.0.tgz", + "integrity": "sha1-6f+EFBimsux6SV6TmYT3jxY+bjE=", + "dev": true + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, + "ncp": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/ncp/-/ncp-0.4.2.tgz", + "integrity": "sha1-q8xsvT7C7Spyn/bnwfqPAXhKhXQ=", + "dev": true + }, + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "object-assign": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", + "integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=", + "dev": true + }, + "object.omit": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", + "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", + "dev": true + }, + "once": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", + "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", + "dev": true + }, + "onetime": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", + "dev": true + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "dev": true + }, + "orchestrator": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/orchestrator/-/orchestrator-0.3.8.tgz", + "integrity": "sha1-FOfp4nZPcxX7rBhOUGx6pt+UrX4=", + "dev": true + }, + "ordered-read-streams": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz", + "integrity": "sha1-/VZamvjrRHO6abbtijQ1LLVS8SY=", + "dev": true + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "dev": true + }, + "parse-filepath": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.1.tgz", + "integrity": "sha1-FZ1hVdQ5BNFsEO9piRHaHpGWm3M=", + "dev": true + }, + "parse-glob": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", + "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", + "dev": true + }, + "parse-passwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "dev": true + }, + "path-parse": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", + "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", + "dev": true + }, + "path-root": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz", + "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", + "dev": true + }, + "path-root-regex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz", + "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=", + "dev": true + }, + "pathval": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-0.1.1.tgz", + "integrity": "sha1-CPkRzcqczllCiA2ngXvAtyO2bYI=", + "dev": true + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true + }, + "pkginfo": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.4.0.tgz", + "integrity": "sha1-NJ27f/04CB/K3AhT32h/DHdEzWU=", + "dev": true + }, + "pluralize": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-1.2.1.tgz", + "integrity": "sha1-0aIUg/0iu0HlihL6NCGCMUCJfEU=", + "dev": true + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "preserve": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", + "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", + "dev": true + }, + "pretty-hrtime": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", + "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=", + "dev": true + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, + "progress": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", + "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", + "dev": true + }, + "prompt": { + "version": "0.2.14", + "resolved": "https://registry.npmjs.org/prompt/-/prompt-0.2.14.tgz", + "integrity": "sha1-V3VPZPVD/XsIRXB8gY7OYY8F/9w=", + "dev": true + }, + "randomatic": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.6.tgz", + "integrity": "sha1-EQ3Kv/OX6dz/fAeJzMCkmt8exbs=", + "dev": true + }, + "read": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz", + "integrity": "sha1-s9oZvQUkMal2cdRKQmNK33ELQMQ=", + "dev": true + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true + }, + "readline2": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz", + "integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=", + "dev": true + }, + "rechoir": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", + "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", + "dev": true + }, + "regex-cache": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz", + "integrity": "sha1-mxpsNdTQ3871cRrmUejp09cRQUU=", + "dev": true + }, + "remove-trailing-separator": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.0.1.tgz", + "integrity": "sha1-YV67lq9VlVLUv0BXyENtSGq2PMQ=", + "dev": true + }, + "repeat-element": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", + "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "repeating": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", + "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", + "dev": true + }, + "replace-ext": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz", + "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", + "dev": true + }, + "require-uncached": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", + "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", + "dev": true + }, + "requizzle": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.1.tgz", + "integrity": "sha1-aUPDUwxNmn5G8c3dUcFY/GcM294=", + "dev": true + }, + "resolve": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.3.3.tgz", + "integrity": "sha1-ZVkHw0aahoDcLeOidaj91paR8OU=", + "dev": true + }, + "resolve-dir": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-0.1.1.tgz", + "integrity": "sha1-shklmlYC+sXFxJatiUpujMQwJh4=", + "dev": true + }, + "resolve-from": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", + "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", + "dev": true + }, + "restore-cursor": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", + "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", + "dev": true + }, + "revalidator": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/revalidator/-/revalidator-0.1.8.tgz", + "integrity": "sha1-/s5hv6DBtSoga9axgZgYS91SOjs=", + "dev": true + }, + "rimraf": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz", + "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=", + "dev": true, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true + } + } + }, + "run-async": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz", + "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", + "dev": true + }, + "rx-lite": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz", + "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=", + "dev": true + }, + "safe-buffer": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz", + "integrity": "sha1-0mPKVGls2KMGtcplUekt5XkY++c=", + "dev": true + }, + "semver": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", + "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=", + "dev": true + }, + "sequencify": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/sequencify/-/sequencify-0.0.7.tgz", + "integrity": "sha1-kM/xnQLgcCf9dn9erT57ldHnOAw=", + "dev": true + }, + "shelljs": { + "version": "0.7.7", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.7.tgz", + "integrity": "sha1-svXHfvlxSPS09uImguELuoZnz/E=", + "dev": true, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true + } + } + }, + "sigmund": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", + "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", + "dev": true + }, + "slice-ansi": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", + "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", + "dev": true + }, + "sparkles": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.0.tgz", + "integrity": "sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM=", + "dev": true + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=", + "dev": true + }, + "stream-consume": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.0.tgz", + "integrity": "sha1-pB6tGm1ggc63n2WwYZAbbY89HQ8=", + "dev": true + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true + }, + "strip-bom": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz", + "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=", + "dev": true + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + }, + "table": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz", + "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=", + "dev": true, + "dependencies": { + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "dev": true + }, + "string-width": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.0.0.tgz", + "integrity": "sha1-Y1xUNsxypuDDh87KJ41OLuxSaH4=", + "dev": true + } + } + }, + "taffydb": { + "version": "https://github.com/hegemonic/taffydb/tarball/master", + "integrity": "sha1-pO5xiCFDkBUx/BcPbSKvBTVloMU=", + "dev": true + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, + "through2": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", + "dev": true, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.2.11", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.11.tgz", + "integrity": "sha512-h+8+r3MKEhkiVrwdKL8aWs1oc1VvBu33ueshOvS26RsZQ3Amhx/oO3TKe4lApSV9ueY6as8EAh7mtuFjdlhg9Q==", + "dev": true + }, + "string_decoder": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.2.tgz", + "integrity": "sha1-sp4fThEl+pehA4K4pTNze3SR4Xk=", + "dev": true + } + } + }, + "tildify": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/tildify/-/tildify-1.2.0.tgz", + "integrity": "sha1-3OwD9V3Km3qj5bBPIYF+tW5jWIo=", + "dev": true + }, + "time-stamp": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz", + "integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=", + "dev": true + }, + "tryit": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tryit/-/tryit-1.0.3.tgz", + "integrity": "sha1-OTvnMKlEb9Hq1tpZoBQwjzbCics=", + "dev": true + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "dev": true + }, + "unc-path-regex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", + "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", + "dev": true + }, + "underscore": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz", + "integrity": "sha1-izixDKze9jM3uLJOT/htRa6lKag=", + "dev": true + }, + "underscore-contrib": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/underscore-contrib/-/underscore-contrib-0.3.0.tgz", + "integrity": "sha1-ZltmwkeD+PorGMn4y7Dix9SMJsc=", + "dev": true + }, + "unique-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz", + "integrity": "sha1-1ZpKdUJ0R9mqbJHnAmP40mpLEEs=", + "dev": true + }, + "user-home": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz", + "integrity": "sha1-K1viOjK2Onyd640PKNSFcko98ZA=", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "utile": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/utile/-/utile-0.2.1.tgz", + "integrity": "sha1-kwyI6ZCY1iIINMNWy9mncFItkNc=", + "dev": true + }, + "uuid": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", + "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=", + "dev": true + }, + "v8flags": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-2.1.1.tgz", + "integrity": "sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ=", + "dev": true + }, + "vinyl": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz", + "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", + "dev": true + }, + "vinyl-fs": { + "version": "0.3.14", + "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-0.3.14.tgz", + "integrity": "sha1-mmhRzhysHBzqX+hsCTHWIMLPqeY=", + "dev": true, + "dependencies": { + "clone": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz", + "integrity": "sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8=", + "dev": true + }, + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true + }, + "through2": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "dev": true + }, + "vinyl": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz", + "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", + "dev": true + } + } + }, + "vow": { + "version": "0.4.16", + "resolved": "https://registry.npmjs.org/vow/-/vow-0.4.16.tgz", + "integrity": "sha1-u51U2TjV+AUg1linQOeoleMP7us=", + "dev": true + }, + "vow-fs": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/vow-fs/-/vow-fs-0.3.6.tgz", + "integrity": "sha1-LUxZviLivyYY3fWXq0uqkjvnIA0=", + "dev": true, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true + } + } + }, + "vow-queue": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/vow-queue/-/vow-queue-0.4.2.tgz", + "integrity": "sha1-5/4XFg4Vx8QYTRtmapvGThjjAYQ=", + "dev": true + }, + "which": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz", + "integrity": "sha1-mofEN48D6CfOyvGs31bHNsAcFOU=", + "dev": true + }, + "winston": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/winston/-/winston-0.8.3.tgz", + "integrity": "sha1-ZLar9M0Brcrv1QCTk7HY6L7BnbA=", + "dev": true, + "dependencies": { + "colors": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", + "integrity": "sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w=", + "dev": true + }, + "pkginfo": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.3.1.tgz", + "integrity": "sha1-Wyn2qB9wcXFC4J52W76rl7T4HiE=", + "dev": true + } + } + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "wrench": { + "version": "1.3.9", + "resolved": "https://registry.npmjs.org/wrench/-/wrench-1.3.9.tgz", + "integrity": "sha1-bxPsNRRTF+spLKX2UxORskQRFBE=", + "dev": true + }, + "write": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", + "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "dev": true + }, + "xmlbuilder": { + "version": "2.6.5", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-2.6.5.tgz", + "integrity": "sha1-b/etYPty0idk8AehZLd/K/FABSY=", + "dev": true, + "dependencies": { + "lodash": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", + "dev": true + } + } + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } +} diff --git a/package.json b/package.json index e7b6b150..2a4a4c03 100644 --- a/package.json +++ b/package.json @@ -7,13 +7,12 @@ "test": "test" }, "devDependencies": { + "gulp-eslint": "^3.0.1", "gulp": "^3.8.10", "gulp-jasmine": "^2.0.1", "gulp-jscs": "^1.4.0", - "gulp-jshint": "^1.9.0", "gulp-shell": "^0.2.11", - "jsdoc": "3.3.0-alpha13", - "jshint-stylish": "^1.0.0" + "jsdoc": "3.3.0-alpha13" }, "scripts": { "test": "gulp test" diff --git a/src/data-structures/avl-tree.js b/src/data-structures/avl-tree.js index 8694246d..6e65f904 100644 --- a/src/data-structures/avl-tree.js +++ b/src/data-structures/avl-tree.js @@ -63,11 +63,11 @@ var height = Math.max(node._left._height, node._right._height); height += 1; return height; - }else if (node._left !== null){ + } else if (node._left !== null){ return node._left._height + 1; - }else if (node._right !== null){ + } else if (node._right !== null){ return node._right._height + 1; - }else { + } else { return 1; } }; @@ -102,8 +102,7 @@ * @param {Array} traveledNodes Array of previously traveled nodes * that are used to help determine the nodes to be restructured. */ - exports.AVLTree.prototype._getNodesToRestructureRemove = - function (traveledNodes) { + exports.AVLTree.prototype._getNodesToRestructureRemove = function (traveledNodes) { // z is last traveled node - imbalance found at z var zIndex = traveledNodes.length; zIndex -= 1; @@ -113,9 +112,9 @@ var y; if (z._left !== null && z._right !== null){ y = (z._left === y) ? z._right : z._left; - }else if (z._left !== null && z._right === null){ + } else if (z._left !== null && z._right === null){ y = z._left; - }else if (z._right !== null && z._left === null){ + } else if (z._right !== null && z._left === null){ y = z._right; } // x should be tallest child of y. @@ -125,14 +124,14 @@ if (y._left !== null && y._right !== null){ if (y._left._height > y._right._height){ x = y._left; - }else if (y._left._height < y._right._height){ + } else if (y._left._height < y._right._height){ x = y._right; - }else if (y._left._height === y._right._height){ + } else if (y._left._height === y._right._height){ x = (z._left === y) ? y._left : y._right; } - }else if (y._left !== null && y._right === null){ + } else if (y._left !== null && y._right === null){ x = y._left; - }else if (y._right !== null && y._left === null){ + } else if (y._right !== null && y._left === null){ x = y._right; } return [x, y, z]; @@ -147,8 +146,7 @@ * @param {Array} traveledNodes Array of previously traveled nodes * that are used to help determine the nodes to be restructured. */ - exports.AVLTree.prototype._getNodesToRestructureInsert = - function (traveledNodes) { + exports.AVLTree.prototype._getNodesToRestructureInsert = function (traveledNodes) { // z is last traveled node - imbalance found at z var zIndex = traveledNodes.length; zIndex -= 1; @@ -166,16 +164,16 @@ if (y._left !== null && y._right !== null){ if (y._left._height > y._right._height){ x = y._left; - }else if (y._left._height < y._right._height){ + } else if (y._left._height < y._right._height){ x = y._right; - }else if (y._left._height === y._right._height){ + } else if (y._left._height === y._right._height){ var xIndex = traveledNodes.length; xIndex -= 3; x = traveledNodes[xIndex]; } - }else if (y._left !== null && y._right === null){ + } else if (y._left !== null && y._right === null){ x = y._left; - }else if (y._right !== null && y._left === null){ + } else if (y._right !== null && y._left === null){ x = y._right; } return [x, y, z]; @@ -192,8 +190,7 @@ * @param {Node} node Started node. * @param {Boolean} isRemove Represents if method was called after remove. */ - exports.AVLTree.prototype._maintainHeightBalanceProperty = - function (node, isRemove) { + exports.AVLTree.prototype._maintainHeightBalanceProperty = function (node, isRemove) { var current = node; var traveledNodes = []; while (current !== null){ @@ -225,11 +222,11 @@ //Determine Rotation Pattern if (z._right === y && y._right === x){ this._rightRight(x, y, z); - }else if (z._left === y && y._left === x){ + } else if (z._left === y && y._left === x){ this._leftLeft(x, y, z); - }else if (z._right === y && y._left === x){ + } else if (z._right === y && y._left === x){ this._rightLeft(x, y, z); - }else if (z._left === y && y._right === x){ + } else if (z._left === y && y._right === x){ this._leftRight(x, y, z); } }; @@ -255,7 +252,7 @@ var orientation = (z._parent._left === z) ? '_left' : '_right'; z._parent[orientation] = y; y._parent = z._parent; - }else { + } else { this._root = y; y._parent = null; } @@ -294,7 +291,7 @@ var orientation = (z._parent._left === z) ? '_left' : '_right'; z._parent[orientation] = y; y._parent = z._parent; - }else { + } else { this._root = y; y._parent = null; } @@ -332,7 +329,7 @@ var orientation = (z._parent._left === z) ? '_left' : '_right'; z._parent[orientation] = x; x._parent = z._parent; - }else { + } else { this._root = x; x._parent = null; } @@ -377,7 +374,7 @@ var orientation = (z._parent._left === z) ? '_left' : '_right'; z._parent[orientation] = x; x._parent = z._parent; - }else { + } else { this._root = x; x._parent = null; } @@ -568,8 +565,7 @@ * @param {Node} oldChild Child to be replaced. * @param {Node} newChild Child replacement. */ - exports.AVLTree.prototype._replaceChild = - function (parent, oldChild, newChild) { + exports.AVLTree.prototype._replaceChild = function (parent, oldChild, newChild) { if (parent === null) { this._root = newChild; if (this._root !== null){ @@ -744,13 +740,11 @@ * @public * @returns {Node} The lowest common ancestor of the two nodes or null. */ - exports.AVLTree.prototype.lowestCommonAncestor = - function (firstNode, secondNode) { + exports.AVLTree.prototype.lowestCommonAncestor = function (firstNode, secondNode) { return this._lowestCommonAncestor(firstNode, secondNode, this._root); }; - exports.AVLTree.prototype._lowestCommonAncestor = - function (firstNode, secondNode, current) { + exports.AVLTree.prototype._lowestCommonAncestor = function (firstNode, secondNode, current) { var firstNodeInLeft = this._existsInSubtree(firstNode, current._left); var secondNodeInLeft = this._existsInSubtree(secondNode, current._left); var firstNodeInRight = this._existsInSubtree(firstNode, current._right); diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index b6605590..234cfd81 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -221,8 +221,7 @@ * @param {Node} oldChild Child to be replaced. * @param {Node} newChild Child replacement. */ - exports.BinaryTree.prototype._replaceChild = - function (parent, oldChild, newChild) { + exports.BinaryTree.prototype._replaceChild = function (parent, oldChild, newChild) { if (!parent) { this._root = newChild; if (this._root !== null){ @@ -411,8 +410,7 @@ * for ancestor. * @returns {Node} The lowest common ancestor of the two nodes or null. */ - exports.BinaryTree.prototype.lowestCommonAncestor = - function (firstNode, secondNode) { + exports.BinaryTree.prototype.lowestCommonAncestor = function (firstNode, secondNode) { return this._lowestCommonAncestor(firstNode, secondNode, this._root); }; @@ -427,8 +425,7 @@ * @param {Node} current Current node. * @returns {Node} The lowest common ancestor of the two nodes or null. */ - exports.BinaryTree.prototype._lowestCommonAncestor = - function (firstNode, secondNode, current) { + exports.BinaryTree.prototype._lowestCommonAncestor = function (firstNode, secondNode, current) { var firstNodeInLeft = this._existsInSubtree(firstNode, current._left); var secondNodeInLeft = this._existsInSubtree(secondNode, current._left); var firstNodeInRight = this._existsInSubtree(firstNode, current._right); diff --git a/src/data-structures/interval-tree.js b/src/data-structures/interval-tree.js index 6d3da17d..24663c98 100644 --- a/src/data-structures/interval-tree.js +++ b/src/data-structures/interval-tree.js @@ -237,8 +237,7 @@ }; // adjust the max value - exports.IntervalTree.prototype._removeHelper = - function (interval, node) { + exports.IntervalTree.prototype._removeHelper = function (interval, node) { if (!node) { return; } diff --git a/src/data-structures/red-black-tree.js b/src/data-structures/red-black-tree.js index 997dc8cd..970fe16d 100644 --- a/src/data-structures/red-black-tree.js +++ b/src/data-structures/red-black-tree.js @@ -280,7 +280,7 @@ var levelOrderString = ''; if (this._root){ queue.push(this._root); - }else { + } else { levelOrderString = ' Tree is empty'; } while (queue.length !== 0){ diff --git a/src/data-structures/size-balanced-tree.js b/src/data-structures/size-balanced-tree.js index 2eb60c58..ed7e1943 100644 --- a/src/data-structures/size-balanced-tree.js +++ b/src/data-structures/size-balanced-tree.js @@ -1,5 +1,3 @@ -'use strict'; - /** * Size balanced tree is a data structure which is * a type of self-balancing binary search tree that use @@ -33,6 +31,8 @@ */ function CreateSBTreeClass (Node, Nil, updateChild) { + 'use strict'; + function LeftRotate(node, childNode) { /* Before rotate: @@ -291,6 +291,7 @@ function CreateSBTreeClass (Node, Nil, updateChild) { } (function (exports) { + 'use strict'; /** * Node constructor of the Size-Balanced tree. diff --git a/src/graphs/spanning-trees/prim.js b/src/graphs/spanning-trees/prim.js index cd915d48..54239587 100644 --- a/src/graphs/spanning-trees/prim.js +++ b/src/graphs/spanning-trees/prim.js @@ -107,42 +107,43 @@ node: startVertex, distance: 0 }); - for (var i = 0; i < this.nodesCount - 1; i += 1) { - current = queue.extract().node; - inTheTree[current] = true; - this.edges.forEach(function (e) { - if (inTheTree[e.v.id] && inTheTree[e.e.id]) { - return; - } - var collection = queue.getCollection(); - var node; - if (e.e.id === current) { - node = e.v.id; - } else if (e.v.id === current) { - node = e.e.id; - } else { - return; - } - for (var i = 0; i < collection.length; i += 1) { - if (collection[i].node === node) { - if (collection[i].distance > e.distance) { - queue.changeKey(i, { - node: node, - distance: e.distance - }); - parents[node] = current; - distances[node] = e.distance; - } - return; + const process = function (e) { + if (inTheTree[e.v.id] && inTheTree[e.e.id]) { + return; + } + var collection = queue.getCollection(); + var node; + if (e.e.id === current) { + node = e.v.id; + } else if (e.v.id === current) { + node = e.e.id; + } else { + return; + } + for (var i = 0; i < collection.length; i += 1) { + if (collection[i].node === node) { + if (collection[i].distance > e.distance) { + queue.changeKey(i, { + node: node, + distance: e.distance + }); + parents[node] = current; + distances[node] = e.distance; } + return; } - queue.add({ - node: node, - distance: e.distance - }); - parents[node] = current; - distances[node] = e.distance; + } + queue.add({ + node: node, + distance: e.distance }); + parents[node] = current; + distances[node] = e.distance; + }; + for (var i = 0; i < this.nodesCount - 1; i += 1) { + current = queue.extract().node; + inTheTree[current] = true; + this.edges.forEach(process); } for (var node in parents) { spannigTree.push( diff --git a/src/searching/longest-increasing-subsequence.js b/src/searching/longest-increasing-subsequence.js index 81d969cf..6b4db8ea 100644 --- a/src/searching/longest-increasing-subsequence.js +++ b/src/searching/longest-increasing-subsequence.js @@ -72,7 +72,7 @@ var neighbours = dag[node]; var neighboursDistance = []; var maxDist; - var maxNode; + // var maxNode; var distance; var result; @@ -85,7 +85,7 @@ } maxDist = max(neighboursDistance); - maxNode = neighbours[maxDist]; + // maxNode = neighbours[maxDist]; distance = 1 + neighboursDistance[maxDist].distance; find.memo[node] = result = { distance: distance, diff --git a/test/data-structures/avl-tree.spec.js b/test/data-structures/avl-tree.spec.js index 19b8c9bb..dbe969be 100644 --- a/test/data-structures/avl-tree.spec.js +++ b/test/data-structures/avl-tree.spec.js @@ -1,16 +1,18 @@ -'use strict'; - var mod = require('../../src/data-structures/avl-tree.js'); var Node = mod.Node; var AVLTree = mod.AVLTree; describe('Node', function () { + 'use strict'; + it('should be a constructor function', function () { expect(typeof Node).toBe('function'); }); }); describe('AVL Tree', function () { + 'use strict'; + it('should be a constructor function', function () { expect(typeof AVLTree).toBe('function'); }); diff --git a/test/data-structures/binary-search-tree.spec.js b/test/data-structures/binary-search-tree.spec.js index fc90744b..fba5cb6f 100644 --- a/test/data-structures/binary-search-tree.spec.js +++ b/test/data-structures/binary-search-tree.spec.js @@ -1,16 +1,18 @@ -'use strict'; - var mod = require('../../src/data-structures/binary-search-tree.js'); var Node = mod.Node; var BinaryTree = mod.BinaryTree; describe('Node', function () { + 'use strict'; + it('should be a constructor function', function () { expect(typeof Node).toBe('function'); }); }); describe('Binary Tree', function () { + 'use strict'; + it('should be a constructor function', function () { expect(typeof BinaryTree).toBe('function'); }); diff --git a/test/data-structures/hash-table.spec.js b/test/data-structures/hash-table.spec.js index 8a598226..bf3f362c 100644 --- a/test/data-structures/hash-table.spec.js +++ b/test/data-structures/hash-table.spec.js @@ -1,16 +1,18 @@ -'use strict'; - var mod = require('../../src/data-structures/hash-table.js'); var Node = mod.Node; var Hashtable = mod.Hashtable; describe('Node', function () { + 'use strict'; + it('should be a constructor function', function () { expect(typeof Node).toBe('function'); }); }); describe('Hash table', function () { + 'use strict'; + it('should be a constructor function.', function () { expect(typeof Hashtable).toBe('function'); }); diff --git a/test/data-structures/heap.spec.js b/test/data-structures/heap.spec.js index 8de81f23..ee44de4a 100644 --- a/test/data-structures/heap.spec.js +++ b/test/data-structures/heap.spec.js @@ -1,9 +1,9 @@ -'use strict'; - var mod = require('../../src/data-structures/heap.js'); var Heap = mod.Heap; describe('Heap', function () { + 'use strict'; + it('should be a constructor function', function () { expect(typeof Heap).toBe('function'); }); diff --git a/test/data-structures/interval-tree.spec.js b/test/data-structures/interval-tree.spec.js index a6d79099..c5745834 100644 --- a/test/data-structures/interval-tree.spec.js +++ b/test/data-structures/interval-tree.spec.js @@ -1,9 +1,9 @@ -'use strict'; - var mod = require('../../src/data-structures/interval-tree.js'); var IntervalTree = mod.IntervalTree; describe('IntervalTree', function () { + 'use strict'; + it('should correctly detect intersections', function () { var it = new IntervalTree(); diff --git a/test/data-structures/linked-list.spec.js b/test/data-structures/linked-list.spec.js index 67f1faea..37ee7084 100644 --- a/test/data-structures/linked-list.spec.js +++ b/test/data-structures/linked-list.spec.js @@ -1,22 +1,24 @@ -'use strict'; - var mod = require('../../src/data-structures/linked-list.js'); var Node = mod.Node; var LinkedList = mod.LinkedList; describe('Node', function () { + 'use strict'; + it('should be a constructor function', function () { expect(typeof Node).toBe('function'); }); it('should construct properly', function () { - var node = new Node("data"); - expect(node.data).toBe("data"); + var node = new Node('data'); + expect(node.data).toBe('data'); expect(node.next).toBe(null); expect(node.prev).toBe(null); }); }); describe('Linked List', function () { + 'use strict'; + it('should be a constructor function', function () { expect(typeof LinkedList).toBe('function'); }); @@ -133,7 +135,8 @@ describe('Linked List', function () { linkedList.push(5); var pushedValue = 1; function callback(node){ - expect(node.data).toBe(pushedValue++); + expect(node.data).toBe(pushedValue); + pushedValue += 1; } linkedList.inorder(callback); }); diff --git a/test/data-structures/red-black-tree.spec.js b/test/data-structures/red-black-tree.spec.js index 085de6a8..8cf1615a 100644 --- a/test/data-structures/red-black-tree.spec.js +++ b/test/data-structures/red-black-tree.spec.js @@ -1,11 +1,10 @@ -'use strict'; - var mod = require('../../src/data-structures/red-black-tree.js'); var Vertex = mod.Node; var RBTree = mod.RBTree; var Colors = mod.Colors; describe('Node', function () { + 'use strict'; it('should be a constructor function', function () { expect(typeof Vertex).toBe('function'); @@ -37,6 +36,8 @@ describe('Node', function () { }); describe('RBTree', function () { + 'use strict'; + it('should be a constructor function', function () { expect(typeof RBTree).toBe('function'); }); diff --git a/test/data-structures/segment-tree.spec.js b/test/data-structures/segment-tree.spec.js index 4679d5cd..42bf127d 100644 --- a/test/data-structures/segment-tree.spec.js +++ b/test/data-structures/segment-tree.spec.js @@ -1,13 +1,13 @@ -'use strict'; - var SegmentTree = require('../../src/data-structures/segment-tree.js') .SegmentTree; var defaultAggregate = function (a, b) { + 'use strict'; return Math.min(a, b); }; describe('Segment Tree', function () { + 'use strict'; describe('indexing', function () { diff --git a/test/data-structures/size-balanced-tree.spec.js b/test/data-structures/size-balanced-tree.spec.js index dff072e7..9051e3fc 100644 --- a/test/data-structures/size-balanced-tree.spec.js +++ b/test/data-structures/size-balanced-tree.spec.js @@ -1,5 +1,3 @@ -'use strict'; - var mod = require('../../src/data-structures/size-balanced-tree.js'); var Node = mod.Node; var Nil = mod.Nil; @@ -7,6 +5,8 @@ var SBTree = mod.SBTree; var updateChild = mod.updateChild; describe('Node', function () { + 'use strict'; + it('should be a constructor function', function () { expect(typeof Node).toBe('function'); }); @@ -39,6 +39,8 @@ describe('Node', function () { }); describe('SBTree', function () { + 'use strict'; + it('should be a constructor function', function () { expect(typeof SBTree).toBe('function'); }); @@ -95,15 +97,15 @@ describe('SBTree', function () { it('push and get 100000 elements, remove the array by always remove the first/last element', function () { var sTree = new SBTree(); - for (var i = 0; i < 200000; ++i) { + for (var i = 0; i < 200000; i += 1) { sTree.push(i); } checkNil(); - for (var i = 0; i < 200000; ++i) { + for (var i = 0; i < 200000; i += 1) { var node = sTree.get(i); expect(node.value).toBe(i); } - for (var i = 0; i < 200000; ++i) { + for (var i = 0; i < 200000; i += 1) { expect(sTree.get(0).value).toBe(i); var node = sTree.remove(0); // Always remove the first element; expect(node.value).toBe(i); @@ -111,32 +113,32 @@ describe('SBTree', function () { checkNil(); expect(sTree._root).toBe(Nil); var count = 10000; - for (var i = 0; i < count; ++i) { + for (var i = 0; i < count; i += 1) { sTree.insert(0, i); } - for (var i = 0; i < count; ++i) { + for (var i = 0; i < count; i += 1) { var node = sTree.remove(count - i - 1); // Always remove the last element; expect(node.value).toBe(i); expect(sTree.size).toBe(count - i - 1); } checkNil(); var expectedArray = []; - for (var i = 0; i < 100000; ++i) { + for (var i = 0; i < 100000; i += 1) { var newPos = getRandomIntInclusive(0, sTree.size); sTree.insert(newPos, i); expectedArray.splice(newPos, 0, i); } expect(sTree.size).toBe(expectedArray.length); - for (var i = 0; i < sTree.size; ++i) { + for (var i = 0; i < sTree.size; i += 1) { var node = sTree.get(i); expect(node.value).toBe(expectedArray[i]); } - for (var i = 0; i < 90000; ++i) { + for (var i = 0; i < 90000; i += 1) { var removedPos = getRandomInt(0, sTree.size); sTree.remove(removedPos); expectedArray.splice(removedPos, 1); } - for (var i = 0; i < sTree.size; ++i) { + for (var i = 0; i < sTree.size; i += 1) { var node = sTree.get(i); expect(node.value).toBe(expectedArray[i]); } @@ -145,12 +147,12 @@ describe('SBTree', function () { it('test getIndex', function () { var sTree = new SBTree(); - for (var i = 0; i < 10000; ++i) { + for (var i = 0; i < 10000; i += 1) { var key = i.toString(); sTree.push(key); } - for (var i = 0; i < 100; ++i) { + for (var i = 0; i < 100; i += 1) { var item = sTree.get(i); expect(item.value).toBe(i.toString()); expect(sTree.getIndex(item)).toBe(i); @@ -159,7 +161,7 @@ describe('SBTree', function () { it('test binary search', function () { var sTree = new SBTree(); - for (var i = 0; i < 10000; ++i) { + for (var i = 0; i < 10000; i += 1) { sTree.push(i); } var cmp = function (a, b) { diff --git a/test/data-structures/splay-tree.spec.js b/test/data-structures/splay-tree.spec.js index 05e13a0d..78e31ebc 100644 --- a/test/data-structures/splay-tree.spec.js +++ b/test/data-structures/splay-tree.spec.js @@ -1,10 +1,10 @@ -'use strict'; - var mod = require('../../src/data-structures/splay-tree.js'); var Node = mod.Node; var SplayTree = mod.SplayTree; describe('Node', function () { + 'use strict'; + it('should be a constructor function', function () { expect(typeof Node).toBe('function'); }); @@ -29,6 +29,8 @@ describe('Node', function () { }); describe('SplayTree', function () { + 'use strict'; + it('should be a constructor function', function () { expect(typeof SplayTree).toBe('function'); }); diff --git a/test/graphs/searching/bfs.spec.js b/test/graphs/searching/bfs.spec.js index 9ade6961..c47c24d7 100644 --- a/test/graphs/searching/bfs.spec.js +++ b/test/graphs/searching/bfs.spec.js @@ -1,7 +1,5 @@ /* jshint multistr: true */ -'use strict'; - var graph = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 0], [0, 0, 0, 0, 0], @@ -11,6 +9,7 @@ var graph = [[0, 0, 0, 0, 1], var bfs = require('../../../src/graphs/searching/bfs').bfs; describe('BFS', function () { + 'use strict'; it('should work with empty graph', function () { expect(bfs([], 0, 0)).toEqual([0]); diff --git a/test/graphs/searching/dfs.spec.js b/test/graphs/searching/dfs.spec.js index b5d983d8..34d59d62 100644 --- a/test/graphs/searching/dfs.spec.js +++ b/test/graphs/searching/dfs.spec.js @@ -1,8 +1,7 @@ -'use strict'; - var dfs = require('../../../src/graphs/searching/dfs').dfs; describe('dfs', function () { + 'use strict'; it('should work with empty graph', function () { expect(dfs([[]])).toBeTruthy(); @@ -12,25 +11,22 @@ describe('dfs', function () { expect(dfs([[0]]), 0, 0).toBeTruthy(); }); - it('should always find a path between two directly connected nodes', - function () { - expect(dfs([[0, 1], [1, 0]], 0, 1)).toBeTruthy(); - expect(dfs([[0, 1], [1, 0]], 1, 0)).toBeTruthy(); - }); + it('should always find a path between two directly connected nodes', function () { + expect(dfs([[0, 1], [1, 0]], 0, 1)).toBeTruthy(); + expect(dfs([[0, 1], [1, 0]], 1, 0)).toBeTruthy(); + }); it('should always find a path between two directly connected' + 'connected nodes in a directed graph', function () { expect(dfs([[0, 0], [1, 0]], 1, 0)).toBeTruthy(); }); - it('should always find a path between two indirectly connected nodes', - function () { - expect(dfs([[0, 1, 0], [0, 0, 1], [0, 0, 0]], 0, 2)).toBeTruthy(); - }); + it('should always find a path between two indirectly connected nodes', function () { + expect(dfs([[0, 1, 0], [0, 0, 1], [0, 0, 0]], 0, 2)).toBeTruthy(); + }); - it('should not find a path between two nodes, which are not connected', - function () { - expect(dfs([[0, 0], [1, 0]], 0, 1)).toBeFalsy(); - expect(dfs([[0, 0, 0], [0, 0, 1], [0, 0, 0]], 0, 2)).toBeFalsy(); - }); + it('should not find a path between two nodes, which are not connected', function () { + expect(dfs([[0, 0], [1, 0]], 0, 1)).toBeFalsy(); + expect(dfs([[0, 0, 0], [0, 0, 1], [0, 0, 0]], 0, 2)).toBeFalsy(); + }); }); diff --git a/test/others/fibonacci.spec.js b/test/others/fibonacci.spec.js index 02cbddd8..80adb5ac 100644 --- a/test/others/fibonacci.spec.js +++ b/test/others/fibonacci.spec.js @@ -1,9 +1,9 @@ -'use strict'; - var mod = require('../../src/others/fibonacci.js'); var fibonacci = mod.fibonacci; describe('fibonacci algorithm', function () { + 'use strict'; + it('should return value 1 with input 1.', function () { expect(fibonacci(1)).toBe(1); }); diff --git a/test/others/levenshtein-distance.spec.js b/test/others/levenshtein-distance.spec.js index 705a3f90..8ff572bb 100644 --- a/test/others/levenshtein-distance.spec.js +++ b/test/others/levenshtein-distance.spec.js @@ -1,9 +1,9 @@ -'use strict'; - var mod = require('../../src/others/levenshtein-distance.js'); var levenshteinDistance = mod.levenshteinDistance; describe('Levenstein\'s minimum edit distance algorithm', function () { + 'use strict'; + it('should be defined', function () { expect(levenshteinDistance).toBeDefined(); }); diff --git a/test/others/min-coins-sum.spec.js b/test/others/min-coins-sum.spec.js index 7a5004d1..f0e46644 100644 --- a/test/others/min-coins-sum.spec.js +++ b/test/others/min-coins-sum.spec.js @@ -1,9 +1,9 @@ -'use strict'; - var minCoinsChange = require('../../src/others/min-coins-change.js').minCoinsChange; describe('Change making problem', function () { + 'use strict'; + it('should be defined', function () { expect(minCoinsChange).toBeDefined(); }); @@ -23,8 +23,7 @@ describe('Change making problem', function () { expect(minCoinsChange([1, 2, 3], 10).length).toEqual(4); }); - it('should return undefined for combination, which is not possible', - function () { - expect(minCoinsChange([1, 2, 3], 0.5)).not.toBeDefined(); - }); + it('should return undefined for combination, which is not possible', function () { + expect(minCoinsChange([1, 2, 3], 0.5)).not.toBeDefined(); + }); }); diff --git a/test/others/minkowski-distance.spec.js b/test/others/minkowski-distance.spec.js index fad96dff..1c1795cf 100644 --- a/test/others/minkowski-distance.spec.js +++ b/test/others/minkowski-distance.spec.js @@ -1,9 +1,9 @@ -'use strict'; - var mod = require('../../src/others/minkowski-distance.js'); var minkowskiDistance = mod.minkowskiDistance; describe('Minkowski Distance', function () { + 'use strict'; + it('should return 1 with points (0, 1), (1, 1) in order 1.', function () { expect(minkowskiDistance([0, 1], [1, 1], 1)).toBe(1); }); diff --git a/test/primes/is-prime.spec.js b/test/primes/is-prime.spec.js index 02a78b2d..65bd4ace 100644 --- a/test/primes/is-prime.spec.js +++ b/test/primes/is-prime.spec.js @@ -1,9 +1,8 @@ -'use strict'; - var isPrime = require('../../src/primes/is-prime').isPrime; -describe('Advanced (optimised) method that checks number on prime', - function () { +describe('Advanced (optimised) method that checks number on prime', function () { + 'use strict'; + it('should give true for number 104743', function () { expect(isPrime(104743)).toBe(true); }); diff --git a/test/primes/prime-factor-tree.spec.js b/test/primes/prime-factor-tree.spec.js index 3daddef5..d8d8c5dd 100644 --- a/test/primes/prime-factor-tree.spec.js +++ b/test/primes/prime-factor-tree.spec.js @@ -1,8 +1,8 @@ -'use strict'; - var primeFactorTree = require('../../src/primes/prime-factor-tree').primeFactorTree; describe('Prime factor tree', function () { + 'use strict'; + it('for number 104743 should return [104743]', function () { expect(primeFactorTree(104743).toString()).toEqual([104743].toString()); }); @@ -20,8 +20,8 @@ describe('Prime factor tree', function () { it('sum of primes for given number 600851475143 should be 9238', function () { var primes = primeFactorTree(600851475143); var sumOfPrimes = primes.reduce(function (previousValue, currentValue) { - return previousValue + currentValue; - }); + return previousValue + currentValue; + }); expect(sumOfPrimes).toEqual(9238); }); diff --git a/test/primes/sieve-of-eratosthenes.spec.js b/test/primes/sieve-of-eratosthenes.spec.js index 96792263..5d9e166c 100644 --- a/test/primes/sieve-of-eratosthenes.spec.js +++ b/test/primes/sieve-of-eratosthenes.spec.js @@ -1,9 +1,9 @@ -'use strict'; - var sieveOfEratosthenes = require('../../src/primes/sieve-of-eratosthenes').sieveOfEratosthenes; describe('Sieve Of Eratosthenes', function () { + 'use strict'; + it('should give the right sequence of primes for limit 12', function () { expect(sieveOfEratosthenes(12).toString()) .toEqual([2, 3, 5, 7, 11].toString()); @@ -15,12 +15,11 @@ describe('Sieve Of Eratosthenes', function () { expect(sieveOfEratosthenes(1).toString()).toEqual([].toString()); }); - it('sum of prime numbers up to 2000000 limit should be 142913828922', - function () { + it('sum of prime numbers up to 2000000 limit should be 142913828922', function () { var sieve = sieveOfEratosthenes(2000000); var sumOfPrimes = sieve.reduce(function (previousValue, currentValue) { - return previousValue + currentValue; - }); + return previousValue + currentValue; + }); expect(sumOfPrimes).toEqual(142913828922); }); diff --git a/test/searching/binarysearch.spec.js b/test/searching/binarysearch.spec.js index 99eeb059..13dbbaca 100644 --- a/test/searching/binarysearch.spec.js +++ b/test/searching/binarysearch.spec.js @@ -1,9 +1,8 @@ -'use strict'; - var binarySearch = require('../../src/searching/binarysearch').binarySearch; describe('Binary search', function () { + 'use strict'; it('should find the element at position 0 ', function () { expect(binarySearch([1, 2, 3, 4, 6, 8], 1)).toBe(0); diff --git a/test/searching/longest-common-subsequence.spec.js b/test/searching/longest-common-subsequence.spec.js index 4adaa080..24fc47cd 100644 --- a/test/searching/longest-common-subsequence.spec.js +++ b/test/searching/longest-common-subsequence.spec.js @@ -1,11 +1,10 @@ -'use strict'; - var longestCommonSubsequence = require('../../src/searching/' + 'longest-common-subsequence') .longestCommonSubsequence; describe('longest common subsequence', function () { + 'use strict'; it('should work with empty strings', function () { expect(longestCommonSubsequence('', '')).toBe(''); diff --git a/test/searching/longest-increasing-subsequence.spec.js b/test/searching/longest-increasing-subsequence.spec.js index 8c764fa7..d6e214e7 100644 --- a/test/searching/longest-increasing-subsequence.spec.js +++ b/test/searching/longest-increasing-subsequence.spec.js @@ -1,11 +1,10 @@ -'use strict'; - var longestIncreasingSubsequence = require('../../src/searching/' + 'longest-increasing-subsequence') .longestIncreasingSubsequence; describe('longest increasing subsequence', function () { + 'use strict'; var sequence; beforeEach(function () { diff --git a/test/searching/maximum-subarray-divide-and-conquer.spec.js b/test/searching/maximum-subarray-divide-and-conquer.spec.js index f84f60d2..cfd58cf3 100644 --- a/test/searching/maximum-subarray-divide-and-conquer.spec.js +++ b/test/searching/maximum-subarray-divide-and-conquer.spec.js @@ -1,10 +1,9 @@ -'use strict'; - var maxSubArray = require('../../src/searching/maximum-subarray-divide-and-conquer') .maxSubarray; describe('Maximum subarray implemented with divide and conquer', function () { + 'use strict'; it('should work with empty arrays', function () { expect(isNaN(maxSubArray([]))).toBeTruthy(); diff --git a/test/searching/recursive-binarysearch.spec.js b/test/searching/recursive-binarysearch.spec.js index 3678ef10..4ab687b3 100644 --- a/test/searching/recursive-binarysearch.spec.js +++ b/test/searching/recursive-binarysearch.spec.js @@ -1,9 +1,8 @@ -'use strict'; - var binarySearch = require('../../src/searching/recursive-binarysearch').binarySearch; describe('Binary search', function () { + 'use strict'; it('should find the element at position 0 ', function () { expect(binarySearch([1, 2, 3, 4, 6, 8], 1)).toBe(0); From 468db5e7eee6bdee0f46174137b9d3967da98314 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 6 Jun 2017 23:34:03 -0400 Subject: [PATCH 533/613] build(lint): remove old config --- .jscsrc | 28 ---------------------------- .jshintrc | 38 -------------------------------------- 2 files changed, 66 deletions(-) delete mode 100644 .jscsrc delete mode 100644 .jshintrc diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index c45cd225..00000000 --- a/.jscsrc +++ /dev/null @@ -1,28 +0,0 @@ -{ - "requireCurlyBraces": ["else", "for", "while", "do", "try", "catch"], - "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], - "requireSpacesInFunctionExpression": { - "beforeOpeningCurlyBrace": true - }, - "disallowMultipleVarDecl": true, - "disallowSpacesInsideArrayBrackets": true, - "disallowSpacesInsideParentheses": true, - "disallowSpaceAfterObjectKeys": true, - "disallowQuotedKeysInObjects": true, - "requireSpaceBeforeBinaryOperators": ["?", "+", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], - "disallowSpaceAfterBinaryOperators": ["!"], - "requireSpaceAfterBinaryOperators": ["?", ",", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], - "disallowSpaceBeforeBinaryOperators": [","], - "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], - "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], - "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], - "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], - "disallowImplicitTypeConversion": ["numeric", "binary", "string"], - "disallowKeywords": ["with", "eval"], - "disallowMultipleLineBreaks": true, - "disallowKeywordsOnNewLine": ["else"], - "requireLineFeedAtFileEnd": true, - "disallowTrailingWhitespace": true, - "excludeFiles": ["node_modules/**", "bower_components/**"], - "validateIndentation": 2 -} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 4cabd67d..00000000 --- a/.jshintrc +++ /dev/null @@ -1,38 +0,0 @@ -{ - "browser": true, - "jquery": true, - "node": true, - "esnext": true, - "bitwise": true, - "camelcase": true, - "curly": true, - "eqeqeq": true, - "indent": 2, - "latedef": true, - "noarg": true, - "newcap": false, - "quotmark": "single", - "unused": true, - "strict": true, - "trailing": true, - "smarttabs": true, - "white": true, - "freeze": true, - "immed": true, - "noempty": true, - "plusplus": true, - "undef": true, - "laxbreak": true, - "maxdepth": 4, - "loopfunc": true, - "maxcomplexity": 13, - "maxlen": 80, - "maxparams": 5, - "globals": { - "expect": true, - "it": true, - "describe": true, - "beforeEach": true, - "afterEach": true - } -} From c5b7a31b176c8e0e20d2786ceb079a692c4505ba Mon Sep 17 00:00:00 2001 From: mik-laj Date: Tue, 6 Jun 2017 09:25:49 +0200 Subject: [PATCH 534/613] Add quick sort (functional variant) --- src/sorting/quicksort-functional.js | 38 +++++++++++++++++++++++ test/sorting/quicksort-functional.spec.js | 5 +++ 2 files changed, 43 insertions(+) create mode 100644 src/sorting/quicksort-functional.js create mode 100644 test/sorting/quicksort-functional.spec.js diff --git a/src/sorting/quicksort-functional.js b/src/sorting/quicksort-functional.js new file mode 100644 index 00000000..10e2787f --- /dev/null +++ b/src/sorting/quicksort-functional.js @@ -0,0 +1,38 @@ +(function (exports) { + + 'use strict'; + + /** + * The quicksort algorithm (functional variant). It's complexity is O(nlog n). + * + * @public + */ + var quickSort = (function () { + + /** + * Sorts given array. + * + * @private + * @param {array} array Array which should be sorted + * @returns {array} array Sorted array + */ + return function quickSort(array, left, right, cmp) { + if ( arr.length < 1) { + return arr; + } + + var [x, ...rest] = arr; + + return [ + ...quickSort(rest.filter(v => v <= x)), + x, + ...quickSort(rest.filter(v => v > x)) + ] + return array; + } + + }()); + + exports.quickSort = quickSort; + +}(typeof exports === 'undefined' ? window : exports)); diff --git a/test/sorting/quicksort-functional.spec.js b/test/sorting/quicksort-functional.spec.js new file mode 100644 index 00000000..a31aafb9 --- /dev/null +++ b/test/sorting/quicksort-functional.spec.js @@ -0,0 +1,5 @@ +var sortTestCase = require('./sort.testcase.js'); +var quickSort = + require('../../src/sorting/quicksort-functional.js').quickSort; + +sortTestCase(quickSort, 'Quick sort', { reverse: false }); From 704669a2ae0db5d090416a2ce8d8513b29e424eb Mon Sep 17 00:00:00 2001 From: mik-laj Date: Wed, 7 Jun 2017 18:13:19 +0200 Subject: [PATCH 535/613] Add a comparator and improve code style --- src/sorting/quicksort-functional.js | 49 ++++++++++++++++++----- test/sorting/quicksort-functional.spec.js | 2 +- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/sorting/quicksort-functional.js b/src/sorting/quicksort-functional.js index 10e2787f..0f1f9e8d 100644 --- a/src/sorting/quicksort-functional.js +++ b/src/sorting/quicksort-functional.js @@ -2,35 +2,66 @@ 'use strict'; + function compare(a, b) { + return a - b; + } + /** - * The quicksort algorithm (functional variant). It's complexity is O(nlog n). + * Quicksort algorithm (functional variant) * * @public + * @param {array} array Array which should be sorted. + * @return {array} Sorted array. */ var quickSort = (function () { /** - * Sorts given array. + * Recursively calls itself. * * @private - * @param {array} array Array which should be sorted - * @returns {array} array Sorted array + * @param {array} array Array which should be processed */ - return function quickSort(array, left, right, cmp) { - if ( arr.length < 1) { + return function quickSort(array, cmp) { + if (arr.length < 1) { return arr; } - var [x, ...rest] = arr; + const [x, ...rest] = arr; return [ - ...quickSort(rest.filter(v => v <= x)), + ...quickSort(rest.filter(v => cmp(v, x) < 0), x, - ...quickSort(rest.filter(v => v > x)) + ...quickSort(rest.filter(v => cmp(v, x) >= 0)) ] return array; } + + /** + * Quicksort algorithm. In this version of quicksort used + * functional programming mechanisms.

+ * Time complexity: O(N log(N)). + * + * @example + * + * var sort = require('path-to-algorithms/src' + + * '/sorting/quicksort-functional').quickSort; + * console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ] + * + * @public + * @module sorting/quicksort-functional + * @param {Array} array Input array. + * @param {Function} cmp Optional. A function that defines an + * alternative sort order. The function should return a negative, + * zero, or positive value, depending on the arguments. + * @return {Array} Sorted array. + */ + return function (array, cmp) { + cmp = cmp || compare; + quicksort(array, 0, array.length - 1, cmp); + return array; + }; + }()); exports.quickSort = quickSort; diff --git a/test/sorting/quicksort-functional.spec.js b/test/sorting/quicksort-functional.spec.js index a31aafb9..a71e6fc0 100644 --- a/test/sorting/quicksort-functional.spec.js +++ b/test/sorting/quicksort-functional.spec.js @@ -2,4 +2,4 @@ var sortTestCase = require('./sort.testcase.js'); var quickSort = require('../../src/sorting/quicksort-functional.js').quickSort; -sortTestCase(quickSort, 'Quick sort', { reverse: false }); +sortTestCase(quickSort, 'Quick sort'); From 59428462a117b09b30c82970225a1ea1759140e2 Mon Sep 17 00:00:00 2001 From: mik-laj Date: Wed, 7 Jun 2017 18:22:15 +0200 Subject: [PATCH 536/613] Fix small typo --- src/sorting/quicksort-functional.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sorting/quicksort-functional.js b/src/sorting/quicksort-functional.js index 0f1f9e8d..01d165a3 100644 --- a/src/sorting/quicksort-functional.js +++ b/src/sorting/quicksort-functional.js @@ -22,7 +22,7 @@ * @param {array} array Array which should be processed */ return function quickSort(array, cmp) { - if (arr.length < 1) { + if (array.length < 1) { return arr; } @@ -33,7 +33,6 @@ x, ...quickSort(rest.filter(v => cmp(v, x) >= 0)) ] - return array; } @@ -58,7 +57,7 @@ */ return function (array, cmp) { cmp = cmp || compare; - quicksort(array, 0, array.length - 1, cmp); + quickSort(array, 0, array.length - 1, cmp); return array; }; From 07903651a9ee46722c764e8abd472fdcd57e5816 Mon Sep 17 00:00:00 2001 From: mik-laj Date: Wed, 7 Jun 2017 18:56:11 +0200 Subject: [PATCH 537/613] Remove return; change functional to declarative --- ...uicksort-functional.js => quicksort-declarative.js} | 10 +++++----- ...unctional.spec.js => quicksort-declarative.spec.js} | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) rename src/sorting/{quicksort-functional.js => quicksort-declarative.js} (85%) rename test/sorting/{quicksort-functional.spec.js => quicksort-declarative.spec.js} (59%) diff --git a/src/sorting/quicksort-functional.js b/src/sorting/quicksort-declarative.js similarity index 85% rename from src/sorting/quicksort-functional.js rename to src/sorting/quicksort-declarative.js index 01d165a3..f266e16f 100644 --- a/src/sorting/quicksort-functional.js +++ b/src/sorting/quicksort-declarative.js @@ -7,7 +7,7 @@ } /** - * Quicksort algorithm (functional variant) + * Quicksort algorithm (declarative variant) * * @public * @param {array} array Array which should be sorted. @@ -21,7 +21,7 @@ * @private * @param {array} array Array which should be processed */ - return function quickSort(array, cmp) { + function quickSort(array, cmp) { if (array.length < 1) { return arr; } @@ -38,17 +38,17 @@ /** * Quicksort algorithm. In this version of quicksort used - * functional programming mechanisms.

+ * declarative programming mechanisms.

* Time complexity: O(N log(N)). * * @example * * var sort = require('path-to-algorithms/src' + - * '/sorting/quicksort-functional').quickSort; + * '/sorting/quicksort-declarative').quickSort; * console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ] * * @public - * @module sorting/quicksort-functional + * @module sorting/quicksort-declarative * @param {Array} array Input array. * @param {Function} cmp Optional. A function that defines an * alternative sort order. The function should return a negative, diff --git a/test/sorting/quicksort-functional.spec.js b/test/sorting/quicksort-declarative.spec.js similarity index 59% rename from test/sorting/quicksort-functional.spec.js rename to test/sorting/quicksort-declarative.spec.js index a71e6fc0..dfe4f06d 100644 --- a/test/sorting/quicksort-functional.spec.js +++ b/test/sorting/quicksort-declarative.spec.js @@ -1,5 +1,5 @@ var sortTestCase = require('./sort.testcase.js'); var quickSort = - require('../../src/sorting/quicksort-functional.js').quickSort; + require('../../src/sorting/quicksort-declarative.js').quickSort; sortTestCase(quickSort, 'Quick sort'); From 6ee5bca51247fcc8a385ced815eac242d9ac85d3 Mon Sep 17 00:00:00 2001 From: mik-laj Date: Wed, 7 Jun 2017 19:05:48 +0200 Subject: [PATCH 538/613] Add missing bracket --- src/sorting/quicksort-declarative.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sorting/quicksort-declarative.js b/src/sorting/quicksort-declarative.js index f266e16f..12b35b0b 100644 --- a/src/sorting/quicksort-declarative.js +++ b/src/sorting/quicksort-declarative.js @@ -29,7 +29,7 @@ const [x, ...rest] = arr; return [ - ...quickSort(rest.filter(v => cmp(v, x) < 0), + ...quickSort(rest.filter(v => cmp(v, x) < 0)), x, ...quickSort(rest.filter(v => cmp(v, x) >= 0)) ] From c9f659f9361d7a6b14acdf413c92e981045edef3 Mon Sep 17 00:00:00 2001 From: mik-laj Date: Wed, 7 Jun 2017 19:42:39 +0200 Subject: [PATCH 539/613] Fix a qucik sort - declarative --- src/sorting/quicksort-declarative.js | 16 ++++++++-------- test/sorting/sort.testcase.js | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/sorting/quicksort-declarative.js b/src/sorting/quicksort-declarative.js index 12b35b0b..062ef790 100644 --- a/src/sorting/quicksort-declarative.js +++ b/src/sorting/quicksort-declarative.js @@ -21,18 +21,18 @@ * @private * @param {array} array Array which should be processed */ - function quickSort(array, cmp) { + function quicksort(array, cmp) { if (array.length < 1) { - return arr; + return array; } - const [x, ...rest] = arr; + const [x, ...rest] = array; return [ - ...quickSort(rest.filter(v => cmp(v, x) < 0)), - x, - ...quickSort(rest.filter(v => cmp(v, x) >= 0)) - ] + ...quicksort(rest.filter(v => cmp(v, x) < 0), cmp), + x, + ...quicksort(rest.filter(v => cmp(v, x) >= 0), cmp) + ]; } @@ -57,7 +57,7 @@ */ return function (array, cmp) { cmp = cmp || compare; - quickSort(array, 0, array.length - 1, cmp); + array = quicksort(array, cmp); return array; }; diff --git a/test/sorting/sort.testcase.js b/test/sorting/sort.testcase.js index 65390edb..d12c1a9f 100644 --- a/test/sorting/sort.testcase.js +++ b/test/sorting/sort.testcase.js @@ -39,7 +39,7 @@ module.exports = function (sort, algorithmName, options) { precision: 0 }); } - sort(array); + array = sort(array); for (var i = 0; i < array.length - 1; i += 1) { expect(array[i] <= array[i + 1]).toBeTruthy(); } @@ -53,7 +53,7 @@ module.exports = function (sort, algorithmName, options) { } var array = createRandomArray(); - sort(array, comparator); + array = sort(array, comparator); for (var i = 0; i < array.length - 1; i += 1) { expect(array[i] >= array[i + 1]).toBeTruthy(); From ac2d2619553774b38dab8a15139c42e7c935727c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Bregu=C5=82a?= Date: Wed, 7 Jun 2017 19:46:10 +0200 Subject: [PATCH 540/613] Add a graphics algorithms to docs --- doc-config.json | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc-config.json b/doc-config.json index bddd99b3..90b5cbb4 100644 --- a/doc-config.json +++ b/doc-config.json @@ -4,14 +4,15 @@ }, "source": { "include": [ - "./src/graphs/searching/", + "./src/combinatorics/", + "./src/data-structures/", + "./src/graphics/", "./src/graphs/others/", + "./src/graphs/searching/", "./src/graphs/shortest-path/", "./src/graphs/spanning-trees/", - "./src/data-structures/", - "./src/combinatorics/", - "./src/primes/", "./src/others/", + "./src/primes/", "./src/searching/", "./src/sets/", "./src/shuffle/", @@ -29,4 +30,4 @@ "private": false, "readme": "./readme.md" } -} \ No newline at end of file +} From 0715aea694814da2741698884e55b7aa06d37463 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 7 Jun 2017 13:55:30 -0400 Subject: [PATCH 541/613] build: remove gulp-jscs --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 2a4a4c03..9d97aa97 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,6 @@ "gulp-eslint": "^3.0.1", "gulp": "^3.8.10", "gulp-jasmine": "^2.0.1", - "gulp-jscs": "^1.4.0", "gulp-shell": "^0.2.11", "jsdoc": "3.3.0-alpha13" }, From f571b1a5d3b8d351d48809e02b2b7a126fe6b1b6 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 7 Jun 2017 14:18:33 -0400 Subject: [PATCH 542/613] ci: use newer node --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bce32da8..e030331b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - "4" + - "8" before_script: - npm install -g gulp script: gulp build From 03eeabd9a3abf90d61951366e872a250bbd8ec5c Mon Sep 17 00:00:00 2001 From: mgechev Date: Thu, 8 Jun 2017 13:43:29 -0700 Subject: [PATCH 543/613] docs: update the list of contributors --- readme.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/readme.md b/readme.md index bfa865b3..85781271 100644 --- a/readme.md +++ b/readme.md @@ -71,23 +71,22 @@ If the build is not successful fix your code in order the tests and jshint valid ## Contributors -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[mik-laj](https://github.com/mik-laj) |[krzysztof-grzybek](https://github.com/krzysztof-grzybek) | :---: |:---: |:---: |:---: |:---: |:---: | -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[mik-laj](https://github.com/mik-laj) |[krzysztof-grzybek](https://github.com/krzysztof-grzybek) | -[jettcalleja](https://github.com/jettcalleja) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[filipefalcaos](https://github.com/filipefalcaos) | +[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[filipefalcaos](https://github.com/filipefalcaos) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) | :---: |:---: |:---: |:---: |:---: |:---: | -[jettcalleja](https://github.com/jettcalleja) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[filipefalcaos](https://github.com/filipefalcaos) | +[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[filipefalcaos](https://github.com/filipefalcaos) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) | -[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[mik-laj](https://github.com/mik-laj) |[amilajack](https://github.com/amilajack) | +[deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[Microfed](https://github.com/Microfed) |[amilajack](https://github.com/amilajack) | :---: |:---: |:---: |:---: |:---: |:---: | -[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[mik-laj](https://github.com/mik-laj) |[amilajack](https://github.com/amilajack) | +[deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[Microfed](https://github.com/Microfed) |[amilajack](https://github.com/amilajack) | -[ysharplanguage](https://github.com/ysharplanguage) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[shaunak1111](https://github.com/shaunak1111) | +[shaunak1111](https://github.com/shaunak1111) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[ysharplanguage](https://github.com/ysharplanguage) | :---: |:---: |:---: |:---: |:---: |:---: | -[ysharplanguage](https://github.com/ysharplanguage) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[shaunak1111](https://github.com/shaunak1111) | +[shaunak1111](https://github.com/shaunak1111) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[ysharplanguage](https://github.com/ysharplanguage) | ## License The code in this repository is distributed under the terms of the MIT license. - From 0429ba1250b7c7ded1390120278a830f8243cdf4 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Sat, 22 Jul 2017 20:25:58 +0300 Subject: [PATCH 544/613] Update readme.md --- readme.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/readme.md b/readme.md index 85781271..0b5ef75e 100644 --- a/readme.md +++ b/readme.md @@ -6,8 +6,6 @@ This repository contains JavaScript implementations of different famous Computer API reference with usage examples available here. -*Note: not all algorithms are well tested so bugs are quite possible.* - ## Development **To install all dev dependencies** From 4229d0fee53d69f5b2bc140125e4bf138f19a86e Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 30 Jul 2017 23:42:45 +0300 Subject: [PATCH 545/613] docs: update the list of contributors --- readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index 85781271..ca83947e 100644 --- a/readme.md +++ b/readme.md @@ -71,19 +71,19 @@ If the build is not successful fix your code in order the tests and jshint valid ## Contributors -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[mik-laj](https://github.com/mik-laj) |[krzysztof-grzybek](https://github.com/krzysztof-grzybek) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[mik-laj](https://github.com/mik-laj) |[krzysztof-grzybek](https://github.com/krzysztof-grzybek) | :---: |:---: |:---: |:---: |:---: |:---: | [mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[mik-laj](https://github.com/mik-laj) |[krzysztof-grzybek](https://github.com/krzysztof-grzybek) | -[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[filipefalcaos](https://github.com/filipefalcaos) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) | +[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[filipefalcaos](https://github.com/filipefalcaos) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) | :---: |:---: |:---: |:---: |:---: |:---: | [pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[filipefalcaos](https://github.com/filipefalcaos) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) | -[deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[Microfed](https://github.com/Microfed) |[amilajack](https://github.com/amilajack) | +[deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[Microfed](https://github.com/Microfed) |[amilajack](https://github.com/amilajack) | :---: |:---: |:---: |:---: |:---: |:---: | [deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[Microfed](https://github.com/Microfed) |[amilajack](https://github.com/amilajack) | -[shaunak1111](https://github.com/shaunak1111) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[ysharplanguage](https://github.com/ysharplanguage) | +[shaunak1111](https://github.com/shaunak1111) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[ysharplanguage](https://github.com/ysharplanguage) | :---: |:---: |:---: |:---: |:---: |:---: | [shaunak1111](https://github.com/shaunak1111) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[ysharplanguage](https://github.com/ysharplanguage) | From 2f90ba9cfb1434179d3e9cefe7d868111d3e0d4a Mon Sep 17 00:00:00 2001 From: Mauro Bringolf Date: Tue, 15 Aug 2017 14:37:35 +0200 Subject: [PATCH 546/613] Raw implementation and test case from wikipedia --- src/graphs/spanning-trees/kruskal.js | 81 ++++++++++++++++++++++ test/graphs/spanning-trees/kruskal.spec.js | 53 ++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 src/graphs/spanning-trees/kruskal.js create mode 100644 test/graphs/spanning-trees/kruskal.spec.js diff --git a/src/graphs/spanning-trees/kruskal.js b/src/graphs/spanning-trees/kruskal.js new file mode 100644 index 00000000..20e031d3 --- /dev/null +++ b/src/graphs/spanning-trees/kruskal.js @@ -0,0 +1,81 @@ +// Kruskal's algorithm for minimal spanning tree implemented with the UnionFind datastructure. + +(function(exports) { + 'use strict'; + + var QuickUnion = require('../../sets/quickunion').QuickUnion; + var mergeSort = require('../../sorting/mergesort').mergeSort; + exports.Vertex = require('../../data-structures/vertex').Vertex; + exports.Edge = require('../../data-structures/edge').Edge; + + exports.Graph = function (edges) { + this.edges = edges || []; + } + + exports.Graph.prototype.kruskal = (function () { + var qunion; + var spanningTree; + var indexes; + + /** + * Used for sorting the edges + * + * @private + * @param {Vertex} a First operand of the comparison. + * @param {Vertex} b Second operand of the comparison. + * @return {number} Number which which is equal, greater or + * less then zero and indicates whether the first vertex is + * "smaller" than the second. + */ + function compareEdges(a, b) { + return a.distance - b.distance; + } + + /** + * Initialize the algorithm. + * + * @private + */ + function init() { + var edge; + var i = 0; + + mergeSort(this.edges, compareEdges); + spanningTree = []; + indexes = {}; + + // Create links from vertices to QuickUnion elements + for (edge of this.edges) { + if (!(edge.from.id in indexes)) { + indexes[edge.from.id] = i; + i += 1; + } + if (!(edge.to.id in indexes)) { + indexes[edge.to.id] = i; + i += 1; + } + } + + qunion = new QuickUnion(i); + } + + return function () { + init.call(this); + + var edge; + + for (edge of this.edges) { + var from = indexes[edge.from.id]; + var to = indexes[edge.to.id]; + if (!qunion.connected(from, to)) { + qunion.union(from, to); + spanningTree.push(edge); + } + } + + return new exports.Graph(spanningTree); + } + + })(); + +})(typeof window === 'undefined' ? module.exports : window); diff --git a/test/graphs/spanning-trees/kruskal.spec.js b/test/graphs/spanning-trees/kruskal.spec.js new file mode 100644 index 00000000..f3094b95 --- /dev/null +++ b/test/graphs/spanning-trees/kruskal.spec.js @@ -0,0 +1,53 @@ +var kruskal = require('../../../src/graphs/spanning-trees/kruskal'); + +describe('Kruskal', function() { + 'use strict'; + + it('should define a function', function () { + expect(kruskal).toBeDefined(); + expect(typeof kruskal).toBe('object'); + expect(typeof kruskal.Graph).toBe('function'); + expect(typeof kruskal.Edge).toBe('function'); + expect(typeof kruskal.Vertex).toBe('function'); + }); + + it('should work with an empty graph', function() { + var graph = new kruskal.Graph([], 0); + var spanningTree = graph.kruskal(); + + expect(spanningTree.edges.length).toEqual(0); + }); + + it('should correctly compute general example', function() { + var nodes = []; + var edges = []; + var i; + for (i = 0; i < 7; i += 1) { + nodes[i] = new kruskal.Vertex(i); + } + + edges.push(new kruskal.Edge(nodes[0], nodes[1], 7)); + edges.push(new kruskal.Edge(nodes[1], nodes[2], 8)); + edges.push(new kruskal.Edge(nodes[2], nodes[4], 5)); + edges.push(new kruskal.Edge(nodes[4], nodes[6], 9)); + edges.push(new kruskal.Edge(nodes[5], nodes[6], 11)); + edges.push(new kruskal.Edge(nodes[3], nodes[5], 6)); + edges.push(new kruskal.Edge(nodes[0], nodes[3], 5)); + edges.push(new kruskal.Edge(nodes[1], nodes[4], 7)); + edges.push(new kruskal.Edge(nodes[1], nodes[3], 9)); + edges.push(new kruskal.Edge(nodes[3], nodes[4], 15)); + edges.push(new kruskal.Edge(nodes[4], nodes[5], 8)); + + var graph = new kruskal.Graph(edges); + var spanningTree = graph.kruskal(); + + expect(spanningTree.edges.length).toEqual(6); + + var sum = spanningTree.edges.reduce(function(acc, edge) { + return acc += edge.distance; + }, 0); + + expect(sum).toEqual(39); + + }) +}); From 370848db94eeb61a8138c01d1ef7a9af1070bdd0 Mon Sep 17 00:00:00 2001 From: Alex Jover Date: Thu, 12 Oct 2017 09:16:43 +0200 Subject: [PATCH 547/613] Simplify linked-list reverse method --- src/data-structures/linked-list.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index 14e9a23e..ac911c24 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -258,21 +258,19 @@ if (!this.first || !this.first.next) { return; } - var current = this.first.next; - var prev = this.first; - var temp; - while (current) { - temp = current.next; - current.next = prev; - prev.prev = current; - prev = current; - current = temp; - } - this.first.next = null; - this.last.prev = null; - temp = this.first; - this.first = prev; - this.last = temp; + var current = this.first + var next + + do { + next = current.next + current.next = current.prev + current.prev = next + current = next + } while (next) + + var tmp = this.first + this.first = this.last + this.last = tmp }; })(typeof window === 'undefined' ? module.exports : window); From 424e14e05898eed3da9e18ac2bf07ded64eb712d Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 15 Oct 2017 22:14:06 +0300 Subject: [PATCH 548/613] docs: update the list of contributors --- readme.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index 5e56cbbc..494a9101 100644 --- a/readme.md +++ b/readme.md @@ -77,13 +77,17 @@ If the build is not successful fix your code in order the tests and jshint valid :---: |:---: |:---: |:---: |:---: |:---: | [pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[filipefalcaos](https://github.com/filipefalcaos) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) | -[deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[Microfed](https://github.com/Microfed) |[amilajack](https://github.com/amilajack) | +[deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[Microfed](https://github.com/Microfed) |[alexjoverm](https://github.com/alexjoverm) | :---: |:---: |:---: |:---: |:---: |:---: | -[deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[Microfed](https://github.com/Microfed) |[amilajack](https://github.com/amilajack) | +[deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[Microfed](https://github.com/Microfed) |[alexjoverm](https://github.com/alexjoverm) | -[shaunak1111](https://github.com/shaunak1111) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[ysharplanguage](https://github.com/ysharplanguage) | +[amilajack](https://github.com/amilajack) |[shaunak1111](https://github.com/shaunak1111) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) | :---: |:---: |:---: |:---: |:---: |:---: | -[shaunak1111](https://github.com/shaunak1111) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) |[ysharplanguage](https://github.com/ysharplanguage) | +[amilajack](https://github.com/amilajack) |[shaunak1111](https://github.com/shaunak1111) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) | + +[ysharplanguage](https://github.com/ysharplanguage) | +:---: | +[ysharplanguage](https://github.com/ysharplanguage) | ## License From a6a2ed98445c208062a62e9605c0d07c8e78dbde Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 3 Nov 2017 18:04:21 -0700 Subject: [PATCH 549/613] Update travis link --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 494a9101..7db2e68a 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ ## About -![](https://travis-ci.org/mgechev/javascript-algorithms.svg?branch=master) +[![Build Status](https://travis-ci.org/mgechev/javascript-algorithms.svg?branch=Jakehp-patch-1)](https://travis-ci.org/mgechev/javascript-algorithms) This repository contains JavaScript implementations of different famous Computer Science algorithms. From d87dc543c4591bdf695471cf1611ee985a19cbf1 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 28 Nov 2017 18:35:37 -0800 Subject: [PATCH 550/613] Update docs --- readme.md | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/readme.md b/readme.md index 7db2e68a..5a7178e7 100644 --- a/readme.md +++ b/readme.md @@ -4,7 +4,8 @@ This repository contains JavaScript implementations of different famous Computer Science algorithms. -API reference with usage examples available here. +API reference with usage examples available +here. ## Development @@ -18,13 +19,13 @@ npm install **To setup repository with documentation** -- Go to the parent directory of the `javascript-algorithms` folder and call: +* Go to the parent directory of the `javascript-algorithms` folder and call: ```bash git clone https://github.com/mgechev/javascript-algorithms.git javascript-algorithms-docs ``` -- Go to the `javascript-algorithms-docs` folder and change current branch to `gh-pages`: +* Go to the `javascript-algorithms-docs` folder and change current branch to `gh-pages`: ```bash git checkout gh-pages @@ -54,8 +55,8 @@ and all `*.spec.js` files will be executed. ## Contributions -Fork the repo and make required changes. After that push your changes in branch, which is named according to the changes you did. -Initiate the PR. +Fork the repo and make required changes. After that push your changes in branch, which is named according to the changes +you did. Initiate the PR. Make sure you're editor makes validations according to the `.jshintrc` in the root directory of the repository. @@ -65,29 +66,30 @@ Before pushing to the repository run: gulp build ``` -If the build is not successful fix your code in order the tests and jshint validation to run successfully and after that create a pull request. +If the build is not successful fix your code in order the tests and jshint validation to run successfully and after that +create a pull request. ## Contributors -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[mik-laj](https://github.com/mik-laj) |[krzysztof-grzybek](https://github.com/krzysztof-grzybek) | -:---: |:---: |:---: |:---: |:---: |:---: | -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[mik-laj](https://github.com/mik-laj) |[krzysztof-grzybek](https://github.com/krzysztof-grzybek) | +| [mgechev](https://github.com/mgechev) | [AndriiHeonia](https://github.com/AndriiHeonia) | [Jakehp](https://github.com/Jakehp) | [lygstate](https://github.com/lygstate) | [mik-laj](https://github.com/mik-laj) | [krzysztof-grzybek](https://github.com/krzysztof-grzybek) | +| :---------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------: | +| [mgechev](https://github.com/mgechev) | [AndriiHeonia](https://github.com/AndriiHeonia) | [Jakehp](https://github.com/Jakehp) | [lygstate](https://github.com/lygstate) | [mik-laj](https://github.com/mik-laj) | [krzysztof-grzybek](https://github.com/krzysztof-grzybek) | -[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[filipefalcaos](https://github.com/filipefalcaos) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) | -:---: |:---: |:---: |:---: |:---: |:---: | -[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[filipefalcaos](https://github.com/filipefalcaos) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) | +| [pvoznenko](https://github.com/pvoznenko) | [jettcalleja](https://github.com/jettcalleja) | [filipefalcaos](https://github.com/filipefalcaos) | [kdamball](https://github.com/kdamball) | [lekkas](https://github.com/lekkas) | [infusion](https://github.com/infusion) | +| :--------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | +| [pvoznenko](https://github.com/pvoznenko) | [jettcalleja](https://github.com/jettcalleja) | [filipefalcaos](https://github.com/filipefalcaos) | [kdamball](https://github.com/kdamball) | [lekkas](https://github.com/lekkas) | [infusion](https://github.com/infusion) | -[deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[Microfed](https://github.com/Microfed) |[alexjoverm](https://github.com/alexjoverm) | -:---: |:---: |:---: |:---: |:---: |:---: | -[deniskyashif](https://github.com/deniskyashif) |[designeng](https://github.com/designeng) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[Microfed](https://github.com/Microfed) |[alexjoverm](https://github.com/alexjoverm) | +| [deniskyashif](https://github.com/deniskyashif) | [designeng](https://github.com/designeng) | [pkerpedjiev](https://github.com/pkerpedjiev) | [Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) | [Microfed](https://github.com/Microfed) | [alexjoverm](https://github.com/alexjoverm) | +| :--------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | +| [deniskyashif](https://github.com/deniskyashif) | [designeng](https://github.com/designeng) | [pkerpedjiev](https://github.com/pkerpedjiev) | [Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) | [Microfed](https://github.com/Microfed) | [alexjoverm](https://github.com/alexjoverm) | -[amilajack](https://github.com/amilajack) |[shaunak1111](https://github.com/shaunak1111) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) | -:---: |:---: |:---: |:---: |:---: |:---: | -[amilajack](https://github.com/amilajack) |[shaunak1111](https://github.com/shaunak1111) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[fanixk](https://github.com/fanixk) | +| [amilajack](https://github.com/amilajack) | [shaunak1111](https://github.com/shaunak1111) | [contra](https://github.com/contra) | [liesislukas](https://github.com/liesislukas) | [millerrach](https://github.com/millerrach) | [fanixk](https://github.com/fanixk) | +| :--------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: | +| [amilajack](https://github.com/amilajack) | [shaunak1111](https://github.com/shaunak1111) | [contra](https://github.com/contra) | [liesislukas](https://github.com/liesislukas) | [millerrach](https://github.com/millerrach) | [fanixk](https://github.com/fanixk) | -[ysharplanguage](https://github.com/ysharplanguage) | -:---: | -[ysharplanguage](https://github.com/ysharplanguage) | +| [ysharplanguage](https://github.com/ysharplanguage) | +| :------------------------------------------------------------------------------------------------------------------------------------------: | +| [ysharplanguage](https://github.com/ysharplanguage) | ## License From 3eee56076fec9a056f158b87ef2a3f01fc5f02eb Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 28 Nov 2017 18:55:58 -0800 Subject: [PATCH 551/613] Update dependencies --- package-lock.json | 1480 ++++++++++++++++++++++++++++++--------------- package.json | 2 +- 2 files changed, 1009 insertions(+), 473 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0fbe7a4c..601891e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2,6 +2,7 @@ "name": "javascript-algorithms", "version": "0.0.0", "lockfileVersion": 1, + "requires": true, "dependencies": { "acorn": { "version": "5.0.3", @@ -14,6 +15,9 @@ "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", "dev": true, + "requires": { + "acorn": "3.3.0" + }, "dependencies": { "acorn": { "version": "3.3.0", @@ -27,7 +31,11 @@ "version": "4.11.8", "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", - "dev": true + "dev": true, + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + } }, "ajv-keywords": { "version": "1.5.1", @@ -63,13 +71,19 @@ "version": "1.0.9", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz", "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=", - "dev": true + "dev": true, + "requires": { + "sprintf-js": "1.0.3" + } }, "arr-diff": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", - "dev": true + "dev": true, + "requires": { + "arr-flatten": "1.0.3" + } }, "arr-flatten": { "version": "1.0.3", @@ -87,7 +101,10 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", - "dev": true + "dev": true, + "requires": { + "array-uniq": "1.0.3" + } }, "array-uniq": { "version": "1.0.3", @@ -107,16 +124,21 @@ "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "dev": true }, - "async": { - "version": "0.2.10", - "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", - "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=", - "dev": true - }, "babel-code-frame": { "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.22.0.tgz", "integrity": "sha1-AnYgvuVnqIwyVhV05/0IAdMxGOQ=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "esutils": "2.0.2", + "js-tokens": "3.0.1" + } + }, + "babylon": { + "version": "7.0.0-beta.19", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.19.tgz", + "integrity": "sha512-Vg0C9s/REX6/WIXN37UKpv5ZhRi6A4pjHlpkE34+8/a6c2W1Q692n3hmc+SZG5lKRnaExLUbxtJ1SVT+KaCQ/A==", "dev": true }, "balanced-match": { @@ -131,23 +153,41 @@ "integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=", "dev": true }, + "bluebird": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", + "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==", + "dev": true + }, "brace-expansion": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.7.tgz", "integrity": "sha1-Pv/DxQ4ABTH7cg6v+A8K6O8jz1k=", - "dev": true + "dev": true, + "requires": { + "balanced-match": "0.4.2", + "concat-map": "0.0.1" + } }, "braces": { "version": "1.8.5", "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", - "dev": true + "dev": true, + "requires": { + "expand-range": "1.8.2", + "preserve": "0.2.0", + "repeat-element": "1.1.2" + } }, "bufferstreams": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/bufferstreams/-/bufferstreams-1.1.1.tgz", "integrity": "sha1-AWE3MGCsWYjv+ZBYcxEU9uGV1R4=", "dev": true, + "requires": { + "readable-stream": "2.2.11" + }, "dependencies": { "isarray": { "version": "1.0.0", @@ -159,13 +199,25 @@ "version": "2.2.11", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.11.tgz", "integrity": "sha512-h+8+r3MKEhkiVrwdKL8aWs1oc1VvBu33ueshOvS26RsZQ3Amhx/oO3TKe4lApSV9ueY6as8EAh7mtuFjdlhg9Q==", - "dev": true + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.0.1", + "string_decoder": "1.0.2", + "util-deprecate": "1.0.2" + } }, "string_decoder": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.2.tgz", "integrity": "sha1-sp4fThEl+pehA4K4pTNze3SR4Xk=", - "dev": true + "dev": true, + "requires": { + "safe-buffer": "5.0.1" + } } } }, @@ -173,7 +225,10 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", - "dev": true + "dev": true, + "requires": { + "callsites": "0.2.0" + } }, "callsites": { "version": "0.2.0", @@ -181,17 +236,18 @@ "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", "dev": true }, - "catharsis": { - "version": "0.8.8", - "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.8.tgz", - "integrity": "sha1-aTR59DqsVJ2Aa9c+kkzQ2USVGgY=", - "dev": true - }, "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true + "dev": true, + "requires": { + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" + } }, "circular-json": { "version": "0.3.1", @@ -203,13 +259,10 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", - "dev": true - }, - "cli-table": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.1.tgz", - "integrity": "sha1-9TsFJmqLGguTSz0IIebi3FkUriM=", - "dev": true + "dev": true, + "requires": { + "restore-cursor": "1.0.1" + } }, "cli-width": { "version": "2.1.0", @@ -241,18 +294,6 @@ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "dev": true }, - "colors": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", - "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=", - "dev": true - }, - "commander": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.6.0.tgz", - "integrity": "sha1-nfflL7Kgyw+4kFjugMMQQiXzfh0=", - "dev": true - }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -264,6 +305,11 @@ "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", "dev": true, + "requires": { + "inherits": "2.0.3", + "readable-stream": "2.2.11", + "typedarray": "0.0.6" + }, "dependencies": { "isarray": { "version": "1.0.0", @@ -275,13 +321,25 @@ "version": "2.2.11", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.11.tgz", "integrity": "sha512-h+8+r3MKEhkiVrwdKL8aWs1oc1VvBu33ueshOvS26RsZQ3Amhx/oO3TKe4lApSV9ueY6as8EAh7mtuFjdlhg9Q==", - "dev": true + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.0.1", + "string_decoder": "1.0.2", + "util-deprecate": "1.0.2" + } }, "string_decoder": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.2.tgz", "integrity": "sha1-sp4fThEl+pehA4K4pTNze3SR4Xk=", - "dev": true + "dev": true, + "requires": { + "safe-buffer": "5.0.1" + } } } }, @@ -291,17 +349,14 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, - "cycle": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz", - "integrity": "sha1-IegLK+hYD5i0aPN5QwZisEbDStI=", - "dev": true - }, "d": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", - "dev": true + "dev": true, + "requires": { + "es5-ext": "0.10.23" + } }, "dateformat": { "version": "2.0.0", @@ -313,13 +368,10 @@ "version": "2.6.8", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", - "dev": true - }, - "deep-equal": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", - "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", - "dev": true + "dev": true, + "requires": { + "ms": "2.0.0" + } }, "deep-is": { "version": "0.1.3", @@ -331,13 +383,25 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", - "dev": true + "dev": true, + "requires": { + "clone": "1.0.2" + } }, "del": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", "dev": true, + "requires": { + "globby": "5.0.0", + "is-path-cwd": "1.0.0", + "is-path-in-cwd": "1.0.0", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1", + "rimraf": "2.6.1" + }, "dependencies": { "object-assign": { "version": "4.1.1", @@ -357,13 +421,20 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-0.1.0.tgz", "integrity": "sha1-STXe39lIhkjgBrASlWbpOGcR6mM=", - "dev": true + "dev": true, + "requires": { + "fs-exists-sync": "0.1.0" + } }, "doctrine": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.0.tgz", "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=", "dev": true, + "requires": { + "esutils": "2.0.2", + "isarray": "1.0.0" + }, "dependencies": { "isarray": { "version": "1.0.0", @@ -377,49 +448,89 @@ "version": "0.0.2", "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", - "dev": true + "dev": true, + "requires": { + "readable-stream": "1.1.14" + } }, "end-of-stream": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-0.1.5.tgz", "integrity": "sha1-jhdyBsPICDfYVjLouTWd/osvbq8=", - "dev": true + "dev": true, + "requires": { + "once": "1.3.3" + } }, "es5-ext": { "version": "0.10.23", "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.23.tgz", "integrity": "sha1-dXi1G+l0IHpUh4IbVlOMIk5Oezg=", - "dev": true + "dev": true, + "requires": { + "es6-iterator": "2.0.1", + "es6-symbol": "3.1.1" + } }, "es6-iterator": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.1.tgz", "integrity": "sha1-jjGcnwRTv1ddN0lAplWSDlnKVRI=", - "dev": true + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.23", + "es6-symbol": "3.1.1" + } }, "es6-map": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/es6-map/-/es6-map-0.1.5.tgz", "integrity": "sha1-kTbgUD3MBqMBaQ8LsU/042TpSfA=", - "dev": true + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.23", + "es6-iterator": "2.0.1", + "es6-set": "0.1.5", + "es6-symbol": "3.1.1", + "event-emitter": "0.3.5" + } }, "es6-set": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", "integrity": "sha1-0rPsXU2ADO2BjbU40ol02wpzzLE=", - "dev": true + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.23", + "es6-iterator": "2.0.1", + "es6-symbol": "3.1.1", + "event-emitter": "0.3.5" + } }, "es6-symbol": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", - "dev": true + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.23" + } }, "es6-weak-map": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz", "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", - "dev": true + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.23", + "es6-iterator": "2.0.1", + "es6-symbol": "3.1.1" + } }, "escape-string-regexp": { "version": "1.0.5", @@ -431,19 +542,70 @@ "version": "3.6.0", "resolved": "https://registry.npmjs.org/escope/-/escope-3.6.0.tgz", "integrity": "sha1-4Bl16BJ4GhY6ba392AOY3GTIicM=", - "dev": true + "dev": true, + "requires": { + "es6-map": "0.1.5", + "es6-weak-map": "2.0.2", + "esrecurse": "4.1.0", + "estraverse": "4.2.0" + } }, "eslint": { "version": "3.19.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-3.19.0.tgz", "integrity": "sha1-yPxiAcf0DdCJQbh8CFdnOGpnmsw=", "dev": true, + "requires": { + "babel-code-frame": "6.22.0", + "chalk": "1.1.3", + "concat-stream": "1.6.0", + "debug": "2.6.8", + "doctrine": "2.0.0", + "escope": "3.6.0", + "espree": "3.4.3", + "esquery": "1.0.0", + "estraverse": "4.2.0", + "esutils": "2.0.2", + "file-entry-cache": "2.0.0", + "glob": "7.1.2", + "globals": "9.17.0", + "ignore": "3.3.3", + "imurmurhash": "0.1.4", + "inquirer": "0.12.0", + "is-my-json-valid": "2.16.0", + "is-resolvable": "1.0.0", + "js-yaml": "3.8.4", + "json-stable-stringify": "1.0.1", + "levn": "0.3.0", + "lodash": "4.17.4", + "mkdirp": "0.5.1", + "natural-compare": "1.4.0", + "optionator": "0.8.2", + "path-is-inside": "1.0.2", + "pluralize": "1.2.1", + "progress": "1.1.8", + "require-uncached": "1.0.3", + "shelljs": "0.7.7", + "strip-bom": "3.0.0", + "strip-json-comments": "2.0.1", + "table": "3.8.3", + "text-table": "0.2.0", + "user-home": "2.0.0" + }, "dependencies": { "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.3.3", + "path-is-absolute": "1.0.1" + } }, "lodash": { "version": "4.17.4", @@ -455,7 +617,10 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true + "dev": true, + "requires": { + "brace-expansion": "1.1.7" + } }, "strip-bom": { "version": "3.0.0", @@ -467,7 +632,10 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=", - "dev": true + "dev": true, + "requires": { + "os-homedir": "1.0.2" + } } } }, @@ -475,7 +643,11 @@ "version": "3.4.3", "resolved": "https://registry.npmjs.org/espree/-/espree-3.4.3.tgz", "integrity": "sha1-KRC1zNSc6JPC//+qtP2LOjG4I3Q=", - "dev": true + "dev": true, + "requires": { + "acorn": "5.0.3", + "acorn-jsx": "3.0.1" + } }, "esprima": { "version": "3.1.3", @@ -483,23 +655,24 @@ "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=", "dev": true }, - "esprima-harmony-jscs": { - "version": "1.1.0-bin", - "resolved": "https://registry.npmjs.org/esprima-harmony-jscs/-/esprima-harmony-jscs-1.1.0-bin.tgz", - "integrity": "sha1-B8sFcdlD7tS8e/6ecmN8Zj/hUe0=", - "dev": true - }, "esquery": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.0.tgz", "integrity": "sha1-z7qLV9f7qT8XKYqKAGoEzaE9gPo=", - "dev": true + "dev": true, + "requires": { + "estraverse": "4.2.0" + } }, "esrecurse": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.1.0.tgz", "integrity": "sha1-RxO2U2rffyrE8yfVWed1a/9kgiA=", "dev": true, + "requires": { + "estraverse": "4.1.1", + "object-assign": "4.1.1" + }, "dependencies": { "estraverse": { "version": "4.1.1", @@ -531,7 +704,11 @@ "version": "0.3.5", "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", - "dev": true + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.23" + } }, "exit": { "version": "0.1.2", @@ -549,19 +726,28 @@ "version": "0.1.5", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", - "dev": true + "dev": true, + "requires": { + "is-posix-bracket": "0.1.1" + } }, "expand-range": { "version": "1.8.2", "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", - "dev": true + "dev": true, + "requires": { + "fill-range": "2.2.3" + } }, "expand-tilde": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-1.2.2.tgz", "integrity": "sha1-C4HrqJflo9MdHD0QL48BRB5VlEk=", - "dev": true + "dev": true, + "requires": { + "os-homedir": "1.0.2" + } }, "extend": { "version": "3.0.1", @@ -573,19 +759,20 @@ "version": "0.3.2", "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", - "dev": true - }, - "eyes": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", - "integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A=", - "dev": true + "dev": true, + "requires": { + "is-extglob": "1.0.0" + } }, "fancy-log": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.0.tgz", "integrity": "sha1-Rb4X0Cu5kX1gzP/UmVyZnmyMmUg=", - "dev": true + "dev": true, + "requires": { + "chalk": "1.1.3", + "time-stamp": "1.1.0" + } }, "fast-levenshtein": { "version": "2.0.6", @@ -598,6 +785,10 @@ "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", "dev": true, + "requires": { + "escape-string-regexp": "1.0.5", + "object-assign": "4.1.1" + }, "dependencies": { "object-assign": { "version": "4.1.1", @@ -612,6 +803,10 @@ "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", "dev": true, + "requires": { + "flat-cache": "1.2.2", + "object-assign": "4.1.1" + }, "dependencies": { "object-assign": { "version": "4.1.1", @@ -631,7 +826,14 @@ "version": "2.2.3", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz", "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", - "dev": true + "dev": true, + "requires": { + "is-number": "2.1.0", + "isobject": "2.1.0", + "randomatic": "1.1.6", + "repeat-element": "1.1.2", + "repeat-string": "1.6.1" + } }, "find-index": { "version": "0.1.1", @@ -643,13 +845,28 @@ "version": "0.4.3", "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.4.3.tgz", "integrity": "sha1-QAQ5Kee8YK3wt/SCfExudaDeyhI=", - "dev": true + "dev": true, + "requires": { + "detect-file": "0.1.0", + "is-glob": "2.0.1", + "micromatch": "2.3.11", + "resolve-dir": "0.1.1" + } }, "fined": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/fined/-/fined-1.0.2.tgz", "integrity": "sha1-WyhCS3YNdZiWC374SA3/itNmDpc=", - "dev": true + "dev": true, + "requires": { + "expand-tilde": "1.2.2", + "lodash.assignwith": "4.2.0", + "lodash.isempty": "4.4.0", + "lodash.isplainobject": "4.0.6", + "lodash.isstring": "4.0.1", + "lodash.pick": "4.4.0", + "parse-filepath": "1.0.1" + } }, "first-chunk-stream": { "version": "1.0.0", @@ -668,6 +885,12 @@ "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.2.2.tgz", "integrity": "sha1-+oZxTnLCHbiGAXYezy9VXRq8a5Y=", "dev": true, + "requires": { + "circular-json": "0.3.1", + "del": "2.2.2", + "graceful-fs": "4.1.11", + "write": "0.2.1" + }, "dependencies": { "graceful-fs": { "version": "4.1.11", @@ -687,7 +910,10 @@ "version": "0.1.5", "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", - "dev": true + "dev": true, + "requires": { + "for-in": "1.0.2" + } }, "fs-exists-sync": { "version": "0.1.0", @@ -705,7 +931,10 @@ "version": "0.5.2", "resolved": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz", "integrity": "sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8=", - "dev": true + "dev": true, + "requires": { + "globule": "0.1.0" + } }, "generate-function": { "version": "2.0.0", @@ -717,49 +946,77 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", - "dev": true - }, - "get-stdin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", - "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", - "dev": true + "dev": true, + "requires": { + "is-property": "1.0.2" + } }, "glob": { "version": "4.5.3", "resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", - "dev": true + "dev": true, + "requires": { + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "2.0.10", + "once": "1.3.3" + } }, "glob-base": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", - "dev": true + "dev": true, + "requires": { + "glob-parent": "2.0.0", + "is-glob": "2.0.1" + } }, "glob-parent": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", - "dev": true + "dev": true, + "requires": { + "is-glob": "2.0.1" + } }, "glob-stream": { "version": "3.1.18", "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-3.1.18.tgz", "integrity": "sha1-kXCl8St5Awb9/lmPMT+PeVT9FDs=", "dev": true, + "requires": { + "glob": "4.5.3", + "glob2base": "0.0.12", + "minimatch": "2.0.10", + "ordered-read-streams": "0.1.0", + "through2": "0.6.5", + "unique-stream": "1.0.0" + }, "dependencies": { "readable-stream": { "version": "1.0.34", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } }, "through2": { "version": "0.6.5", "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true + "dev": true, + "requires": { + "readable-stream": "1.0.34", + "xtend": "4.0.1" + } } } }, @@ -767,25 +1024,41 @@ "version": "0.0.6", "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.6.tgz", "integrity": "sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs=", - "dev": true + "dev": true, + "requires": { + "gaze": "0.5.2" + } }, "glob2base": { "version": "0.0.12", "resolved": "https://registry.npmjs.org/glob2base/-/glob2base-0.0.12.tgz", "integrity": "sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY=", - "dev": true + "dev": true, + "requires": { + "find-index": "0.1.1" + } }, "global-modules": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-0.2.3.tgz", "integrity": "sha1-6lo77ULG1s6ZWk+KEmm12uIjgo0=", - "dev": true + "dev": true, + "requires": { + "global-prefix": "0.1.5", + "is-windows": "0.2.0" + } }, "global-prefix": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-0.1.5.tgz", "integrity": "sha1-jTvGuNo8qBEqFg2NSW/wRiv+948=", - "dev": true + "dev": true, + "requires": { + "homedir-polyfill": "1.0.1", + "ini": "1.3.4", + "is-windows": "0.2.0", + "which": "1.2.14" + } }, "globals": { "version": "9.17.0", @@ -798,18 +1071,37 @@ "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", "dev": true, + "requires": { + "array-union": "1.0.2", + "arrify": "1.0.1", + "glob": "7.1.2", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" + }, "dependencies": { "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.3.3", + "path-is-absolute": "1.0.1" + } }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true + "dev": true, + "requires": { + "brace-expansion": "1.1.7" + } }, "object-assign": { "version": "4.1.1", @@ -824,12 +1116,22 @@ "resolved": "https://registry.npmjs.org/globule/-/globule-0.1.0.tgz", "integrity": "sha1-2cjt3h2nnRJaFRt5UzuXhnY0auU=", "dev": true, + "requires": { + "glob": "3.1.21", + "lodash": "1.0.2", + "minimatch": "0.2.14" + }, "dependencies": { "glob": { "version": "3.1.21", "resolved": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz", "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", - "dev": true + "dev": true, + "requires": { + "graceful-fs": "1.2.3", + "inherits": "1.0.2", + "minimatch": "0.2.14" + } }, "graceful-fs": { "version": "1.2.3", @@ -847,7 +1149,11 @@ "version": "0.2.14", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", - "dev": true + "dev": true, + "requires": { + "lru-cache": "2.7.3", + "sigmund": "1.0.1" + } } } }, @@ -855,56 +1161,63 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.0.tgz", "integrity": "sha1-f+DxmfV6yQbPUS/urY+Q7kooT8U=", - "dev": true + "dev": true, + "requires": { + "sparkles": "1.0.0" + } }, "graceful-fs": { "version": "3.0.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", - "dev": true + "dev": true, + "requires": { + "natives": "1.1.0" + } }, "gulp": { "version": "3.9.1", "resolved": "https://registry.npmjs.org/gulp/-/gulp-3.9.1.tgz", "integrity": "sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ=", - "dev": true + "dev": true, + "requires": { + "archy": "1.0.0", + "chalk": "1.1.3", + "deprecated": "0.0.1", + "gulp-util": "3.0.8", + "interpret": "1.0.3", + "liftoff": "2.3.0", + "minimist": "1.2.0", + "orchestrator": "0.3.8", + "pretty-hrtime": "1.0.3", + "semver": "4.3.6", + "tildify": "1.2.0", + "v8flags": "2.1.1", + "vinyl-fs": "0.3.14" + } }, "gulp-eslint": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/gulp-eslint/-/gulp-eslint-3.0.1.tgz", "integrity": "sha1-BOV+PhjGl0JnwSz2hV3HF9SjE70=", - "dev": true + "dev": true, + "requires": { + "bufferstreams": "1.1.1", + "eslint": "3.19.0", + "gulp-util": "3.0.8" + } }, "gulp-jasmine": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/gulp-jasmine/-/gulp-jasmine-2.4.2.tgz", "integrity": "sha1-Wn9H4nNww2GawKKkQr45lnFAnbM=", - "dev": true - }, - "gulp-jscs": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/gulp-jscs/-/gulp-jscs-1.6.0.tgz", - "integrity": "sha1-sV7lJgH391pyXTQdHaFhsBJ9Z6A=", "dev": true, - "dependencies": { - "object-assign": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-2.1.1.tgz", - "integrity": "sha1-Q8NuXVaf+OSBbE76i+AtJpZ8GKo=", - "dev": true - }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true - }, - "through2": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true - } + "requires": { + "arrify": "1.0.1", + "gulp-util": "3.0.8", + "jasmine": "2.6.0", + "jasmine-terminal-reporter": "1.0.3", + "through2": "2.0.3" } }, "gulp-shell": { @@ -912,6 +1225,12 @@ "resolved": "https://registry.npmjs.org/gulp-shell/-/gulp-shell-0.2.11.tgz", "integrity": "sha1-GbpoC2WoZvYELt4LDjS2LbcfITk=", "dev": true, + "requires": { + "async": "0.9.2", + "gulp-util": "3.0.8", + "lodash": "2.4.2", + "through2": "0.6.5" + }, "dependencies": { "async": { "version": "0.9.2", @@ -929,13 +1248,23 @@ "version": "1.0.34", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } }, "through2": { "version": "0.6.5", "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true + "dev": true, + "requires": { + "readable-stream": "1.0.34", + "xtend": "4.0.1" + } } } }, @@ -943,37 +1272,63 @@ "version": "3.0.8", "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", - "dev": true + "dev": true, + "requires": { + "array-differ": "1.0.0", + "array-uniq": "1.0.3", + "beeper": "1.1.1", + "chalk": "1.1.3", + "dateformat": "2.0.0", + "fancy-log": "1.3.0", + "gulplog": "1.0.0", + "has-gulplog": "0.1.0", + "lodash._reescape": "3.0.0", + "lodash._reevaluate": "3.0.0", + "lodash._reinterpolate": "3.0.0", + "lodash.template": "3.6.2", + "minimist": "1.2.0", + "multipipe": "0.1.2", + "object-assign": "3.0.0", + "replace-ext": "0.0.1", + "through2": "2.0.3", + "vinyl": "0.5.3" + } }, "gulplog": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz", "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=", - "dev": true + "dev": true, + "requires": { + "glogg": "1.0.0" + } }, "has-ansi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } }, "has-gulplog": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz", "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=", - "dev": true + "dev": true, + "requires": { + "sparkles": "1.0.0" + } }, "homedir-polyfill": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", - "dev": true - }, - "i": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/i/-/i-0.3.5.tgz", - "integrity": "sha1-HSuFQVjsgWkRPGy39raAHpniEdU=", - "dev": true + "dev": true, + "requires": { + "parse-passwd": "1.0.0" + } }, "ignore": { "version": "3.3.3", @@ -991,13 +1346,20 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", - "dev": true + "dev": true, + "requires": { + "repeating": "2.0.1" + } }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true + "dev": true, + "requires": { + "once": "1.3.3", + "wrappy": "1.0.2" + } }, "inherits": { "version": "2.0.3", @@ -1016,6 +1378,21 @@ "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz", "integrity": "sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=", "dev": true, + "requires": { + "ansi-escapes": "1.4.0", + "ansi-regex": "2.1.1", + "chalk": "1.1.3", + "cli-cursor": "1.0.2", + "cli-width": "2.1.0", + "figures": "1.7.0", + "lodash": "4.17.4", + "readline2": "1.0.1", + "run-async": "0.1.0", + "rx-lite": "3.1.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "through": "2.3.8" + }, "dependencies": { "lodash": { "version": "4.17.4", @@ -1035,7 +1412,11 @@ "version": "0.2.6", "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-0.2.6.tgz", "integrity": "sha1-IN5p89uULvLYe5wto28XIjWxtes=", - "dev": true + "dev": true, + "requires": { + "is-relative": "0.2.1", + "is-windows": "0.2.0" + } }, "is-buffer": { "version": "1.1.5", @@ -1053,7 +1434,10 @@ "version": "0.1.3", "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", - "dev": true + "dev": true, + "requires": { + "is-primitive": "2.0.0" + } }, "is-extendable": { "version": "0.1.1", @@ -1071,31 +1455,49 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", - "dev": true + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } }, "is-fullwidth-code-point": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } }, "is-glob": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "dev": true + "dev": true, + "requires": { + "is-extglob": "1.0.0" + } }, "is-my-json-valid": { "version": "2.16.0", "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.16.0.tgz", "integrity": "sha1-8Hndm/2uZe4gOKrorLyGqxCeNpM=", - "dev": true + "dev": true, + "requires": { + "generate-function": "2.0.0", + "generate-object-property": "1.2.0", + "jsonpointer": "4.0.1", + "xtend": "4.0.1" + } }, "is-number": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", - "dev": true + "dev": true, + "requires": { + "kind-of": "3.2.2" + } }, "is-path-cwd": { "version": "1.0.0", @@ -1107,14 +1509,20 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz", "integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=", - "dev": true + "dev": true, + "requires": { + "is-path-inside": "1.0.0" + } }, "is-path-inside": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.0.tgz", "integrity": "sha1-/AbloWg/vaE95mev9xe7wQpI838=", - "dev": true - }, + "dev": true, + "requires": { + "path-is-inside": "1.0.2" + } + }, "is-posix-bracket": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", @@ -1137,19 +1545,28 @@ "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-0.2.1.tgz", "integrity": "sha1-0n9MfVFtF1+2ENuEu+7yPDvJeqU=", - "dev": true + "dev": true, + "requires": { + "is-unc-path": "0.1.2" + } }, "is-resolvable": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.0.tgz", "integrity": "sha1-jfV8YeouPFAUCNEA+wE8+NbgzGI=", - "dev": true + "dev": true, + "requires": { + "tryit": "1.0.3" + } }, "is-unc-path": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-0.1.2.tgz", "integrity": "sha1-arBTpyVzwQJQ/0FqOBTDUXivObk=", - "dev": true + "dev": true, + "requires": { + "unc-path-regex": "0.1.2" + } }, "is-utf8": { "version": "0.2.1", @@ -1180,6 +1597,9 @@ "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", "dev": true, + "requires": { + "isarray": "1.0.0" + }, "dependencies": { "isarray": { "version": "1.0.0", @@ -1189,29 +1609,39 @@ } } }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", - "dev": true - }, "jasmine": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-2.6.0.tgz", "integrity": "sha1-ayLnCIPo5YnUVjRhU7TSBt2+IX8=", "dev": true, + "requires": { + "exit": "0.1.2", + "glob": "7.1.2", + "jasmine-core": "2.6.2" + }, "dependencies": { "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.3.3", + "path-is-absolute": "1.0.1" + } }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true + "dev": true, + "requires": { + "brace-expansion": "1.1.7" + } } } }, @@ -1225,7 +1655,11 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/jasmine-terminal-reporter/-/jasmine-terminal-reporter-1.0.3.tgz", "integrity": "sha1-iW8eyP30v2rs3UHFA+2nNH9hUms=", - "dev": true + "dev": true, + "requires": { + "indent-string": "2.1.0", + "pluralize": "1.2.1" + } }, "js-tokens": { "version": "3.0.1", @@ -1237,97 +1671,60 @@ "version": "3.8.4", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.8.4.tgz", "integrity": "sha1-UgtFZPhlc7qWZir4Woyvp7S1pvY=", - "dev": true - }, - "js2xmlparser": { - "version": "0.1.9", - "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-0.1.9.tgz", - "integrity": "sha1-LFFniOCUYGN/mkA9/te5JfcdI54=", - "dev": true - }, - "jscs": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/jscs/-/jscs-1.13.1.tgz", - "integrity": "sha1-fdRuGG8PzgcSzQMerMCkXvfc/rA=", "dev": true, - "dependencies": { - "ansi-regex": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-1.1.1.tgz", - "integrity": "sha1-QchHGUZGN15qGl0Qw8oFTvn8mA0=", - "dev": true - }, - "chalk": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.0.0.tgz", - "integrity": "sha1-s89O0P9Tl8mcdbj2edsvUoMfltw=", - "dev": true - }, - "esprima": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.5.tgz", - "integrity": "sha1-CZNQL+r2aBODJXVvMPmlH+7sEek=", - "dev": true - }, - "estraverse": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.9.3.tgz", - "integrity": "sha1-r2fy3JIlgkFZUJJgkaQAXSnJu0Q=", - "dev": true - }, - "glob": { - "version": "5.0.15", - "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", - "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", - "dev": true - }, - "has-ansi": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-1.0.3.tgz", - "integrity": "sha1-wLWxYV2eOCsP9nFp2We0JeSMpTg=", - "dev": true - }, - "strip-ansi": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-2.0.1.tgz", - "integrity": "sha1-32LBqpTtLxFOHQ8h/R1QSCt5pg4=", - "dev": true - }, - "strip-json-comments": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", - "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", - "dev": true - }, - "supports-color": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.3.1.tgz", - "integrity": "sha1-FXWN8J2P87SswwdTn6vicJXhBC0=", - "dev": true - } + "requires": { + "argparse": "1.0.9", + "esprima": "3.1.3" } }, "jsdoc": { - "version": "3.3.0-alpha13", - "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.3.0-alpha13.tgz", - "integrity": "sha1-rWS5iaT2++8xEqse6AkIMopOv9I=", + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.5.5.tgz", + "integrity": "sha512-6PxB65TAU4WO0Wzyr/4/YhlGovXl0EVYfpKbpSroSj0qBxT4/xod/l40Opkm38dRHRdQgdeY836M0uVnJQG7kg==", "dev": true, + "requires": { + "babylon": "7.0.0-beta.19", + "bluebird": "3.5.1", + "catharsis": "0.8.9", + "escape-string-regexp": "1.0.5", + "js2xmlparser": "3.0.0", + "klaw": "2.0.0", + "marked": "0.3.6", + "mkdirp": "0.5.1", + "requizzle": "0.2.1", + "strip-json-comments": "2.0.1", + "taffydb": "2.6.2", + "underscore": "1.8.3" + }, "dependencies": { - "async": { - "version": "0.1.22", - "resolved": "https://registry.npmjs.org/async/-/async-0.1.22.tgz", - "integrity": "sha1-D8GqoIig4+8Ovi2IMbqw3PiEUGE=", - "dev": true + "catharsis": { + "version": "0.8.9", + "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.9.tgz", + "integrity": "sha1-mMyJDKZS3S7w5ws3klMQ/56Q/Is=", + "dev": true, + "requires": { + "underscore-contrib": "0.3.0" + } }, - "esprima": { - "version": "https://github.com/ariya/esprima/tarball/49a2eccb243f29bd653b11e9419241a9d726af7c", - "integrity": "sha1-oD6sqD7BElqj1Kzd0mNrTdcH22c=", + "js2xmlparser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-3.0.0.tgz", + "integrity": "sha1-P7YOqgicVED5MZ9RdgzNB+JJlzM=", + "dev": true, + "requires": { + "xmlcreate": "1.0.2" + } + }, + "taffydb": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", + "integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=", "dev": true }, - "strip-json-comments": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-0.1.3.tgz", - "integrity": "sha1-Fkxk43Coo8wAyeAbU55WmCPw7lQ=", + "underscore": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", + "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=", "dev": true } } @@ -1336,7 +1733,10 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", - "dev": true + "dev": true, + "requires": { + "jsonify": "0.0.0" + } }, "jsonify": { "version": "0.0.0", @@ -1354,19 +1754,54 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true + "dev": true, + "requires": { + "is-buffer": "1.1.5" + } + }, + "klaw": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/klaw/-/klaw-2.0.0.tgz", + "integrity": "sha1-WcEo4Nxc5BAgEVEZTuucv4WGUPY=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + } + } }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "dev": true + "dev": true, + "requires": { + "prelude-ls": "1.1.2", + "type-check": "0.3.2" + } }, "liftoff": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-2.3.0.tgz", "integrity": "sha1-qY8v9nGD2Lp8+soQVIvX/wVQs4U=", - "dev": true + "dev": true, + "requires": { + "extend": "3.0.1", + "findup-sync": "0.4.3", + "fined": "1.0.2", + "flagged-respawn": "0.3.2", + "lodash.isplainobject": "4.0.6", + "lodash.isstring": "4.0.1", + "lodash.mapvalues": "4.6.0", + "rechoir": "0.6.2", + "resolve": "1.3.3" + } }, "lodash": { "version": "1.0.2", @@ -1374,12 +1809,6 @@ "integrity": "sha1-j1dWDIO1n8JwvT1WG2kAQ0MOJVE=", "dev": true }, - "lodash._baseassign": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", - "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", - "dev": true - }, "lodash._basecopy": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", @@ -1398,18 +1827,6 @@ "integrity": "sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc=", "dev": true }, - "lodash._bindcallback": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz", - "integrity": "sha1-5THCdkTPi1epnhftlbNcdIeJOS4=", - "dev": true - }, - "lodash._createassigner": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz", - "integrity": "sha1-g4pbri/aymOsIt7o4Z+k5taXCxE=", - "dev": true - }, "lodash._getnative": { "version": "3.9.1", "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", @@ -1446,12 +1863,6 @@ "integrity": "sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI=", "dev": true }, - "lodash.assign": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-3.0.0.tgz", - "integrity": "sha1-93SdFYCkEgJzo3H1SmaxTJ1yJvo=", - "dev": true - }, "lodash.assignwith": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/lodash.assignwith/-/lodash.assignwith-4.2.0.tgz", @@ -1462,7 +1873,10 @@ "version": "3.2.0", "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", - "dev": true + "dev": true, + "requires": { + "lodash._root": "3.0.1" + } }, "lodash.isarguments": { "version": "3.1.0", @@ -1498,7 +1912,12 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", - "dev": true + "dev": true, + "requires": { + "lodash._getnative": "3.9.1", + "lodash.isarguments": "3.1.0", + "lodash.isarray": "3.0.4" + } }, "lodash.mapvalues": { "version": "4.6.0", @@ -1522,13 +1941,28 @@ "version": "3.6.2", "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz", "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", - "dev": true + "dev": true, + "requires": { + "lodash._basecopy": "3.0.1", + "lodash._basetostring": "3.0.1", + "lodash._basevalues": "3.0.0", + "lodash._isiterateecall": "3.0.9", + "lodash._reinterpolate": "3.0.0", + "lodash.escape": "3.2.0", + "lodash.keys": "3.1.2", + "lodash.restparam": "3.6.1", + "lodash.templatesettings": "3.1.1" + } }, "lodash.templatesettings": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz", "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=", - "dev": true + "dev": true, + "requires": { + "lodash._reinterpolate": "3.0.0", + "lodash.escape": "3.2.0" + } }, "lru-cache": { "version": "2.7.3", @@ -1552,13 +1986,31 @@ "version": "2.3.11", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", - "dev": true + "dev": true, + "requires": { + "arr-diff": "2.0.0", + "array-unique": "0.2.1", + "braces": "1.8.5", + "expand-brackets": "0.1.5", + "extglob": "0.3.2", + "filename-regex": "2.0.1", + "is-extglob": "1.0.0", + "is-glob": "2.0.1", + "kind-of": "3.2.2", + "normalize-path": "2.1.1", + "object.omit": "2.0.1", + "parse-glob": "3.0.4", + "regex-cache": "0.4.3" + } }, "minimatch": { "version": "2.0.10", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", - "dev": true + "dev": true, + "requires": { + "brace-expansion": "1.1.7" + } }, "minimist": { "version": "1.2.0", @@ -1571,6 +2023,9 @@ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "requires": { + "minimist": "0.0.8" + }, "dependencies": { "minimist": { "version": "0.0.8", @@ -1590,7 +2045,10 @@ "version": "0.1.2", "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", "integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=", - "dev": true + "dev": true, + "requires": { + "duplexer2": "0.0.2" + } }, "mute-stream": { "version": "0.0.5", @@ -1610,17 +2068,14 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, - "ncp": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/ncp/-/ncp-0.4.2.tgz", - "integrity": "sha1-q8xsvT7C7Spyn/bnwfqPAXhKhXQ=", - "dev": true - }, "normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true + "dev": true, + "requires": { + "remove-trailing-separator": "1.0.1" + } }, "number-is-nan": { "version": "1.0.1", @@ -1638,13 +2093,20 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", - "dev": true + "dev": true, + "requires": { + "for-own": "0.1.5", + "is-extendable": "0.1.1" + } }, "once": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", - "dev": true + "dev": true, + "requires": { + "wrappy": "1.0.2" + } }, "onetime": { "version": "1.1.0", @@ -1656,13 +2118,26 @@ "version": "0.8.2", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", - "dev": true + "dev": true, + "requires": { + "deep-is": "0.1.3", + "fast-levenshtein": "2.0.6", + "levn": "0.3.0", + "prelude-ls": "1.1.2", + "type-check": "0.3.2", + "wordwrap": "1.0.0" + } }, "orchestrator": { "version": "0.3.8", "resolved": "https://registry.npmjs.org/orchestrator/-/orchestrator-0.3.8.tgz", "integrity": "sha1-FOfp4nZPcxX7rBhOUGx6pt+UrX4=", - "dev": true + "dev": true, + "requires": { + "end-of-stream": "0.1.5", + "sequencify": "0.0.7", + "stream-consume": "0.1.0" + } }, "ordered-read-streams": { "version": "0.1.0", @@ -1680,13 +2155,24 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.1.tgz", "integrity": "sha1-FZ1hVdQ5BNFsEO9piRHaHpGWm3M=", - "dev": true + "dev": true, + "requires": { + "is-absolute": "0.2.6", + "map-cache": "0.2.2", + "path-root": "0.1.1" + } }, "parse-glob": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", - "dev": true + "dev": true, + "requires": { + "glob-base": "0.3.0", + "is-dotfile": "1.0.3", + "is-extglob": "1.0.0", + "is-glob": "2.0.1" + } }, "parse-passwd": { "version": "1.0.0", @@ -1716,7 +2202,10 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz", "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", - "dev": true + "dev": true, + "requires": { + "path-root-regex": "0.1.2" + } }, "path-root-regex": { "version": "0.1.2", @@ -1724,12 +2213,6 @@ "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=", "dev": true }, - "pathval": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-0.1.1.tgz", - "integrity": "sha1-CPkRzcqczllCiA2ngXvAtyO2bYI=", - "dev": true - }, "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", @@ -1746,13 +2229,10 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "dev": true - }, - "pkginfo": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.4.0.tgz", - "integrity": "sha1-NJ27f/04CB/K3AhT32h/DHdEzWU=", - "dev": true + "dev": true, + "requires": { + "pinkie": "2.0.4" + } }, "pluralize": { "version": "1.2.1", @@ -1790,47 +2270,57 @@ "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", "dev": true }, - "prompt": { - "version": "0.2.14", - "resolved": "https://registry.npmjs.org/prompt/-/prompt-0.2.14.tgz", - "integrity": "sha1-V3VPZPVD/XsIRXB8gY7OYY8F/9w=", - "dev": true - }, "randomatic": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.6.tgz", "integrity": "sha1-EQ3Kv/OX6dz/fAeJzMCkmt8exbs=", - "dev": true - }, - "read": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz", - "integrity": "sha1-s9oZvQUkMal2cdRKQmNK33ELQMQ=", - "dev": true + "dev": true, + "requires": { + "is-number": "2.1.0", + "kind-of": "3.2.2" + } }, "readable-stream": { "version": "1.1.14", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } }, "readline2": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz", "integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=", - "dev": true + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "mute-stream": "0.0.5" + } }, "rechoir": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", - "dev": true + "dev": true, + "requires": { + "resolve": "1.3.3" + } }, "regex-cache": { "version": "0.4.3", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz", "integrity": "sha1-mxpsNdTQ3871cRrmUejp09cRQUU=", - "dev": true + "dev": true, + "requires": { + "is-equal-shallow": "0.1.3", + "is-primitive": "2.0.0" + } }, "remove-trailing-separator": { "version": "1.0.1", @@ -1854,7 +2344,10 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", - "dev": true + "dev": true, + "requires": { + "is-finite": "1.0.2" + } }, "replace-ext": { "version": "0.0.1", @@ -1866,25 +2359,39 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", - "dev": true + "dev": true, + "requires": { + "caller-path": "0.1.0", + "resolve-from": "1.0.1" + } }, "requizzle": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.1.tgz", "integrity": "sha1-aUPDUwxNmn5G8c3dUcFY/GcM294=", - "dev": true + "dev": true, + "requires": { + "underscore": "1.6.0" + } }, "resolve": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.3.3.tgz", "integrity": "sha1-ZVkHw0aahoDcLeOidaj91paR8OU=", - "dev": true + "dev": true, + "requires": { + "path-parse": "1.0.5" + } }, "resolve-dir": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-0.1.1.tgz", "integrity": "sha1-shklmlYC+sXFxJatiUpujMQwJh4=", - "dev": true + "dev": true, + "requires": { + "expand-tilde": "1.2.2", + "global-modules": "0.2.3" + } }, "resolve-from": { "version": "1.0.1", @@ -1896,31 +2403,43 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", - "dev": true - }, - "revalidator": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/revalidator/-/revalidator-0.1.8.tgz", - "integrity": "sha1-/s5hv6DBtSoga9axgZgYS91SOjs=", - "dev": true + "dev": true, + "requires": { + "exit-hook": "1.1.1", + "onetime": "1.1.0" + } }, "rimraf": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz", "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=", "dev": true, + "requires": { + "glob": "7.1.2" + }, "dependencies": { "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.3.3", + "path-is-absolute": "1.0.1" + } }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true + "dev": true, + "requires": { + "brace-expansion": "1.1.7" + } } } }, @@ -1928,7 +2447,10 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz", "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", - "dev": true + "dev": true, + "requires": { + "once": "1.3.3" + } }, "rx-lite": { "version": "3.1.2", @@ -1959,18 +2481,34 @@ "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.7.tgz", "integrity": "sha1-svXHfvlxSPS09uImguELuoZnz/E=", "dev": true, + "requires": { + "glob": "7.1.2", + "interpret": "1.0.3", + "rechoir": "0.6.2" + }, "dependencies": { "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.3.3", + "path-is-absolute": "1.0.1" + } }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true + "dev": true, + "requires": { + "brace-expansion": "1.1.7" + } } } }, @@ -1998,41 +2536,47 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, - "stack-trace": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", - "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=", - "dev": true - }, "stream-consume": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.0.tgz", "integrity": "sha1-pB6tGm1ggc63n2WwYZAbbY89HQ8=", "dev": true }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "dev": true }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } }, "strip-bom": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz", "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=", - "dev": true + "dev": true, + "requires": { + "first-chunk-stream": "1.0.0", + "is-utf8": "0.2.1" + } }, "strip-json-comments": { "version": "2.0.1", @@ -2051,6 +2595,14 @@ "resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz", "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=", "dev": true, + "requires": { + "ajv": "4.11.8", + "ajv-keywords": "1.5.1", + "chalk": "1.1.3", + "lodash": "4.17.4", + "slice-ansi": "0.0.4", + "string-width": "2.0.0" + }, "dependencies": { "is-fullwidth-code-point": { "version": "2.0.0", @@ -2068,15 +2620,14 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.0.0.tgz", "integrity": "sha1-Y1xUNsxypuDDh87KJ41OLuxSaH4=", - "dev": true + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "3.0.1" + } } } }, - "taffydb": { - "version": "https://github.com/hegemonic/taffydb/tarball/master", - "integrity": "sha1-pO5xiCFDkBUx/BcPbSKvBTVloMU=", - "dev": true - }, "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -2094,6 +2645,10 @@ "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", "dev": true, + "requires": { + "readable-stream": "2.2.11", + "xtend": "4.0.1" + }, "dependencies": { "isarray": { "version": "1.0.0", @@ -2105,13 +2660,25 @@ "version": "2.2.11", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.11.tgz", "integrity": "sha512-h+8+r3MKEhkiVrwdKL8aWs1oc1VvBu33ueshOvS26RsZQ3Amhx/oO3TKe4lApSV9ueY6as8EAh7mtuFjdlhg9Q==", - "dev": true + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.0.1", + "string_decoder": "1.0.2", + "util-deprecate": "1.0.2" + } }, "string_decoder": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.2.tgz", "integrity": "sha1-sp4fThEl+pehA4K4pTNze3SR4Xk=", - "dev": true + "dev": true, + "requires": { + "safe-buffer": "5.0.1" + } } } }, @@ -2119,7 +2686,10 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/tildify/-/tildify-1.2.0.tgz", "integrity": "sha1-3OwD9V3Km3qj5bBPIYF+tW5jWIo=", - "dev": true + "dev": true, + "requires": { + "os-homedir": "1.0.2" + } }, "time-stamp": { "version": "1.1.0", @@ -2137,7 +2707,10 @@ "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "dev": true + "dev": true, + "requires": { + "prelude-ls": "1.1.2" + } }, "typedarray": { "version": "0.0.6", @@ -2161,7 +2734,10 @@ "version": "0.3.0", "resolved": "https://registry.npmjs.org/underscore-contrib/-/underscore-contrib-0.3.0.tgz", "integrity": "sha1-ZltmwkeD+PorGMn4y7Dix9SMJsc=", - "dev": true + "dev": true, + "requires": { + "underscore": "1.6.0" + } }, "unique-stream": { "version": "1.0.0", @@ -2181,35 +2757,41 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, - "utile": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/utile/-/utile-0.2.1.tgz", - "integrity": "sha1-kwyI6ZCY1iIINMNWy9mncFItkNc=", - "dev": true - }, - "uuid": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", - "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=", - "dev": true - }, "v8flags": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-2.1.1.tgz", "integrity": "sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ=", - "dev": true + "dev": true, + "requires": { + "user-home": "1.1.1" + } }, "vinyl": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz", "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", - "dev": true + "dev": true, + "requires": { + "clone": "1.0.2", + "clone-stats": "0.0.1", + "replace-ext": "0.0.1" + } }, "vinyl-fs": { "version": "0.3.14", "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-0.3.14.tgz", "integrity": "sha1-mmhRzhysHBzqX+hsCTHWIMLPqeY=", "dev": true, + "requires": { + "defaults": "1.0.3", + "glob-stream": "3.1.18", + "glob-watcher": "0.0.6", + "graceful-fs": "3.0.11", + "mkdirp": "0.5.1", + "strip-bom": "1.0.0", + "through2": "0.6.5", + "vinyl": "0.4.6" + }, "dependencies": { "clone": { "version": "0.2.0", @@ -2221,78 +2803,43 @@ "version": "1.0.34", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } }, "through2": { "version": "0.6.5", "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true + "dev": true, + "requires": { + "readable-stream": "1.0.34", + "xtend": "4.0.1" + } }, "vinyl": { "version": "0.4.6", "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz", "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", - "dev": true + "dev": true, + "requires": { + "clone": "0.2.0", + "clone-stats": "0.0.1" + } } } }, - "vow": { - "version": "0.4.16", - "resolved": "https://registry.npmjs.org/vow/-/vow-0.4.16.tgz", - "integrity": "sha1-u51U2TjV+AUg1linQOeoleMP7us=", - "dev": true - }, - "vow-fs": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/vow-fs/-/vow-fs-0.3.6.tgz", - "integrity": "sha1-LUxZviLivyYY3fWXq0uqkjvnIA0=", - "dev": true, - "dependencies": { - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true - } - } - }, - "vow-queue": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/vow-queue/-/vow-queue-0.4.2.tgz", - "integrity": "sha1-5/4XFg4Vx8QYTRtmapvGThjjAYQ=", - "dev": true - }, "which": { "version": "1.2.14", "resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz", "integrity": "sha1-mofEN48D6CfOyvGs31bHNsAcFOU=", - "dev": true - }, - "winston": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/winston/-/winston-0.8.3.tgz", - "integrity": "sha1-ZLar9M0Brcrv1QCTk7HY6L7BnbA=", "dev": true, - "dependencies": { - "colors": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", - "integrity": "sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w=", - "dev": true - }, - "pkginfo": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.3.1.tgz", - "integrity": "sha1-Wyn2qB9wcXFC4J52W76rl7T4HiE=", - "dev": true - } + "requires": { + "isexe": "2.0.0" } }, "wordwrap": { @@ -2307,32 +2854,21 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, - "wrench": { - "version": "1.3.9", - "resolved": "https://registry.npmjs.org/wrench/-/wrench-1.3.9.tgz", - "integrity": "sha1-bxPsNRRTF+spLKX2UxORskQRFBE=", - "dev": true - }, "write": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", - "dev": true - }, - "xmlbuilder": { - "version": "2.6.5", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-2.6.5.tgz", - "integrity": "sha1-b/etYPty0idk8AehZLd/K/FABSY=", "dev": true, - "dependencies": { - "lodash": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", - "dev": true - } + "requires": { + "mkdirp": "0.5.1" } }, + "xmlcreate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-1.0.2.tgz", + "integrity": "sha1-+mv3YqYKQT+z3Y9LA8WyaSONMI8=", + "dev": true + }, "xtend": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", diff --git a/package.json b/package.json index 9d97aa97..0713eba3 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "gulp": "^3.8.10", "gulp-jasmine": "^2.0.1", "gulp-shell": "^0.2.11", - "jsdoc": "3.3.0-alpha13" + "jsdoc": "3.5.5" }, "scripts": { "test": "gulp test" From e17a272d90f46c457fc6b9264a11e28f74ba0242 Mon Sep 17 00:00:00 2001 From: miyes Date: Sat, 16 Dec 2017 15:03:14 +0800 Subject: [PATCH 552/613] repair recursiveReverse bug The prev reference error of the node after the iteration is called. --- src/data-structures/linked-list.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index ac911c24..c8d22db5 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -235,6 +235,7 @@ return; } inverse(next, next.next); + next.prev = next.next; next.next = current; } @@ -242,6 +243,7 @@ return; } inverse(this.first, this.first.next); + this.first.prev = this.first.next; this.first.next = null; var temp = this.first; this.first = this.last; From 55ed569ce7a097a58b9aa0674c72f0d3f26e850b Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 16 Dec 2017 21:18:09 +0200 Subject: [PATCH 553/613] docs: update the list of contributors --- readme.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/readme.md b/readme.md index 5a7178e7..f64700bf 100644 --- a/readme.md +++ b/readme.md @@ -75,21 +75,21 @@ create a pull request. | :---------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------: | | [mgechev](https://github.com/mgechev) | [AndriiHeonia](https://github.com/AndriiHeonia) | [Jakehp](https://github.com/Jakehp) | [lygstate](https://github.com/lygstate) | [mik-laj](https://github.com/mik-laj) | [krzysztof-grzybek](https://github.com/krzysztof-grzybek) | -| [pvoznenko](https://github.com/pvoznenko) | [jettcalleja](https://github.com/jettcalleja) | [filipefalcaos](https://github.com/filipefalcaos) | [kdamball](https://github.com/kdamball) | [lekkas](https://github.com/lekkas) | [infusion](https://github.com/infusion) | -| :--------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | -| [pvoznenko](https://github.com/pvoznenko) | [jettcalleja](https://github.com/jettcalleja) | [filipefalcaos](https://github.com/filipefalcaos) | [kdamball](https://github.com/kdamball) | [lekkas](https://github.com/lekkas) | [infusion](https://github.com/infusion) | +| [pvoznenko](https://github.com/pvoznenko) | [jettcalleja](https://github.com/jettcalleja) | [kdamball](https://github.com/kdamball) | [lekkas](https://github.com/lekkas) | [infusion](https://github.com/infusion) | [deniskyashif](https://github.com/deniskyashif) | +| :--------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------: | +| [pvoznenko](https://github.com/pvoznenko) | [jettcalleja](https://github.com/jettcalleja) | [kdamball](https://github.com/kdamball) | [lekkas](https://github.com/lekkas) | [infusion](https://github.com/infusion) | [deniskyashif](https://github.com/deniskyashif) | -| [deniskyashif](https://github.com/deniskyashif) | [designeng](https://github.com/designeng) | [pkerpedjiev](https://github.com/pkerpedjiev) | [Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) | [Microfed](https://github.com/Microfed) | [alexjoverm](https://github.com/alexjoverm) | -| :--------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | -| [deniskyashif](https://github.com/deniskyashif) | [designeng](https://github.com/designeng) | [pkerpedjiev](https://github.com/pkerpedjiev) | [Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) | [Microfed](https://github.com/Microfed) | [alexjoverm](https://github.com/alexjoverm) | +| [filipefalcaos](https://github.com/filipefalcaos) | [designeng](https://github.com/designeng) | [Microfed](https://github.com/Microfed) | [pkerpedjiev](https://github.com/pkerpedjiev) | [Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) | [alexjoverm](https://github.com/alexjoverm) | +| :----------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | +| [filipefalcaos](https://github.com/filipefalcaos) | [designeng](https://github.com/designeng) | [Microfed](https://github.com/Microfed) | [pkerpedjiev](https://github.com/pkerpedjiev) | [Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) | [alexjoverm](https://github.com/alexjoverm) | -| [amilajack](https://github.com/amilajack) | [shaunak1111](https://github.com/shaunak1111) | [contra](https://github.com/contra) | [liesislukas](https://github.com/liesislukas) | [millerrach](https://github.com/millerrach) | [fanixk](https://github.com/fanixk) | -| :--------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: | -| [amilajack](https://github.com/amilajack) | [shaunak1111](https://github.com/shaunak1111) | [contra](https://github.com/contra) | [liesislukas](https://github.com/liesislukas) | [millerrach](https://github.com/millerrach) | [fanixk](https://github.com/fanixk) | +| [amilajack](https://github.com/amilajack) | [ysharplanguage](https://github.com/ysharplanguage) | [contra](https://github.com/contra) | [liesislukas](https://github.com/liesislukas) | [maurobringolf](https://github.com/maurobringolf) | [millerrach](https://github.com/millerrach) | +| :--------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------: | +| [amilajack](https://github.com/amilajack) | [ysharplanguage](https://github.com/ysharplanguage) | [contra](https://github.com/contra) | [liesislukas](https://github.com/liesislukas) | [maurobringolf](https://github.com/maurobringolf) | [millerrach](https://github.com/millerrach) | -| [ysharplanguage](https://github.com/ysharplanguage) | -| :------------------------------------------------------------------------------------------------------------------------------------------: | -| [ysharplanguage](https://github.com/ysharplanguage) | +| [fanixk](https://github.com/fanixk) | [shaunak1111](https://github.com/shaunak1111) | +| :-------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | +| [fanixk](https://github.com/fanixk) | [shaunak1111](https://github.com/shaunak1111) | ## License From dfaa6cd75e687328ff4448d688c9484eedf4c1e7 Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Fri, 22 Dec 2017 16:09:35 -0600 Subject: [PATCH 554/613] Switch to @jeremyckahn/minami theme --- doc-config.json | 2 +- package.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc-config.json b/doc-config.json index 90b5cbb4..b3d76520 100644 --- a/doc-config.json +++ b/doc-config.json @@ -23,7 +23,7 @@ }, "plugins": [], "opts": { - "template": "templates/default", + "template": "node_modules/@jeremyckahn/minami", "encoding": "utf8", "destination": "../javascript-algorithms-docs", "recurse": true, diff --git a/package.json b/package.json index 0713eba3..2085a973 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "test": "test" }, "devDependencies": { + "@jeremyckahn/minami": "^1.3.1", "gulp-eslint": "^3.0.1", "gulp": "^3.8.10", "gulp-jasmine": "^2.0.1", From 84cf1353767ac821fe931eb9b3b1dcd51e977575 Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Fri, 22 Dec 2017 16:22:02 -0600 Subject: [PATCH 555/613] Build docs to dist directory --- .gitignore | 3 ++- doc-config.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 7e6c166d..3fcdef0c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules npm-debug.log debug -.idea \ No newline at end of file +dist +.idea diff --git a/doc-config.json b/doc-config.json index b3d76520..ee4dedd3 100644 --- a/doc-config.json +++ b/doc-config.json @@ -25,7 +25,7 @@ "opts": { "template": "node_modules/@jeremyckahn/minami", "encoding": "utf8", - "destination": "../javascript-algorithms-docs", + "destination": "dist", "recurse": true, "private": false, "readme": "./readme.md" From aec32003120719b9f170a7118b2f3edd6e11eef6 Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Fri, 22 Dec 2017 16:22:37 -0600 Subject: [PATCH 556/613] Switch from gulp to npm for doc generation --- gulpfile.js | 8 -------- package.json | 10 +++++++--- readme.md | 20 +++----------------- 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 95f2a2c0..81073a4d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,15 +1,7 @@ 'use strict'; var gulp = require('gulp'); -var shell = require('gulp-shell'); var eslint = require('gulp-eslint'); var jasmine = require('gulp-jasmine'); -var isWin = /^win/.test(process.platform); - -gulp.task('jsdoc', shell.task([ - (isWin) ? - '"node_modules/.bin/jsdoc.cmd" -c ./doc-config.json' : - './node_modules/.bin/jsdoc -c ./doc-config.json' -])); gulp.task('test', function () { return gulp.src('test/**/*.spec.js') diff --git a/package.json b/package.json index 2085a973..64b57779 100644 --- a/package.json +++ b/package.json @@ -8,14 +8,18 @@ }, "devDependencies": { "@jeremyckahn/minami": "^1.3.1", - "gulp-eslint": "^3.0.1", "gulp": "^3.8.10", + "gulp-eslint": "^3.0.1", "gulp-jasmine": "^2.0.1", "gulp-shell": "^0.2.11", - "jsdoc": "3.5.5" + "jsdoc": "3.5.5", + "live-server": "^1.2.0" }, "scripts": { - "test": "gulp test" + "test": "gulp test", + "doc": "npm run doc:build && npm run doc:view", + "doc:build": "jsdoc -c doc-config.json", + "doc:view": "live-server dist --port=9124" }, "repository": { "type": "git", diff --git a/readme.md b/readme.md index f64700bf..281b3680 100644 --- a/readme.md +++ b/readme.md @@ -19,29 +19,15 @@ npm install **To setup repository with documentation** -* Go to the parent directory of the `javascript-algorithms` folder and call: - -```bash -git clone https://github.com/mgechev/javascript-algorithms.git javascript-algorithms-docs -``` - -* Go to the `javascript-algorithms-docs` folder and change current branch to `gh-pages`: - ```bash -git checkout gh-pages +npm run:doc ``` -Now you can see `index.html` file in this folder and open it in your browser. +This will build the documentation and open it in your browser. **To update .html files with documentation** -Go to the `javascript-algorithms` folder and call: - -```bash -gulp jsdoc -``` - -and all files in `javascript-algorithms-docs` folder will be updated. +Just run `npm run:doc` again. **To run tests** From 30caa8b5e0eca9e8c07911508bf5dcda0a2037e6 Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Fri, 22 Dec 2017 16:24:05 -0600 Subject: [PATCH 557/613] Add deploy script --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 64b57779..d200b5ab 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ }, "devDependencies": { "@jeremyckahn/minami": "^1.3.1", + "gh-pages": "^1.1.0", "gulp": "^3.8.10", "gulp-eslint": "^3.0.1", "gulp-jasmine": "^2.0.1", @@ -17,6 +18,7 @@ }, "scripts": { "test": "gulp test", + "deploy": "npm run doc:build && gh-pages -d dist -b gh-pages", "doc": "npm run doc:build && npm run doc:view", "doc:build": "jsdoc -c doc-config.json", "doc:view": "live-server dist --port=9124" From 9a0e6353fedc23f68a1d615fb3d7cae2e0622395 Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Fri, 22 Dec 2017 16:31:02 -0600 Subject: [PATCH 558/613] Document deploy process --- readme.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/readme.md b/readme.md index 281b3680..f24c4899 100644 --- a/readme.md +++ b/readme.md @@ -39,6 +39,14 @@ gulp test and all `*.spec.js` files will be executed. +**To deploy documentation site** + +```bash +npm run deploy +``` + +This requires you to have commit access to your Git remote. + ## Contributions Fork the repo and make required changes. After that push your changes in branch, which is named according to the changes From 652fef84ab0ceda7d865197fea29b36b1f53db4d Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Fri, 22 Dec 2017 16:39:27 -0600 Subject: [PATCH 559/613] Uninstall gulp-shell --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index d200b5ab..8836a1c4 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,6 @@ "gulp": "^3.8.10", "gulp-eslint": "^3.0.1", "gulp-jasmine": "^2.0.1", - "gulp-shell": "^0.2.11", "jsdoc": "3.5.5", "live-server": "^1.2.0" }, From 5f09b8d2049b7c0c9b587ac14a9bd7b91ae2723c Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Fri, 22 Dec 2017 16:39:39 -0600 Subject: [PATCH 560/613] Update package-lock.json --- package-lock.json | 1792 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 1724 insertions(+), 68 deletions(-) diff --git a/package-lock.json b/package-lock.json index 601891e0..78e33fc3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,22 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@jeremyckahn/minami": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@jeremyckahn/minami/-/minami-1.3.1.tgz", + "integrity": "sha512-jeOFPfq3zLxnQ0dhlhrZd5J0qZDdF1wkrNlr6ErVaGtjPTq9gn/NIK0GDOmGcAJgN/6yKwRdMxPy33u12lQWiQ==", + "dev": true + }, + "accepts": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.4.tgz", + "integrity": "sha1-hiRnWMfdbSGmR0/whKR0DsBesh8=", + "dev": true, + "requires": { + "mime-types": "2.1.17", + "negotiator": "0.6.1" + } + }, "acorn": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.0.3.tgz", @@ -61,6 +77,31 @@ "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", "dev": true }, + "anymatch": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz", + "integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==", + "dev": true, + "requires": { + "micromatch": "2.3.11", + "normalize-path": "2.1.1" + } + }, + "apache-crypt": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/apache-crypt/-/apache-crypt-1.2.1.tgz", + "integrity": "sha1-1vxyqm0n2ZyVqU/RiNcx7v/6Zjw=", + "dev": true, + "requires": { + "unix-crypt-td-js": "1.0.0" + } + }, + "apache-md5": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/apache-md5/-/apache-md5-1.1.2.tgz", + "integrity": "sha1-7klza2ObTxCLbp5ibG2pkwa0FpI=", + "dev": true + }, "archy": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", @@ -124,6 +165,29 @@ "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "dev": true }, + "async": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", + "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", + "dev": true, + "requires": { + "lodash": "4.17.4" + }, + "dependencies": { + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "dev": true + } + } + }, + "async-each": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", + "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", + "dev": true + }, "babel-code-frame": { "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.22.0.tgz", @@ -147,12 +211,53 @@ "integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=", "dev": true }, + "base64url": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/base64url/-/base64url-2.0.0.tgz", + "integrity": "sha1-6sFuA+oUOO/5Qj1puqNiYu0fcLs=", + "dev": true + }, + "basic-auth": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz", + "integrity": "sha1-AV2z81PgLlY3d1X5YnQuiYHnu7o=", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true + } + } + }, + "batch": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", + "integrity": "sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY=", + "dev": true + }, + "bcryptjs": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", + "integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=", + "dev": true + }, "beeper": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/beeper/-/beeper-1.1.1.tgz", "integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=", "dev": true }, + "binary-extensions": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.11.0.tgz", + "integrity": "sha1-RqoXUftqL5PuXmibsQh9SxTGwgU=", + "dev": true + }, "bluebird": { "version": "3.5.1", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", @@ -249,6 +354,23 @@ "supports-color": "2.0.0" } }, + "chokidar": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", + "integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=", + "dev": true, + "requires": { + "anymatch": "1.3.2", + "async-each": "1.0.1", + "fsevents": "1.1.3", + "glob-parent": "2.0.0", + "inherits": "2.0.3", + "is-binary-path": "1.0.1", + "is-glob": "2.0.1", + "path-is-absolute": "1.0.1", + "readdirp": "2.1.0" + } + }, "circular-json": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.1.tgz", @@ -294,6 +416,18 @@ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "dev": true }, + "colors": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", + "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=", + "dev": true + }, + "commander": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", + "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", + "dev": true + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -343,12 +477,59 @@ } } }, + "connect": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/connect/-/connect-3.5.1.tgz", + "integrity": "sha1-bTDXpjx/FwhXprOqazY9lz3KWI4=", + "dev": true, + "requires": { + "debug": "2.2.0", + "finalhandler": "0.5.1", + "parseurl": "1.3.2", + "utils-merge": "1.0.0" + }, + "dependencies": { + "debug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "dev": true, + "requires": { + "ms": "0.7.1" + } + }, + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", + "dev": true + } + } + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, + "cors": { + "version": "2.8.4", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.4.tgz", + "integrity": "sha1-K9OB8usgECAQXNUOpZ2mMJBpRoY=", + "dev": true, + "requires": { + "object-assign": "4.1.1", + "vary": "1.1.2" + }, + "dependencies": { + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + } + } + }, "d": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", @@ -411,12 +592,24 @@ } } }, + "depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=", + "dev": true + }, "deprecated": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/deprecated/-/deprecated-0.0.1.tgz", "integrity": "sha1-+cmvVGSvoeepcUWKi97yqpTVuxk=", "dev": true }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", + "dev": true + }, "detect-file": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-0.1.0.tgz", @@ -444,6 +637,12 @@ } } }, + "duplexer": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", + "dev": true + }, "duplexer2": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", @@ -453,6 +652,18 @@ "readable-stream": "1.1.14" } }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", + "dev": true + }, + "encodeurl": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", + "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=", + "dev": true + }, "end-of-stream": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-0.1.5.tgz", @@ -532,6 +743,12 @@ "es6-symbol": "3.1.1" } }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", + "dev": true + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -700,6 +917,12 @@ "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", "dev": true }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", + "dev": true + }, "event-emitter": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", @@ -710,6 +933,21 @@ "es5-ext": "0.10.23" } }, + "event-stream": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", + "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", + "dev": true, + "requires": { + "duplexer": "0.1.1", + "from": "0.1.7", + "map-stream": "0.1.0", + "pause-stream": "0.0.11", + "split": "0.3.3", + "stream-combiner": "0.0.4", + "through": "2.3.8" + } + }, "exit": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", @@ -780,6 +1018,15 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, + "faye-websocket": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.1.tgz", + "integrity": "sha1-8O/hjE9W5PQK/H4Gxxn9XuYYjzg=", + "dev": true, + "requires": { + "websocket-driver": "0.7.0" + } + }, "figures": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", @@ -835,6 +1082,36 @@ "repeat-string": "1.6.1" } }, + "finalhandler": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.5.1.tgz", + "integrity": "sha1-LEANjUUwk1vCMlScX6OF7Afeb80=", + "dev": true, + "requires": { + "debug": "2.2.0", + "escape-html": "1.0.3", + "on-finished": "2.3.0", + "statuses": "1.3.1", + "unpipe": "1.0.0" + }, + "dependencies": { + "debug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "dev": true, + "requires": { + "ms": "0.7.1" + } + }, + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", + "dev": true + } + } + }, "find-index": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/find-index/-/find-index-0.1.1.tgz", @@ -915,40 +1192,1049 @@ "for-in": "1.0.2" } }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", + "dev": true + }, + "from": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", + "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", + "dev": true + }, "fs-exists-sync": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz", "integrity": "sha1-mC1ok6+RjnLQjeyehnP/K1qNat0=", "dev": true }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "gaze": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz", - "integrity": "sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8=", + "fs-extra": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", + "integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", "dev": true, "requires": { - "globule": "0.1.0" + "graceful-fs": "4.1.11", + "jsonfile": "4.0.0", + "universalify": "0.1.1" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + } } }, - "generate-function": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", - "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=", + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, - "generate-object-property": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", - "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", + "fsevents": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.3.tgz", + "integrity": "sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q==", "dev": true, + "optional": true, "requires": { - "is-property": "1.0.2" + "nan": "2.8.0", + "node-pre-gyp": "0.6.39" + }, + "dependencies": { + "abbrev": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true + }, + "ajv": { + "version": "4.11.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + } + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true + }, + "aproba": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "delegates": "1.0.0", + "readable-stream": "2.2.9" + } + }, + "asn1": { + "version": "0.2.3", + "bundled": true, + "dev": true, + "optional": true + }, + "assert-plus": { + "version": "0.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "asynckit": { + "version": "0.4.0", + "bundled": true, + "dev": true, + "optional": true + }, + "aws-sign2": { + "version": "0.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "aws4": { + "version": "1.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "balanced-match": { + "version": "0.4.2", + "bundled": true, + "dev": true + }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } + }, + "block-stream": { + "version": "0.0.9", + "bundled": true, + "dev": true, + "requires": { + "inherits": "2.0.3" + } + }, + "boom": { + "version": "2.10.1", + "bundled": true, + "dev": true, + "requires": { + "hoek": "2.16.3" + } + }, + "brace-expansion": { + "version": "1.1.7", + "bundled": true, + "dev": true, + "requires": { + "balanced-match": "0.4.2", + "concat-map": "0.0.1" + } + }, + "buffer-shims": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "caseless": { + "version": "0.12.0", + "bundled": true, + "dev": true, + "optional": true + }, + "co": { + "version": "4.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "combined-stream": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "requires": { + "delayed-stream": "1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "bundled": true, + "dev": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "cryptiles": { + "version": "2.0.5", + "bundled": true, + "dev": true, + "requires": { + "boom": "2.10.1" + } + }, + "dashdash": { + "version": "1.14.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "debug": { + "version": "2.6.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-extend": { + "version": "0.4.2", + "bundled": true, + "dev": true, + "optional": true + }, + "delayed-stream": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "detect-libc": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "ecc-jsbn": { + "version": "0.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "extend": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "extsprintf": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "forever-agent": { + "version": "0.6.1", + "bundled": true, + "dev": true, + "optional": true + }, + "form-data": { + "version": "2.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.15" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "fstream": { + "version": "1.0.11", + "bundled": true, + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "inherits": "2.0.3", + "mkdirp": "0.5.1", + "rimraf": "2.6.1" + } + }, + "fstream-ignore": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "fstream": "1.0.11", + "inherits": "2.0.3", + "minimatch": "3.0.4" + } + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aproba": "1.1.1", + "console-control-strings": "1.1.0", + "has-unicode": "2.0.1", + "object-assign": "4.1.1", + "signal-exit": "3.0.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wide-align": "1.1.2" + } + }, + "getpass": { + "version": "0.1.7", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "glob": { + "version": "7.1.2", + "bundled": true, + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "bundled": true, + "dev": true + }, + "har-schema": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "optional": true + }, + "har-validator": { + "version": "4.2.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ajv": "4.11.8", + "har-schema": "1.0.5" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "hawk": { + "version": "3.1.3", + "bundled": true, + "dev": true, + "requires": { + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" + } + }, + "hoek": { + "version": "2.16.3", + "bundled": true, + "dev": true + }, + "http-signature": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "0.2.0", + "jsprim": "1.4.0", + "sshpk": "1.13.0" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "dev": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true, + "dev": true + }, + "ini": { + "version": "1.3.4", + "bundled": true, + "dev": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "isarray": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "isstream": { + "version": "0.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "jodid25519": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "jsbn": { + "version": "0.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "json-schema": { + "version": "0.2.3", + "bundled": true, + "dev": true, + "optional": true + }, + "json-stable-stringify": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsonify": "0.0.0" + } + }, + "json-stringify-safe": { + "version": "5.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "jsonify": { + "version": "0.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "jsprim": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.0.2", + "json-schema": "0.2.3", + "verror": "1.3.6" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "mime-db": { + "version": "1.27.0", + "bundled": true, + "dev": true + }, + "mime-types": { + "version": "2.1.15", + "bundled": true, + "dev": true, + "requires": { + "mime-db": "1.27.0" + } + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "dev": true, + "requires": { + "brace-expansion": "1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true, + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "node-pre-gyp": { + "version": "0.6.39", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "detect-libc": "1.0.2", + "hawk": "3.1.3", + "mkdirp": "0.5.1", + "nopt": "4.0.1", + "npmlog": "4.1.0", + "rc": "1.2.1", + "request": "2.81.0", + "rimraf": "2.6.1", + "semver": "5.3.0", + "tar": "2.2.1", + "tar-pack": "3.4.0" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "abbrev": "1.1.0", + "osenv": "0.1.4" + } + }, + "npmlog": { + "version": "4.1.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "are-we-there-yet": "1.1.4", + "console-control-strings": "1.1.0", + "gauge": "2.7.4", + "set-blocking": "2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "oauth-sign": { + "version": "0.8.2", + "bundled": true, + "dev": true, + "optional": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "osenv": { + "version": "0.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "os-homedir": "1.0.2", + "os-tmpdir": "1.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "performance-now": { + "version": "0.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "process-nextick-args": { + "version": "1.0.7", + "bundled": true, + "dev": true + }, + "punycode": { + "version": "1.4.1", + "bundled": true, + "dev": true, + "optional": true + }, + "qs": { + "version": "6.4.0", + "bundled": true, + "dev": true, + "optional": true + }, + "rc": { + "version": "1.2.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "deep-extend": "0.4.2", + "ini": "1.3.4", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "readable-stream": { + "version": "2.2.9", + "bundled": true, + "dev": true, + "requires": { + "buffer-shims": "1.0.0", + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "string_decoder": "1.0.1", + "util-deprecate": "1.0.2" + } + }, + "request": { + "version": "2.81.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.1.4", + "har-validator": "4.2.1", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.15", + "oauth-sign": "0.8.2", + "performance-now": "0.2.0", + "qs": "6.4.0", + "safe-buffer": "5.0.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.2", + "tunnel-agent": "0.6.0", + "uuid": "3.0.1" + } + }, + "rimraf": { + "version": "2.6.1", + "bundled": true, + "dev": true, + "requires": { + "glob": "7.1.2" + } + }, + "safe-buffer": { + "version": "5.0.1", + "bundled": true, + "dev": true + }, + "semver": { + "version": "5.3.0", + "bundled": true, + "dev": true, + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "sntp": { + "version": "1.0.9", + "bundled": true, + "dev": true, + "requires": { + "hoek": "2.16.3" + } + }, + "sshpk": { + "version": "1.13.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jodid25519": "1.0.2", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "string_decoder": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, + "stringstream": { + "version": "0.0.5", + "bundled": true, + "dev": true, + "optional": true + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "tar": { + "version": "2.2.1", + "bundled": true, + "dev": true, + "requires": { + "block-stream": "0.0.9", + "fstream": "1.0.11", + "inherits": "2.0.3" + } + }, + "tar-pack": { + "version": "3.4.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "debug": "2.6.8", + "fstream": "1.0.11", + "fstream-ignore": "1.0.5", + "once": "1.4.0", + "readable-stream": "2.2.9", + "rimraf": "2.6.1", + "tar": "2.2.1", + "uid-number": "0.0.6" + } + }, + "tough-cookie": { + "version": "2.3.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "punycode": "1.4.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "bundled": true, + "dev": true, + "optional": true + }, + "uid-number": { + "version": "0.0.6", + "bundled": true, + "dev": true, + "optional": true + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "uuid": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "verror": { + "version": "1.3.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "extsprintf": "1.0.2" + } + }, + "wide-align": { + "version": "1.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "string-width": "1.0.2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true, + "dev": true + } + } + }, + "gaze": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz", + "integrity": "sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8=", + "dev": true, + "requires": { + "globule": "0.1.0" + } + }, + "generate-function": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", + "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=", + "dev": true + }, + "generate-object-property": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", + "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", + "dev": true, + "requires": { + "is-property": "1.0.2" + } + }, + "gh-pages": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/gh-pages/-/gh-pages-1.1.0.tgz", + "integrity": "sha512-ZpDkeOVmIrN5mz+sBWDz5zmTqcbNJzI/updCwEv/7rrSdpTNlj1B5GhBqG7f4Q8p5sJOdnBV0SIqxJrxtZQ9FA==", + "dev": true, + "requires": { + "async": "2.6.0", + "base64url": "2.0.0", + "commander": "2.11.0", + "fs-extra": "4.0.3", + "globby": "6.1.0", + "graceful-fs": "4.1.11", + "rimraf": "2.6.2" + }, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.3.3", + "path-is-absolute": "1.0.1" + } + }, + "globby": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", + "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", + "dev": true, + "requires": { + "array-union": "1.0.2", + "glob": "7.1.2", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.7" + } + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "dev": true, + "requires": { + "glob": "7.1.2" + } + } } }, "glob": { @@ -1220,54 +2506,6 @@ "through2": "2.0.3" } }, - "gulp-shell": { - "version": "0.2.11", - "resolved": "https://registry.npmjs.org/gulp-shell/-/gulp-shell-0.2.11.tgz", - "integrity": "sha1-GbpoC2WoZvYELt4LDjS2LbcfITk=", - "dev": true, - "requires": { - "async": "0.9.2", - "gulp-util": "3.0.8", - "lodash": "2.4.2", - "through2": "0.6.5" - }, - "dependencies": { - "async": { - "version": "0.9.2", - "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", - "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=", - "dev": true - }, - "lodash": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", - "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=", - "dev": true - }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "0.0.1", - "string_decoder": "0.10.31" - } - }, - "through2": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true, - "requires": { - "readable-stream": "1.0.34", - "xtend": "4.0.1" - } - } - } - }, "gulp-util": { "version": "3.0.8", "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", @@ -1330,6 +2568,36 @@ "parse-passwd": "1.0.0" } }, + "http-auth": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/http-auth/-/http-auth-3.1.3.tgz", + "integrity": "sha1-lFz63WZSHq+PfISRPTd9exXyTjE=", + "dev": true, + "requires": { + "apache-crypt": "1.2.1", + "apache-md5": "1.1.2", + "bcryptjs": "2.4.3", + "uuid": "3.1.0" + } + }, + "http-errors": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", + "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", + "dev": true, + "requires": { + "depd": "1.1.1", + "inherits": "2.0.3", + "setprototypeof": "1.0.3", + "statuses": "1.3.1" + } + }, + "http-parser-js": { + "version": "0.4.9", + "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.4.9.tgz", + "integrity": "sha1-6hoE+2St/wJC6ZdPKX3Uw8rSceE=", + "dev": true + }, "ignore": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.3.tgz", @@ -1418,6 +2686,15 @@ "is-windows": "0.2.0" } }, + "is-binary-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "dev": true, + "requires": { + "binary-extensions": "1.11.0" + } + }, "is-buffer": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", @@ -1580,6 +2857,12 @@ "integrity": "sha1-3hqm1j6indJIc3tp8f+LgALSEIw=", "dev": true }, + "is-wsl": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", + "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=", + "dev": true + }, "isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", @@ -1738,6 +3021,24 @@ "jsonify": "0.0.0" } }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true, + "optional": true + } + } + }, "jsonify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", @@ -1803,6 +3104,35 @@ "resolve": "1.3.3" } }, + "live-server": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/live-server/-/live-server-1.2.0.tgz", + "integrity": "sha1-RJhkS7+Bpm8Y3Y3/3vYcTBw3TKM=", + "dev": true, + "requires": { + "chokidar": "1.7.0", + "colors": "1.1.2", + "connect": "3.5.1", + "cors": "2.8.4", + "event-stream": "3.3.4", + "faye-websocket": "0.11.1", + "http-auth": "3.1.3", + "morgan": "1.9.0", + "object-assign": "4.1.1", + "opn": "5.1.0", + "proxy-middleware": "0.15.0", + "send": "0.16.1", + "serve-index": "1.9.1" + }, + "dependencies": { + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + } + } + }, "lodash": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/lodash/-/lodash-1.0.2.tgz", @@ -1976,6 +3306,12 @@ "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", "dev": true }, + "map-stream": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", + "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", + "dev": true + }, "marked": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.6.tgz", @@ -2003,6 +3339,27 @@ "regex-cache": "0.4.3" } }, + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==", + "dev": true + }, + "mime-db": { + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", + "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=", + "dev": true + }, + "mime-types": { + "version": "2.1.17", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", + "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", + "dev": true, + "requires": { + "mime-db": "1.30.0" + } + }, "minimatch": { "version": "2.0.10", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", @@ -2035,6 +3392,30 @@ } } }, + "morgan": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.0.tgz", + "integrity": "sha1-0B+mxlhZt2/PMbPLU6OCGjEdgFE=", + "dev": true, + "requires": { + "basic-auth": "2.0.0", + "debug": "2.6.9", + "depd": "1.1.1", + "on-finished": "2.3.0", + "on-headers": "1.0.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } + } + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -2056,6 +3437,13 @@ "integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=", "dev": true }, + "nan": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.8.0.tgz", + "integrity": "sha1-7XFfP+neArV6XmJS2QqWZ14fCFo=", + "dev": true, + "optional": true + }, "natives": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.0.tgz", @@ -2068,6 +3456,12 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", + "dev": true + }, "normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", @@ -2099,6 +3493,21 @@ "is-extendable": "0.1.1" } }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "dev": true, + "requires": { + "ee-first": "1.1.1" + } + }, + "on-headers": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz", + "integrity": "sha1-ko9dD0cNSTQmUepnlLCFfBAGk/c=", + "dev": true + }, "once": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", @@ -2114,6 +3523,15 @@ "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", "dev": true }, + "opn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/opn/-/opn-5.1.0.tgz", + "integrity": "sha512-iPNl7SyM8L30Rm1sjGdLLheyHVw5YXVfi3SKWJzBI7efxRwHojfRFjwE/OLM6qp9xJYMgab8WicTU1cPoY+Hpg==", + "dev": true, + "requires": { + "is-wsl": "1.1.0" + } + }, "optionator": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", @@ -2180,6 +3598,12 @@ "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", "dev": true }, + "parseurl": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", + "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=", + "dev": true + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -2213,6 +3637,15 @@ "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=", "dev": true }, + "pause-stream": { + "version": "0.0.11", + "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", + "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", + "dev": true, + "requires": { + "through": "2.3.8" + } + }, "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", @@ -2270,6 +3703,12 @@ "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", "dev": true }, + "proxy-middleware": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/proxy-middleware/-/proxy-middleware-0.15.0.tgz", + "integrity": "sha1-o/3xvvtzD5UZZYcqwvYHTGFHelY=", + "dev": true + }, "randomatic": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.6.tgz", @@ -2280,6 +3719,12 @@ "kind-of": "3.2.2" } }, + "range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=", + "dev": true + }, "readable-stream": { "version": "1.1.14", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", @@ -2292,6 +3737,71 @@ "string_decoder": "0.10.31" } }, + "readdirp": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", + "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "minimatch": "3.0.4", + "readable-stream": "2.3.3", + "set-immediate-shim": "1.0.1" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.7" + } + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + } + } + }, "readline2": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz", @@ -2470,12 +3980,82 @@ "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=", "dev": true }, + "send": { + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.1.tgz", + "integrity": "sha512-ElCLJdJIKPk6ux/Hocwhk7NFHpI3pVm/IZOYWqUmoxcgeyM+MpxHHKhb8QmlJDX1pU6WrgaHBkVNm73Sv7uc2A==", + "dev": true, + "requires": { + "debug": "2.6.9", + "depd": "1.1.1", + "destroy": "1.0.4", + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "etag": "1.8.1", + "fresh": "0.5.2", + "http-errors": "1.6.2", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "2.3.0", + "range-parser": "1.2.0", + "statuses": "1.3.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } + } + }, "sequencify": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/sequencify/-/sequencify-0.0.7.tgz", "integrity": "sha1-kM/xnQLgcCf9dn9erT57ldHnOAw=", "dev": true }, + "serve-index": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", + "integrity": "sha1-03aNabHn2C5c4FD/9bRTvqEqkjk=", + "dev": true, + "requires": { + "accepts": "1.3.4", + "batch": "0.6.1", + "debug": "2.6.9", + "escape-html": "1.0.3", + "http-errors": "1.6.2", + "mime-types": "2.1.17", + "parseurl": "1.3.2" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } + } + }, + "set-immediate-shim": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", + "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", + "dev": true + }, + "setprototypeof": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", + "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=", + "dev": true + }, "shelljs": { "version": "0.7.7", "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.7.tgz", @@ -2530,12 +4110,36 @@ "integrity": "sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM=", "dev": true }, + "split": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", + "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", + "dev": true, + "requires": { + "through": "2.3.8" + } + }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", + "dev": true + }, + "stream-combiner": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", + "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", + "dev": true, + "requires": { + "duplexer": "0.1.1" + } + }, "stream-consume": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.0.tgz", @@ -2745,6 +4349,24 @@ "integrity": "sha1-1ZpKdUJ0R9mqbJHnAmP40mpLEEs=", "dev": true }, + "universalify": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz", + "integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc=", + "dev": true + }, + "unix-crypt-td-js": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unix-crypt-td-js/-/unix-crypt-td-js-1.0.0.tgz", + "integrity": "sha1-HAgkFQSBvHoB1J6Y8exmjYJBLzs=", + "dev": true + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "dev": true + }, "user-home": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz", @@ -2757,6 +4379,18 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "utils-merge": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz", + "integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg=", + "dev": true + }, + "uuid": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", + "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==", + "dev": true + }, "v8flags": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-2.1.1.tgz", @@ -2766,6 +4400,12 @@ "user-home": "1.1.1" } }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", + "dev": true + }, "vinyl": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz", @@ -2833,6 +4473,22 @@ } } }, + "websocket-driver": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.0.tgz", + "integrity": "sha1-DK+dLXVdk67gSdS90NP+LMoqJOs=", + "dev": true, + "requires": { + "http-parser-js": "0.4.9", + "websocket-extensions": "0.1.3" + } + }, + "websocket-extensions": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.3.tgz", + "integrity": "sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==", + "dev": true + }, "which": { "version": "1.2.14", "resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz", From b02c0b2b7b76b7cbc2d4b481baae9513e45fcc13 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 1 Jan 2018 18:07:56 +0200 Subject: [PATCH 561/613] docs: fix readme --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index f24c4899..a30fcd85 100644 --- a/readme.md +++ b/readme.md @@ -20,14 +20,14 @@ npm install **To setup repository with documentation** ```bash -npm run:doc +npm run doc ``` This will build the documentation and open it in your browser. **To update .html files with documentation** -Just run `npm run:doc` again. +Just run `npm run doc` again. **To run tests** From 7393fd2e3aa24ac9d3811c9461e43b2bea734f48 Mon Sep 17 00:00:00 2001 From: Borislav Borisov Date: Wed, 3 Jan 2018 14:50:55 +0200 Subject: [PATCH 562/613] Fixed _existsInSubtree comparison of nodes' values bug. --- src/data-structures/binary-search-tree.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data-structures/binary-search-tree.js b/src/data-structures/binary-search-tree.js index 234cfd81..cf059a27 100644 --- a/src/data-structures/binary-search-tree.js +++ b/src/data-structures/binary-search-tree.js @@ -455,7 +455,7 @@ if (!root) { return false; } - if (node === root.value) { + if (node.value === root.value) { return true; } return this._existsInSubtree(node, root._left) || From 45de167bc08c78f2f0cbc74b434ce6073ef6586f Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 13 Jan 2018 22:10:41 +0200 Subject: [PATCH 563/613] docs: update the list of contributors --- readme.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/readme.md b/readme.md index a30fcd85..53f622bb 100644 --- a/readme.md +++ b/readme.md @@ -65,25 +65,25 @@ create a pull request. ## Contributors -| [mgechev](https://github.com/mgechev) | [AndriiHeonia](https://github.com/AndriiHeonia) | [Jakehp](https://github.com/Jakehp) | [lygstate](https://github.com/lygstate) | [mik-laj](https://github.com/mik-laj) | [krzysztof-grzybek](https://github.com/krzysztof-grzybek) | -| :---------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------: | -| [mgechev](https://github.com/mgechev) | [AndriiHeonia](https://github.com/AndriiHeonia) | [Jakehp](https://github.com/Jakehp) | [lygstate](https://github.com/lygstate) | [mik-laj](https://github.com/mik-laj) | [krzysztof-grzybek](https://github.com/krzysztof-grzybek) | +| [mgechev](https://github.com/mgechev) | [AndriiHeonia](https://github.com/AndriiHeonia) | [Jakehp](https://github.com/Jakehp) | [lygstate](https://github.com/lygstate) | [mik-laj](https://github.com/mik-laj) | [jeremyckahn](https://github.com/jeremyckahn) | +| :---------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------: | +| [mgechev](https://github.com/mgechev) | [AndriiHeonia](https://github.com/AndriiHeonia) | [Jakehp](https://github.com/Jakehp) | [lygstate](https://github.com/lygstate) | [mik-laj](https://github.com/mik-laj) | [jeremyckahn](https://github.com/jeremyckahn) | -| [pvoznenko](https://github.com/pvoznenko) | [jettcalleja](https://github.com/jettcalleja) | [kdamball](https://github.com/kdamball) | [lekkas](https://github.com/lekkas) | [infusion](https://github.com/infusion) | [deniskyashif](https://github.com/deniskyashif) | -| :--------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------: | -| [pvoznenko](https://github.com/pvoznenko) | [jettcalleja](https://github.com/jettcalleja) | [kdamball](https://github.com/kdamball) | [lekkas](https://github.com/lekkas) | [infusion](https://github.com/infusion) | [deniskyashif](https://github.com/deniskyashif) | +| [krzysztof-grzybek](https://github.com/krzysztof-grzybek) | [pvoznenko](https://github.com/pvoznenko) | [jettcalleja](https://github.com/jettcalleja) | [kdamball](https://github.com/kdamball) | [lekkas](https://github.com/lekkas) | [infusion](https://github.com/infusion) | +| :------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | +| [krzysztof-grzybek](https://github.com/krzysztof-grzybek) | [pvoznenko](https://github.com/pvoznenko) | [jettcalleja](https://github.com/jettcalleja) | [kdamball](https://github.com/kdamball) | [lekkas](https://github.com/lekkas) | [infusion](https://github.com/infusion) | -| [filipefalcaos](https://github.com/filipefalcaos) | [designeng](https://github.com/designeng) | [Microfed](https://github.com/Microfed) | [pkerpedjiev](https://github.com/pkerpedjiev) | [Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) | [alexjoverm](https://github.com/alexjoverm) | -| :----------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | -| [filipefalcaos](https://github.com/filipefalcaos) | [designeng](https://github.com/designeng) | [Microfed](https://github.com/Microfed) | [pkerpedjiev](https://github.com/pkerpedjiev) | [Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) | [alexjoverm](https://github.com/alexjoverm) | +| [deniskyashif](https://github.com/deniskyashif) | [filipefalcaos](https://github.com/filipefalcaos) | [designeng](https://github.com/designeng) | [Microfed](https://github.com/Microfed) | [pkerpedjiev](https://github.com/pkerpedjiev) | [Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) | +| :--------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | +| [deniskyashif](https://github.com/deniskyashif) | [filipefalcaos](https://github.com/filipefalcaos) | [designeng](https://github.com/designeng) | [Microfed](https://github.com/Microfed) | [pkerpedjiev](https://github.com/pkerpedjiev) | [Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) | -| [amilajack](https://github.com/amilajack) | [ysharplanguage](https://github.com/ysharplanguage) | [contra](https://github.com/contra) | [liesislukas](https://github.com/liesislukas) | [maurobringolf](https://github.com/maurobringolf) | [millerrach](https://github.com/millerrach) | -| :--------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------: | -| [amilajack](https://github.com/amilajack) | [ysharplanguage](https://github.com/ysharplanguage) | [contra](https://github.com/contra) | [liesislukas](https://github.com/liesislukas) | [maurobringolf](https://github.com/maurobringolf) | [millerrach](https://github.com/millerrach) | +| [liesislukas](https://github.com/liesislukas) | [alexjoverm](https://github.com/alexjoverm) | [BorislavBorisov22](https://github.com/BorislavBorisov22) | [ysharplanguage](https://github.com/ysharplanguage) | [contra](https://github.com/contra) | [amilajack](https://github.com/amilajack) | +| :------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | +| [liesislukas](https://github.com/liesislukas) | [alexjoverm](https://github.com/alexjoverm) | [BorislavBorisov22](https://github.com/BorislavBorisov22) | [ysharplanguage](https://github.com/ysharplanguage) | [contra](https://github.com/contra) | [amilajack](https://github.com/amilajack) | -| [fanixk](https://github.com/fanixk) | [shaunak1111](https://github.com/shaunak1111) | -| :-------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | -| [fanixk](https://github.com/fanixk) | [shaunak1111](https://github.com/shaunak1111) | +| [maurobringolf](https://github.com/maurobringolf) | [millerrach](https://github.com/millerrach) | [fanixk](https://github.com/fanixk) | [miyes](https://github.com/miyes) | [shaunak1111](https://github.com/shaunak1111) | +| :-----------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | +| [maurobringolf](https://github.com/maurobringolf) | [millerrach](https://github.com/millerrach) | [fanixk](https://github.com/fanixk) | [miyes](https://github.com/miyes) | [shaunak1111](https://github.com/shaunak1111) | ## License From 1c828f2ab15a685d1a41c31ddc3b1a31acec75e1 Mon Sep 17 00:00:00 2001 From: emyarod Date: Tue, 27 Feb 2018 10:16:52 -0500 Subject: [PATCH 564/613] Add O(n) maximum subarray test --- test/searching/maximum-subarray.spec.js | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/searching/maximum-subarray.spec.js diff --git a/test/searching/maximum-subarray.spec.js b/test/searching/maximum-subarray.spec.js new file mode 100644 index 00000000..66daa8c7 --- /dev/null +++ b/test/searching/maximum-subarray.spec.js @@ -0,0 +1,29 @@ +var maxSubArray = require('../../src/searching/maximum-subarray').maxSubarray; + +describe('Maximum subarray', function() { + 'use strict'; + + it('should work with empty arrays', function() { + expect(maxSubArray([])).toBeUndefined(); + }); + + it('should return the only element when an array with single element is passed', function() { + expect(maxSubArray([42])).toBe(42); + }); + + it('should return the only negative element when an array with single element is passed', function() { + expect(maxSubArray([-42])).toBe(-42); + }); + + it('should return the zero when an array with single element, which is zero is passed', function() { + expect(maxSubArray([0])).toBe(0); + }); + + it('should return the max sum of a subarray', function() { + expect(maxSubArray([1, -1, 2, 3, -1])).toBe(5); + }); + + it('should return the max negative number when array with negative numbers is provided', function() { + expect(maxSubArray([-10, -1, -2, -3, -1])).toBe(-1); + }); +}); From 1fe106d531b442d06777faee9c2cd98d7b6e3247 Mon Sep 17 00:00:00 2001 From: emyarod Date: Tue, 27 Feb 2018 10:17:06 -0500 Subject: [PATCH 565/613] Fix O(n) maximum subarray solution --- src/searching/maximum-subarray.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/searching/maximum-subarray.js b/src/searching/maximum-subarray.js index 4628369e..85ae9d11 100644 --- a/src/searching/maximum-subarray.js +++ b/src/searching/maximum-subarray.js @@ -20,11 +20,10 @@ * @return {Number} Maximum sum of the elements of a subarray. */ function maxSubarray(array) { - var currentMax = 0; - var max = 0; - - for (var i = 0; i < array.length; i += 1) { - currentMax = Math.max(0, currentMax + array[i]); + var currentMax = array[0]; + var max = array[0]; + for (var i = 1; i < array.length; i += 1) { + currentMax = Math.max(array[i], currentMax + array[i]); max = Math.max(max, currentMax); } return max; From 5c06a4386a9fad9cc5a7d7a1d4597aa27b0ce53f Mon Sep 17 00:00:00 2001 From: Bruno Simas Hadlich Date: Sat, 17 Mar 2018 22:30:55 -0300 Subject: [PATCH 566/613] Added Sieve Of Atkins implementation. --- src/primes/sieve-of-atkins.js | 87 +++++++++++++++++++++++++++++ test/primes/sieve-of-atkins.spec.js | 26 +++++++++ 2 files changed, 113 insertions(+) create mode 100644 src/primes/sieve-of-atkins.js create mode 100644 test/primes/sieve-of-atkins.spec.js diff --git a/src/primes/sieve-of-atkins.js b/src/primes/sieve-of-atkins.js new file mode 100644 index 00000000..1f75cfd3 --- /dev/null +++ b/src/primes/sieve-of-atkins.js @@ -0,0 +1,87 @@ +(function (exports) { + 'use strict'; + + /** + * Sieve of Atkins. + * + * Modern algorithm for finding all prime numbers up to a specified integer. + * + * Returns list of primes up to specified limit. + * + * For example, for limit 10 it should return following list of primes: + * [2, 3, 5, 7]. + * + * @module primes/sieve-of-atkins + * @param {Number} limit - Algorithm will returns list of primes up to + * specified limit. + * @returns {Array} Will return list with all prime numbers up to provided. + * limit. + * + * @example + * var sieveOfAtkins = + * require('path-to-algorithms/src/sieve-of-atkins').sieveOfAtkins; + * + * console.log(sieveOfAtkins(12)); // [2, 3, 5, 7, 11] + */ + exports.sieveOfAtkins = function (limit) { + if (limit <= 1) { + return []; + } + + const sieve = Array(limit + 1); + + const testingLimit = Math.ceil(Math.sqrt(limit)); + + var i; + var j; + var n; + + for (i = 1; i < testingLimit; i += 1) { + var ii = i * i; + for (j = 1; j < testingLimit; j += 1) { + var jj = j * j; + if (ii + jj >= limit) { + break; + } + + n = 4 * ii + jj; + if (n <= limit && (n % 12 === 1 || n % 12 === 5)) { + sieve[n] = !sieve[n]; + } + + n = 3 * ii + jj; + if (n <= limit && (n % 12 === 7)) { + sieve[n] = !sieve[n]; + } + + n = 3 * ii - jj; + if (i > j && n <= limit && (n % 12 === 11)) { + sieve[n] = !sieve[n]; + } + } + } + + for (n = 5; n <= testingLimit; n += 1) { + if (sieve[n]) { + j = n * n; + for (i = j; i <= limit; i += j) { + sieve[i] = false; + } + } + } + + const primes = [2]; + + if (limit > 2) { + primes.push(3); + } + + sieve.forEach(function (value, key) { + if (value) { + this.push(key); + } + }, primes); + + return primes; + } +}(typeof exports === 'undefined' ? window : exports)); diff --git a/test/primes/sieve-of-atkins.spec.js b/test/primes/sieve-of-atkins.spec.js new file mode 100644 index 00000000..c371d915 --- /dev/null +++ b/test/primes/sieve-of-atkins.spec.js @@ -0,0 +1,26 @@ +var sieveOfAtkins = + require('../../src/primes/sieve-of-atkins').sieveOfAtkins; + +describe('Sieve Of Atkins', function () { + 'use strict'; + + it('should give the right sequence of primes for limit 12', function () { + expect(sieveOfAtkins(12).toString()) + .toEqual([2, 3, 5, 7, 11].toString()); + }); + + it('should give the empty list for limit less or equal 1', function () { + expect(sieveOfAtkins(-12).toString()).toEqual([].toString()); + expect(sieveOfAtkins(0).toString()).toEqual([].toString()); + expect(sieveOfAtkins(1).toString()).toEqual([].toString()); + }); + + it('sum of prime numbers up to 2000000 limit should be 142913828922', function () { + var sieve = sieveOfAtkins(2000000); + var sumOfPrimes = sieve.reduce(function (previousValue, currentValue) { + return previousValue + currentValue; + }); + + expect(sumOfPrimes).toEqual(142913828922); + }); +}); From 8912c62288a4b685ef45ec24f51efda0cc134c8f Mon Sep 17 00:00:00 2001 From: Clint Ayres Date: Thu, 10 May 2018 21:58:16 -0400 Subject: [PATCH 567/613] minor typo --- src/data-structures/hash-table.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data-structures/hash-table.js b/src/data-structures/hash-table.js index 079845d7..1635e484 100644 --- a/src/data-structures/hash-table.js +++ b/src/data-structures/hash-table.js @@ -55,7 +55,7 @@ /** * Simple non-crypto hash used to hash keys, which determines - * while bucket the value will be placed in. + * which bucket the value will be placed in. * A javascript implementation of Java's 32bitint hash. * * @public From ba6eec4db534276f5d282f38e2a982b86d2a1187 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 11 May 2018 10:54:38 -0700 Subject: [PATCH 568/613] docs: update the contributors list --- readme.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index 53f622bb..c4e46837 100644 --- a/readme.md +++ b/readme.md @@ -77,13 +77,17 @@ create a pull request. | :--------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | | [deniskyashif](https://github.com/deniskyashif) | [filipefalcaos](https://github.com/filipefalcaos) | [designeng](https://github.com/designeng) | [Microfed](https://github.com/Microfed) | [pkerpedjiev](https://github.com/pkerpedjiev) | [Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) | -| [liesislukas](https://github.com/liesislukas) | [alexjoverm](https://github.com/alexjoverm) | [BorislavBorisov22](https://github.com/BorislavBorisov22) | [ysharplanguage](https://github.com/ysharplanguage) | [contra](https://github.com/contra) | [amilajack](https://github.com/amilajack) | -| :------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | -| [liesislukas](https://github.com/liesislukas) | [alexjoverm](https://github.com/alexjoverm) | [BorislavBorisov22](https://github.com/BorislavBorisov22) | [ysharplanguage](https://github.com/ysharplanguage) | [contra](https://github.com/contra) | [amilajack](https://github.com/amilajack) | +| [emyarod](https://github.com/emyarod) | [liesislukas](https://github.com/liesislukas) | [alexjoverm](https://github.com/alexjoverm) | [BorislavBorisov22](https://github.com/BorislavBorisov22) | [ysharplanguage](https://github.com/ysharplanguage) | [jurassix](https://github.com/jurassix) | +| :----------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: | +| [emyarod](https://github.com/emyarod) | [liesislukas](https://github.com/liesislukas) | [alexjoverm](https://github.com/alexjoverm) | [BorislavBorisov22](https://github.com/BorislavBorisov22) | [ysharplanguage](https://github.com/ysharplanguage) | [jurassix](https://github.com/jurassix) | -| [maurobringolf](https://github.com/maurobringolf) | [millerrach](https://github.com/millerrach) | [fanixk](https://github.com/fanixk) | [miyes](https://github.com/miyes) | [shaunak1111](https://github.com/shaunak1111) | -| :-----------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | -| [maurobringolf](https://github.com/maurobringolf) | [millerrach](https://github.com/millerrach) | [fanixk](https://github.com/fanixk) | [miyes](https://github.com/miyes) | [shaunak1111](https://github.com/shaunak1111) | +| [contra](https://github.com/contra) | [amilajack](https://github.com/amilajack) | [maurobringolf](https://github.com/maurobringolf) | [millerrach](https://github.com/millerrach) | [xiedezhuo](https://github.com/xiedezhuo) | [fanixk](https://github.com/fanixk) | +| :-------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: | +| [contra](https://github.com/contra) | [amilajack](https://github.com/amilajack) | [maurobringolf](https://github.com/maurobringolf) | [millerrach](https://github.com/millerrach) | [xiedezhuo](https://github.com/xiedezhuo) | [fanixk](https://github.com/fanixk) | + +| [miyes](https://github.com/miyes) | [shaunak1111](https://github.com/shaunak1111) | +| :------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | +| [miyes](https://github.com/miyes) | [shaunak1111](https://github.com/shaunak1111) | ## License From 44267862f3682eb3912dbf3e83c6329cdce41750 Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 26 Sep 2018 17:07:47 -0700 Subject: [PATCH 569/613] docs: update the list of contributors --- readme.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/readme.md b/readme.md index c4e46837..ee4eab93 100644 --- a/readme.md +++ b/readme.md @@ -65,29 +65,29 @@ create a pull request. ## Contributors -| [mgechev](https://github.com/mgechev) | [AndriiHeonia](https://github.com/AndriiHeonia) | [Jakehp](https://github.com/Jakehp) | [lygstate](https://github.com/lygstate) | [mik-laj](https://github.com/mik-laj) | [jeremyckahn](https://github.com/jeremyckahn) | -| :---------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------: | -| [mgechev](https://github.com/mgechev) | [AndriiHeonia](https://github.com/AndriiHeonia) | [Jakehp](https://github.com/Jakehp) | [lygstate](https://github.com/lygstate) | [mik-laj](https://github.com/mik-laj) | [jeremyckahn](https://github.com/jeremyckahn) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[mik-laj](https://github.com/mik-laj) |[jeremyckahn](https://github.com/jeremyckahn) | +:---: |:---: |:---: |:---: |:---: |:---: | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[mik-laj](https://github.com/mik-laj) |[jeremyckahn](https://github.com/jeremyckahn) | -| [krzysztof-grzybek](https://github.com/krzysztof-grzybek) | [pvoznenko](https://github.com/pvoznenko) | [jettcalleja](https://github.com/jettcalleja) | [kdamball](https://github.com/kdamball) | [lekkas](https://github.com/lekkas) | [infusion](https://github.com/infusion) | -| :------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | -| [krzysztof-grzybek](https://github.com/krzysztof-grzybek) | [pvoznenko](https://github.com/pvoznenko) | [jettcalleja](https://github.com/jettcalleja) | [kdamball](https://github.com/kdamball) | [lekkas](https://github.com/lekkas) | [infusion](https://github.com/infusion) | +[krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) | +:---: |:---: |:---: |:---: |:---: |:---: | +[krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) | -| [deniskyashif](https://github.com/deniskyashif) | [filipefalcaos](https://github.com/filipefalcaos) | [designeng](https://github.com/designeng) | [Microfed](https://github.com/Microfed) | [pkerpedjiev](https://github.com/pkerpedjiev) | [Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) | -| :--------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | -| [deniskyashif](https://github.com/deniskyashif) | [filipefalcaos](https://github.com/filipefalcaos) | [designeng](https://github.com/designeng) | [Microfed](https://github.com/Microfed) | [pkerpedjiev](https://github.com/pkerpedjiev) | [Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) | +[deniskyashif](https://github.com/deniskyashif) |[filipefalcaos](https://github.com/filipefalcaos) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) | +:---: |:---: |:---: |:---: |:---: |:---: | +[deniskyashif](https://github.com/deniskyashif) |[filipefalcaos](https://github.com/filipefalcaos) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) | -| [emyarod](https://github.com/emyarod) | [liesislukas](https://github.com/liesislukas) | [alexjoverm](https://github.com/alexjoverm) | [BorislavBorisov22](https://github.com/BorislavBorisov22) | [ysharplanguage](https://github.com/ysharplanguage) | [jurassix](https://github.com/jurassix) | -| :----------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: | -| [emyarod](https://github.com/emyarod) | [liesislukas](https://github.com/liesislukas) | [alexjoverm](https://github.com/alexjoverm) | [BorislavBorisov22](https://github.com/BorislavBorisov22) | [ysharplanguage](https://github.com/ysharplanguage) | [jurassix](https://github.com/jurassix) | +[emyarod](https://github.com/emyarod) |[contra](https://github.com/contra) |[alexjoverm](https://github.com/alexjoverm) |[BorislavBorisov22](https://github.com/BorislavBorisov22) |[brunohadlich](https://github.com/brunohadlich) |[ysharplanguage](https://github.com/ysharplanguage) | +:---: |:---: |:---: |:---: |:---: |:---: | +[emyarod](https://github.com/emyarod) |[contra](https://github.com/contra) |[alexjoverm](https://github.com/alexjoverm) |[BorislavBorisov22](https://github.com/BorislavBorisov22) |[brunohadlich](https://github.com/brunohadlich) |[ysharplanguage](https://github.com/ysharplanguage) | -| [contra](https://github.com/contra) | [amilajack](https://github.com/amilajack) | [maurobringolf](https://github.com/maurobringolf) | [millerrach](https://github.com/millerrach) | [xiedezhuo](https://github.com/xiedezhuo) | [fanixk](https://github.com/fanixk) | -| :-------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: | -| [contra](https://github.com/contra) | [amilajack](https://github.com/amilajack) | [maurobringolf](https://github.com/maurobringolf) | [millerrach](https://github.com/millerrach) | [xiedezhuo](https://github.com/xiedezhuo) | [fanixk](https://github.com/fanixk) | +[jurassix](https://github.com/jurassix) |[amilajack](https://github.com/amilajack) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) |[fanixk](https://github.com/fanixk) | +:---: |:---: |:---: |:---: |:---: |:---: | +[jurassix](https://github.com/jurassix) |[amilajack](https://github.com/amilajack) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) |[fanixk](https://github.com/fanixk) | -| [miyes](https://github.com/miyes) | [shaunak1111](https://github.com/shaunak1111) | -| :------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | -| [miyes](https://github.com/miyes) | [shaunak1111](https://github.com/shaunak1111) | +[miyes](https://github.com/miyes) |[shaunak1111](https://github.com/shaunak1111) | +:---: |:---: | +[miyes](https://github.com/miyes) |[shaunak1111](https://github.com/shaunak1111) | ## License From 26bb4317b8efedfb917107a125b91a48acb94f87 Mon Sep 17 00:00:00 2001 From: Krzysztof Grzybek Date: Sun, 14 Oct 2018 21:30:03 +0200 Subject: [PATCH 570/613] update build and test scripts (#143) --- .travis.yml | 4 +--- package.json | 1 + readme.md | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index e030331b..07d8aa30 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,4 @@ language: node_js node_js: - "8" -before_script: - - npm install -g gulp -script: gulp build +script: npm run build diff --git a/package.json b/package.json index 8836a1c4..5e9ea3f4 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "live-server": "^1.2.0" }, "scripts": { + "build": "gulp build", "test": "gulp test", "deploy": "npm run doc:build && gh-pages -d dist -b gh-pages", "doc": "npm run doc:build && npm run doc:view", diff --git a/readme.md b/readme.md index ee4eab93..2a0122ff 100644 --- a/readme.md +++ b/readme.md @@ -34,7 +34,7 @@ Just run `npm run doc` again. Call: ```bash -gulp test +npm run test ``` and all `*.spec.js` files will be executed. @@ -57,7 +57,7 @@ Make sure you're editor makes validations according to the `.jshintrc` in the ro Before pushing to the repository run: ```bash -gulp build +npm run build ``` If the build is not successful fix your code in order the tests and jshint validation to run successfully and after that From cd4830fd99161b0edfcd6426863b85456bd136cb Mon Sep 17 00:00:00 2001 From: Bruno Simas Hadlich Date: Tue, 11 Dec 2018 14:39:20 -0200 Subject: [PATCH 571/613] Added the Burrows-Wheeler algorithm. (#145) * Added the Burrows-Wheeler algorithm. * Added the Burrows-Wheeler algorithm. --- doc-config.json | 1 + .../burrows-wheeler/burrows-wheeler.js | 84 +++++++++++++++++++ .../burrows-wheeler/burrows-wheeler.spec.js | 13 +++ 3 files changed, 98 insertions(+) create mode 100644 src/compression/burrows-wheeler/burrows-wheeler.js create mode 100644 test/compression/burrows-wheeler/burrows-wheeler.spec.js diff --git a/doc-config.json b/doc-config.json index ee4dedd3..520991a4 100644 --- a/doc-config.json +++ b/doc-config.json @@ -5,6 +5,7 @@ "source": { "include": [ "./src/combinatorics/", + "./src/compression/", "./src/data-structures/", "./src/graphics/", "./src/graphs/others/", diff --git a/src/compression/burrows-wheeler/burrows-wheeler.js b/src/compression/burrows-wheeler/burrows-wheeler.js new file mode 100644 index 00000000..f2f68e03 --- /dev/null +++ b/src/compression/burrows-wheeler/burrows-wheeler.js @@ -0,0 +1,84 @@ +(function (exports) { + 'use strict'; + + /** + * Burrows Wheeler. + * + * This algorithm is commonly used as a step in the process of compressing data, + * it rearranges a character string into runs of similar characters making algorithms + * like move-to-front transform and run-length encoding reach higher compression + * rates. This implementation only supports characters with ascii code greater than $(36) as + * 36 is used at the process of encode and decode. + * + * @example + * const burrows = require('path-to-algorithms/src/burrows-wheeler/burrows-wheeler').burrowsWheeler; + * const s = 'ananabanana'; + * const encodedStr = burrows.encode(s); + * console.log(encodedStr); + * const decodedStr = burrows.decode(encodedStr); + * console.log(decodedStr); + * + * @module compression/burrows-wheeler/burrows-wheeler + */ + exports.burrowsWheeler = function() { + + } + + /** + * Consumes n^2 space. + */ + exports.burrowsWheeler.encode = function(str) { + str = '$' + str; + var combinations = []; + for (let i = 0; i < str.length; i += 1) { + combinations.push(str.substring(i) + str.substring(0, i)); + } + var sorted = combinations.sort(); + var result = []; + for (let i = 0; i < sorted.length; i += 1) { + result.push(combinations[i][str.length - 1]); + } + return result.join(''); + } + + exports.burrowsWheeler.decode = function(encodedStr) { + const sortedCharSequence = encodedStr.split('').sort().join(''); + const leftSide = {}; + const rightSide = {}; + var maxEachCharLeft = {}; + var maxEachCharRight = {}; + + for (let i = 0; i < encodedStr.length; i += 1) { + var idLeft = sortedCharSequence[i]; + if (idLeft in maxEachCharLeft) { + maxEachCharLeft[idLeft] = maxEachCharLeft[idLeft] + 1; + } else { + maxEachCharLeft[idLeft] = 1; + } + idLeft += String(maxEachCharLeft[idLeft]); + + var idRight = encodedStr[i]; + if (idRight in maxEachCharRight) { + maxEachCharRight[idRight] = maxEachCharRight[idRight] + 1; + } else { + maxEachCharRight[idRight] = 1; + } + idRight += String(maxEachCharRight[idRight]); + + leftSide[idLeft] = {char: sortedCharSequence[i], right: idRight}; + rightSide[idRight] = {char: encodedStr[i], left: idRight}; + } + var result = ''; + var firstChar = sortedCharSequence[0]; + var searchChar = firstChar + '1'; + var endChar = searchChar; + while (rightSide[leftSide[searchChar].right].left !== endChar) { + result += leftSide[searchChar].char; + searchChar = rightSide[leftSide[searchChar].right].left; + } + result += leftSide[searchChar].char; + result = result.substring(1).split('').reverse().join(''); + return result; + } + +}(typeof exports === 'undefined' ? window : exports)); diff --git a/test/compression/burrows-wheeler/burrows-wheeler.spec.js b/test/compression/burrows-wheeler/burrows-wheeler.spec.js new file mode 100644 index 00000000..94ea02dc --- /dev/null +++ b/test/compression/burrows-wheeler/burrows-wheeler.spec.js @@ -0,0 +1,13 @@ +var bw = require('../../../src/compression/burrows-wheeler/burrows-wheeler').burrowsWheeler; + +describe('Burrows Wheeler', function () { + 'use strict'; + + it('should return "annnnb$aaaaa" for the entry "ananabanana"', function () { + expect(bw.encode('ananabanana')).toEqual('annnnb$aaaaa'); + }); + + it('should return "ananabanana" for the entry "annnnb$aaaaa"', function () { + expect(bw.decode('annnnb$aaaaa')).toEqual('ananabanana'); + }); +}); From bf0c22ef8be499deee22cb146c30e8514866c2ac Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Sun, 30 Dec 2018 19:32:58 -0800 Subject: [PATCH 572/613] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..c617c7e0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Minko Gechev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From e5b50fa4546c80f21d95ffebbdee5ef929be9b1f Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Wed, 2 Jan 2019 20:51:59 -0800 Subject: [PATCH 573/613] Create CODE_OF_CONDUCT.md --- CODE_OF_CONDUCT.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..02a003f5 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at minko@gechev.io. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq From 2db78a48bd12ac2b50145a72f5e7de34bdd4a4d0 Mon Sep 17 00:00:00 2001 From: Yiping Deng Date: Mon, 11 Mar 2019 15:52:53 +0100 Subject: [PATCH 574/613] [feature] add probablistic data structure bloomfilter (#151) * add probablistic data structure bloomfilter * Use Error in the code, change comment style, update bitmap interfaces --- src/data-structures/bloomfilter.js | 221 +++++++++++++++++++++++ test/data-structures/bloomfilter.spec.js | 57 ++++++ 2 files changed, 278 insertions(+) create mode 100644 src/data-structures/bloomfilter.js create mode 100644 test/data-structures/bloomfilter.spec.js diff --git a/src/data-structures/bloomfilter.js b/src/data-structures/bloomfilter.js new file mode 100644 index 00000000..f3432a0d --- /dev/null +++ b/src/data-structures/bloomfilter.js @@ -0,0 +1,221 @@ +/** + * Bloomfilter and a bitmap. + * Probablistic data structure useful for deduplication + * + * @example + * // create a bloom filter with capacity of 1024 and 0.01 error rat + * var bloomfilter = new Bloomfilter(1024, 0.01); + * bloomfilter.set('hello'); + * bloomfilter.get('hello') === true; + * bloomfilter.get('world') === false; + * @module data-structures/bloomfilter + */ +(function(exports) { + 'use strict'; + + function randomUint32() { + return Math.floor(Math.random() * Math.pow(2, 32)); + } + /** + * Calculate a 32 bit FNV-1a hash + * Found here: https://gist.github.com/vaiorabbit/5657561 + * Ref.: http://isthe.com/chongo/tech/comp/fnv/ + * + * @param {string} str the input value + * @param {boolean} [asString=false] set to true to return the hash value as + * 8-digit hex string instead of an integer + * @param {integer} [seed] optionally pass the hash of the previous chunk + * @returns {integer | string} + */ + function hashFnv32a(str, asString, seed) { + /*jshint bitwise:false */ + var i; + var l; + var hval = seed === undefined ? 0x811c9dc5 : seed; + + for (i = 0, l = str.length; i < l; i = i + 1) { + hval ^= str.charCodeAt(i); + hval += + (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24); + } + if (asString) { + // Convert to 8 digit hex string + return ('0000000' + (hval >>> 0).toString(16)).substr(-8); + } + return hval >>> 0; + } + + // Make a hash function + function mkHashFun(seed, limit) { + return function(value) { + return hashFnv32a(value, false, seed) % limit; + }; + } + /** + * Create a bitmap with a given size + * Bit map is not resizeable + * @public + * @constructor + * @param {Number} size the size of the bitmap + */ + exports.Bitmap = function(size) { + size = size || 1024; + if (size < 0) { + throw new Error('The size cannot be negative'); + } + this.size = size; + this.intSize = Math.ceil(size / 32); // number of underlying integers + // Create a 0 initialized array + this.intArray = Array.from({ length: this.intSize }, function() { + return 0; + }); + }; + + /** + * Get the size of the bit map + * @public + * @return {Number} size of the bit map + */ + exports.Bitmap.prototype.getSize = function() { + return this.size; + }; + + /** + * Get if a bit is set at a particular index + * @public + * @return {Boolean} true or false value of the bit + */ + exports.Bitmap.prototype.exists = function(index) { + // Necessary boundary check + if (index < 0 || index > this.size) { + throw new Error('Index out of bound') + } + + // Calculate the offset within the int + var intOffset = index % 32; + var arrayOffset = Math.floor(index / 32); // the offset for the array + var mask = 1 << intOffset; + return (mask & this.intArray[arrayOffset]) !== 0; + }; + + /** + * Get the bit at a particular index + * @public + * @return {Number} true or false value of the bit + */ + exports.Bitmap.prototype.get = function(index) { + // Necessary boundary check + if (index < 0 || index > this.size) { + throw new Error('Index out of bound') + } + + // Calculate the offset within the int + var intOffset = index % 32; + var arrayOffset = Math.floor(index / 32); // the offset for the array + var mask = 1 << intOffset; + if ((mask & this.intArray[arrayOffset]) !== 0) { + return 1; + } else { + return 0; + } + }; + + /** + * Set the bit at a particular index + * @public + * @param {Number} index the index to set + * @param {Boolean} value the value that is necessary + */ + exports.Bitmap.prototype.set = function(index, value) { + // necessary boundary check + if (index < 0 || index > this.size) { + throw new Error('Index out of bound') + } + + var intOffset = index % 32; //calculate the offset within the int + var arrayOffset = Math.floor(index / 32); // the offset for the array + var mask = 1 << intOffset; + + // Check trutyness + if (value) { + this.intArray[arrayOffset] |= mask; // or operation + } else { + this.intArray[arrayOffset] &= ~mask; // and opertation to set 0 + } + }; + + /** + * Construct a bloom filter by given the capacity and the error rate, default error rate is 0.001 + * @public + * @constructor + * @param {Number} capacity the maximum capacity to maintain the given error rate + * @param {Number} errorRate the error rate expected under maximum capacity + */ + exports.Bloomfilter = function(capacity, errorRate) { + errorRate = errorRate || 0.001; // default error rate + if (errorRate > 1 || errorRate < 0) { + throw new Error('The error rate range is outside of bound'); + } + if (capacity < 0) { + throw new Error('The capacity cannot be negative'); + } + this.capacity = capacity; + this.errorRate = errorRate; + + // Calculate the optimal size of the bitmap + var numBit = Math.ceil( + (capacity * Math.log(1.0 / errorRate)) / Math.pow(Math.log(2), 2) + ); + + // Calculate the optimal number of hash functions + this.numHashFunction = Math.ceil(Math.log(2), numBit / capacity); + + // Create a bitmap + this.bitmap = new exports.Bitmap(numBit); + + // Generate an array of hash functions + this.hashFunctions = Array.from( + { length: this.numHashFunction }, + function() { + return mkHashFun(randomUint32(), numBit); + }.bind(this) + ); + }; + + /** + * To check if an item is in the filter. If it is in, it will return true, + * if it is not in the filter, highly likely it will return false, but guaranteed + * @param {Number | String} value the value that we are trying to check in the filter + */ + exports.Bloomfilter.prototype.get = function(value) { + value = String(value); // make it string + var hashes = this.hashFunctions.map(function(hashFct) { + return hashFct(value); + }); + + // if one of the bits is not set + for (var i = 0; i < hashes.length; i = i + 1) { + if (this.bitmap.exists(hashes[i]) === false) { + return false; + } + } + return true; + }; + + /** + * To set(put) an item in the bloom filter + * @public + * @param {Number | String} value the value that is been set in the filter + */ + exports.Bloomfilter.prototype.set = function(value) { + value = String(value); // make it string + var hashes = this.hashFunctions.map(function(hashFct) { + return hashFct(value); + }); + + // Set all the corresponding bits + for (var i = 0; i < hashes.length; i = i + 1) { + this.bitmap.set(hashes[i], true); + } + }; +})(typeof window === 'undefined' ? module.exports : window); diff --git a/test/data-structures/bloomfilter.spec.js b/test/data-structures/bloomfilter.spec.js new file mode 100644 index 00000000..e72d8748 --- /dev/null +++ b/test/data-structures/bloomfilter.spec.js @@ -0,0 +1,57 @@ +var mod = require('../../src/data-structures/bloomfilter.js'); +var Bitmap = mod.Bitmap; +var Bloomfilter = mod.Bloomfilter; + +describe('Bitmap', function() { + 'use strict'; + + it('should be able to get and set values', function() { + var bitmap = new Bitmap(1024); + expect(bitmap.exists(0)).toBe(false); + bitmap.set(0, true); + expect(bitmap.exists(0)).toBe(true); + expect(bitmap.exists(1023)).toBe(false); + bitmap.set(1023, 1); + expect(bitmap.exists(1023)).toBe(true); + }); + + it('should be able to change everthing back', function() { + var bitmap = new Bitmap(2048); + for (var i = 0; i < 2048; i = i + 1) { + expect(bitmap.get(i)).toBe(0); + bitmap.set(i, 1); + expect(bitmap.get(i)).toBe(1); + bitmap.set(i, 0); + expect(bitmap.get(i)).toBe(0); + } + }); +}); + +describe('Bloomfilter', function() { + 'use strict'; + it('should be able to identify duplicates', function() { + var bloomfilter = new Bloomfilter(1024, 0.01); + expect(bloomfilter.get('a')).toBe(false); + expect(bloomfilter.get('b')).toBe(false); + bloomfilter.set('a'); + expect(bloomfilter.get('a')).toBe(true); + expect(bloomfilter.get('b')).toBe(false); + bloomfilter.set('b'); + expect(bloomfilter.get('a')).toBe(true); + expect(bloomfilter.get('b')).toBe(true); + }); + + it('should handle large amount of data inside', function() { + var bloomfilter = new Bloomfilter(4096, 0.001); // high precision + + var falsePositive = 0; + for (var i = 0; i < 1024; i = i + 1) { + if (bloomfilter.get(i)) { + falsePositive = falsePositive + 1; + } + bloomfilter.set(i, true); + expect(bloomfilter.get(i)).toBe(true); + } + expect(falsePositive).toBeLessThan(100); // set a high theshold + }); +}); From 28130e05c3e2023eb28f90888b1a342906c82654 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 23 Mar 2019 13:42:20 -0700 Subject: [PATCH 575/613] docs: update the list of contributors --- readme.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/readme.md b/readme.md index 2a0122ff..af682e88 100644 --- a/readme.md +++ b/readme.md @@ -73,22 +73,23 @@ create a pull request. :---: |:---: |:---: |:---: |:---: |:---: | [krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) | -[deniskyashif](https://github.com/deniskyashif) |[filipefalcaos](https://github.com/filipefalcaos) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) | +[deniskyashif](https://github.com/deniskyashif) |[filipefalcaos](https://github.com/filipefalcaos) |[brunohadlich](https://github.com/brunohadlich) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[pkerpedjiev](https://github.com/pkerpedjiev) | :---: |:---: |:---: |:---: |:---: |:---: | -[deniskyashif](https://github.com/deniskyashif) |[filipefalcaos](https://github.com/filipefalcaos) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) | +[deniskyashif](https://github.com/deniskyashif) |[filipefalcaos](https://github.com/filipefalcaos) |[brunohadlich](https://github.com/brunohadlich) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[pkerpedjiev](https://github.com/pkerpedjiev) | -[emyarod](https://github.com/emyarod) |[contra](https://github.com/contra) |[alexjoverm](https://github.com/alexjoverm) |[BorislavBorisov22](https://github.com/BorislavBorisov22) |[brunohadlich](https://github.com/brunohadlich) |[ysharplanguage](https://github.com/ysharplanguage) | +[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[emyarod](https://github.com/emyarod) |[liesislukas](https://github.com/liesislukas) |[alexjoverm](https://github.com/alexjoverm) |[BorislavBorisov22](https://github.com/BorislavBorisov22) |[ysharplanguage](https://github.com/ysharplanguage) | :---: |:---: |:---: |:---: |:---: |:---: | -[emyarod](https://github.com/emyarod) |[contra](https://github.com/contra) |[alexjoverm](https://github.com/alexjoverm) |[BorislavBorisov22](https://github.com/BorislavBorisov22) |[brunohadlich](https://github.com/brunohadlich) |[ysharplanguage](https://github.com/ysharplanguage) | +[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[emyarod](https://github.com/emyarod) |[liesislukas](https://github.com/liesislukas) |[alexjoverm](https://github.com/alexjoverm) |[BorislavBorisov22](https://github.com/BorislavBorisov22) |[ysharplanguage](https://github.com/ysharplanguage) | -[jurassix](https://github.com/jurassix) |[amilajack](https://github.com/amilajack) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) |[fanixk](https://github.com/fanixk) | +[jurassix](https://github.com/jurassix) |[contra](https://github.com/contra) |[amilajack](https://github.com/amilajack) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) |[DengYiping](https://github.com/DengYiping) | :---: |:---: |:---: |:---: |:---: |:---: | -[jurassix](https://github.com/jurassix) |[amilajack](https://github.com/amilajack) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) |[fanixk](https://github.com/fanixk) | +[jurassix](https://github.com/jurassix) |[contra](https://github.com/contra) |[amilajack](https://github.com/amilajack) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) |[DengYiping](https://github.com/DengYiping) | -[miyes](https://github.com/miyes) |[shaunak1111](https://github.com/shaunak1111) | -:---: |:---: | -[miyes](https://github.com/miyes) |[shaunak1111](https://github.com/shaunak1111) | +[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | +:---: |:---: |:---: | +[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | ## License The code in this repository is distributed under the terms of the MIT license. + From 368cfca44f236e6e4633620376b6408789cbf566 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 24 Mar 2019 21:01:18 -0700 Subject: [PATCH 576/613] feat: add Graham's convex hull algorithm --- package-lock.json | 4535 --------------------------------- src/graphics/graham.js | 72 + test/graphics/grapham.spec.js | 26 + yarn.lock | 3344 ++++++++++++++++++++++++ 4 files changed, 3442 insertions(+), 4535 deletions(-) delete mode 100644 package-lock.json create mode 100644 src/graphics/graham.js create mode 100644 test/graphics/grapham.spec.js create mode 100644 yarn.lock diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 78e33fc3..00000000 --- a/package-lock.json +++ /dev/null @@ -1,4535 +0,0 @@ -{ - "name": "javascript-algorithms", - "version": "0.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@jeremyckahn/minami": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@jeremyckahn/minami/-/minami-1.3.1.tgz", - "integrity": "sha512-jeOFPfq3zLxnQ0dhlhrZd5J0qZDdF1wkrNlr6ErVaGtjPTq9gn/NIK0GDOmGcAJgN/6yKwRdMxPy33u12lQWiQ==", - "dev": true - }, - "accepts": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.4.tgz", - "integrity": "sha1-hiRnWMfdbSGmR0/whKR0DsBesh8=", - "dev": true, - "requires": { - "mime-types": "2.1.17", - "negotiator": "0.6.1" - } - }, - "acorn": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.0.3.tgz", - "integrity": "sha1-xGDfCEkUY/AozLguqzcwvwEIez0=", - "dev": true - }, - "acorn-jsx": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", - "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", - "dev": true, - "requires": { - "acorn": "3.3.0" - }, - "dependencies": { - "acorn": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", - "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", - "dev": true - } - } - }, - "ajv": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", - "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", - "dev": true, - "requires": { - "co": "4.6.0", - "json-stable-stringify": "1.0.1" - } - }, - "ajv-keywords": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz", - "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=", - "dev": true - }, - "ansi-escapes": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", - "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", - "dev": true - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "anymatch": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz", - "integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==", - "dev": true, - "requires": { - "micromatch": "2.3.11", - "normalize-path": "2.1.1" - } - }, - "apache-crypt": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/apache-crypt/-/apache-crypt-1.2.1.tgz", - "integrity": "sha1-1vxyqm0n2ZyVqU/RiNcx7v/6Zjw=", - "dev": true, - "requires": { - "unix-crypt-td-js": "1.0.0" - } - }, - "apache-md5": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/apache-md5/-/apache-md5-1.1.2.tgz", - "integrity": "sha1-7klza2ObTxCLbp5ibG2pkwa0FpI=", - "dev": true - }, - "archy": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", - "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", - "dev": true - }, - "argparse": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz", - "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=", - "dev": true, - "requires": { - "sprintf-js": "1.0.3" - } - }, - "arr-diff": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", - "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", - "dev": true, - "requires": { - "arr-flatten": "1.0.3" - } - }, - "arr-flatten": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.0.3.tgz", - "integrity": "sha1-onTthawIhJtr14R8RYB0XcUa37E=", - "dev": true - }, - "array-differ": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", - "integrity": "sha1-7/UuN1gknTO+QCuLuOVkuytdQDE=", - "dev": true - }, - "array-union": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", - "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", - "dev": true, - "requires": { - "array-uniq": "1.0.3" - } - }, - "array-uniq": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", - "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", - "dev": true - }, - "array-unique": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", - "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", - "dev": true - }, - "arrify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", - "dev": true - }, - "async": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", - "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", - "dev": true, - "requires": { - "lodash": "4.17.4" - }, - "dependencies": { - "lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", - "dev": true - } - } - }, - "async-each": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", - "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", - "dev": true - }, - "babel-code-frame": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.22.0.tgz", - "integrity": "sha1-AnYgvuVnqIwyVhV05/0IAdMxGOQ=", - "dev": true, - "requires": { - "chalk": "1.1.3", - "esutils": "2.0.2", - "js-tokens": "3.0.1" - } - }, - "babylon": { - "version": "7.0.0-beta.19", - "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.19.tgz", - "integrity": "sha512-Vg0C9s/REX6/WIXN37UKpv5ZhRi6A4pjHlpkE34+8/a6c2W1Q692n3hmc+SZG5lKRnaExLUbxtJ1SVT+KaCQ/A==", - "dev": true - }, - "balanced-match": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz", - "integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=", - "dev": true - }, - "base64url": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/base64url/-/base64url-2.0.0.tgz", - "integrity": "sha1-6sFuA+oUOO/5Qj1puqNiYu0fcLs=", - "dev": true - }, - "basic-auth": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz", - "integrity": "sha1-AV2z81PgLlY3d1X5YnQuiYHnu7o=", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - } - } - }, - "batch": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", - "integrity": "sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY=", - "dev": true - }, - "bcryptjs": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", - "integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=", - "dev": true - }, - "beeper": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/beeper/-/beeper-1.1.1.tgz", - "integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=", - "dev": true - }, - "binary-extensions": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.11.0.tgz", - "integrity": "sha1-RqoXUftqL5PuXmibsQh9SxTGwgU=", - "dev": true - }, - "bluebird": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", - "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==", - "dev": true - }, - "brace-expansion": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.7.tgz", - "integrity": "sha1-Pv/DxQ4ABTH7cg6v+A8K6O8jz1k=", - "dev": true, - "requires": { - "balanced-match": "0.4.2", - "concat-map": "0.0.1" - } - }, - "braces": { - "version": "1.8.5", - "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", - "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", - "dev": true, - "requires": { - "expand-range": "1.8.2", - "preserve": "0.2.0", - "repeat-element": "1.1.2" - } - }, - "bufferstreams": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/bufferstreams/-/bufferstreams-1.1.1.tgz", - "integrity": "sha1-AWE3MGCsWYjv+ZBYcxEU9uGV1R4=", - "dev": true, - "requires": { - "readable-stream": "2.2.11" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.2.11", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.11.tgz", - "integrity": "sha512-h+8+r3MKEhkiVrwdKL8aWs1oc1VvBu33ueshOvS26RsZQ3Amhx/oO3TKe4lApSV9ueY6as8EAh7mtuFjdlhg9Q==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.0.1", - "string_decoder": "1.0.2", - "util-deprecate": "1.0.2" - } - }, - "string_decoder": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.2.tgz", - "integrity": "sha1-sp4fThEl+pehA4K4pTNze3SR4Xk=", - "dev": true, - "requires": { - "safe-buffer": "5.0.1" - } - } - } - }, - "caller-path": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", - "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", - "dev": true, - "requires": { - "callsites": "0.2.0" - } - }, - "callsites": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", - "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" - } - }, - "chokidar": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", - "integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=", - "dev": true, - "requires": { - "anymatch": "1.3.2", - "async-each": "1.0.1", - "fsevents": "1.1.3", - "glob-parent": "2.0.0", - "inherits": "2.0.3", - "is-binary-path": "1.0.1", - "is-glob": "2.0.1", - "path-is-absolute": "1.0.1", - "readdirp": "2.1.0" - } - }, - "circular-json": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.1.tgz", - "integrity": "sha1-vos2rvzN6LPKeqLWr8B6NyQsDS0=", - "dev": true - }, - "cli-cursor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", - "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", - "dev": true, - "requires": { - "restore-cursor": "1.0.1" - } - }, - "cli-width": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.1.0.tgz", - "integrity": "sha1-sjTKIJsp72b8UY2bmNWEewDt8Ao=", - "dev": true - }, - "clone": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.2.tgz", - "integrity": "sha1-Jgt6meux7f4kdTgXX3gyQ8sZ0Uk=", - "dev": true - }, - "clone-stats": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", - "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=", - "dev": true - }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", - "dev": true - }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true - }, - "colors": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", - "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=", - "dev": true - }, - "commander": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "concat-stream": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", - "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", - "dev": true, - "requires": { - "inherits": "2.0.3", - "readable-stream": "2.2.11", - "typedarray": "0.0.6" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.2.11", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.11.tgz", - "integrity": "sha512-h+8+r3MKEhkiVrwdKL8aWs1oc1VvBu33ueshOvS26RsZQ3Amhx/oO3TKe4lApSV9ueY6as8EAh7mtuFjdlhg9Q==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.0.1", - "string_decoder": "1.0.2", - "util-deprecate": "1.0.2" - } - }, - "string_decoder": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.2.tgz", - "integrity": "sha1-sp4fThEl+pehA4K4pTNze3SR4Xk=", - "dev": true, - "requires": { - "safe-buffer": "5.0.1" - } - } - } - }, - "connect": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/connect/-/connect-3.5.1.tgz", - "integrity": "sha1-bTDXpjx/FwhXprOqazY9lz3KWI4=", - "dev": true, - "requires": { - "debug": "2.2.0", - "finalhandler": "0.5.1", - "parseurl": "1.3.2", - "utils-merge": "1.0.0" - }, - "dependencies": { - "debug": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", - "dev": true, - "requires": { - "ms": "0.7.1" - } - }, - "ms": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", - "dev": true - } - } - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "cors": { - "version": "2.8.4", - "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.4.tgz", - "integrity": "sha1-K9OB8usgECAQXNUOpZ2mMJBpRoY=", - "dev": true, - "requires": { - "object-assign": "4.1.1", - "vary": "1.1.2" - }, - "dependencies": { - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - } - } - }, - "d": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", - "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", - "dev": true, - "requires": { - "es5-ext": "0.10.23" - } - }, - "dateformat": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.0.0.tgz", - "integrity": "sha1-J0Pjq7XD/CRi5SfcpEXgTp9N7hc=", - "dev": true - }, - "debug": { - "version": "2.6.8", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", - "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "deep-is": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", - "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", - "dev": true - }, - "defaults": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", - "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", - "dev": true, - "requires": { - "clone": "1.0.2" - } - }, - "del": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", - "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", - "dev": true, - "requires": { - "globby": "5.0.0", - "is-path-cwd": "1.0.0", - "is-path-in-cwd": "1.0.0", - "object-assign": "4.1.1", - "pify": "2.3.0", - "pinkie-promise": "2.0.1", - "rimraf": "2.6.1" - }, - "dependencies": { - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - } - } - }, - "depd": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", - "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=", - "dev": true - }, - "deprecated": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/deprecated/-/deprecated-0.0.1.tgz", - "integrity": "sha1-+cmvVGSvoeepcUWKi97yqpTVuxk=", - "dev": true - }, - "destroy": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", - "dev": true - }, - "detect-file": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-0.1.0.tgz", - "integrity": "sha1-STXe39lIhkjgBrASlWbpOGcR6mM=", - "dev": true, - "requires": { - "fs-exists-sync": "0.1.0" - } - }, - "doctrine": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.0.tgz", - "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=", - "dev": true, - "requires": { - "esutils": "2.0.2", - "isarray": "1.0.0" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - } - } - }, - "duplexer": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", - "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", - "dev": true - }, - "duplexer2": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", - "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", - "dev": true, - "requires": { - "readable-stream": "1.1.14" - } - }, - "ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", - "dev": true - }, - "encodeurl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", - "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=", - "dev": true - }, - "end-of-stream": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-0.1.5.tgz", - "integrity": "sha1-jhdyBsPICDfYVjLouTWd/osvbq8=", - "dev": true, - "requires": { - "once": "1.3.3" - } - }, - "es5-ext": { - "version": "0.10.23", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.23.tgz", - "integrity": "sha1-dXi1G+l0IHpUh4IbVlOMIk5Oezg=", - "dev": true, - "requires": { - "es6-iterator": "2.0.1", - "es6-symbol": "3.1.1" - } - }, - "es6-iterator": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.1.tgz", - "integrity": "sha1-jjGcnwRTv1ddN0lAplWSDlnKVRI=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.23", - "es6-symbol": "3.1.1" - } - }, - "es6-map": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/es6-map/-/es6-map-0.1.5.tgz", - "integrity": "sha1-kTbgUD3MBqMBaQ8LsU/042TpSfA=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.23", - "es6-iterator": "2.0.1", - "es6-set": "0.1.5", - "es6-symbol": "3.1.1", - "event-emitter": "0.3.5" - } - }, - "es6-set": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", - "integrity": "sha1-0rPsXU2ADO2BjbU40ol02wpzzLE=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.23", - "es6-iterator": "2.0.1", - "es6-symbol": "3.1.1", - "event-emitter": "0.3.5" - } - }, - "es6-symbol": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", - "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.23" - } - }, - "es6-weak-map": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz", - "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.23", - "es6-iterator": "2.0.1", - "es6-symbol": "3.1.1" - } - }, - "escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", - "dev": true - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, - "escope": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/escope/-/escope-3.6.0.tgz", - "integrity": "sha1-4Bl16BJ4GhY6ba392AOY3GTIicM=", - "dev": true, - "requires": { - "es6-map": "0.1.5", - "es6-weak-map": "2.0.2", - "esrecurse": "4.1.0", - "estraverse": "4.2.0" - } - }, - "eslint": { - "version": "3.19.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-3.19.0.tgz", - "integrity": "sha1-yPxiAcf0DdCJQbh8CFdnOGpnmsw=", - "dev": true, - "requires": { - "babel-code-frame": "6.22.0", - "chalk": "1.1.3", - "concat-stream": "1.6.0", - "debug": "2.6.8", - "doctrine": "2.0.0", - "escope": "3.6.0", - "espree": "3.4.3", - "esquery": "1.0.0", - "estraverse": "4.2.0", - "esutils": "2.0.2", - "file-entry-cache": "2.0.0", - "glob": "7.1.2", - "globals": "9.17.0", - "ignore": "3.3.3", - "imurmurhash": "0.1.4", - "inquirer": "0.12.0", - "is-my-json-valid": "2.16.0", - "is-resolvable": "1.0.0", - "js-yaml": "3.8.4", - "json-stable-stringify": "1.0.1", - "levn": "0.3.0", - "lodash": "4.17.4", - "mkdirp": "0.5.1", - "natural-compare": "1.4.0", - "optionator": "0.8.2", - "path-is-inside": "1.0.2", - "pluralize": "1.2.1", - "progress": "1.1.8", - "require-uncached": "1.0.3", - "shelljs": "0.7.7", - "strip-bom": "3.0.0", - "strip-json-comments": "2.0.1", - "table": "3.8.3", - "text-table": "0.2.0", - "user-home": "2.0.0" - }, - "dependencies": { - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.3.3", - "path-is-absolute": "1.0.1" - } - }, - "lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", - "dev": true - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.7" - } - }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true - }, - "user-home": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", - "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=", - "dev": true, - "requires": { - "os-homedir": "1.0.2" - } - } - } - }, - "espree": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/espree/-/espree-3.4.3.tgz", - "integrity": "sha1-KRC1zNSc6JPC//+qtP2LOjG4I3Q=", - "dev": true, - "requires": { - "acorn": "5.0.3", - "acorn-jsx": "3.0.1" - } - }, - "esprima": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", - "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=", - "dev": true - }, - "esquery": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.0.tgz", - "integrity": "sha1-z7qLV9f7qT8XKYqKAGoEzaE9gPo=", - "dev": true, - "requires": { - "estraverse": "4.2.0" - } - }, - "esrecurse": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.1.0.tgz", - "integrity": "sha1-RxO2U2rffyrE8yfVWed1a/9kgiA=", - "dev": true, - "requires": { - "estraverse": "4.1.1", - "object-assign": "4.1.1" - }, - "dependencies": { - "estraverse": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.1.1.tgz", - "integrity": "sha1-9srKcokzqFDvkGYdDheYK6RxEaI=", - "dev": true - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - } - } - }, - "estraverse": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", - "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", - "dev": true - }, - "esutils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", - "dev": true - }, - "etag": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", - "dev": true - }, - "event-emitter": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", - "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.23" - } - }, - "event-stream": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", - "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", - "dev": true, - "requires": { - "duplexer": "0.1.1", - "from": "0.1.7", - "map-stream": "0.1.0", - "pause-stream": "0.0.11", - "split": "0.3.3", - "stream-combiner": "0.0.4", - "through": "2.3.8" - } - }, - "exit": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", - "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", - "dev": true - }, - "exit-hook": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz", - "integrity": "sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=", - "dev": true - }, - "expand-brackets": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", - "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", - "dev": true, - "requires": { - "is-posix-bracket": "0.1.1" - } - }, - "expand-range": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", - "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", - "dev": true, - "requires": { - "fill-range": "2.2.3" - } - }, - "expand-tilde": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-1.2.2.tgz", - "integrity": "sha1-C4HrqJflo9MdHD0QL48BRB5VlEk=", - "dev": true, - "requires": { - "os-homedir": "1.0.2" - } - }, - "extend": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", - "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", - "dev": true - }, - "extglob": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", - "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", - "dev": true, - "requires": { - "is-extglob": "1.0.0" - } - }, - "fancy-log": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.0.tgz", - "integrity": "sha1-Rb4X0Cu5kX1gzP/UmVyZnmyMmUg=", - "dev": true, - "requires": { - "chalk": "1.1.3", - "time-stamp": "1.1.0" - } - }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", - "dev": true - }, - "faye-websocket": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.1.tgz", - "integrity": "sha1-8O/hjE9W5PQK/H4Gxxn9XuYYjzg=", - "dev": true, - "requires": { - "websocket-driver": "0.7.0" - } - }, - "figures": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", - "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", - "dev": true, - "requires": { - "escape-string-regexp": "1.0.5", - "object-assign": "4.1.1" - }, - "dependencies": { - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - } - } - }, - "file-entry-cache": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", - "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", - "dev": true, - "requires": { - "flat-cache": "1.2.2", - "object-assign": "4.1.1" - }, - "dependencies": { - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - } - } - }, - "filename-regex": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", - "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=", - "dev": true - }, - "fill-range": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz", - "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", - "dev": true, - "requires": { - "is-number": "2.1.0", - "isobject": "2.1.0", - "randomatic": "1.1.6", - "repeat-element": "1.1.2", - "repeat-string": "1.6.1" - } - }, - "finalhandler": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.5.1.tgz", - "integrity": "sha1-LEANjUUwk1vCMlScX6OF7Afeb80=", - "dev": true, - "requires": { - "debug": "2.2.0", - "escape-html": "1.0.3", - "on-finished": "2.3.0", - "statuses": "1.3.1", - "unpipe": "1.0.0" - }, - "dependencies": { - "debug": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", - "dev": true, - "requires": { - "ms": "0.7.1" - } - }, - "ms": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", - "dev": true - } - } - }, - "find-index": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/find-index/-/find-index-0.1.1.tgz", - "integrity": "sha1-Z101iyyjiS15Whq0cjL4tuLg3eQ=", - "dev": true - }, - "findup-sync": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.4.3.tgz", - "integrity": "sha1-QAQ5Kee8YK3wt/SCfExudaDeyhI=", - "dev": true, - "requires": { - "detect-file": "0.1.0", - "is-glob": "2.0.1", - "micromatch": "2.3.11", - "resolve-dir": "0.1.1" - } - }, - "fined": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/fined/-/fined-1.0.2.tgz", - "integrity": "sha1-WyhCS3YNdZiWC374SA3/itNmDpc=", - "dev": true, - "requires": { - "expand-tilde": "1.2.2", - "lodash.assignwith": "4.2.0", - "lodash.isempty": "4.4.0", - "lodash.isplainobject": "4.0.6", - "lodash.isstring": "4.0.1", - "lodash.pick": "4.4.0", - "parse-filepath": "1.0.1" - } - }, - "first-chunk-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz", - "integrity": "sha1-Wb+1DNkF9g18OUzT2ayqtOatk04=", - "dev": true - }, - "flagged-respawn": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-0.3.2.tgz", - "integrity": "sha1-/xke3c1wiKZ1smEP/8l2vpuAdLU=", - "dev": true - }, - "flat-cache": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.2.2.tgz", - "integrity": "sha1-+oZxTnLCHbiGAXYezy9VXRq8a5Y=", - "dev": true, - "requires": { - "circular-json": "0.3.1", - "del": "2.2.2", - "graceful-fs": "4.1.11", - "write": "0.2.1" - }, - "dependencies": { - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - } - } - }, - "for-in": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true - }, - "for-own": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", - "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", - "dev": true, - "requires": { - "for-in": "1.0.2" - } - }, - "fresh": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", - "dev": true - }, - "from": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", - "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", - "dev": true - }, - "fs-exists-sync": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz", - "integrity": "sha1-mC1ok6+RjnLQjeyehnP/K1qNat0=", - "dev": true - }, - "fs-extra": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", - "integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "jsonfile": "4.0.0", - "universalify": "0.1.1" - }, - "dependencies": { - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - } - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "fsevents": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.3.tgz", - "integrity": "sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q==", - "dev": true, - "optional": true, - "requires": { - "nan": "2.8.0", - "node-pre-gyp": "0.6.39" - }, - "dependencies": { - "abbrev": { - "version": "1.1.0", - "bundled": true, - "dev": true, - "optional": true - }, - "ajv": { - "version": "4.11.8", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "co": "4.6.0", - "json-stable-stringify": "1.0.1" - } - }, - "ansi-regex": { - "version": "2.1.1", - "bundled": true, - "dev": true - }, - "aproba": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "are-we-there-yet": { - "version": "1.1.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "delegates": "1.0.0", - "readable-stream": "2.2.9" - } - }, - "asn1": { - "version": "0.2.3", - "bundled": true, - "dev": true, - "optional": true - }, - "assert-plus": { - "version": "0.2.0", - "bundled": true, - "dev": true, - "optional": true - }, - "asynckit": { - "version": "0.4.0", - "bundled": true, - "dev": true, - "optional": true - }, - "aws-sign2": { - "version": "0.6.0", - "bundled": true, - "dev": true, - "optional": true - }, - "aws4": { - "version": "1.6.0", - "bundled": true, - "dev": true, - "optional": true - }, - "balanced-match": { - "version": "0.4.2", - "bundled": true, - "dev": true - }, - "bcrypt-pbkdf": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "tweetnacl": "0.14.5" - } - }, - "block-stream": { - "version": "0.0.9", - "bundled": true, - "dev": true, - "requires": { - "inherits": "2.0.3" - } - }, - "boom": { - "version": "2.10.1", - "bundled": true, - "dev": true, - "requires": { - "hoek": "2.16.3" - } - }, - "brace-expansion": { - "version": "1.1.7", - "bundled": true, - "dev": true, - "requires": { - "balanced-match": "0.4.2", - "concat-map": "0.0.1" - } - }, - "buffer-shims": { - "version": "1.0.0", - "bundled": true, - "dev": true - }, - "caseless": { - "version": "0.12.0", - "bundled": true, - "dev": true, - "optional": true - }, - "co": { - "version": "4.6.0", - "bundled": true, - "dev": true, - "optional": true - }, - "code-point-at": { - "version": "1.1.0", - "bundled": true, - "dev": true - }, - "combined-stream": { - "version": "1.0.5", - "bundled": true, - "dev": true, - "requires": { - "delayed-stream": "1.0.0" - } - }, - "concat-map": { - "version": "0.0.1", - "bundled": true, - "dev": true - }, - "console-control-strings": { - "version": "1.1.0", - "bundled": true, - "dev": true - }, - "core-util-is": { - "version": "1.0.2", - "bundled": true, - "dev": true - }, - "cryptiles": { - "version": "2.0.5", - "bundled": true, - "dev": true, - "requires": { - "boom": "2.10.1" - } - }, - "dashdash": { - "version": "1.14.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, - "debug": { - "version": "2.6.8", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ms": "2.0.0" - } - }, - "deep-extend": { - "version": "0.4.2", - "bundled": true, - "dev": true, - "optional": true - }, - "delayed-stream": { - "version": "1.0.0", - "bundled": true, - "dev": true - }, - "delegates": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "detect-libc": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "ecc-jsbn": { - "version": "0.1.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "jsbn": "0.1.1" - } - }, - "extend": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "extsprintf": { - "version": "1.0.2", - "bundled": true, - "dev": true - }, - "forever-agent": { - "version": "0.6.1", - "bundled": true, - "dev": true, - "optional": true - }, - "form-data": { - "version": "2.1.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.15" - } - }, - "fs.realpath": { - "version": "1.0.0", - "bundled": true, - "dev": true - }, - "fstream": { - "version": "1.0.11", - "bundled": true, - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "inherits": "2.0.3", - "mkdirp": "0.5.1", - "rimraf": "2.6.1" - } - }, - "fstream-ignore": { - "version": "1.0.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "fstream": "1.0.11", - "inherits": "2.0.3", - "minimatch": "3.0.4" - } - }, - "gauge": { - "version": "2.7.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "aproba": "1.1.1", - "console-control-strings": "1.1.0", - "has-unicode": "2.0.1", - "object-assign": "4.1.1", - "signal-exit": "3.0.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wide-align": "1.1.2" - } - }, - "getpass": { - "version": "0.1.7", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, - "glob": { - "version": "7.1.2", - "bundled": true, - "dev": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" - } - }, - "graceful-fs": { - "version": "4.1.11", - "bundled": true, - "dev": true - }, - "har-schema": { - "version": "1.0.5", - "bundled": true, - "dev": true, - "optional": true - }, - "har-validator": { - "version": "4.2.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ajv": "4.11.8", - "har-schema": "1.0.5" - } - }, - "has-unicode": { - "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "hawk": { - "version": "3.1.3", - "bundled": true, - "dev": true, - "requires": { - "boom": "2.10.1", - "cryptiles": "2.0.5", - "hoek": "2.16.3", - "sntp": "1.0.9" - } - }, - "hoek": { - "version": "2.16.3", - "bundled": true, - "dev": true - }, - "http-signature": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "assert-plus": "0.2.0", - "jsprim": "1.4.0", - "sshpk": "1.13.0" - } - }, - "inflight": { - "version": "1.0.6", - "bundled": true, - "dev": true, - "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" - } - }, - "inherits": { - "version": "2.0.3", - "bundled": true, - "dev": true - }, - "ini": { - "version": "1.3.4", - "bundled": true, - "dev": true, - "optional": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "requires": { - "number-is-nan": "1.0.1" - } - }, - "is-typedarray": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "isarray": { - "version": "1.0.0", - "bundled": true, - "dev": true - }, - "isstream": { - "version": "0.1.2", - "bundled": true, - "dev": true, - "optional": true - }, - "jodid25519": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "jsbn": "0.1.1" - } - }, - "jsbn": { - "version": "0.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "json-schema": { - "version": "0.2.3", - "bundled": true, - "dev": true, - "optional": true - }, - "json-stable-stringify": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "jsonify": "0.0.0" - } - }, - "json-stringify-safe": { - "version": "5.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "jsonify": { - "version": "0.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "jsprim": { - "version": "1.4.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.0.2", - "json-schema": "0.2.3", - "verror": "1.3.6" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, - "mime-db": { - "version": "1.27.0", - "bundled": true, - "dev": true - }, - "mime-types": { - "version": "2.1.15", - "bundled": true, - "dev": true, - "requires": { - "mime-db": "1.27.0" - } - }, - "minimatch": { - "version": "3.0.4", - "bundled": true, - "dev": true, - "requires": { - "brace-expansion": "1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "bundled": true, - "dev": true - }, - "mkdirp": { - "version": "0.5.1", - "bundled": true, - "dev": true, - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "node-pre-gyp": { - "version": "0.6.39", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "detect-libc": "1.0.2", - "hawk": "3.1.3", - "mkdirp": "0.5.1", - "nopt": "4.0.1", - "npmlog": "4.1.0", - "rc": "1.2.1", - "request": "2.81.0", - "rimraf": "2.6.1", - "semver": "5.3.0", - "tar": "2.2.1", - "tar-pack": "3.4.0" - } - }, - "nopt": { - "version": "4.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "abbrev": "1.1.0", - "osenv": "0.1.4" - } - }, - "npmlog": { - "version": "4.1.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "are-we-there-yet": "1.1.4", - "console-control-strings": "1.1.0", - "gauge": "2.7.4", - "set-blocking": "2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "bundled": true, - "dev": true - }, - "oauth-sign": { - "version": "0.8.2", - "bundled": true, - "dev": true, - "optional": true - }, - "object-assign": { - "version": "4.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "once": { - "version": "1.4.0", - "bundled": true, - "dev": true, - "requires": { - "wrappy": "1.0.2" - } - }, - "os-homedir": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "os-tmpdir": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "osenv": { - "version": "0.1.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true, - "dev": true - }, - "performance-now": { - "version": "0.2.0", - "bundled": true, - "dev": true, - "optional": true - }, - "process-nextick-args": { - "version": "1.0.7", - "bundled": true, - "dev": true - }, - "punycode": { - "version": "1.4.1", - "bundled": true, - "dev": true, - "optional": true - }, - "qs": { - "version": "6.4.0", - "bundled": true, - "dev": true, - "optional": true - }, - "rc": { - "version": "1.2.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "deep-extend": "0.4.2", - "ini": "1.3.4", - "minimist": "1.2.0", - "strip-json-comments": "2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, - "readable-stream": { - "version": "2.2.9", - "bundled": true, - "dev": true, - "requires": { - "buffer-shims": "1.0.0", - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "string_decoder": "1.0.1", - "util-deprecate": "1.0.2" - } - }, - "request": { - "version": "2.81.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "aws-sign2": "0.6.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.1.4", - "har-validator": "4.2.1", - "hawk": "3.1.3", - "http-signature": "1.1.1", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.15", - "oauth-sign": "0.8.2", - "performance-now": "0.2.0", - "qs": "6.4.0", - "safe-buffer": "5.0.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.2", - "tunnel-agent": "0.6.0", - "uuid": "3.0.1" - } - }, - "rimraf": { - "version": "2.6.1", - "bundled": true, - "dev": true, - "requires": { - "glob": "7.1.2" - } - }, - "safe-buffer": { - "version": "5.0.1", - "bundled": true, - "dev": true - }, - "semver": { - "version": "5.3.0", - "bundled": true, - "dev": true, - "optional": true - }, - "set-blocking": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "signal-exit": { - "version": "3.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "sntp": { - "version": "1.0.9", - "bundled": true, - "dev": true, - "requires": { - "hoek": "2.16.3" - } - }, - "sshpk": { - "version": "1.13.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jodid25519": "1.0.2", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, - "string-width": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" - } - }, - "string_decoder": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "requires": { - "safe-buffer": "5.0.1" - } - }, - "stringstream": { - "version": "0.0.5", - "bundled": true, - "dev": true, - "optional": true - }, - "strip-ansi": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "tar": { - "version": "2.2.1", - "bundled": true, - "dev": true, - "requires": { - "block-stream": "0.0.9", - "fstream": "1.0.11", - "inherits": "2.0.3" - } - }, - "tar-pack": { - "version": "3.4.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "debug": "2.6.8", - "fstream": "1.0.11", - "fstream-ignore": "1.0.5", - "once": "1.4.0", - "readable-stream": "2.2.9", - "rimraf": "2.6.1", - "tar": "2.2.1", - "uid-number": "0.0.6" - } - }, - "tough-cookie": { - "version": "2.3.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "punycode": "1.4.1" - } - }, - "tunnel-agent": { - "version": "0.6.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safe-buffer": "5.0.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "bundled": true, - "dev": true, - "optional": true - }, - "uid-number": { - "version": "0.0.6", - "bundled": true, - "dev": true, - "optional": true - }, - "util-deprecate": { - "version": "1.0.2", - "bundled": true, - "dev": true - }, - "uuid": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "verror": { - "version": "1.3.6", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "extsprintf": "1.0.2" - } - }, - "wide-align": { - "version": "1.1.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "string-width": "1.0.2" - } - }, - "wrappy": { - "version": "1.0.2", - "bundled": true, - "dev": true - } - } - }, - "gaze": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz", - "integrity": "sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8=", - "dev": true, - "requires": { - "globule": "0.1.0" - } - }, - "generate-function": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", - "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=", - "dev": true - }, - "generate-object-property": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", - "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", - "dev": true, - "requires": { - "is-property": "1.0.2" - } - }, - "gh-pages": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/gh-pages/-/gh-pages-1.1.0.tgz", - "integrity": "sha512-ZpDkeOVmIrN5mz+sBWDz5zmTqcbNJzI/updCwEv/7rrSdpTNlj1B5GhBqG7f4Q8p5sJOdnBV0SIqxJrxtZQ9FA==", - "dev": true, - "requires": { - "async": "2.6.0", - "base64url": "2.0.0", - "commander": "2.11.0", - "fs-extra": "4.0.3", - "globby": "6.1.0", - "graceful-fs": "4.1.11", - "rimraf": "2.6.2" - }, - "dependencies": { - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.3.3", - "path-is-absolute": "1.0.1" - } - }, - "globby": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", - "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", - "dev": true, - "requires": { - "array-union": "1.0.2", - "glob": "7.1.2", - "object-assign": "4.1.1", - "pify": "2.3.0", - "pinkie-promise": "2.0.1" - } - }, - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.7" - } - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - }, - "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", - "dev": true, - "requires": { - "glob": "7.1.2" - } - } - } - }, - "glob": { - "version": "4.5.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", - "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", - "dev": true, - "requires": { - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "2.0.10", - "once": "1.3.3" - } - }, - "glob-base": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", - "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", - "dev": true, - "requires": { - "glob-parent": "2.0.0", - "is-glob": "2.0.1" - } - }, - "glob-parent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", - "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", - "dev": true, - "requires": { - "is-glob": "2.0.1" - } - }, - "glob-stream": { - "version": "3.1.18", - "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-3.1.18.tgz", - "integrity": "sha1-kXCl8St5Awb9/lmPMT+PeVT9FDs=", - "dev": true, - "requires": { - "glob": "4.5.3", - "glob2base": "0.0.12", - "minimatch": "2.0.10", - "ordered-read-streams": "0.1.0", - "through2": "0.6.5", - "unique-stream": "1.0.0" - }, - "dependencies": { - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "0.0.1", - "string_decoder": "0.10.31" - } - }, - "through2": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true, - "requires": { - "readable-stream": "1.0.34", - "xtend": "4.0.1" - } - } - } - }, - "glob-watcher": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.6.tgz", - "integrity": "sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs=", - "dev": true, - "requires": { - "gaze": "0.5.2" - } - }, - "glob2base": { - "version": "0.0.12", - "resolved": "https://registry.npmjs.org/glob2base/-/glob2base-0.0.12.tgz", - "integrity": "sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY=", - "dev": true, - "requires": { - "find-index": "0.1.1" - } - }, - "global-modules": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-0.2.3.tgz", - "integrity": "sha1-6lo77ULG1s6ZWk+KEmm12uIjgo0=", - "dev": true, - "requires": { - "global-prefix": "0.1.5", - "is-windows": "0.2.0" - } - }, - "global-prefix": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-0.1.5.tgz", - "integrity": "sha1-jTvGuNo8qBEqFg2NSW/wRiv+948=", - "dev": true, - "requires": { - "homedir-polyfill": "1.0.1", - "ini": "1.3.4", - "is-windows": "0.2.0", - "which": "1.2.14" - } - }, - "globals": { - "version": "9.17.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-9.17.0.tgz", - "integrity": "sha1-DAymltm5u2lNLlRwvTd3fKrVAoY=", - "dev": true - }, - "globby": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", - "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", - "dev": true, - "requires": { - "array-union": "1.0.2", - "arrify": "1.0.1", - "glob": "7.1.2", - "object-assign": "4.1.1", - "pify": "2.3.0", - "pinkie-promise": "2.0.1" - }, - "dependencies": { - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.3.3", - "path-is-absolute": "1.0.1" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.7" - } - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - } - } - }, - "globule": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/globule/-/globule-0.1.0.tgz", - "integrity": "sha1-2cjt3h2nnRJaFRt5UzuXhnY0auU=", - "dev": true, - "requires": { - "glob": "3.1.21", - "lodash": "1.0.2", - "minimatch": "0.2.14" - }, - "dependencies": { - "glob": { - "version": "3.1.21", - "resolved": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz", - "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", - "dev": true, - "requires": { - "graceful-fs": "1.2.3", - "inherits": "1.0.2", - "minimatch": "0.2.14" - } - }, - "graceful-fs": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz", - "integrity": "sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=", - "dev": true - }, - "inherits": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-1.0.2.tgz", - "integrity": "sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js=", - "dev": true - }, - "minimatch": { - "version": "0.2.14", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", - "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", - "dev": true, - "requires": { - "lru-cache": "2.7.3", - "sigmund": "1.0.1" - } - } - } - }, - "glogg": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.0.tgz", - "integrity": "sha1-f+DxmfV6yQbPUS/urY+Q7kooT8U=", - "dev": true, - "requires": { - "sparkles": "1.0.0" - } - }, - "graceful-fs": { - "version": "3.0.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", - "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", - "dev": true, - "requires": { - "natives": "1.1.0" - } - }, - "gulp": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/gulp/-/gulp-3.9.1.tgz", - "integrity": "sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ=", - "dev": true, - "requires": { - "archy": "1.0.0", - "chalk": "1.1.3", - "deprecated": "0.0.1", - "gulp-util": "3.0.8", - "interpret": "1.0.3", - "liftoff": "2.3.0", - "minimist": "1.2.0", - "orchestrator": "0.3.8", - "pretty-hrtime": "1.0.3", - "semver": "4.3.6", - "tildify": "1.2.0", - "v8flags": "2.1.1", - "vinyl-fs": "0.3.14" - } - }, - "gulp-eslint": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/gulp-eslint/-/gulp-eslint-3.0.1.tgz", - "integrity": "sha1-BOV+PhjGl0JnwSz2hV3HF9SjE70=", - "dev": true, - "requires": { - "bufferstreams": "1.1.1", - "eslint": "3.19.0", - "gulp-util": "3.0.8" - } - }, - "gulp-jasmine": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/gulp-jasmine/-/gulp-jasmine-2.4.2.tgz", - "integrity": "sha1-Wn9H4nNww2GawKKkQr45lnFAnbM=", - "dev": true, - "requires": { - "arrify": "1.0.1", - "gulp-util": "3.0.8", - "jasmine": "2.6.0", - "jasmine-terminal-reporter": "1.0.3", - "through2": "2.0.3" - } - }, - "gulp-util": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", - "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", - "dev": true, - "requires": { - "array-differ": "1.0.0", - "array-uniq": "1.0.3", - "beeper": "1.1.1", - "chalk": "1.1.3", - "dateformat": "2.0.0", - "fancy-log": "1.3.0", - "gulplog": "1.0.0", - "has-gulplog": "0.1.0", - "lodash._reescape": "3.0.0", - "lodash._reevaluate": "3.0.0", - "lodash._reinterpolate": "3.0.0", - "lodash.template": "3.6.2", - "minimist": "1.2.0", - "multipipe": "0.1.2", - "object-assign": "3.0.0", - "replace-ext": "0.0.1", - "through2": "2.0.3", - "vinyl": "0.5.3" - } - }, - "gulplog": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz", - "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=", - "dev": true, - "requires": { - "glogg": "1.0.0" - } - }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "has-gulplog": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz", - "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=", - "dev": true, - "requires": { - "sparkles": "1.0.0" - } - }, - "homedir-polyfill": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", - "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", - "dev": true, - "requires": { - "parse-passwd": "1.0.0" - } - }, - "http-auth": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/http-auth/-/http-auth-3.1.3.tgz", - "integrity": "sha1-lFz63WZSHq+PfISRPTd9exXyTjE=", - "dev": true, - "requires": { - "apache-crypt": "1.2.1", - "apache-md5": "1.1.2", - "bcryptjs": "2.4.3", - "uuid": "3.1.0" - } - }, - "http-errors": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", - "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", - "dev": true, - "requires": { - "depd": "1.1.1", - "inherits": "2.0.3", - "setprototypeof": "1.0.3", - "statuses": "1.3.1" - } - }, - "http-parser-js": { - "version": "0.4.9", - "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.4.9.tgz", - "integrity": "sha1-6hoE+2St/wJC6ZdPKX3Uw8rSceE=", - "dev": true - }, - "ignore": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.3.tgz", - "integrity": "sha1-QyNS5XrM2HqzEQ6C0/6g5HgSFW0=", - "dev": true - }, - "imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", - "dev": true - }, - "indent-string": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", - "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", - "dev": true, - "requires": { - "repeating": "2.0.1" - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "1.3.3", - "wrappy": "1.0.2" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "ini": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", - "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=", - "dev": true - }, - "inquirer": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz", - "integrity": "sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=", - "dev": true, - "requires": { - "ansi-escapes": "1.4.0", - "ansi-regex": "2.1.1", - "chalk": "1.1.3", - "cli-cursor": "1.0.2", - "cli-width": "2.1.0", - "figures": "1.7.0", - "lodash": "4.17.4", - "readline2": "1.0.1", - "run-async": "0.1.0", - "rx-lite": "3.1.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "through": "2.3.8" - }, - "dependencies": { - "lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", - "dev": true - } - } - }, - "interpret": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.0.3.tgz", - "integrity": "sha1-y8NcYu7uc/Gat7EKgBURQBr8D5A=", - "dev": true - }, - "is-absolute": { - "version": "0.2.6", - "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-0.2.6.tgz", - "integrity": "sha1-IN5p89uULvLYe5wto28XIjWxtes=", - "dev": true, - "requires": { - "is-relative": "0.2.1", - "is-windows": "0.2.0" - } - }, - "is-binary-path": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", - "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", - "dev": true, - "requires": { - "binary-extensions": "1.11.0" - } - }, - "is-buffer": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", - "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", - "dev": true - }, - "is-dotfile": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", - "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=", - "dev": true - }, - "is-equal-shallow": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", - "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", - "dev": true, - "requires": { - "is-primitive": "2.0.0" - } - }, - "is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true - }, - "is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", - "dev": true - }, - "is-finite": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", - "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", - "dev": true, - "requires": { - "number-is-nan": "1.0.1" - } - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "requires": { - "number-is-nan": "1.0.1" - } - }, - "is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "dev": true, - "requires": { - "is-extglob": "1.0.0" - } - }, - "is-my-json-valid": { - "version": "2.16.0", - "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.16.0.tgz", - "integrity": "sha1-8Hndm/2uZe4gOKrorLyGqxCeNpM=", - "dev": true, - "requires": { - "generate-function": "2.0.0", - "generate-object-property": "1.2.0", - "jsonpointer": "4.0.1", - "xtend": "4.0.1" - } - }, - "is-number": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", - "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - } - }, - "is-path-cwd": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", - "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=", - "dev": true - }, - "is-path-in-cwd": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz", - "integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=", - "dev": true, - "requires": { - "is-path-inside": "1.0.0" - } - }, - "is-path-inside": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.0.tgz", - "integrity": "sha1-/AbloWg/vaE95mev9xe7wQpI838=", - "dev": true, - "requires": { - "path-is-inside": "1.0.2" - } - }, - "is-posix-bracket": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", - "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=", - "dev": true - }, - "is-primitive": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", - "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", - "dev": true - }, - "is-property": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", - "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", - "dev": true - }, - "is-relative": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-0.2.1.tgz", - "integrity": "sha1-0n9MfVFtF1+2ENuEu+7yPDvJeqU=", - "dev": true, - "requires": { - "is-unc-path": "0.1.2" - } - }, - "is-resolvable": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.0.tgz", - "integrity": "sha1-jfV8YeouPFAUCNEA+wE8+NbgzGI=", - "dev": true, - "requires": { - "tryit": "1.0.3" - } - }, - "is-unc-path": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-0.1.2.tgz", - "integrity": "sha1-arBTpyVzwQJQ/0FqOBTDUXivObk=", - "dev": true, - "requires": { - "unc-path-regex": "0.1.2" - } - }, - "is-utf8": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", - "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", - "dev": true - }, - "is-windows": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-0.2.0.tgz", - "integrity": "sha1-3hqm1j6indJIc3tp8f+LgALSEIw=", - "dev": true - }, - "is-wsl": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", - "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=", - "dev": true - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true - }, - "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "1.0.0" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - } - } - }, - "jasmine": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-2.6.0.tgz", - "integrity": "sha1-ayLnCIPo5YnUVjRhU7TSBt2+IX8=", - "dev": true, - "requires": { - "exit": "0.1.2", - "glob": "7.1.2", - "jasmine-core": "2.6.2" - }, - "dependencies": { - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.3.3", - "path-is-absolute": "1.0.1" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.7" - } - } - } - }, - "jasmine-core": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.6.2.tgz", - "integrity": "sha1-dOoffPQoaRryARB9YxI0AnoJ2qs=", - "dev": true - }, - "jasmine-terminal-reporter": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/jasmine-terminal-reporter/-/jasmine-terminal-reporter-1.0.3.tgz", - "integrity": "sha1-iW8eyP30v2rs3UHFA+2nNH9hUms=", - "dev": true, - "requires": { - "indent-string": "2.1.0", - "pluralize": "1.2.1" - } - }, - "js-tokens": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.1.tgz", - "integrity": "sha1-COnxMkhKLEWjCQfp3E1VZ7fxFNc=", - "dev": true - }, - "js-yaml": { - "version": "3.8.4", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.8.4.tgz", - "integrity": "sha1-UgtFZPhlc7qWZir4Woyvp7S1pvY=", - "dev": true, - "requires": { - "argparse": "1.0.9", - "esprima": "3.1.3" - } - }, - "jsdoc": { - "version": "3.5.5", - "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.5.5.tgz", - "integrity": "sha512-6PxB65TAU4WO0Wzyr/4/YhlGovXl0EVYfpKbpSroSj0qBxT4/xod/l40Opkm38dRHRdQgdeY836M0uVnJQG7kg==", - "dev": true, - "requires": { - "babylon": "7.0.0-beta.19", - "bluebird": "3.5.1", - "catharsis": "0.8.9", - "escape-string-regexp": "1.0.5", - "js2xmlparser": "3.0.0", - "klaw": "2.0.0", - "marked": "0.3.6", - "mkdirp": "0.5.1", - "requizzle": "0.2.1", - "strip-json-comments": "2.0.1", - "taffydb": "2.6.2", - "underscore": "1.8.3" - }, - "dependencies": { - "catharsis": { - "version": "0.8.9", - "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.9.tgz", - "integrity": "sha1-mMyJDKZS3S7w5ws3klMQ/56Q/Is=", - "dev": true, - "requires": { - "underscore-contrib": "0.3.0" - } - }, - "js2xmlparser": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-3.0.0.tgz", - "integrity": "sha1-P7YOqgicVED5MZ9RdgzNB+JJlzM=", - "dev": true, - "requires": { - "xmlcreate": "1.0.2" - } - }, - "taffydb": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", - "integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=", - "dev": true - }, - "underscore": { - "version": "1.8.3", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", - "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=", - "dev": true - } - } - }, - "json-stable-stringify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", - "dev": true, - "requires": { - "jsonify": "0.0.0" - } - }, - "jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11" - }, - "dependencies": { - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true, - "optional": true - } - } - }, - "jsonify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", - "dev": true - }, - "jsonpointer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", - "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", - "dev": true - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.5" - } - }, - "klaw": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-2.0.0.tgz", - "integrity": "sha1-WcEo4Nxc5BAgEVEZTuucv4WGUPY=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11" - }, - "dependencies": { - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - } - } - }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "dev": true, - "requires": { - "prelude-ls": "1.1.2", - "type-check": "0.3.2" - } - }, - "liftoff": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-2.3.0.tgz", - "integrity": "sha1-qY8v9nGD2Lp8+soQVIvX/wVQs4U=", - "dev": true, - "requires": { - "extend": "3.0.1", - "findup-sync": "0.4.3", - "fined": "1.0.2", - "flagged-respawn": "0.3.2", - "lodash.isplainobject": "4.0.6", - "lodash.isstring": "4.0.1", - "lodash.mapvalues": "4.6.0", - "rechoir": "0.6.2", - "resolve": "1.3.3" - } - }, - "live-server": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/live-server/-/live-server-1.2.0.tgz", - "integrity": "sha1-RJhkS7+Bpm8Y3Y3/3vYcTBw3TKM=", - "dev": true, - "requires": { - "chokidar": "1.7.0", - "colors": "1.1.2", - "connect": "3.5.1", - "cors": "2.8.4", - "event-stream": "3.3.4", - "faye-websocket": "0.11.1", - "http-auth": "3.1.3", - "morgan": "1.9.0", - "object-assign": "4.1.1", - "opn": "5.1.0", - "proxy-middleware": "0.15.0", - "send": "0.16.1", - "serve-index": "1.9.1" - }, - "dependencies": { - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - } - } - }, - "lodash": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-1.0.2.tgz", - "integrity": "sha1-j1dWDIO1n8JwvT1WG2kAQ0MOJVE=", - "dev": true - }, - "lodash._basecopy": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", - "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", - "dev": true - }, - "lodash._basetostring": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", - "integrity": "sha1-0YYdh3+CSlL2aYMtyvPuFVZqB9U=", - "dev": true - }, - "lodash._basevalues": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz", - "integrity": "sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc=", - "dev": true - }, - "lodash._getnative": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", - "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", - "dev": true - }, - "lodash._isiterateecall": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", - "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", - "dev": true - }, - "lodash._reescape": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._reescape/-/lodash._reescape-3.0.0.tgz", - "integrity": "sha1-Kx1vXf4HyKNVdT5fJ/rH8c3hYWo=", - "dev": true - }, - "lodash._reevaluate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz", - "integrity": "sha1-WLx0xAZklTrgsSTYBpltrKQx4u0=", - "dev": true - }, - "lodash._reinterpolate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", - "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", - "dev": true - }, - "lodash._root": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/lodash._root/-/lodash._root-3.0.1.tgz", - "integrity": "sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI=", - "dev": true - }, - "lodash.assignwith": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lodash.assignwith/-/lodash.assignwith-4.2.0.tgz", - "integrity": "sha1-EnqX8CrcQXUalU0ksN4X4QDgOOs=", - "dev": true - }, - "lodash.escape": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", - "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", - "dev": true, - "requires": { - "lodash._root": "3.0.1" - } - }, - "lodash.isarguments": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", - "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", - "dev": true - }, - "lodash.isarray": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", - "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", - "dev": true - }, - "lodash.isempty": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.isempty/-/lodash.isempty-4.4.0.tgz", - "integrity": "sha1-b4bL7di+TsmHvpqvM8loTbGzHn4=", - "dev": true - }, - "lodash.isplainobject": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=", - "dev": true - }, - "lodash.isstring": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", - "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=", - "dev": true - }, - "lodash.keys": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", - "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", - "dev": true, - "requires": { - "lodash._getnative": "3.9.1", - "lodash.isarguments": "3.1.0", - "lodash.isarray": "3.0.4" - } - }, - "lodash.mapvalues": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/lodash.mapvalues/-/lodash.mapvalues-4.6.0.tgz", - "integrity": "sha1-G6+lAF3p3W9PJmaMMMo3IwzJaJw=", - "dev": true - }, - "lodash.pick": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz", - "integrity": "sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM=", - "dev": true - }, - "lodash.restparam": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", - "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=", - "dev": true - }, - "lodash.template": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz", - "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", - "dev": true, - "requires": { - "lodash._basecopy": "3.0.1", - "lodash._basetostring": "3.0.1", - "lodash._basevalues": "3.0.0", - "lodash._isiterateecall": "3.0.9", - "lodash._reinterpolate": "3.0.0", - "lodash.escape": "3.2.0", - "lodash.keys": "3.1.2", - "lodash.restparam": "3.6.1", - "lodash.templatesettings": "3.1.1" - } - }, - "lodash.templatesettings": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz", - "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=", - "dev": true, - "requires": { - "lodash._reinterpolate": "3.0.0", - "lodash.escape": "3.2.0" - } - }, - "lru-cache": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", - "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", - "dev": true - }, - "map-cache": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true - }, - "map-stream": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", - "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", - "dev": true - }, - "marked": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.6.tgz", - "integrity": "sha1-ssbGGPzOzk74bE/Gy4p8v1rtqNc=", - "dev": true - }, - "micromatch": { - "version": "2.3.11", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", - "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", - "dev": true, - "requires": { - "arr-diff": "2.0.0", - "array-unique": "0.2.1", - "braces": "1.8.5", - "expand-brackets": "0.1.5", - "extglob": "0.3.2", - "filename-regex": "2.0.1", - "is-extglob": "1.0.0", - "is-glob": "2.0.1", - "kind-of": "3.2.2", - "normalize-path": "2.1.1", - "object.omit": "2.0.1", - "parse-glob": "3.0.4", - "regex-cache": "0.4.3" - } - }, - "mime": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", - "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==", - "dev": true - }, - "mime-db": { - "version": "1.30.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", - "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=", - "dev": true - }, - "mime-types": { - "version": "2.1.17", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", - "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", - "dev": true, - "requires": { - "mime-db": "1.30.0" - } - }, - "minimatch": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", - "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", - "dev": true, - "requires": { - "brace-expansion": "1.1.7" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - } - } - }, - "morgan": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.0.tgz", - "integrity": "sha1-0B+mxlhZt2/PMbPLU6OCGjEdgFE=", - "dev": true, - "requires": { - "basic-auth": "2.0.0", - "debug": "2.6.9", - "depd": "1.1.1", - "on-finished": "2.3.0", - "on-headers": "1.0.1" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "multipipe": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", - "integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=", - "dev": true, - "requires": { - "duplexer2": "0.0.2" - } - }, - "mute-stream": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", - "integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=", - "dev": true - }, - "nan": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.8.0.tgz", - "integrity": "sha1-7XFfP+neArV6XmJS2QqWZ14fCFo=", - "dev": true, - "optional": true - }, - "natives": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.0.tgz", - "integrity": "sha1-6f+EFBimsux6SV6TmYT3jxY+bjE=", - "dev": true - }, - "natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", - "dev": true - }, - "negotiator": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", - "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", - "dev": true - }, - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true, - "requires": { - "remove-trailing-separator": "1.0.1" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true - }, - "object-assign": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", - "integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=", - "dev": true - }, - "object.omit": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", - "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", - "dev": true, - "requires": { - "for-own": "0.1.5", - "is-extendable": "0.1.1" - } - }, - "on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", - "dev": true, - "requires": { - "ee-first": "1.1.1" - } - }, - "on-headers": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz", - "integrity": "sha1-ko9dD0cNSTQmUepnlLCFfBAGk/c=", - "dev": true - }, - "once": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", - "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", - "dev": true, - "requires": { - "wrappy": "1.0.2" - } - }, - "onetime": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", - "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", - "dev": true - }, - "opn": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/opn/-/opn-5.1.0.tgz", - "integrity": "sha512-iPNl7SyM8L30Rm1sjGdLLheyHVw5YXVfi3SKWJzBI7efxRwHojfRFjwE/OLM6qp9xJYMgab8WicTU1cPoY+Hpg==", - "dev": true, - "requires": { - "is-wsl": "1.1.0" - } - }, - "optionator": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", - "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", - "dev": true, - "requires": { - "deep-is": "0.1.3", - "fast-levenshtein": "2.0.6", - "levn": "0.3.0", - "prelude-ls": "1.1.2", - "type-check": "0.3.2", - "wordwrap": "1.0.0" - } - }, - "orchestrator": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/orchestrator/-/orchestrator-0.3.8.tgz", - "integrity": "sha1-FOfp4nZPcxX7rBhOUGx6pt+UrX4=", - "dev": true, - "requires": { - "end-of-stream": "0.1.5", - "sequencify": "0.0.7", - "stream-consume": "0.1.0" - } - }, - "ordered-read-streams": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz", - "integrity": "sha1-/VZamvjrRHO6abbtijQ1LLVS8SY=", - "dev": true - }, - "os-homedir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", - "dev": true - }, - "parse-filepath": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.1.tgz", - "integrity": "sha1-FZ1hVdQ5BNFsEO9piRHaHpGWm3M=", - "dev": true, - "requires": { - "is-absolute": "0.2.6", - "map-cache": "0.2.2", - "path-root": "0.1.1" - } - }, - "parse-glob": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", - "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", - "dev": true, - "requires": { - "glob-base": "0.3.0", - "is-dotfile": "1.0.3", - "is-extglob": "1.0.0", - "is-glob": "2.0.1" - } - }, - "parse-passwd": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", - "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", - "dev": true - }, - "parseurl": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", - "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=", - "dev": true - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-is-inside": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", - "dev": true - }, - "path-parse": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", - "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", - "dev": true - }, - "path-root": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz", - "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", - "dev": true, - "requires": { - "path-root-regex": "0.1.2" - } - }, - "path-root-regex": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz", - "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=", - "dev": true - }, - "pause-stream": { - "version": "0.0.11", - "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", - "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", - "dev": true, - "requires": { - "through": "2.3.8" - } - }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - }, - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "dev": true, - "requires": { - "pinkie": "2.0.4" - } - }, - "pluralize": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-1.2.1.tgz", - "integrity": "sha1-0aIUg/0iu0HlihL6NCGCMUCJfEU=", - "dev": true - }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "dev": true - }, - "preserve": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", - "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", - "dev": true - }, - "pretty-hrtime": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", - "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=", - "dev": true - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "progress": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", - "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", - "dev": true - }, - "proxy-middleware": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/proxy-middleware/-/proxy-middleware-0.15.0.tgz", - "integrity": "sha1-o/3xvvtzD5UZZYcqwvYHTGFHelY=", - "dev": true - }, - "randomatic": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.6.tgz", - "integrity": "sha1-EQ3Kv/OX6dz/fAeJzMCkmt8exbs=", - "dev": true, - "requires": { - "is-number": "2.1.0", - "kind-of": "3.2.2" - } - }, - "range-parser": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", - "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=", - "dev": true - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "0.0.1", - "string_decoder": "0.10.31" - } - }, - "readdirp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", - "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "minimatch": "3.0.4", - "readable-stream": "2.3.3", - "set-immediate-shim": "1.0.1" - }, - "dependencies": { - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.7" - } - }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" - } - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - } - } - }, - "readline2": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz", - "integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=", - "dev": true, - "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "mute-stream": "0.0.5" - } - }, - "rechoir": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", - "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", - "dev": true, - "requires": { - "resolve": "1.3.3" - } - }, - "regex-cache": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz", - "integrity": "sha1-mxpsNdTQ3871cRrmUejp09cRQUU=", - "dev": true, - "requires": { - "is-equal-shallow": "0.1.3", - "is-primitive": "2.0.0" - } - }, - "remove-trailing-separator": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.0.1.tgz", - "integrity": "sha1-YV67lq9VlVLUv0BXyENtSGq2PMQ=", - "dev": true - }, - "repeat-element": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", - "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", - "dev": true - }, - "repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true - }, - "repeating": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", - "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", - "dev": true, - "requires": { - "is-finite": "1.0.2" - } - }, - "replace-ext": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz", - "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", - "dev": true - }, - "require-uncached": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", - "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", - "dev": true, - "requires": { - "caller-path": "0.1.0", - "resolve-from": "1.0.1" - } - }, - "requizzle": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.1.tgz", - "integrity": "sha1-aUPDUwxNmn5G8c3dUcFY/GcM294=", - "dev": true, - "requires": { - "underscore": "1.6.0" - } - }, - "resolve": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.3.3.tgz", - "integrity": "sha1-ZVkHw0aahoDcLeOidaj91paR8OU=", - "dev": true, - "requires": { - "path-parse": "1.0.5" - } - }, - "resolve-dir": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-0.1.1.tgz", - "integrity": "sha1-shklmlYC+sXFxJatiUpujMQwJh4=", - "dev": true, - "requires": { - "expand-tilde": "1.2.2", - "global-modules": "0.2.3" - } - }, - "resolve-from": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", - "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", - "dev": true - }, - "restore-cursor": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", - "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", - "dev": true, - "requires": { - "exit-hook": "1.1.1", - "onetime": "1.1.0" - } - }, - "rimraf": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz", - "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=", - "dev": true, - "requires": { - "glob": "7.1.2" - }, - "dependencies": { - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.3.3", - "path-is-absolute": "1.0.1" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.7" - } - } - } - }, - "run-async": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz", - "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", - "dev": true, - "requires": { - "once": "1.3.3" - } - }, - "rx-lite": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz", - "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=", - "dev": true - }, - "safe-buffer": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz", - "integrity": "sha1-0mPKVGls2KMGtcplUekt5XkY++c=", - "dev": true - }, - "semver": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", - "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=", - "dev": true - }, - "send": { - "version": "0.16.1", - "resolved": "https://registry.npmjs.org/send/-/send-0.16.1.tgz", - "integrity": "sha512-ElCLJdJIKPk6ux/Hocwhk7NFHpI3pVm/IZOYWqUmoxcgeyM+MpxHHKhb8QmlJDX1pU6WrgaHBkVNm73Sv7uc2A==", - "dev": true, - "requires": { - "debug": "2.6.9", - "depd": "1.1.1", - "destroy": "1.0.4", - "encodeurl": "1.0.1", - "escape-html": "1.0.3", - "etag": "1.8.1", - "fresh": "0.5.2", - "http-errors": "1.6.2", - "mime": "1.4.1", - "ms": "2.0.0", - "on-finished": "2.3.0", - "range-parser": "1.2.0", - "statuses": "1.3.1" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "sequencify": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/sequencify/-/sequencify-0.0.7.tgz", - "integrity": "sha1-kM/xnQLgcCf9dn9erT57ldHnOAw=", - "dev": true - }, - "serve-index": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", - "integrity": "sha1-03aNabHn2C5c4FD/9bRTvqEqkjk=", - "dev": true, - "requires": { - "accepts": "1.3.4", - "batch": "0.6.1", - "debug": "2.6.9", - "escape-html": "1.0.3", - "http-errors": "1.6.2", - "mime-types": "2.1.17", - "parseurl": "1.3.2" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "set-immediate-shim": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", - "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", - "dev": true - }, - "setprototypeof": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", - "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=", - "dev": true - }, - "shelljs": { - "version": "0.7.7", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.7.tgz", - "integrity": "sha1-svXHfvlxSPS09uImguELuoZnz/E=", - "dev": true, - "requires": { - "glob": "7.1.2", - "interpret": "1.0.3", - "rechoir": "0.6.2" - }, - "dependencies": { - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.3.3", - "path-is-absolute": "1.0.1" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.7" - } - } - } - }, - "sigmund": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", - "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", - "dev": true - }, - "slice-ansi": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", - "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", - "dev": true - }, - "sparkles": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.0.tgz", - "integrity": "sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM=", - "dev": true - }, - "split": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", - "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", - "dev": true, - "requires": { - "through": "2.3.8" - } - }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, - "statuses": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", - "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", - "dev": true - }, - "stream-combiner": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", - "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", - "dev": true, - "requires": { - "duplexer": "0.1.1" - } - }, - "stream-consume": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.0.tgz", - "integrity": "sha1-pB6tGm1ggc63n2WwYZAbbY89HQ8=", - "dev": true - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, - "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "strip-bom": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz", - "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=", - "dev": true, - "requires": { - "first-chunk-stream": "1.0.0", - "is-utf8": "0.2.1" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - }, - "table": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz", - "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=", - "dev": true, - "requires": { - "ajv": "4.11.8", - "ajv-keywords": "1.5.1", - "chalk": "1.1.3", - "lodash": "4.17.4", - "slice-ansi": "0.0.4", - "string-width": "2.0.0" - }, - "dependencies": { - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", - "dev": true - }, - "string-width": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.0.0.tgz", - "integrity": "sha1-Y1xUNsxypuDDh87KJ41OLuxSaH4=", - "dev": true, - "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "3.0.1" - } - } - } - }, - "text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", - "dev": true - }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true - }, - "through2": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", - "dev": true, - "requires": { - "readable-stream": "2.2.11", - "xtend": "4.0.1" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.2.11", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.11.tgz", - "integrity": "sha512-h+8+r3MKEhkiVrwdKL8aWs1oc1VvBu33ueshOvS26RsZQ3Amhx/oO3TKe4lApSV9ueY6as8EAh7mtuFjdlhg9Q==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.0.1", - "string_decoder": "1.0.2", - "util-deprecate": "1.0.2" - } - }, - "string_decoder": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.2.tgz", - "integrity": "sha1-sp4fThEl+pehA4K4pTNze3SR4Xk=", - "dev": true, - "requires": { - "safe-buffer": "5.0.1" - } - } - } - }, - "tildify": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/tildify/-/tildify-1.2.0.tgz", - "integrity": "sha1-3OwD9V3Km3qj5bBPIYF+tW5jWIo=", - "dev": true, - "requires": { - "os-homedir": "1.0.2" - } - }, - "time-stamp": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz", - "integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=", - "dev": true - }, - "tryit": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/tryit/-/tryit-1.0.3.tgz", - "integrity": "sha1-OTvnMKlEb9Hq1tpZoBQwjzbCics=", - "dev": true - }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "dev": true, - "requires": { - "prelude-ls": "1.1.2" - } - }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true - }, - "unc-path-regex": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", - "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", - "dev": true - }, - "underscore": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz", - "integrity": "sha1-izixDKze9jM3uLJOT/htRa6lKag=", - "dev": true - }, - "underscore-contrib": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/underscore-contrib/-/underscore-contrib-0.3.0.tgz", - "integrity": "sha1-ZltmwkeD+PorGMn4y7Dix9SMJsc=", - "dev": true, - "requires": { - "underscore": "1.6.0" - } - }, - "unique-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz", - "integrity": "sha1-1ZpKdUJ0R9mqbJHnAmP40mpLEEs=", - "dev": true - }, - "universalify": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz", - "integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc=", - "dev": true - }, - "unix-crypt-td-js": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unix-crypt-td-js/-/unix-crypt-td-js-1.0.0.tgz", - "integrity": "sha1-HAgkFQSBvHoB1J6Y8exmjYJBLzs=", - "dev": true - }, - "unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", - "dev": true - }, - "user-home": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz", - "integrity": "sha1-K1viOjK2Onyd640PKNSFcko98ZA=", - "dev": true - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "utils-merge": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz", - "integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg=", - "dev": true - }, - "uuid": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==", - "dev": true - }, - "v8flags": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-2.1.1.tgz", - "integrity": "sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ=", - "dev": true, - "requires": { - "user-home": "1.1.1" - } - }, - "vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", - "dev": true - }, - "vinyl": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz", - "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", - "dev": true, - "requires": { - "clone": "1.0.2", - "clone-stats": "0.0.1", - "replace-ext": "0.0.1" - } - }, - "vinyl-fs": { - "version": "0.3.14", - "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-0.3.14.tgz", - "integrity": "sha1-mmhRzhysHBzqX+hsCTHWIMLPqeY=", - "dev": true, - "requires": { - "defaults": "1.0.3", - "glob-stream": "3.1.18", - "glob-watcher": "0.0.6", - "graceful-fs": "3.0.11", - "mkdirp": "0.5.1", - "strip-bom": "1.0.0", - "through2": "0.6.5", - "vinyl": "0.4.6" - }, - "dependencies": { - "clone": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz", - "integrity": "sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8=", - "dev": true - }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "0.0.1", - "string_decoder": "0.10.31" - } - }, - "through2": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true, - "requires": { - "readable-stream": "1.0.34", - "xtend": "4.0.1" - } - }, - "vinyl": { - "version": "0.4.6", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz", - "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", - "dev": true, - "requires": { - "clone": "0.2.0", - "clone-stats": "0.0.1" - } - } - } - }, - "websocket-driver": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.0.tgz", - "integrity": "sha1-DK+dLXVdk67gSdS90NP+LMoqJOs=", - "dev": true, - "requires": { - "http-parser-js": "0.4.9", - "websocket-extensions": "0.1.3" - } - }, - "websocket-extensions": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.3.tgz", - "integrity": "sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==", - "dev": true - }, - "which": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz", - "integrity": "sha1-mofEN48D6CfOyvGs31bHNsAcFOU=", - "dev": true, - "requires": { - "isexe": "2.0.0" - } - }, - "wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", - "dev": true - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "write": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", - "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", - "dev": true, - "requires": { - "mkdirp": "0.5.1" - } - }, - "xmlcreate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-1.0.2.tgz", - "integrity": "sha1-+mv3YqYKQT+z3Y9LA8WyaSONMI8=", - "dev": true - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true - } - } -} diff --git a/src/graphics/graham.js b/src/graphics/graham.js new file mode 100644 index 00000000..bab1889a --- /dev/null +++ b/src/graphics/graham.js @@ -0,0 +1,72 @@ +(function(exports) { + 'use strict'; + + const slope = (p, a) => (a.y - p.y) / (a.x - p.x); + + const dist = (a, b) => Math.sqrt((b.y - a.y) * (b.y - a.y) + (b.x - a.x) * (b.x - a.x)); + + const sort = (p, memo, a, b) => { + const sa = slope(p, a); + const sb = slope(p, b); + [[sa, a], [sb, b]].forEach(e => { + if (!memo.has(e[0])) { + memo.set(e[0], new Set()); + } + memo.get(e[0]).add(e[1]); + }); + return sa - sb; + }; + + const ccw = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x); + + /** + * Graham's algorithm for calculating the convex hull. + * + * @public + * @module graphics/graham + * @param {Array} all + * @returns {Array} + * + * @example + * const points = [ + * { x: 0, y: 0 }, + * { x: 1, y: 0 }, + * { x: 0, y: 1 }, + * { x: 0.15, y: 0.15 }, + * { x: 0.5, y: 0.5 } + * ]; + * const list = convexHull(points); + * // [{ x: 0, y: 0 }, + * // { x: 1, y: 0 }, + * // { x: 0.5, y: 0.5 }, + * // { x: 0, y: 1 }] + */ + const convexHull = all => { + if (!all.length) return []; + + const p = all.reduce((a, c) => { + if (a.y < c.y) return a; + if (a.y > c.y) return c; + if (a.x < c.x) return a; + return c; + }); + const memo = new Map(); + const points = all.sort(sort.bind(null, p, memo)).filter(c => { + const s = slope(p, c); + // Liner check, can consider more efficient data structure + const set = Array.from(memo.get(s)); + return !set.some(e => dist(p, e) > dist(p, c)); + }); + + const stack = []; + points.forEach(p => { + while (stack.length > 1 && ccw(stack[stack.length - 2], stack[stack.length - 1], p) < 0) { + stack.pop(); + } + stack.push(p); + }); + return stack; + }; + + exports.convexHull = convexHull; +})(typeof exports === 'undefined' ? window : exports); diff --git a/test/graphics/grapham.spec.js b/test/graphics/grapham.spec.js new file mode 100644 index 00000000..8b6db0e6 --- /dev/null +++ b/test/graphics/grapham.spec.js @@ -0,0 +1,26 @@ +var convexHull = require('../../src/graphics/graham').convexHull; + +const points = [ + { x: 0, y: 0 }, + { x: 1, y: 0 }, + { x: 0, y: 1 }, + { x: 0.15, y: 0.15 }, + { x: 0.5, y: 0.5 } +]; + +describe("Graham's algorithm for convex hull", function() { + 'use strict'; + + it('should not throw with empty list', () => { + expect(() => convexHull([])).not.toThrow(); + }); + + it('should calculate the convex hull', () => { + expect(convexHull(points)).toEqual([ + { x: 0, y: 0 }, + { x: 1, y: 0 }, + { x: 0.5, y: 0.5 }, + { x: 0, y: 1 } + ]); + }); +}); diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 00000000..cae998a0 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,3344 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@jeremyckahn/minami@^1.3.1": + version "1.3.1" + resolved "https://registry.yarnpkg.com/@jeremyckahn/minami/-/minami-1.3.1.tgz#cec9a26c1484b0cacdc9d7a86eb476fe864a0515" + integrity sha512-jeOFPfq3zLxnQ0dhlhrZd5J0qZDdF1wkrNlr6ErVaGtjPTq9gn/NIK0GDOmGcAJgN/6yKwRdMxPy33u12lQWiQ== + +abbrev@1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" + integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== + +accepts@~1.3.4: + version "1.3.5" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.5.tgz#eb777df6011723a3b14e8a72c0805c8e86746bd2" + integrity sha1-63d99gEXI6OxTopywIBcjoZ0a9I= + dependencies: + mime-types "~2.1.18" + negotiator "0.6.1" + +acorn-jsx@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b" + integrity sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s= + dependencies: + acorn "^3.0.4" + +acorn@^3.0.4: + version "3.3.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" + integrity sha1-ReN/s56No/JbruP/U2niu18iAXo= + +acorn@^5.5.0: + version "5.7.3" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.3.tgz#67aa231bf8812974b85235a96771eb6bd07ea279" + integrity sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw== + +ajv-keywords@^1.0.0: + version "1.5.1" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" + integrity sha1-MU3QpLM2j609/NxU7eYXG4htrzw= + +ajv@^4.7.0: + version "4.11.8" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" + integrity sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY= + dependencies: + co "^4.6.0" + json-stable-stringify "^1.0.1" + +ansi-escapes@^1.1.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" + integrity sha1-06ioOzGapneTZisT52HHkRQiMG4= + +ansi-gray@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/ansi-gray/-/ansi-gray-0.1.1.tgz#2962cf54ec9792c48510a3deb524436861ef7251" + integrity sha1-KWLPVOyXksSFEKPetSRDaGHvclE= + dependencies: + ansi-wrap "0.1.0" + +ansi-regex@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8= + +ansi-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" + integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= + +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + integrity sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4= + +ansi-wrap@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/ansi-wrap/-/ansi-wrap-0.1.0.tgz#a82250ddb0015e9a27ca82e82ea603bbfa45efaf" + integrity sha1-qCJQ3bABXponyoLoLqYDu/pF768= + +anymatch@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" + integrity sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw== + dependencies: + micromatch "^3.1.4" + normalize-path "^2.1.1" + +apache-crypt@^1.1.2: + version "1.2.1" + resolved "https://registry.yarnpkg.com/apache-crypt/-/apache-crypt-1.2.1.tgz#d6fc72aa6d27d99c95a94fd188d731eefffa663c" + integrity sha1-1vxyqm0n2ZyVqU/RiNcx7v/6Zjw= + dependencies: + unix-crypt-td-js "^1.0.0" + +apache-md5@^1.0.6: + version "1.1.2" + resolved "https://registry.yarnpkg.com/apache-md5/-/apache-md5-1.1.2.tgz#ee49736b639b4f108b6e9e626c6da99306b41692" + integrity sha1-7klza2ObTxCLbp5ibG2pkwa0FpI= + +aproba@^1.0.3: + version "1.2.0" + resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" + integrity sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw== + +archy@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40" + integrity sha1-+cjBN1fMHde8N5rHeyxipcKGjEA= + +are-we-there-yet@~1.1.2: + version "1.1.5" + resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz#4b35c2944f062a8bfcda66410760350fe9ddfc21" + integrity sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w== + dependencies: + delegates "^1.0.0" + readable-stream "^2.0.6" + +argparse@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== + dependencies: + sprintf-js "~1.0.2" + +arr-diff@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" + integrity sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA= + +arr-flatten@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" + integrity sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg== + +arr-union@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" + integrity sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ= + +array-differ@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-1.0.0.tgz#eff52e3758249d33be402b8bb8e564bb2b5d4031" + integrity sha1-7/UuN1gknTO+QCuLuOVkuytdQDE= + +array-each@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/array-each/-/array-each-1.0.1.tgz#a794af0c05ab1752846ee753a1f211a05ba0c44f" + integrity sha1-p5SvDAWrF1KEbudTofIRoFugxE8= + +array-slice@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/array-slice/-/array-slice-1.1.0.tgz#e368ea15f89bc7069f7ffb89aec3a6c7d4ac22d4" + integrity sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w== + +array-union@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" + integrity sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk= + dependencies: + array-uniq "^1.0.1" + +array-uniq@^1.0.1, array-uniq@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" + integrity sha1-r2rId6Jcx/dOBYiUdThY39sk/bY= + +array-unique@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" + integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg= + +arrify@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + integrity sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0= + +assign-symbols@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" + integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c= + +async-each@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.2.tgz#8b8a7ca2a658f927e9f307d6d1a42f4199f0f735" + integrity sha512-6xrbvN0MOBKSJDdonmSSz2OwFSgxRaVtBDes26mj9KIGtDo+g9xosFRSC+i1gQh2oAN/tQ62AI/pGZGQjVOiRg== + +async@2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.1.tgz#b245a23ca71930044ec53fa46aa00a3e87c6a610" + integrity sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ== + dependencies: + lodash "^4.17.10" + +atob@^2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" + integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== + +babel-code-frame@^6.16.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" + integrity sha1-Y/1D99weO7fONZR9uP42mj9Yx0s= + dependencies: + chalk "^1.1.3" + esutils "^2.0.2" + js-tokens "^3.0.2" + +babylon@7.0.0-beta.19: + version "7.0.0-beta.19" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.19.tgz#e928c7e807e970e0536b078ab3e0c48f9e052503" + integrity sha512-Vg0C9s/REX6/WIXN37UKpv5ZhRi6A4pjHlpkE34+8/a6c2W1Q692n3hmc+SZG5lKRnaExLUbxtJ1SVT+KaCQ/A== + +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= + +base@^0.11.1: + version "0.11.2" + resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f" + integrity sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg== + dependencies: + cache-base "^1.0.1" + class-utils "^0.3.5" + component-emitter "^1.2.1" + define-property "^1.0.0" + isobject "^3.0.1" + mixin-deep "^1.2.0" + pascalcase "^0.1.1" + +basic-auth@~2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/basic-auth/-/basic-auth-2.0.1.tgz#b998279bf47ce38344b4f3cf916d4679bbf51e3a" + integrity sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg== + dependencies: + safe-buffer "5.1.2" + +batch@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16" + integrity sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY= + +bcryptjs@^2.3.0: + version "2.4.3" + resolved "https://registry.yarnpkg.com/bcryptjs/-/bcryptjs-2.4.3.tgz#9ab5627b93e60621ff7cdac5da9733027df1d0cb" + integrity sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms= + +beeper@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/beeper/-/beeper-1.1.1.tgz#e6d5ea8c5dad001304a70b22638447f69cb2f809" + integrity sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak= + +binary-extensions@^1.0.0: + version "1.13.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.13.0.tgz#9523e001306a32444b907423f1de2164222f6ab1" + integrity sha512-EgmjVLMn22z7eGGv3kcnHwSnJXmFHjISTY9E/S5lIcTD3Oxw05QTcBLNkJFzcb3cNueUdF/IN4U+d78V0zO8Hw== + +bluebird@~3.5.0: + version "3.5.3" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.3.tgz#7d01c6f9616c9a51ab0f8c549a79dfe6ec33efa7" + integrity sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw== + +brace-expansion@^1.0.0, brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +braces@^2.3.1, braces@^2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" + integrity sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w== + dependencies: + arr-flatten "^1.1.0" + array-unique "^0.3.2" + extend-shallow "^2.0.1" + fill-range "^4.0.0" + isobject "^3.0.1" + repeat-element "^1.1.2" + snapdragon "^0.8.1" + snapdragon-node "^2.0.1" + split-string "^3.0.2" + to-regex "^3.0.1" + +buffer-from@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" + integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== + +bufferstreams@^1.1.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/bufferstreams/-/bufferstreams-1.1.3.tgz#a8515ac024fa90e8fa7d58c11b13dea1f28abe72" + integrity sha512-HaJnVuslRF4g2kSDeyl++AaVizoitCpL9PglzCYwy0uHHyvWerfvEb8jWmYbF1z4kiVFolGomnxSGl+GUQp2jg== + dependencies: + readable-stream "^2.0.2" + +cache-base@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2" + integrity sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ== + dependencies: + collection-visit "^1.0.0" + component-emitter "^1.2.1" + get-value "^2.0.6" + has-value "^1.0.0" + isobject "^3.0.1" + set-value "^2.0.0" + to-object-path "^0.3.0" + union-value "^1.0.0" + unset-value "^1.0.0" + +caller-path@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f" + integrity sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8= + dependencies: + callsites "^0.2.0" + +callsites@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca" + integrity sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo= + +catharsis@~0.8.9: + version "0.8.9" + resolved "https://registry.yarnpkg.com/catharsis/-/catharsis-0.8.9.tgz#98cc890ca652dd2ef0e70b37925310ff9e90fc8b" + integrity sha1-mMyJDKZS3S7w5ws3klMQ/56Q/Is= + dependencies: + underscore-contrib "~0.3.0" + +chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + integrity sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg= + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +chokidar@^2.0.4: + version "2.1.5" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.1.5.tgz#0ae8434d962281a5f56c72869e79cb6d9d86ad4d" + integrity sha512-i0TprVWp+Kj4WRPtInjexJ8Q+BqTE909VpH8xVhXrJkoc5QC8VO9TryGOqTr+2hljzc1sC62t22h5tZePodM/A== + dependencies: + anymatch "^2.0.0" + async-each "^1.0.1" + braces "^2.3.2" + glob-parent "^3.1.0" + inherits "^2.0.3" + is-binary-path "^1.0.0" + is-glob "^4.0.0" + normalize-path "^3.0.0" + path-is-absolute "^1.0.0" + readdirp "^2.2.1" + upath "^1.1.1" + optionalDependencies: + fsevents "^1.2.7" + +chownr@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.1.tgz#54726b8b8fff4df053c42187e801fb4412df1494" + integrity sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g== + +circular-json@^0.3.1: + version "0.3.3" + resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66" + integrity sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A== + +class-utils@^0.3.5: + version "0.3.6" + resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" + integrity sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg== + dependencies: + arr-union "^3.1.0" + define-property "^0.2.5" + isobject "^3.0.0" + static-extend "^0.1.1" + +cli-cursor@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" + integrity sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc= + dependencies: + restore-cursor "^1.0.1" + +cli-width@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" + integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk= + +clone-stats@^0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/clone-stats/-/clone-stats-0.0.1.tgz#b88f94a82cf38b8791d58046ea4029ad88ca99d1" + integrity sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE= + +clone@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/clone/-/clone-0.2.0.tgz#c6126a90ad4f72dbf5acdb243cc37724fe93fc1f" + integrity sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8= + +clone@^1.0.0, clone@^1.0.2: + version "1.0.4" + resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" + integrity sha1-2jCcwmPfFZlMaIypAheco8fNfH4= + +co@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" + integrity sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ= + +code-point-at@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" + integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= + +collection-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0" + integrity sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA= + dependencies: + map-visit "^1.0.0" + object-visit "^1.0.0" + +color-support@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2" + integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg== + +colors@latest: + version "1.3.3" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.3.tgz#39e005d546afe01e01f9c4ca8fa50f686a01205d" + integrity sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg== + +commander@2.15.1: + version "2.15.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" + integrity sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag== + +component-emitter@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" + integrity sha1-E3kY1teCg/ffemt8WmPhQOaUJeY= + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= + +concat-stream@^1.5.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" + integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== + dependencies: + buffer-from "^1.0.0" + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" + +connect@^3.6.6: + version "3.6.6" + resolved "https://registry.yarnpkg.com/connect/-/connect-3.6.6.tgz#09eff6c55af7236e137135a72574858b6786f524" + integrity sha1-Ce/2xVr3I24TcTWnJXSFi2eG9SQ= + dependencies: + debug "2.6.9" + finalhandler "1.1.0" + parseurl "~1.3.2" + utils-merge "1.0.1" + +console-control-strings@^1.0.0, console-control-strings@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" + integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4= + +copy-descriptor@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" + integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= + +core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= + +cors@latest: + version "2.8.5" + resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" + integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g== + dependencies: + object-assign "^4" + vary "^1" + +d@1: + version "1.0.0" + resolved "https://registry.yarnpkg.com/d/-/d-1.0.0.tgz#754bb5bfe55451da69a58b94d45f4c5b0462d58f" + integrity sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8= + dependencies: + es5-ext "^0.10.9" + +dateformat@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-2.2.0.tgz#4065e2013cf9fb916ddfd82efb506ad4c6769062" + integrity sha1-QGXiATz5+5Ft39gu+1Bq1MZ2kGI= + +debug@2.6.9, debug@^2.1.1, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== + dependencies: + ms "2.0.0" + +decode-uri-component@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" + integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= + +deep-extend@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + +deep-is@~0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" + integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= + +defaults@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d" + integrity sha1-xlYFHpgX2f8I7YgUd/P+QBnz730= + dependencies: + clone "^1.0.2" + +define-property@^0.2.5: + version "0.2.5" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116" + integrity sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY= + dependencies: + is-descriptor "^0.1.0" + +define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6" + integrity sha1-dp66rz9KY6rTr56NMEybvnm/sOY= + dependencies: + is-descriptor "^1.0.0" + +define-property@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d" + integrity sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ== + dependencies: + is-descriptor "^1.0.2" + isobject "^3.0.1" + +delegates@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" + integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o= + +depd@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" + integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= + +deprecated@^0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/deprecated/-/deprecated-0.0.1.tgz#f9c9af5464afa1e7a971458a8bdef2aa94d5bb19" + integrity sha1-+cmvVGSvoeepcUWKi97yqpTVuxk= + +destroy@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" + integrity sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA= + +detect-file@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/detect-file/-/detect-file-1.0.0.tgz#f0d66d03672a825cb1b73bdb3fe62310c8e552b7" + integrity sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc= + +detect-libc@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" + integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= + +doctrine@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" + integrity sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw== + dependencies: + esutils "^2.0.2" + +duplexer2@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.0.2.tgz#c614dcf67e2fb14995a91711e5a617e8a60a31db" + integrity sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds= + dependencies: + readable-stream "~1.1.9" + +duplexer@~0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" + integrity sha1-rOb/gIwc5mtX0ev5eXessCM0z8E= + +ee-first@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= + +encodeurl@~1.0.1, encodeurl@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" + integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k= + +end-of-stream@~0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-0.1.5.tgz#8e177206c3c80837d85632e8b9359dfe8b2f6eaf" + integrity sha1-jhdyBsPICDfYVjLouTWd/osvbq8= + dependencies: + once "~1.3.0" + +es5-ext@^0.10.14, es5-ext@^0.10.35, es5-ext@^0.10.9, es5-ext@~0.10.14: + version "0.10.49" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.49.tgz#059a239de862c94494fec28f8150c977028c6c5e" + integrity sha512-3NMEhi57E31qdzmYp2jwRArIUsj1HI/RxbQ4bgnSB+AIKIxsAmTiK83bYMifIcpWvEc3P1X30DhUKOqEtF/kvg== + dependencies: + es6-iterator "~2.0.3" + es6-symbol "~3.1.1" + next-tick "^1.0.0" + +es6-iterator@^2.0.1, es6-iterator@~2.0.1, es6-iterator@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" + integrity sha1-p96IkUGgWpSwhUQDstCg+/qY87c= + dependencies: + d "1" + es5-ext "^0.10.35" + es6-symbol "^3.1.1" + +es6-map@^0.1.3: + version "0.1.5" + resolved "https://registry.yarnpkg.com/es6-map/-/es6-map-0.1.5.tgz#9136e0503dcc06a301690f0bb14ff4e364e949f0" + integrity sha1-kTbgUD3MBqMBaQ8LsU/042TpSfA= + dependencies: + d "1" + es5-ext "~0.10.14" + es6-iterator "~2.0.1" + es6-set "~0.1.5" + es6-symbol "~3.1.1" + event-emitter "~0.3.5" + +es6-set@~0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.5.tgz#d2b3ec5d4d800ced818db538d28974db0a73ccb1" + integrity sha1-0rPsXU2ADO2BjbU40ol02wpzzLE= + dependencies: + d "1" + es5-ext "~0.10.14" + es6-iterator "~2.0.1" + es6-symbol "3.1.1" + event-emitter "~0.3.5" + +es6-symbol@3.1.1, es6-symbol@^3.1.1, es6-symbol@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" + integrity sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc= + dependencies: + d "1" + es5-ext "~0.10.14" + +es6-weak-map@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.2.tgz#5e3ab32251ffd1538a1f8e5ffa1357772f92d96f" + integrity sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8= + dependencies: + d "1" + es5-ext "^0.10.14" + es6-iterator "^2.0.1" + es6-symbol "^3.1.1" + +escape-html@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= + +escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5, escape-string-regexp@~1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= + +escope@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/escope/-/escope-3.6.0.tgz#e01975e812781a163a6dadfdd80398dc64c889c3" + integrity sha1-4Bl16BJ4GhY6ba392AOY3GTIicM= + dependencies: + es6-map "^0.1.3" + es6-weak-map "^2.0.1" + esrecurse "^4.1.0" + estraverse "^4.1.1" + +eslint@^3.0.0: + version "3.19.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.19.0.tgz#c8fc6201c7f40dd08941b87c085767386a679acc" + integrity sha1-yPxiAcf0DdCJQbh8CFdnOGpnmsw= + dependencies: + babel-code-frame "^6.16.0" + chalk "^1.1.3" + concat-stream "^1.5.2" + debug "^2.1.1" + doctrine "^2.0.0" + escope "^3.6.0" + espree "^3.4.0" + esquery "^1.0.0" + estraverse "^4.2.0" + esutils "^2.0.2" + file-entry-cache "^2.0.0" + glob "^7.0.3" + globals "^9.14.0" + ignore "^3.2.0" + imurmurhash "^0.1.4" + inquirer "^0.12.0" + is-my-json-valid "^2.10.0" + is-resolvable "^1.0.0" + js-yaml "^3.5.1" + json-stable-stringify "^1.0.0" + levn "^0.3.0" + lodash "^4.0.0" + mkdirp "^0.5.0" + natural-compare "^1.4.0" + optionator "^0.8.2" + path-is-inside "^1.0.1" + pluralize "^1.2.1" + progress "^1.1.8" + require-uncached "^1.0.2" + shelljs "^0.7.5" + strip-bom "^3.0.0" + strip-json-comments "~2.0.1" + table "^3.7.8" + text-table "~0.2.0" + user-home "^2.0.0" + +espree@^3.4.0: + version "3.5.4" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.4.tgz#b0f447187c8a8bed944b815a660bddf5deb5d1a7" + integrity sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A== + dependencies: + acorn "^5.5.0" + acorn-jsx "^3.0.0" + +esprima@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + +esquery@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.1.tgz#406c51658b1f5991a5f9b62b1dc25b00e3e5c708" + integrity sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA== + dependencies: + estraverse "^4.0.0" + +esrecurse@^4.1.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.1.tgz#007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf" + integrity sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ== + dependencies: + estraverse "^4.1.0" + +estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" + integrity sha1-De4/7TH81GlhjOc0IJn8GvoL2xM= + +esutils@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + integrity sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs= + +etag@~1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" + integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= + +event-emitter@~0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.5.tgz#df8c69eef1647923c7157b9ce83840610b02cc39" + integrity sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk= + dependencies: + d "1" + es5-ext "~0.10.14" + +event-stream@3.3.4: + version "3.3.4" + resolved "https://registry.yarnpkg.com/event-stream/-/event-stream-3.3.4.tgz#4ab4c9a0f5a54db9338b4c34d86bfce8f4b35571" + integrity sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE= + dependencies: + duplexer "~0.1.1" + from "~0" + map-stream "~0.1.0" + pause-stream "0.0.11" + split "0.3" + stream-combiner "~0.0.4" + through "~2.3.1" + +exit-hook@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" + integrity sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g= + +exit@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" + integrity sha1-BjJjj42HfMghB9MKD/8aF8uhzQw= + +expand-brackets@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" + integrity sha1-t3c14xXOMPa27/D4OwQVGiJEliI= + dependencies: + debug "^2.3.3" + define-property "^0.2.5" + extend-shallow "^2.0.1" + posix-character-classes "^0.1.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +expand-tilde@^2.0.0, expand-tilde@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/expand-tilde/-/expand-tilde-2.0.2.tgz#97e801aa052df02454de46b02bf621642cdc8502" + integrity sha1-l+gBqgUt8CRU3kawK/YhZCzchQI= + dependencies: + homedir-polyfill "^1.0.1" + +extend-shallow@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" + integrity sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8= + dependencies: + is-extendable "^0.1.0" + +extend-shallow@^3.0.0, extend-shallow@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8" + integrity sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg= + dependencies: + assign-symbols "^1.0.0" + is-extendable "^1.0.1" + +extend@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" + integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== + +extglob@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" + integrity sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw== + dependencies: + array-unique "^0.3.2" + define-property "^1.0.0" + expand-brackets "^2.1.4" + extend-shallow "^2.0.1" + fragment-cache "^0.2.1" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +fancy-log@^1.1.0: + version "1.3.3" + resolved "https://registry.yarnpkg.com/fancy-log/-/fancy-log-1.3.3.tgz#dbc19154f558690150a23953a0adbd035be45fc7" + integrity sha512-k9oEhlyc0FrVh25qYuSELjr8oxsCoc4/LEZfg2iJJrfEk/tZL9bCoJE47gqAvI2m/AUjluCS4+3I0eTx8n3AEw== + dependencies: + ansi-gray "^0.1.1" + color-support "^1.1.3" + parse-node-version "^1.0.0" + time-stamp "^1.0.0" + +fast-levenshtein@~2.0.4: + version "2.0.6" + resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" + integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= + +faye-websocket@0.11.x: + version "0.11.1" + resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.11.1.tgz#f0efe18c4f56e4f40afc7e06c719fd5ee6188f38" + integrity sha1-8O/hjE9W5PQK/H4Gxxn9XuYYjzg= + dependencies: + websocket-driver ">=0.5.1" + +figures@^1.3.5: + version "1.7.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e" + integrity sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4= + dependencies: + escape-string-regexp "^1.0.5" + object-assign "^4.1.0" + +file-entry-cache@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-2.0.0.tgz#c392990c3e684783d838b8c84a45d8a048458361" + integrity sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E= + dependencies: + flat-cache "^1.2.1" + object-assign "^4.0.1" + +filename-reserved-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/filename-reserved-regex/-/filename-reserved-regex-1.0.0.tgz#e61cf805f0de1c984567d0386dc5df50ee5af7e4" + integrity sha1-5hz4BfDeHJhFZ9A4bcXfUO5a9+Q= + +filenamify-url@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/filenamify-url/-/filenamify-url-1.0.0.tgz#b32bd81319ef5863b73078bed50f46a4f7975f50" + integrity sha1-syvYExnvWGO3MHi+1Q9GpPeXX1A= + dependencies: + filenamify "^1.0.0" + humanize-url "^1.0.0" + +filenamify@^1.0.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/filenamify/-/filenamify-1.2.1.tgz#a9f2ffd11c503bed300015029272378f1f1365a5" + integrity sha1-qfL/0RxQO+0wABUCknI3jx8TZaU= + dependencies: + filename-reserved-regex "^1.0.0" + strip-outer "^1.0.0" + trim-repeated "^1.0.0" + +fill-range@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" + integrity sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc= + dependencies: + extend-shallow "^2.0.1" + is-number "^3.0.0" + repeat-string "^1.6.1" + to-regex-range "^2.1.0" + +finalhandler@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.0.tgz#ce0b6855b45853e791b2fcc680046d88253dd7f5" + integrity sha1-zgtoVbRYU+eRsvzGgARtiCU91/U= + dependencies: + debug "2.6.9" + encodeurl "~1.0.1" + escape-html "~1.0.3" + on-finished "~2.3.0" + parseurl "~1.3.2" + statuses "~1.3.1" + unpipe "~1.0.0" + +find-index@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/find-index/-/find-index-0.1.1.tgz#675d358b2ca3892d795a1ab47232f8b6e2e0dde4" + integrity sha1-Z101iyyjiS15Whq0cjL4tuLg3eQ= + +findup-sync@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-2.0.0.tgz#9326b1488c22d1a6088650a86901b2d9a90a2cbc" + integrity sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw= + dependencies: + detect-file "^1.0.0" + is-glob "^3.1.0" + micromatch "^3.0.4" + resolve-dir "^1.0.1" + +fined@^1.0.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/fined/-/fined-1.1.1.tgz#95d88ff329123dd1a6950fdfcd321f746271e01f" + integrity sha512-jQp949ZmEbiYHk3gkbdtpJ0G1+kgtLQBNdP5edFP7Fh+WAYceLQz6yO1SBj72Xkg8GVyTB3bBzAYrHJVh5Xd5g== + dependencies: + expand-tilde "^2.0.2" + is-plain-object "^2.0.3" + object.defaults "^1.1.0" + object.pick "^1.2.0" + parse-filepath "^1.0.1" + +first-chunk-stream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz#59bfb50cd905f60d7c394cd3d9acaab4e6ad934e" + integrity sha1-Wb+1DNkF9g18OUzT2ayqtOatk04= + +flagged-respawn@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/flagged-respawn/-/flagged-respawn-1.0.1.tgz#e7de6f1279ddd9ca9aac8a5971d618606b3aab41" + integrity sha512-lNaHNVymajmk0OJMBn8fVUAU1BtDeKIqKoVhk4xAALB57aALg6b4W0MfJ/cUE0g9YBXy5XhSlPIpYIJ7HaY/3Q== + +flat-cache@^1.2.1: + version "1.3.4" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.3.4.tgz#2c2ef77525cc2929007dfffa1dd314aa9c9dee6f" + integrity sha512-VwyB3Lkgacfik2vhqR4uv2rvebqmDvFu4jlN/C1RzWoJEo8I7z4Q404oiqYCkq41mni8EzQnm95emU9seckwtg== + dependencies: + circular-json "^0.3.1" + graceful-fs "^4.1.2" + rimraf "~2.6.2" + write "^0.2.1" + +for-in@^1.0.1, for-in@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" + integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA= + +for-own@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/for-own/-/for-own-1.0.0.tgz#c63332f415cedc4b04dbfe70cf836494c53cb44b" + integrity sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs= + dependencies: + for-in "^1.0.1" + +fragment-cache@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" + integrity sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk= + dependencies: + map-cache "^0.2.2" + +fresh@0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" + integrity sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac= + +from@~0: + version "0.1.7" + resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe" + integrity sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4= + +fs-extra@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-5.0.0.tgz#414d0110cdd06705734d055652c5411260c31abd" + integrity sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ== + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + +fs-minipass@^1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d" + integrity sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ== + dependencies: + minipass "^2.2.1" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= + +fsevents@^1.2.7: + version "1.2.7" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.7.tgz#4851b664a3783e52003b3c66eb0eee1074933aa4" + integrity sha512-Pxm6sI2MeBD7RdD12RYsqaP0nMiwx8eZBXCa6z2L+mRHm2DYrOYwihmhjpkdjUHwQhslWQjRpEgNq4XvBmaAuw== + dependencies: + nan "^2.9.2" + node-pre-gyp "^0.10.0" + +gauge@~2.7.3: + version "2.7.4" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" + integrity sha1-LANAXHU4w51+s3sxcCLjJfsBi/c= + dependencies: + aproba "^1.0.3" + console-control-strings "^1.0.0" + has-unicode "^2.0.0" + object-assign "^4.1.0" + signal-exit "^3.0.0" + string-width "^1.0.1" + strip-ansi "^3.0.1" + wide-align "^1.1.0" + +gaze@^0.5.1: + version "0.5.2" + resolved "https://registry.yarnpkg.com/gaze/-/gaze-0.5.2.tgz#40b709537d24d1d45767db5a908689dfe69ac44f" + integrity sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8= + dependencies: + globule "~0.1.0" + +generate-function@^2.0.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.3.1.tgz#f069617690c10c868e73b8465746764f97c3479f" + integrity sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ== + dependencies: + is-property "^1.0.2" + +generate-object-property@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/generate-object-property/-/generate-object-property-1.2.0.tgz#9c0e1c40308ce804f4783618b937fa88f99d50d0" + integrity sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA= + dependencies: + is-property "^1.0.0" + +get-value@^2.0.3, get-value@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" + integrity sha1-3BXKHGcjh8p2vTesCjlbogQqLCg= + +gh-pages@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/gh-pages/-/gh-pages-1.2.0.tgz#1acb92801078f7c038a167f447221d1496ccfbee" + integrity sha512-cGLYAvxtlQ1iTwAS4g7FreZPXoE/g62Fsxln2mmR19mgs4zZI+XJ+wVVUhBFCF/0+Nmvbq+abyTWue1m1BSnmg== + dependencies: + async "2.6.1" + commander "2.15.1" + filenamify-url "^1.0.0" + fs-extra "^5.0.0" + globby "^6.1.0" + graceful-fs "4.1.11" + rimraf "^2.6.2" + +glob-parent@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" + integrity sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4= + dependencies: + is-glob "^3.1.0" + path-dirname "^1.0.0" + +glob-stream@^3.1.5: + version "3.1.18" + resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-3.1.18.tgz#9170a5f12b790306fdfe598f313f8f7954fd143b" + integrity sha1-kXCl8St5Awb9/lmPMT+PeVT9FDs= + dependencies: + glob "^4.3.1" + glob2base "^0.0.12" + minimatch "^2.0.1" + ordered-read-streams "^0.1.0" + through2 "^0.6.1" + unique-stream "^1.0.0" + +glob-watcher@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/glob-watcher/-/glob-watcher-0.0.6.tgz#b95b4a8df74b39c83298b0c05c978b4d9a3b710b" + integrity sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs= + dependencies: + gaze "^0.5.1" + +glob2base@^0.0.12: + version "0.0.12" + resolved "https://registry.yarnpkg.com/glob2base/-/glob2base-0.0.12.tgz#9d419b3e28f12e83a362164a277055922c9c0d56" + integrity sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY= + dependencies: + find-index "^0.1.1" + +glob@^4.3.1: + version "4.5.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-4.5.3.tgz#c6cb73d3226c1efef04de3c56d012f03377ee15f" + integrity sha1-xstz0yJsHv7wTePFbQEvAzd+4V8= + dependencies: + inflight "^1.0.4" + inherits "2" + minimatch "^2.0.1" + once "^1.3.0" + +glob@^7.0.0, glob@^7.0.3, glob@^7.0.6, glob@^7.1.3: + version "7.1.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1" + integrity sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@~3.1.21: + version "3.1.21" + resolved "https://registry.yarnpkg.com/glob/-/glob-3.1.21.tgz#d29e0a055dea5138f4d07ed40e8982e83c2066cd" + integrity sha1-0p4KBV3qUTj00H7UDomC6DwgZs0= + dependencies: + graceful-fs "~1.2.0" + inherits "1" + minimatch "~0.2.11" + +global-modules@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/global-modules/-/global-modules-1.0.0.tgz#6d770f0eb523ac78164d72b5e71a8877265cc3ea" + integrity sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg== + dependencies: + global-prefix "^1.0.1" + is-windows "^1.0.1" + resolve-dir "^1.0.0" + +global-prefix@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/global-prefix/-/global-prefix-1.0.2.tgz#dbf743c6c14992593c655568cb66ed32c0122ebe" + integrity sha1-2/dDxsFJklk8ZVVoy2btMsASLr4= + dependencies: + expand-tilde "^2.0.2" + homedir-polyfill "^1.0.1" + ini "^1.3.4" + is-windows "^1.0.1" + which "^1.2.14" + +globals@^9.14.0: + version "9.18.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" + integrity sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ== + +globby@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c" + integrity sha1-9abXDoOV4hyFj7BInWTfAkJNUGw= + dependencies: + array-union "^1.0.1" + glob "^7.0.3" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +globule@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/globule/-/globule-0.1.0.tgz#d9c8edde1da79d125a151b79533b978676346ae5" + integrity sha1-2cjt3h2nnRJaFRt5UzuXhnY0auU= + dependencies: + glob "~3.1.21" + lodash "~1.0.1" + minimatch "~0.2.11" + +glogg@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/glogg/-/glogg-1.0.2.tgz#2d7dd702beda22eb3bffadf880696da6d846313f" + integrity sha512-5mwUoSuBk44Y4EshyiqcH95ZntbDdTQqA3QYSrxmzj28Ai0vXBGMH1ApSANH14j2sIRtqCEyg6PfsuP7ElOEDA== + dependencies: + sparkles "^1.0.0" + +graceful-fs@4.1.11: + version "4.1.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" + integrity sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg= + +graceful-fs@^3.0.0: + version "3.0.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.11.tgz#7613c778a1afea62f25c630a086d7f3acbbdd818" + integrity sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg= + dependencies: + natives "^1.1.0" + +graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: + version "4.1.15" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00" + integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA== + +graceful-fs@~1.2.0: + version "1.2.3" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-1.2.3.tgz#15a4806a57547cb2d2dbf27f42e89a8c3451b364" + integrity sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q= + +gulp-eslint@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/gulp-eslint/-/gulp-eslint-3.0.1.tgz#04e57e3e18c6974267c12cf6855dc717d4a313bd" + integrity sha1-BOV+PhjGl0JnwSz2hV3HF9SjE70= + dependencies: + bufferstreams "^1.1.1" + eslint "^3.0.0" + gulp-util "^3.0.6" + +gulp-jasmine@^2.0.1: + version "2.4.2" + resolved "https://registry.yarnpkg.com/gulp-jasmine/-/gulp-jasmine-2.4.2.tgz#5a7f47e27370c3619ac0a2a442be399671409db3" + integrity sha1-Wn9H4nNww2GawKKkQr45lnFAnbM= + dependencies: + arrify "^1.0.0" + gulp-util "^3.0.0" + jasmine "^2.3.0" + jasmine-terminal-reporter "^1.0.0" + through2 "^2.0.0" + +gulp-util@^3.0.0, gulp-util@^3.0.6: + version "3.0.8" + resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f" + integrity sha1-AFTh50RQLifATBh8PsxQXdVLu08= + dependencies: + array-differ "^1.0.0" + array-uniq "^1.0.2" + beeper "^1.0.0" + chalk "^1.0.0" + dateformat "^2.0.0" + fancy-log "^1.1.0" + gulplog "^1.0.0" + has-gulplog "^0.1.0" + lodash._reescape "^3.0.0" + lodash._reevaluate "^3.0.0" + lodash._reinterpolate "^3.0.0" + lodash.template "^3.0.0" + minimist "^1.1.0" + multipipe "^0.1.2" + object-assign "^3.0.0" + replace-ext "0.0.1" + through2 "^2.0.0" + vinyl "^0.5.0" + +gulp@^3.8.10: + version "3.9.1" + resolved "https://registry.yarnpkg.com/gulp/-/gulp-3.9.1.tgz#571ce45928dd40af6514fc4011866016c13845b4" + integrity sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ= + dependencies: + archy "^1.0.0" + chalk "^1.0.0" + deprecated "^0.0.1" + gulp-util "^3.0.0" + interpret "^1.0.0" + liftoff "^2.1.0" + minimist "^1.1.0" + orchestrator "^0.3.0" + pretty-hrtime "^1.0.0" + semver "^4.1.0" + tildify "^1.0.0" + v8flags "^2.0.2" + vinyl-fs "^0.3.0" + +gulplog@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/gulplog/-/gulplog-1.0.0.tgz#e28c4d45d05ecbbed818363ce8f9c5926229ffe5" + integrity sha1-4oxNRdBey77YGDY86PnFkmIp/+U= + dependencies: + glogg "^1.0.0" + +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + integrity sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE= + dependencies: + ansi-regex "^2.0.0" + +has-gulplog@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/has-gulplog/-/has-gulplog-0.1.0.tgz#6414c82913697da51590397dafb12f22967811ce" + integrity sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4= + dependencies: + sparkles "^1.0.0" + +has-unicode@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" + integrity sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk= + +has-value@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f" + integrity sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8= + dependencies: + get-value "^2.0.3" + has-values "^0.1.4" + isobject "^2.0.0" + +has-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177" + integrity sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc= + dependencies: + get-value "^2.0.6" + has-values "^1.0.0" + isobject "^3.0.0" + +has-values@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771" + integrity sha1-bWHeldkd/Km5oCCJrThL/49it3E= + +has-values@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f" + integrity sha1-lbC2P+whRmGab+V/51Yo1aOe/k8= + dependencies: + is-number "^3.0.0" + kind-of "^4.0.0" + +homedir-polyfill@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8" + integrity sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA== + dependencies: + parse-passwd "^1.0.0" + +http-auth@3.1.x: + version "3.1.3" + resolved "https://registry.yarnpkg.com/http-auth/-/http-auth-3.1.3.tgz#945cfadd66521eaf8f7c84913d377d7b15f24e31" + integrity sha1-lFz63WZSHq+PfISRPTd9exXyTjE= + dependencies: + apache-crypt "^1.1.2" + apache-md5 "^1.0.6" + bcryptjs "^2.3.0" + uuid "^3.0.0" + +http-errors@~1.6.2: + version "1.6.3" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.3.tgz#8b55680bb4be283a0b5bf4ea2e38580be1d9320d" + integrity sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0= + dependencies: + depd "~1.1.2" + inherits "2.0.3" + setprototypeof "1.1.0" + statuses ">= 1.4.0 < 2" + +http-parser-js@>=0.4.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.5.0.tgz#d65edbede84349d0dc30320815a15d39cc3cbbd8" + integrity sha512-cZdEF7r4gfRIq7ezX9J0T+kQmJNOub71dWbgAXVHDct80TKP4MCETtZQ31xyv38UwgzkWPYF/Xc0ge55dW9Z9w== + +humanize-url@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/humanize-url/-/humanize-url-1.0.1.tgz#f4ab99e0d288174ca4e1e50407c55fbae464efff" + integrity sha1-9KuZ4NKIF0yk4eUEB8VfuuRk7/8= + dependencies: + normalize-url "^1.0.0" + strip-url-auth "^1.0.0" + +iconv-lite@^0.4.4: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== + dependencies: + safer-buffer ">= 2.1.2 < 3" + +ignore-walk@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.1.tgz#a83e62e7d272ac0e3b551aaa82831a19b69f82f8" + integrity sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ== + dependencies: + minimatch "^3.0.4" + +ignore@^3.2.0: + version "3.3.10" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043" + integrity sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug== + +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= + +indent-string@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" + integrity sha1-ji1INIdCEhtKghi3oTfppSBJ3IA= + dependencies: + repeating "^2.0.0" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-1.0.2.tgz#ca4309dadee6b54cc0b8d247e8d7c7a0975bdc9b" + integrity sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js= + +inherits@2, inherits@2.0.3, inherits@^2.0.3, inherits@~2.0.1, inherits@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= + +ini@^1.3.4, ini@~1.3.0: + version "1.3.5" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" + integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== + +inquirer@^0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-0.12.0.tgz#1ef2bfd63504df0bc75785fff8c2c41df12f077e" + integrity sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34= + dependencies: + ansi-escapes "^1.1.0" + ansi-regex "^2.0.0" + chalk "^1.0.0" + cli-cursor "^1.0.1" + cli-width "^2.0.0" + figures "^1.3.5" + lodash "^4.3.0" + readline2 "^1.0.1" + run-async "^0.1.0" + rx-lite "^3.1.2" + string-width "^1.0.1" + strip-ansi "^3.0.0" + through "^2.3.6" + +interpret@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.2.0.tgz#d5061a6224be58e8083985f5014d844359576296" + integrity sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw== + +is-absolute@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-absolute/-/is-absolute-1.0.0.tgz#395e1ae84b11f26ad1795e73c17378e48a301576" + integrity sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA== + dependencies: + is-relative "^1.0.0" + is-windows "^1.0.1" + +is-accessor-descriptor@^0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" + integrity sha1-qeEss66Nh2cn7u84Q/igiXtcmNY= + dependencies: + kind-of "^3.0.2" + +is-accessor-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz#169c2f6d3df1f992618072365c9b0ea1f6878656" + integrity sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ== + dependencies: + kind-of "^6.0.0" + +is-binary-path@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" + integrity sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg= + dependencies: + binary-extensions "^1.0.0" + +is-buffer@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" + integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== + +is-data-descriptor@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" + integrity sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y= + dependencies: + kind-of "^3.0.2" + +is-data-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz#d84876321d0e7add03990406abbbbd36ba9268c7" + integrity sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ== + dependencies: + kind-of "^6.0.0" + +is-descriptor@^0.1.0: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca" + integrity sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg== + dependencies: + is-accessor-descriptor "^0.1.6" + is-data-descriptor "^0.1.4" + kind-of "^5.0.0" + +is-descriptor@^1.0.0, is-descriptor@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec" + integrity sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg== + dependencies: + is-accessor-descriptor "^1.0.0" + is-data-descriptor "^1.0.0" + kind-of "^6.0.2" + +is-extendable@^0.1.0, is-extendable@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + integrity sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik= + +is-extendable@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4" + integrity sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA== + dependencies: + is-plain-object "^2.0.4" + +is-extglob@^2.1.0, is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= + +is-finite@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" + integrity sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko= + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + integrity sha1-754xOG8DGn8NZDr4L95QxFfvAMs= + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= + +is-glob@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" + integrity sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo= + dependencies: + is-extglob "^2.1.0" + +is-glob@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.0.tgz#9521c76845cc2610a85203ddf080a958c2ffabc0" + integrity sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A= + dependencies: + is-extglob "^2.1.1" + +is-my-ip-valid@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz#7b351b8e8edd4d3995d4d066680e664d94696824" + integrity sha512-gmh/eWXROncUzRnIa1Ubrt5b8ep/MGSnfAUI3aRp+sqTCs1tv1Isl8d8F6JmkN3dXKc3ehZMrtiPN9eL03NuaQ== + +is-my-json-valid@^2.10.0: + version "2.19.0" + resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.19.0.tgz#8fd6e40363cd06b963fa877d444bfb5eddc62175" + integrity sha512-mG0f/unGX1HZ5ep4uhRaPOS8EkAY8/j6mDRMJrutq4CqhoJWYp7qAlonIPy3TV7p3ju4TK9fo/PbnoksWmsp5Q== + dependencies: + generate-function "^2.0.0" + generate-object-property "^1.1.0" + is-my-ip-valid "^1.0.0" + jsonpointer "^4.0.0" + xtend "^4.0.0" + +is-number@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" + integrity sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU= + dependencies: + kind-of "^3.0.2" + +is-plain-obj@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" + integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4= + +is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" + integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== + dependencies: + isobject "^3.0.1" + +is-property@^1.0.0, is-property@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" + integrity sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ= + +is-relative@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-relative/-/is-relative-1.0.0.tgz#a1bb6935ce8c5dba1e8b9754b9b2dcc020e2260d" + integrity sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA== + dependencies: + is-unc-path "^1.0.0" + +is-resolvable@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.1.0.tgz#fb18f87ce1feb925169c9a407c19318a3206ed88" + integrity sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg== + +is-unc-path@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-unc-path/-/is-unc-path-1.0.0.tgz#d731e8898ed090a12c352ad2eaed5095ad322c9d" + integrity sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ== + dependencies: + unc-path-regex "^0.1.2" + +is-utf8@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI= + +is-windows@^1.0.1, is-windows@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" + integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== + +is-wsl@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d" + integrity sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0= + +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8= + +isarray@1.0.0, isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= + +isobject@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + integrity sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk= + dependencies: + isarray "1.0.0" + +isobject@^3.0.0, isobject@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" + integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= + +jasmine-core@~2.99.0: + version "2.99.1" + resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.99.1.tgz#e6400df1e6b56e130b61c4bcd093daa7f6e8ca15" + integrity sha1-5kAN8ea1bhMLYcS80JPap/boyhU= + +jasmine-terminal-reporter@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/jasmine-terminal-reporter/-/jasmine-terminal-reporter-1.0.3.tgz#896f1ec8fdf4bf6aecdd41c503eda7347f61526b" + integrity sha1-iW8eyP30v2rs3UHFA+2nNH9hUms= + dependencies: + indent-string "^2.1.0" + pluralize "^1.2.1" + +jasmine@^2.3.0: + version "2.99.0" + resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-2.99.0.tgz#8ca72d102e639b867c6489856e0e18a9c7aa42b7" + integrity sha1-jKctEC5jm4Z8ZImFbg4YqceqQrc= + dependencies: + exit "^0.1.2" + glob "^7.0.6" + jasmine-core "~2.99.0" + +js-tokens@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" + integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls= + +js-yaml@^3.5.1: + version "3.13.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.0.tgz#38ee7178ac0eea2c97ff6d96fff4b18c7d8cf98e" + integrity sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +js2xmlparser@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/js2xmlparser/-/js2xmlparser-3.0.0.tgz#3fb60eaa089c5440f9319f51760ccd07e2499733" + integrity sha1-P7YOqgicVED5MZ9RdgzNB+JJlzM= + dependencies: + xmlcreate "^1.0.1" + +jsdoc@3.5.5: + version "3.5.5" + resolved "https://registry.yarnpkg.com/jsdoc/-/jsdoc-3.5.5.tgz#484521b126e81904d632ff83ec9aaa096708fa4d" + integrity sha512-6PxB65TAU4WO0Wzyr/4/YhlGovXl0EVYfpKbpSroSj0qBxT4/xod/l40Opkm38dRHRdQgdeY836M0uVnJQG7kg== + dependencies: + babylon "7.0.0-beta.19" + bluebird "~3.5.0" + catharsis "~0.8.9" + escape-string-regexp "~1.0.5" + js2xmlparser "~3.0.0" + klaw "~2.0.0" + marked "~0.3.6" + mkdirp "~0.5.1" + requizzle "~0.2.1" + strip-json-comments "~2.0.1" + taffydb "2.6.2" + underscore "~1.8.3" + +json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" + integrity sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8= + dependencies: + jsonify "~0.0.0" + +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= + optionalDependencies: + graceful-fs "^4.1.6" + +jsonify@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" + integrity sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM= + +jsonpointer@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" + integrity sha1-T9kss04OnbPInIYi7PUfm5eMbLk= + +kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + integrity sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ= + dependencies: + is-buffer "^1.1.5" + +kind-of@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" + integrity sha1-IIE989cSkosgc3hpGkUGb65y3Vc= + dependencies: + is-buffer "^1.1.5" + +kind-of@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" + integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw== + +kind-of@^6.0.0, kind-of@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051" + integrity sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA== + +klaw@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/klaw/-/klaw-2.0.0.tgz#59c128e0dc5ce410201151194eeb9cbf858650f6" + integrity sha1-WcEo4Nxc5BAgEVEZTuucv4WGUPY= + dependencies: + graceful-fs "^4.1.9" + +levn@^0.3.0, levn@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" + integrity sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4= + dependencies: + prelude-ls "~1.1.2" + type-check "~0.3.2" + +liftoff@^2.1.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/liftoff/-/liftoff-2.5.0.tgz#2009291bb31cea861bbf10a7c15a28caf75c31ec" + integrity sha1-IAkpG7Mc6oYbvxCnwVooyvdcMew= + dependencies: + extend "^3.0.0" + findup-sync "^2.0.0" + fined "^1.0.1" + flagged-respawn "^1.0.0" + is-plain-object "^2.0.4" + object.map "^1.0.0" + rechoir "^0.6.2" + resolve "^1.1.7" + +live-server@^1.2.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/live-server/-/live-server-1.2.1.tgz#670630dd409d22fe9c513ab1c1894686c757153e" + integrity sha512-Yn2XCVjErTkqnM3FfTmM7/kWy3zP7+cEtC7x6u+wUzlQ+1UW3zEYbbyJrc0jNDwiMDZI0m4a0i3dxlGHVyXczw== + dependencies: + chokidar "^2.0.4" + colors latest + connect "^3.6.6" + cors latest + event-stream "3.3.4" + faye-websocket "0.11.x" + http-auth "3.1.x" + morgan "^1.9.1" + object-assign latest + opn latest + proxy-middleware latest + send latest + serve-index "^1.9.1" + +lodash._basecopy@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" + integrity sha1-jaDmqHbPNEwK2KVIghEd08XHyjY= + +lodash._basetostring@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz#d1861d877f824a52f669832dcaf3ee15566a07d5" + integrity sha1-0YYdh3+CSlL2aYMtyvPuFVZqB9U= + +lodash._basevalues@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz#5b775762802bde3d3297503e26300820fdf661b7" + integrity sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc= + +lodash._getnative@^3.0.0: + version "3.9.1" + resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" + integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U= + +lodash._isiterateecall@^3.0.0: + version "3.0.9" + resolved "https://registry.yarnpkg.com/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz#5203ad7ba425fae842460e696db9cf3e6aac057c" + integrity sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw= + +lodash._reescape@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._reescape/-/lodash._reescape-3.0.0.tgz#2b1d6f5dfe07c8a355753e5f27fac7f1cde1616a" + integrity sha1-Kx1vXf4HyKNVdT5fJ/rH8c3hYWo= + +lodash._reevaluate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz#58bc74c40664953ae0b124d806996daca431e2ed" + integrity sha1-WLx0xAZklTrgsSTYBpltrKQx4u0= + +lodash._reinterpolate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" + integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0= + +lodash._root@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692" + integrity sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI= + +lodash.escape@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lodash.escape/-/lodash.escape-3.2.0.tgz#995ee0dc18c1b48cc92effae71a10aab5b487698" + integrity sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg= + dependencies: + lodash._root "^3.0.0" + +lodash.isarguments@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" + integrity sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo= + +lodash.isarray@^3.0.0: + version "3.0.4" + resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" + integrity sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U= + +lodash.keys@^3.0.0: + version "3.1.2" + resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" + integrity sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo= + dependencies: + lodash._getnative "^3.0.0" + lodash.isarguments "^3.0.0" + lodash.isarray "^3.0.0" + +lodash.restparam@^3.0.0: + version "3.6.1" + resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" + integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU= + +lodash.template@^3.0.0: + version "3.6.2" + resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-3.6.2.tgz#f8cdecc6169a255be9098ae8b0c53d378931d14f" + integrity sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8= + dependencies: + lodash._basecopy "^3.0.0" + lodash._basetostring "^3.0.0" + lodash._basevalues "^3.0.0" + lodash._isiterateecall "^3.0.0" + lodash._reinterpolate "^3.0.0" + lodash.escape "^3.0.0" + lodash.keys "^3.0.0" + lodash.restparam "^3.0.0" + lodash.templatesettings "^3.0.0" + +lodash.templatesettings@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz#fb307844753b66b9f1afa54e262c745307dba8e5" + integrity sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU= + dependencies: + lodash._reinterpolate "^3.0.0" + lodash.escape "^3.0.0" + +lodash@^4.0.0, lodash@^4.17.10, lodash@^4.3.0: + version "4.17.11" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" + integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== + +lodash@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-1.0.2.tgz#8f57560c83b59fc270bd3d561b690043430e2551" + integrity sha1-j1dWDIO1n8JwvT1WG2kAQ0MOJVE= + +lru-cache@2: + version "2.7.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952" + integrity sha1-bUUk6LlV+V1PW1iFHOId1y+06VI= + +make-iterator@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/make-iterator/-/make-iterator-1.0.1.tgz#29b33f312aa8f547c4a5e490f56afcec99133ad6" + integrity sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw== + dependencies: + kind-of "^6.0.2" + +map-cache@^0.2.0, map-cache@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" + integrity sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8= + +map-stream@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194" + integrity sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ= + +map-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f" + integrity sha1-7Nyo8TFE5mDxtb1B8S80edmN+48= + dependencies: + object-visit "^1.0.0" + +marked@~0.3.6: + version "0.3.19" + resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.19.tgz#5d47f709c4c9fc3c216b6d46127280f40b39d790" + integrity sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg== + +micromatch@^3.0.4, micromatch@^3.1.10, micromatch@^3.1.4: + version "3.1.10" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" + integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + braces "^2.3.1" + define-property "^2.0.2" + extend-shallow "^3.0.2" + extglob "^2.0.4" + fragment-cache "^0.2.1" + kind-of "^6.0.2" + nanomatch "^1.2.9" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.2" + +mime-db@~1.38.0: + version "1.38.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.38.0.tgz#1a2aab16da9eb167b49c6e4df2d9c68d63d8e2ad" + integrity sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg== + +mime-types@~2.1.17, mime-types@~2.1.18: + version "2.1.22" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.22.tgz#fe6b355a190926ab7698c9a0556a11199b2199bd" + integrity sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog== + dependencies: + mime-db "~1.38.0" + +mime@1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6" + integrity sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ== + +minimatch@^2.0.1: + version "2.0.10" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-2.0.10.tgz#8d087c39c6b38c001b97fca7ce6d0e1e80afbac7" + integrity sha1-jQh8OcazjAAbl/ynzm0OHoCvusc= + dependencies: + brace-expansion "^1.0.0" + +minimatch@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== + dependencies: + brace-expansion "^1.1.7" + +minimatch@~0.2.11: + version "0.2.14" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.2.14.tgz#c74e780574f63c6f9a090e90efbe6ef53a6a756a" + integrity sha1-x054BXT2PG+aCQ6Q775u9TpqdWo= + dependencies: + lru-cache "2" + sigmund "~1.0.0" + +minimist@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0= + +minimist@^1.1.0, minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= + +minipass@^2.2.1, minipass@^2.3.4: + version "2.3.5" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.3.5.tgz#cacebe492022497f656b0f0f51e2682a9ed2d848" + integrity sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA== + dependencies: + safe-buffer "^5.1.2" + yallist "^3.0.0" + +minizlib@^1.1.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.2.1.tgz#dd27ea6136243c7c880684e8672bb3a45fd9b614" + integrity sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA== + dependencies: + minipass "^2.2.1" + +mixin-deep@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe" + integrity sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ== + dependencies: + for-in "^1.0.2" + is-extendable "^1.0.1" + +mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM= + dependencies: + minimist "0.0.8" + +morgan@^1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/morgan/-/morgan-1.9.1.tgz#0a8d16734a1d9afbc824b99df87e738e58e2da59" + integrity sha512-HQStPIV4y3afTiCYVxirakhlCfGkI161c76kKFca7Fk1JusM//Qeo1ej2XaMniiNeaZklMVrh3vTtIzpzwbpmA== + dependencies: + basic-auth "~2.0.0" + debug "2.6.9" + depd "~1.1.2" + on-finished "~2.3.0" + on-headers "~1.0.1" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= + +multipipe@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/multipipe/-/multipipe-0.1.2.tgz#2a8f2ddf70eed564dff2d57f1e1a137d9f05078b" + integrity sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s= + dependencies: + duplexer2 "0.0.2" + +mute-stream@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.5.tgz#8fbfabb0a98a253d3184331f9e8deb7372fac6c0" + integrity sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA= + +nan@^2.9.2: + version "2.13.2" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.13.2.tgz#f51dc7ae66ba7d5d55e1e6d4d8092e802c9aefe7" + integrity sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw== + +nanomatch@^1.2.9: + version "1.2.13" + resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" + integrity sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + define-property "^2.0.2" + extend-shallow "^3.0.2" + fragment-cache "^0.2.1" + is-windows "^1.0.2" + kind-of "^6.0.2" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +natives@^1.1.0: + version "1.1.6" + resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.6.tgz#a603b4a498ab77173612b9ea1acdec4d980f00bb" + integrity sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA== + +natural-compare@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" + integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= + +needle@^2.2.1: + version "2.2.4" + resolved "https://registry.yarnpkg.com/needle/-/needle-2.2.4.tgz#51931bff82533b1928b7d1d69e01f1b00ffd2a4e" + integrity sha512-HyoqEb4wr/rsoaIDfTH2aVL9nWtQqba2/HvMv+++m8u0dz808MaagKILxtfeSN7QU7nvbQ79zk3vYOJp9zsNEA== + dependencies: + debug "^2.1.2" + iconv-lite "^0.4.4" + sax "^1.2.4" + +negotiator@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" + integrity sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk= + +next-tick@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" + integrity sha1-yobR/ogoFpsBICCOPchCS524NCw= + +node-pre-gyp@^0.10.0: + version "0.10.3" + resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.10.3.tgz#3070040716afdc778747b61b6887bf78880b80fc" + integrity sha512-d1xFs+C/IPS8Id0qPTZ4bUT8wWryfR/OzzAFxweG+uLN85oPzyo2Iw6bVlLQ/JOdgNonXLCoRyqDzDWq4iw72A== + dependencies: + detect-libc "^1.0.2" + mkdirp "^0.5.1" + needle "^2.2.1" + nopt "^4.0.1" + npm-packlist "^1.1.6" + npmlog "^4.0.2" + rc "^1.2.7" + rimraf "^2.6.1" + semver "^5.3.0" + tar "^4" + +nopt@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d" + integrity sha1-0NRoWv1UFRk8jHUFYC0NF81kR00= + dependencies: + abbrev "1" + osenv "^0.1.4" + +normalize-path@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" + integrity sha1-GrKLVW4Zg2Oowab35vogE3/mrtk= + dependencies: + remove-trailing-separator "^1.0.1" + +normalize-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +normalize-url@^1.0.0: + version "1.9.1" + resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-1.9.1.tgz#2cc0d66b31ea23036458436e3620d85954c66c3c" + integrity sha1-LMDWazHqIwNkWENuNiDYWVTGbDw= + dependencies: + object-assign "^4.0.1" + prepend-http "^1.0.0" + query-string "^4.1.0" + sort-keys "^1.0.0" + +npm-bundled@^1.0.1: + version "1.0.6" + resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.0.6.tgz#e7ba9aadcef962bb61248f91721cd932b3fe6bdd" + integrity sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g== + +npm-packlist@^1.1.6: + version "1.4.1" + resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.4.1.tgz#19064cdf988da80ea3cee45533879d90192bbfbc" + integrity sha512-+TcdO7HJJ8peiiYhvPxsEDhF3PJFGUGRcFsGve3vxvxdcpO2Z4Z7rkosRM0kWj6LfbK/P0gu3dzk5RU1ffvFcw== + dependencies: + ignore-walk "^3.0.1" + npm-bundled "^1.0.1" + +npmlog@^4.0.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" + integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg== + dependencies: + are-we-there-yet "~1.1.2" + console-control-strings "~1.1.0" + gauge "~2.7.3" + set-blocking "~2.0.0" + +number-is-nan@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= + +object-assign@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-3.0.0.tgz#9bedd5ca0897949bca47e7ff408062d549f587f2" + integrity sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I= + +object-assign@^4, object-assign@^4.0.1, object-assign@^4.1.0, object-assign@latest: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= + +object-copy@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c" + integrity sha1-fn2Fi3gb18mRpBupde04EnVOmYw= + dependencies: + copy-descriptor "^0.1.0" + define-property "^0.2.5" + kind-of "^3.0.3" + +object-visit@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" + integrity sha1-95xEk68MU3e1n+OdOV5BBC3QRbs= + dependencies: + isobject "^3.0.0" + +object.defaults@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/object.defaults/-/object.defaults-1.1.0.tgz#3a7f868334b407dea06da16d88d5cd29e435fecf" + integrity sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8= + dependencies: + array-each "^1.0.1" + array-slice "^1.0.0" + for-own "^1.0.0" + isobject "^3.0.0" + +object.map@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/object.map/-/object.map-1.0.1.tgz#cf83e59dc8fcc0ad5f4250e1f78b3b81bd801d37" + integrity sha1-z4Plncj8wK1fQlDh94s7gb2AHTc= + dependencies: + for-own "^1.0.0" + make-iterator "^1.0.0" + +object.pick@^1.2.0, object.pick@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" + integrity sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c= + dependencies: + isobject "^3.0.1" + +on-finished@~2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" + integrity sha1-IPEzZIGwg811M3mSoWlxqi2QaUc= + dependencies: + ee-first "1.1.1" + +on-headers@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/on-headers/-/on-headers-1.0.2.tgz#772b0ae6aaa525c399e489adfad90c403eb3c28f" + integrity sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA== + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= + dependencies: + wrappy "1" + +once@~1.3.0: + version "1.3.3" + resolved "https://registry.yarnpkg.com/once/-/once-1.3.3.tgz#b2e261557ce4c314ec8304f3fa82663e4297ca20" + integrity sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA= + dependencies: + wrappy "1" + +onetime@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789" + integrity sha1-ofeDj4MUxRbwXs78vEzP4EtO14k= + +opn@latest: + version "5.5.0" + resolved "https://registry.yarnpkg.com/opn/-/opn-5.5.0.tgz#fc7164fab56d235904c51c3b27da6758ca3b9bfc" + integrity sha512-PqHpggC9bLV0VeWcdKhkpxY+3JTzetLSqTCWL/z/tFIbI6G8JCjondXklT1JinczLz2Xib62sSp0T/gKT4KksA== + dependencies: + is-wsl "^1.1.0" + +optionator@^0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" + integrity sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q= + dependencies: + deep-is "~0.1.3" + fast-levenshtein "~2.0.4" + levn "~0.3.0" + prelude-ls "~1.1.2" + type-check "~0.3.2" + wordwrap "~1.0.0" + +orchestrator@^0.3.0: + version "0.3.8" + resolved "https://registry.yarnpkg.com/orchestrator/-/orchestrator-0.3.8.tgz#14e7e9e2764f7315fbac184e506c7aa6df94ad7e" + integrity sha1-FOfp4nZPcxX7rBhOUGx6pt+UrX4= + dependencies: + end-of-stream "~0.1.5" + sequencify "~0.0.7" + stream-consume "~0.1.0" + +ordered-read-streams@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz#fd565a9af8eb4473ba69b6ed8a34352cb552f126" + integrity sha1-/VZamvjrRHO6abbtijQ1LLVS8SY= + +os-homedir@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= + +os-tmpdir@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= + +osenv@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.5.tgz#85cdfafaeb28e8677f416e287592b5f3f49ea410" + integrity sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g== + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.0" + +parse-filepath@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/parse-filepath/-/parse-filepath-1.0.2.tgz#a632127f53aaf3d15876f5872f3ffac763d6c891" + integrity sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE= + dependencies: + is-absolute "^1.0.0" + map-cache "^0.2.0" + path-root "^0.1.1" + +parse-node-version@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/parse-node-version/-/parse-node-version-1.0.1.tgz#e2b5dbede00e7fa9bc363607f53327e8b073189b" + integrity sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA== + +parse-passwd@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6" + integrity sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY= + +parseurl@~1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3" + integrity sha1-/CidTtiZMRlGDBViUyYs3I3mW/M= + +pascalcase@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" + integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ= + +path-dirname@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" + integrity sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA= + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= + +path-is-inside@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" + integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM= + +path-parse@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" + integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== + +path-root-regex@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/path-root-regex/-/path-root-regex-0.1.2.tgz#bfccdc8df5b12dc52c8b43ec38d18d72c04ba96d" + integrity sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0= + +path-root@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/path-root/-/path-root-0.1.1.tgz#9a4a6814cac1c0cd73360a95f32083c8ea4745b7" + integrity sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc= + dependencies: + path-root-regex "^0.1.0" + +pause-stream@0.0.11: + version "0.0.11" + resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445" + integrity sha1-/lo0sMvOErWqaitAPuLnO2AvFEU= + dependencies: + through "~2.3" + +pify@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" + integrity sha1-7RQaasBDqEnqWISY59yosVMw6Qw= + +pinkie-promise@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" + integrity sha1-ITXW36ejWMBprJsXh3YogihFD/o= + dependencies: + pinkie "^2.0.0" + +pinkie@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" + integrity sha1-clVrgM+g1IqXToDnckjoDtT3+HA= + +pluralize@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-1.2.1.tgz#d1a21483fd22bb41e58a12fa3421823140897c45" + integrity sha1-0aIUg/0iu0HlihL6NCGCMUCJfEU= + +posix-character-classes@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" + integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= + +prelude-ls@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" + integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= + +prepend-http@^1.0.0: + version "1.0.4" + resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" + integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw= + +pretty-hrtime@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" + integrity sha1-t+PqQkNaTJsnWdmeDyAesZWALuE= + +process-nextick-args@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" + integrity sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw== + +progress@^1.1.8: + version "1.1.8" + resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" + integrity sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74= + +proxy-middleware@latest: + version "0.15.0" + resolved "https://registry.yarnpkg.com/proxy-middleware/-/proxy-middleware-0.15.0.tgz#a3fdf1befb730f951965872ac2f6074c61477a56" + integrity sha1-o/3xvvtzD5UZZYcqwvYHTGFHelY= + +query-string@^4.1.0: + version "4.3.4" + resolved "https://registry.yarnpkg.com/query-string/-/query-string-4.3.4.tgz#bbb693b9ca915c232515b228b1a02b609043dbeb" + integrity sha1-u7aTucqRXCMlFbIosaArYJBD2+s= + dependencies: + object-assign "^4.1.0" + strict-uri-encode "^1.0.0" + +range-parser@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" + integrity sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4= + +rc@^1.2.7: + version "1.2.8" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" + integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== + dependencies: + deep-extend "^0.6.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + +"readable-stream@>=1.0.33-1 <1.1.0-0": + version "1.0.34" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" + integrity sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw= + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.2.2, readable-stream@~2.3.6: + version "2.3.6" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" + integrity sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + +readable-stream@~1.1.9: + version "1.1.14" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" + integrity sha1-fPTFTvZI44EwhMY23SB54WbAgdk= + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readdirp@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.2.1.tgz#0e87622a3325aa33e892285caf8b4e846529a525" + integrity sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ== + dependencies: + graceful-fs "^4.1.11" + micromatch "^3.1.10" + readable-stream "^2.0.2" + +readline2@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/readline2/-/readline2-1.0.1.tgz#41059608ffc154757b715d9989d199ffbf372e35" + integrity sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU= + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + mute-stream "0.0.5" + +rechoir@^0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" + integrity sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q= + dependencies: + resolve "^1.1.6" + +regex-not@^1.0.0, regex-not@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" + integrity sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A== + dependencies: + extend-shallow "^3.0.2" + safe-regex "^1.1.0" + +remove-trailing-separator@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" + integrity sha1-wkvOKig62tW8P1jg1IJJuSN52O8= + +repeat-element@^1.1.2: + version "1.1.3" + resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.3.tgz#782e0d825c0c5a3bb39731f84efee6b742e6b1ce" + integrity sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g== + +repeat-string@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc= + +repeating@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + integrity sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo= + dependencies: + is-finite "^1.0.0" + +replace-ext@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-0.0.1.tgz#29bbd92078a739f0bcce2b4ee41e837953522924" + integrity sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ= + +require-uncached@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3" + integrity sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM= + dependencies: + caller-path "^0.1.0" + resolve-from "^1.0.0" + +requizzle@~0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/requizzle/-/requizzle-0.2.1.tgz#6943c3530c4d9a7e46f1cddd51c158fc670cdbde" + integrity sha1-aUPDUwxNmn5G8c3dUcFY/GcM294= + dependencies: + underscore "~1.6.0" + +resolve-dir@^1.0.0, resolve-dir@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/resolve-dir/-/resolve-dir-1.0.1.tgz#79a40644c362be82f26effe739c9bb5382046f43" + integrity sha1-eaQGRMNivoLybv/nOcm7U4IEb0M= + dependencies: + expand-tilde "^2.0.0" + global-modules "^1.0.0" + +resolve-from@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" + integrity sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY= + +resolve-url@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" + integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= + +resolve@^1.1.6, resolve@^1.1.7: + version "1.10.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.10.0.tgz#3bdaaeaf45cc07f375656dfd2e54ed0810b101ba" + integrity sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg== + dependencies: + path-parse "^1.0.6" + +restore-cursor@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" + integrity sha1-NGYfRohjJ/7SmRR5FSJS35LapUE= + dependencies: + exit-hook "^1.0.0" + onetime "^1.0.0" + +ret@~0.1.10: + version "0.1.15" + resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" + integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== + +rimraf@^2.6.1, rimraf@^2.6.2, rimraf@~2.6.2: + version "2.6.3" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" + integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== + dependencies: + glob "^7.1.3" + +run-async@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-0.1.0.tgz#c8ad4a5e110661e402a7d21b530e009f25f8e389" + integrity sha1-yK1KXhEGYeQCp9IbUw4AnyX444k= + dependencies: + once "^1.3.0" + +rx-lite@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-3.1.2.tgz#19ce502ca572665f3b647b10939f97fd1615f102" + integrity sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI= + +safe-buffer@5.1.2, safe-buffer@^5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + +safe-regex@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" + integrity sha1-QKNmnzsHfR6UPURinhV91IAjvy4= + dependencies: + ret "~0.1.10" + +"safer-buffer@>= 2.1.2 < 3": + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== + +sax@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" + integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== + +semver@^4.1.0: + version "4.3.6" + resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da" + integrity sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto= + +semver@^5.3.0: + version "5.6.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" + integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg== + +send@latest: + version "0.16.2" + resolved "https://registry.yarnpkg.com/send/-/send-0.16.2.tgz#6ecca1e0f8c156d141597559848df64730a6bbc1" + integrity sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw== + dependencies: + debug "2.6.9" + depd "~1.1.2" + destroy "~1.0.4" + encodeurl "~1.0.2" + escape-html "~1.0.3" + etag "~1.8.1" + fresh "0.5.2" + http-errors "~1.6.2" + mime "1.4.1" + ms "2.0.0" + on-finished "~2.3.0" + range-parser "~1.2.0" + statuses "~1.4.0" + +sequencify@~0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/sequencify/-/sequencify-0.0.7.tgz#90cff19d02e07027fd767f5ead3e7b95d1e7380c" + integrity sha1-kM/xnQLgcCf9dn9erT57ldHnOAw= + +serve-index@^1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/serve-index/-/serve-index-1.9.1.tgz#d3768d69b1e7d82e5ce050fff5b453bea12a9239" + integrity sha1-03aNabHn2C5c4FD/9bRTvqEqkjk= + dependencies: + accepts "~1.3.4" + batch "0.6.1" + debug "2.6.9" + escape-html "~1.0.3" + http-errors "~1.6.2" + mime-types "~2.1.17" + parseurl "~1.3.2" + +set-blocking@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= + +set-value@^0.4.3: + version "0.4.3" + resolved "https://registry.yarnpkg.com/set-value/-/set-value-0.4.3.tgz#7db08f9d3d22dc7f78e53af3c3bf4666ecdfccf1" + integrity sha1-fbCPnT0i3H945Trzw79GZuzfzPE= + dependencies: + extend-shallow "^2.0.1" + is-extendable "^0.1.1" + is-plain-object "^2.0.1" + to-object-path "^0.3.0" + +set-value@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.0.tgz#71ae4a88f0feefbbf52d1ea604f3fb315ebb6274" + integrity sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg== + dependencies: + extend-shallow "^2.0.1" + is-extendable "^0.1.1" + is-plain-object "^2.0.3" + split-string "^3.0.1" + +setprototypeof@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" + integrity sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ== + +shelljs@^0.7.5: + version "0.7.8" + resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.8.tgz#decbcf874b0d1e5fb72e14b164a9683048e9acb3" + integrity sha1-3svPh0sNHl+3LhSxZKloMEjprLM= + dependencies: + glob "^7.0.0" + interpret "^1.0.0" + rechoir "^0.6.2" + +sigmund@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590" + integrity sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA= + +signal-exit@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" + integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= + +slice-ansi@0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35" + integrity sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU= + +snapdragon-node@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" + integrity sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw== + dependencies: + define-property "^1.0.0" + isobject "^3.0.0" + snapdragon-util "^3.0.1" + +snapdragon-util@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/snapdragon-util/-/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2" + integrity sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ== + dependencies: + kind-of "^3.2.0" + +snapdragon@^0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/snapdragon/-/snapdragon-0.8.2.tgz#64922e7c565b0e14204ba1aa7d6964278d25182d" + integrity sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg== + dependencies: + base "^0.11.1" + debug "^2.2.0" + define-property "^0.2.5" + extend-shallow "^2.0.1" + map-cache "^0.2.2" + source-map "^0.5.6" + source-map-resolve "^0.5.0" + use "^3.1.0" + +sort-keys@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-1.1.2.tgz#441b6d4d346798f1b4e49e8920adfba0e543f9ad" + integrity sha1-RBttTTRnmPG05J6JIK37oOVD+a0= + dependencies: + is-plain-obj "^1.0.0" + +source-map-resolve@^0.5.0: + version "0.5.2" + resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.2.tgz#72e2cc34095543e43b2c62b2c4c10d4a9054f259" + integrity sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA== + dependencies: + atob "^2.1.1" + decode-uri-component "^0.2.0" + resolve-url "^0.2.1" + source-map-url "^0.4.0" + urix "^0.1.0" + +source-map-url@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" + integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM= + +source-map@^0.5.6: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= + +sparkles@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.1.tgz#008db65edce6c50eec0c5e228e1945061dd0437c" + integrity sha512-dSO0DDYUahUt/0/pD/Is3VIm5TGJjludZ0HVymmhYF6eNA53PVLhnUk0znSYbH8IYBuJdCE+1luR22jNLMaQdw== + +split-string@^3.0.1, split-string@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" + integrity sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw== + dependencies: + extend-shallow "^3.0.0" + +split@0.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/split/-/split-0.3.3.tgz#cd0eea5e63a211dfff7eb0f091c4133e2d0dd28f" + integrity sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8= + dependencies: + through "2" + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= + +static-extend@^0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" + integrity sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY= + dependencies: + define-property "^0.2.5" + object-copy "^0.1.0" + +"statuses@>= 1.4.0 < 2": + version "1.5.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" + integrity sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow= + +statuses@~1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" + integrity sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4= + +statuses@~1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087" + integrity sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew== + +stream-combiner@~0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/stream-combiner/-/stream-combiner-0.0.4.tgz#4d5e433c185261dde623ca3f44c586bcf5c4ad14" + integrity sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ= + dependencies: + duplexer "~0.1.1" + +stream-consume@~0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/stream-consume/-/stream-consume-0.1.1.tgz#d3bdb598c2bd0ae82b8cac7ac50b1107a7996c48" + integrity sha512-tNa3hzgkjEP7XbCkbRXe1jpg+ievoa0O4SCFlMOYEscGSS4JJsckGL8swUyAa/ApGU3Ae4t6Honor4HhL+tRyg== + +strict-uri-encode@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713" + integrity sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM= + +string-width@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + integrity sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M= + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + strip-ansi "^3.0.0" + +"string-width@^1.0.2 || 2", string-width@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" + integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^4.0.0" + +string_decoder@~0.10.x: + version "0.10.31" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + integrity sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ= + +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== + dependencies: + safe-buffer "~5.1.0" + +strip-ansi@^3.0.0, strip-ansi@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8= + dependencies: + ansi-regex "^2.0.0" + +strip-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" + integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8= + dependencies: + ansi-regex "^3.0.0" + +strip-bom@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-1.0.0.tgz#85b8862f3844b5a6d5ec8467a93598173a36f794" + integrity sha1-hbiGLzhEtabV7IRnqTWYFzo295Q= + dependencies: + first-chunk-stream "^1.0.0" + is-utf8 "^0.2.0" + +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + integrity sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= + +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= + +strip-outer@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/strip-outer/-/strip-outer-1.0.1.tgz#b2fd2abf6604b9d1e6013057195df836b8a9d631" + integrity sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg== + dependencies: + escape-string-regexp "^1.0.2" + +strip-url-auth@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/strip-url-auth/-/strip-url-auth-1.0.1.tgz#22b0fa3a41385b33be3f331551bbb837fa0cd7ae" + integrity sha1-IrD6OkE4WzO+PzMVUbu4N/oM164= + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc= + +table@^3.7.8: + version "3.8.3" + resolved "https://registry.yarnpkg.com/table/-/table-3.8.3.tgz#2bbc542f0fda9861a755d3947fefd8b3f513855f" + integrity sha1-K7xULw/amGGnVdOUf+/Ys/UThV8= + dependencies: + ajv "^4.7.0" + ajv-keywords "^1.0.0" + chalk "^1.1.1" + lodash "^4.0.0" + slice-ansi "0.0.4" + string-width "^2.0.0" + +taffydb@2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/taffydb/-/taffydb-2.6.2.tgz#7cbcb64b5a141b6a2efc2c5d2c67b4e150b2a268" + integrity sha1-fLy2S1oUG2ou/CxdLGe04VCyomg= + +tar@^4: + version "4.4.8" + resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.8.tgz#b19eec3fde2a96e64666df9fdb40c5ca1bc3747d" + integrity sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ== + dependencies: + chownr "^1.1.1" + fs-minipass "^1.2.5" + minipass "^2.3.4" + minizlib "^1.1.1" + mkdirp "^0.5.0" + safe-buffer "^5.1.2" + yallist "^3.0.2" + +text-table@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" + integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= + +through2@^0.6.1: + version "0.6.5" + resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48" + integrity sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg= + dependencies: + readable-stream ">=1.0.33-1 <1.1.0-0" + xtend ">=4.0.0 <4.1.0-0" + +through2@^2.0.0: + version "2.0.5" + resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd" + integrity sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ== + dependencies: + readable-stream "~2.3.6" + xtend "~4.0.1" + +through@2, through@^2.3.6, through@~2.3, through@~2.3.1: + version "2.3.8" + resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= + +tildify@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/tildify/-/tildify-1.2.0.tgz#dcec03f55dca9b7aa3e5b04f21817eb56e63588a" + integrity sha1-3OwD9V3Km3qj5bBPIYF+tW5jWIo= + dependencies: + os-homedir "^1.0.0" + +time-stamp@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/time-stamp/-/time-stamp-1.1.0.tgz#764a5a11af50561921b133f3b44e618687e0f5c3" + integrity sha1-dkpaEa9QVhkhsTPztE5hhofg9cM= + +to-object-path@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" + integrity sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68= + dependencies: + kind-of "^3.0.2" + +to-regex-range@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38" + integrity sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg= + dependencies: + is-number "^3.0.0" + repeat-string "^1.6.1" + +to-regex@^3.0.1, to-regex@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce" + integrity sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw== + dependencies: + define-property "^2.0.2" + extend-shallow "^3.0.2" + regex-not "^1.0.2" + safe-regex "^1.1.0" + +trim-repeated@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/trim-repeated/-/trim-repeated-1.0.0.tgz#e3646a2ea4e891312bf7eace6cfb05380bc01c21" + integrity sha1-42RqLqTokTEr9+rObPsFOAvAHCE= + dependencies: + escape-string-regexp "^1.0.2" + +type-check@~0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" + integrity sha1-WITKtRLPHTVeP7eE8wgEsrUg23I= + dependencies: + prelude-ls "~1.1.2" + +typedarray@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" + integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= + +unc-path-regex@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa" + integrity sha1-5z3T17DXxe2G+6xrCufYxqadUPo= + +underscore-contrib@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/underscore-contrib/-/underscore-contrib-0.3.0.tgz#665b66c24783f8fa2b18c9f8cbb0e2c7d48c26c7" + integrity sha1-ZltmwkeD+PorGMn4y7Dix9SMJsc= + dependencies: + underscore "1.6.0" + +underscore@1.6.0, underscore@~1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.6.0.tgz#8b38b10cacdef63337b8b24e4ff86d45aea529a8" + integrity sha1-izixDKze9jM3uLJOT/htRa6lKag= + +underscore@~1.8.3: + version "1.8.3" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" + integrity sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI= + +union-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4" + integrity sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ= + dependencies: + arr-union "^3.1.0" + get-value "^2.0.6" + is-extendable "^0.1.1" + set-value "^0.4.3" + +unique-stream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-1.0.0.tgz#d59a4a75427447d9aa6c91e70263f8d26a4b104b" + integrity sha1-1ZpKdUJ0R9mqbJHnAmP40mpLEEs= + +universalify@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" + integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== + +unix-crypt-td-js@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unix-crypt-td-js/-/unix-crypt-td-js-1.0.0.tgz#1c0824150481bc7a01d49e98f1ec668d82412f3b" + integrity sha1-HAgkFQSBvHoB1J6Y8exmjYJBLzs= + +unpipe@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw= + +unset-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" + integrity sha1-g3aHP30jNRef+x5vw6jtDfyKtVk= + dependencies: + has-value "^0.3.1" + isobject "^3.0.0" + +upath@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/upath/-/upath-1.1.2.tgz#3db658600edaeeccbe6db5e684d67ee8c2acd068" + integrity sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q== + +urix@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" + integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI= + +use@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" + integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== + +user-home@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" + integrity sha1-K1viOjK2Onyd640PKNSFcko98ZA= + +user-home@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/user-home/-/user-home-2.0.0.tgz#9c70bfd8169bc1dcbf48604e0f04b8b49cde9e9f" + integrity sha1-nHC/2Babwdy/SGBODwS4tJzenp8= + dependencies: + os-homedir "^1.0.0" + +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= + +utils-merge@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" + integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= + +uuid@^3.0.0: + version "3.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" + integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA== + +v8flags@^2.0.2: + version "2.1.1" + resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" + integrity sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ= + dependencies: + user-home "^1.1.1" + +vary@^1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" + integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw= + +vinyl-fs@^0.3.0: + version "0.3.14" + resolved "https://registry.yarnpkg.com/vinyl-fs/-/vinyl-fs-0.3.14.tgz#9a6851ce1cac1c1cea5fe86c0931d620c2cfa9e6" + integrity sha1-mmhRzhysHBzqX+hsCTHWIMLPqeY= + dependencies: + defaults "^1.0.0" + glob-stream "^3.1.5" + glob-watcher "^0.0.6" + graceful-fs "^3.0.0" + mkdirp "^0.5.0" + strip-bom "^1.0.0" + through2 "^0.6.1" + vinyl "^0.4.0" + +vinyl@^0.4.0: + version "0.4.6" + resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-0.4.6.tgz#2f356c87a550a255461f36bbeb2a5ba8bf784847" + integrity sha1-LzVsh6VQolVGHza76ypbqL94SEc= + dependencies: + clone "^0.2.0" + clone-stats "^0.0.1" + +vinyl@^0.5.0: + version "0.5.3" + resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-0.5.3.tgz#b0455b38fc5e0cf30d4325132e461970c2091cde" + integrity sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4= + dependencies: + clone "^1.0.0" + clone-stats "^0.0.1" + replace-ext "0.0.1" + +websocket-driver@>=0.5.1: + version "0.7.0" + resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.0.tgz#0caf9d2d755d93aee049d4bdd0d3fe2cca2a24eb" + integrity sha1-DK+dLXVdk67gSdS90NP+LMoqJOs= + dependencies: + http-parser-js ">=0.4.0" + websocket-extensions ">=0.1.1" + +websocket-extensions@>=0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.3.tgz#5d2ff22977003ec687a4b87073dfbbac146ccf29" + integrity sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg== + +which@^1.2.14: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== + dependencies: + isexe "^2.0.0" + +wide-align@^1.1.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" + integrity sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== + dependencies: + string-width "^1.0.2 || 2" + +wordwrap@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" + integrity sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus= + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= + +write@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/write/-/write-0.2.1.tgz#5fc03828e264cea3fe91455476f7a3c566cb0757" + integrity sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c= + dependencies: + mkdirp "^0.5.1" + +xmlcreate@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/xmlcreate/-/xmlcreate-1.0.2.tgz#fa6bf762a60a413fb3dd8f4b03c5b269238d308f" + integrity sha1-+mv3YqYKQT+z3Y9LA8WyaSONMI8= + +"xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@~4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" + integrity sha1-pcbVMr5lbiPbgg77lDofBJmNY68= + +yallist@^3.0.0, yallist@^3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9" + integrity sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A== From 4ad78b3951a1279c740979963a4b020872578860 Mon Sep 17 00:00:00 2001 From: mgechev Date: Sun, 24 Mar 2019 21:12:21 -0700 Subject: [PATCH 577/613] refactor: improve Graham implementation --- src/graphics/graham.js | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/graphics/graham.js b/src/graphics/graham.js index bab1889a..019fd239 100644 --- a/src/graphics/graham.js +++ b/src/graphics/graham.js @@ -9,10 +9,8 @@ const sa = slope(p, a); const sb = slope(p, b); [[sa, a], [sb, b]].forEach(e => { - if (!memo.has(e[0])) { - memo.set(e[0], new Set()); - } - memo.get(e[0]).add(e[1]); + const el = memo.get(e[0]); + if (!el || dist(p, el) < dist(p, e[1])) memo.set(e[0], e[1]); }); return sa - sb; }; @@ -50,21 +48,19 @@ if (a.x < c.x) return a; return c; }); - const memo = new Map(); - const points = all.sort(sort.bind(null, p, memo)).filter(c => { - const s = slope(p, c); - // Liner check, can consider more efficient data structure - const set = Array.from(memo.get(s)); - return !set.some(e => dist(p, e) > dist(p, c)); - }); + const memo = new Map(); const stack = []; - points.forEach(p => { - while (stack.length > 1 && ccw(stack[stack.length - 2], stack[stack.length - 1], p) < 0) { - stack.pop(); - } - stack.push(p); - }); + + all + .sort(sort.bind(null, p, memo)) + .filter(c => memo.get(slope(p, c)) === c) + .forEach(p => { + while (stack.length > 1 && ccw(stack[stack.length - 2], stack[stack.length - 1], p) < 0) + stack.pop(); + stack.push(p); + }); + return stack; }; From 5f81b4a3578713187d734c83378c0de10cf94e62 Mon Sep 17 00:00:00 2001 From: Dmitry Fisenko Date: Sun, 30 Jun 2019 19:30:32 -0400 Subject: [PATCH 578/613] Fix spelling (#154) Fix eslint errors Remove duplicates in eslintrc --- .eslintrc.json | 16 +- package-lock.json | 4774 ++++++++++++++++++++ src/combinatorics/variations-repetition.js | 6 +- src/compression/runlength/runlength.js | 2 +- src/graphics/graham.js | 23 +- src/others/min-coins-change.js | 2 +- src/searching/recursive-binarysearch.js | 2 +- src/sorting/quicksort-middle.js | 2 +- src/sorting/quicksort.js | 2 +- test/graphics/grapham.spec.js | 2 +- 10 files changed, 4803 insertions(+), 28 deletions(-) create mode 100644 package-lock.json diff --git a/.eslintrc.json b/.eslintrc.json index 0c7a9c7b..82ecf768 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -2,7 +2,8 @@ "env": { "browser": true, "jquery": true, - "node": true + "node": true, + "es6": true }, "globals": { "expect": true, @@ -15,9 +16,7 @@ "ecmaVersion": 6 }, "rules": { - "camelcase": 2, - "curly": 2, "eqeqeq": 2, "indent": [ 2, @@ -72,8 +71,6 @@ 2, 5 ], - - "curly": [ 2, "all" @@ -132,13 +129,6 @@ } ], "eol-last": 2, - "no-trailing-spaces": 2, - "indent": [ - 2, - 2, - { - "SwitchCase": 1 - } - ] + "no-trailing-spaces": 2 } } diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..7474ed1c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,4774 @@ +{ + "name": "javascript-algorithms", + "version": "0.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@jeremyckahn/minami": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@jeremyckahn/minami/-/minami-1.3.1.tgz", + "integrity": "sha512-jeOFPfq3zLxnQ0dhlhrZd5J0qZDdF1wkrNlr6ErVaGtjPTq9gn/NIK0GDOmGcAJgN/6yKwRdMxPy33u12lQWiQ==", + "dev": true + }, + "accepts": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "dev": true, + "requires": { + "mime-types": "~2.1.24", + "negotiator": "0.6.2" + } + }, + "acorn": { + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", + "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==", + "dev": true + }, + "acorn-jsx": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", + "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", + "dev": true, + "requires": { + "acorn": "^3.0.4" + }, + "dependencies": { + "acorn": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", + "dev": true + } + } + }, + "ajv": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", + "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", + "dev": true, + "requires": { + "co": "^4.6.0", + "json-stable-stringify": "^1.0.1" + } + }, + "ajv-keywords": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz", + "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=", + "dev": true + }, + "ansi-escapes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", + "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", + "dev": true + }, + "ansi-gray": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ansi-gray/-/ansi-gray-0.1.1.tgz", + "integrity": "sha1-KWLPVOyXksSFEKPetSRDaGHvclE=", + "dev": true, + "requires": { + "ansi-wrap": "0.1.0" + } + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "ansi-wrap": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz", + "integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=", + "dev": true + }, + "anymatch": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", + "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "dev": true, + "requires": { + "micromatch": "^3.1.4", + "normalize-path": "^2.1.1" + }, + "dependencies": { + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + } + } + }, + "apache-crypt": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/apache-crypt/-/apache-crypt-1.2.1.tgz", + "integrity": "sha1-1vxyqm0n2ZyVqU/RiNcx7v/6Zjw=", + "dev": true, + "requires": { + "unix-crypt-td-js": "^1.0.0" + } + }, + "apache-md5": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/apache-md5/-/apache-md5-1.1.2.tgz", + "integrity": "sha1-7klza2ObTxCLbp5ibG2pkwa0FpI=", + "dev": true + }, + "archy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", + "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", + "dev": true + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true + }, + "arr-flatten": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", + "dev": true + }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", + "dev": true + }, + "array-differ": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", + "integrity": "sha1-7/UuN1gknTO+QCuLuOVkuytdQDE=", + "dev": true + }, + "array-each": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/array-each/-/array-each-1.0.1.tgz", + "integrity": "sha1-p5SvDAWrF1KEbudTofIRoFugxE8=", + "dev": true + }, + "array-slice": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-1.1.0.tgz", + "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==", + "dev": true + }, + "array-union": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", + "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "dev": true, + "requires": { + "array-uniq": "^1.0.1" + } + }, + "array-uniq": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "dev": true + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", + "dev": true + }, + "assign-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", + "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "dev": true + }, + "async": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", + "integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==", + "dev": true, + "requires": { + "lodash": "^4.17.10" + } + }, + "async-each": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", + "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", + "dev": true + }, + "atob": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", + "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", + "dev": true + }, + "babel-code-frame": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "dev": true, + "requires": { + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" + } + }, + "babylon": { + "version": "7.0.0-beta.19", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.19.tgz", + "integrity": "sha512-Vg0C9s/REX6/WIXN37UKpv5ZhRi6A4pjHlpkE34+8/a6c2W1Q692n3hmc+SZG5lKRnaExLUbxtJ1SVT+KaCQ/A==", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "base": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", + "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", + "dev": true, + "requires": { + "cache-base": "^1.0.1", + "class-utils": "^0.3.5", + "component-emitter": "^1.2.1", + "define-property": "^1.0.0", + "isobject": "^3.0.1", + "mixin-deep": "^1.2.0", + "pascalcase": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "basic-auth": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", + "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", + "dev": true, + "requires": { + "safe-buffer": "5.1.2" + } + }, + "batch": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", + "integrity": "sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY=", + "dev": true + }, + "bcryptjs": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", + "integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=", + "dev": true + }, + "beeper": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/beeper/-/beeper-1.1.1.tgz", + "integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=", + "dev": true + }, + "binary-extensions": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", + "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", + "dev": true + }, + "bluebird": { + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz", + "integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, + "bufferstreams": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/bufferstreams/-/bufferstreams-1.1.3.tgz", + "integrity": "sha512-HaJnVuslRF4g2kSDeyl++AaVizoitCpL9PglzCYwy0uHHyvWerfvEb8jWmYbF1z4kiVFolGomnxSGl+GUQp2jg==", + "dev": true, + "requires": { + "readable-stream": "^2.0.2" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "cache-base": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", + "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", + "dev": true, + "requires": { + "collection-visit": "^1.0.0", + "component-emitter": "^1.2.1", + "get-value": "^2.0.6", + "has-value": "^1.0.0", + "isobject": "^3.0.1", + "set-value": "^2.0.0", + "to-object-path": "^0.3.0", + "union-value": "^1.0.0", + "unset-value": "^1.0.0" + } + }, + "caller-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", + "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", + "dev": true, + "requires": { + "callsites": "^0.2.0" + } + }, + "callsites": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", + "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", + "dev": true + }, + "catharsis": { + "version": "0.8.10", + "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.10.tgz", + "integrity": "sha512-l2OUaz/3PU3MZylspVFJvwHCVfWyvcduPq4lv3AzZ2pJzZCo7kNKFNyatwujD7XgvGkNAE/Jhhbh2uARNwNkfw==", + "dev": true, + "requires": { + "lodash": "^4.17.11" + } + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "chokidar": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.6.tgz", + "integrity": "sha512-V2jUo67OKkc6ySiRpJrjlpJKl9kDuG+Xb8VgsGzb+aEouhgS1D0weyPU4lEzdAcsCAvrih2J2BqyXqHWvVLw5g==", + "dev": true, + "requires": { + "anymatch": "^2.0.0", + "async-each": "^1.0.1", + "braces": "^2.3.2", + "fsevents": "^1.2.7", + "glob-parent": "^3.1.0", + "inherits": "^2.0.3", + "is-binary-path": "^1.0.0", + "is-glob": "^4.0.0", + "normalize-path": "^3.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.2.1", + "upath": "^1.1.1" + }, + "dependencies": { + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + } + } + }, + "circular-json": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", + "dev": true + }, + "class-utils": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", + "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "define-property": "^0.2.5", + "isobject": "^3.0.0", + "static-extend": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "cli-cursor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", + "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", + "dev": true, + "requires": { + "restore-cursor": "^1.0.1" + } + }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "dev": true + }, + "clone": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", + "dev": true + }, + "clone-stats": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", + "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=", + "dev": true + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "dev": true + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true + }, + "collection-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", + "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", + "dev": true, + "requires": { + "map-visit": "^1.0.0", + "object-visit": "^1.0.0" + } + }, + "color-support": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", + "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", + "dev": true + }, + "colors": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz", + "integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==", + "dev": true + }, + "commander": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, + "component-emitter": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "connect": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/connect/-/connect-3.7.0.tgz", + "integrity": "sha512-ZqRXc+tZukToSNmh5C2iWMSoV3X1YUcPbqEM4DkEG5tNQXrQUZCNVGGv3IuicnkMtPfGf3Xtp8WCXs295iQ1pQ==", + "dev": true, + "requires": { + "debug": "2.6.9", + "finalhandler": "1.1.2", + "parseurl": "~1.3.3", + "utils-merge": "1.0.1" + } + }, + "copy-descriptor": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", + "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "dev": true, + "requires": { + "object-assign": "^4", + "vary": "^1" + } + }, + "d": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "dev": true, + "requires": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, + "dateformat": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.2.0.tgz", + "integrity": "sha1-QGXiATz5+5Ft39gu+1Bq1MZ2kGI=", + "dev": true + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "decode-uri-component": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", + "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", + "dev": true + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, + "defaults": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", + "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", + "dev": true, + "requires": { + "clone": "^1.0.2" + } + }, + "define-property": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", + "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", + "dev": true, + "requires": { + "is-descriptor": "^1.0.2", + "isobject": "^3.0.1" + }, + "dependencies": { + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "dev": true + }, + "deprecated": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/deprecated/-/deprecated-0.0.1.tgz", + "integrity": "sha1-+cmvVGSvoeepcUWKi97yqpTVuxk=", + "dev": true + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", + "dev": true + }, + "detect-file": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", + "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", + "dev": true + }, + "doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, + "duplexer": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", + "dev": true + }, + "duplexer2": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", + "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", + "dev": true, + "requires": { + "readable-stream": "~1.1.9" + } + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", + "dev": true + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", + "dev": true + }, + "end-of-stream": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-0.1.5.tgz", + "integrity": "sha1-jhdyBsPICDfYVjLouTWd/osvbq8=", + "dev": true, + "requires": { + "once": "~1.3.0" + }, + "dependencies": { + "once": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", + "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", + "dev": true, + "requires": { + "wrappy": "1" + } + } + } + }, + "es5-ext": { + "version": "0.10.50", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.50.tgz", + "integrity": "sha512-KMzZTPBkeQV/JcSQhI5/z6d9VWJ3EnQ194USTUwIYZ2ZbpN8+SGXQKt1h68EX44+qt+Fzr8DO17vnxrw7c3agw==", + "dev": true, + "requires": { + "es6-iterator": "~2.0.3", + "es6-symbol": "~3.1.1", + "next-tick": "^1.0.0" + } + }, + "es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", + "dev": true, + "requires": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, + "es6-map": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/es6-map/-/es6-map-0.1.5.tgz", + "integrity": "sha1-kTbgUD3MBqMBaQ8LsU/042TpSfA=", + "dev": true, + "requires": { + "d": "1", + "es5-ext": "~0.10.14", + "es6-iterator": "~2.0.1", + "es6-set": "~0.1.5", + "es6-symbol": "~3.1.1", + "event-emitter": "~0.3.5" + } + }, + "es6-set": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", + "integrity": "sha1-0rPsXU2ADO2BjbU40ol02wpzzLE=", + "dev": true, + "requires": { + "d": "1", + "es5-ext": "~0.10.14", + "es6-iterator": "~2.0.1", + "es6-symbol": "3.1.1", + "event-emitter": "~0.3.5" + } + }, + "es6-symbol": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", + "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", + "dev": true, + "requires": { + "d": "1", + "es5-ext": "~0.10.14" + } + }, + "es6-weak-map": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz", + "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", + "dev": true, + "requires": { + "d": "1", + "es5-ext": "^0.10.46", + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.1" + } + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "escope": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/escope/-/escope-3.6.0.tgz", + "integrity": "sha1-4Bl16BJ4GhY6ba392AOY3GTIicM=", + "dev": true, + "requires": { + "es6-map": "^0.1.3", + "es6-weak-map": "^2.0.1", + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "eslint": { + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-3.19.0.tgz", + "integrity": "sha1-yPxiAcf0DdCJQbh8CFdnOGpnmsw=", + "dev": true, + "requires": { + "babel-code-frame": "^6.16.0", + "chalk": "^1.1.3", + "concat-stream": "^1.5.2", + "debug": "^2.1.1", + "doctrine": "^2.0.0", + "escope": "^3.6.0", + "espree": "^3.4.0", + "esquery": "^1.0.0", + "estraverse": "^4.2.0", + "esutils": "^2.0.2", + "file-entry-cache": "^2.0.0", + "glob": "^7.0.3", + "globals": "^9.14.0", + "ignore": "^3.2.0", + "imurmurhash": "^0.1.4", + "inquirer": "^0.12.0", + "is-my-json-valid": "^2.10.0", + "is-resolvable": "^1.0.0", + "js-yaml": "^3.5.1", + "json-stable-stringify": "^1.0.0", + "levn": "^0.3.0", + "lodash": "^4.0.0", + "mkdirp": "^0.5.0", + "natural-compare": "^1.4.0", + "optionator": "^0.8.2", + "path-is-inside": "^1.0.1", + "pluralize": "^1.2.1", + "progress": "^1.1.8", + "require-uncached": "^1.0.2", + "shelljs": "^0.7.5", + "strip-bom": "^3.0.0", + "strip-json-comments": "~2.0.1", + "table": "^3.7.8", + "text-table": "~0.2.0", + "user-home": "^2.0.0" + }, + "dependencies": { + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, + "user-home": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", + "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=", + "dev": true, + "requires": { + "os-homedir": "^1.0.0" + } + } + } + }, + "espree": { + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", + "dev": true, + "requires": { + "acorn": "^5.5.0", + "acorn-jsx": "^3.0.0" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "esquery": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", + "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "dev": true, + "requires": { + "estraverse": "^4.0.0" + } + }, + "esrecurse": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "dev": true, + "requires": { + "estraverse": "^4.1.0" + } + }, + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", + "dev": true + }, + "event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", + "dev": true, + "requires": { + "d": "1", + "es5-ext": "~0.10.14" + } + }, + "event-stream": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", + "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", + "dev": true, + "requires": { + "duplexer": "~0.1.1", + "from": "~0", + "map-stream": "~0.1.0", + "pause-stream": "0.0.11", + "split": "0.3", + "stream-combiner": "~0.0.4", + "through": "~2.3.1" + } + }, + "exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", + "dev": true + }, + "exit-hook": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz", + "integrity": "sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=", + "dev": true + }, + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "dev": true, + "requires": { + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "expand-tilde": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", + "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", + "dev": true, + "requires": { + "homedir-polyfill": "^1.0.1" + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "extglob": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", + "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", + "dev": true, + "requires": { + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "fancy-log": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.3.tgz", + "integrity": "sha512-k9oEhlyc0FrVh25qYuSELjr8oxsCoc4/LEZfg2iJJrfEk/tZL9bCoJE47gqAvI2m/AUjluCS4+3I0eTx8n3AEw==", + "dev": true, + "requires": { + "ansi-gray": "^0.1.1", + "color-support": "^1.1.3", + "parse-node-version": "^1.0.0", + "time-stamp": "^1.0.0" + } + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "faye-websocket": { + "version": "0.11.3", + "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.3.tgz", + "integrity": "sha512-D2y4bovYpzziGgbHYtGCMjlJM36vAl/y+xUyn1C+FVx8szd1E+86KwVw6XvYSzOP8iMpm1X0I4xJD+QtUb36OA==", + "dev": true, + "requires": { + "websocket-driver": ">=0.5.1" + } + }, + "figures": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", + "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5", + "object-assign": "^4.1.0" + } + }, + "file-entry-cache": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", + "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "dev": true, + "requires": { + "flat-cache": "^1.2.1", + "object-assign": "^4.0.1" + } + }, + "filename-reserved-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/filename-reserved-regex/-/filename-reserved-regex-1.0.0.tgz", + "integrity": "sha1-5hz4BfDeHJhFZ9A4bcXfUO5a9+Q=", + "dev": true + }, + "filenamify": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/filenamify/-/filenamify-1.2.1.tgz", + "integrity": "sha1-qfL/0RxQO+0wABUCknI3jx8TZaU=", + "dev": true, + "requires": { + "filename-reserved-regex": "^1.0.0", + "strip-outer": "^1.0.0", + "trim-repeated": "^1.0.0" + } + }, + "filenamify-url": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/filenamify-url/-/filenamify-url-1.0.0.tgz", + "integrity": "sha1-syvYExnvWGO3MHi+1Q9GpPeXX1A=", + "dev": true, + "requires": { + "filenamify": "^1.0.0", + "humanize-url": "^1.0.0" + } + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "finalhandler": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "dev": true, + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", + "unpipe": "~1.0.0" + } + }, + "find-index": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/find-index/-/find-index-0.1.1.tgz", + "integrity": "sha1-Z101iyyjiS15Whq0cjL4tuLg3eQ=", + "dev": true + }, + "findup-sync": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-2.0.0.tgz", + "integrity": "sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw=", + "dev": true, + "requires": { + "detect-file": "^1.0.0", + "is-glob": "^3.1.0", + "micromatch": "^3.0.4", + "resolve-dir": "^1.0.1" + } + }, + "fined": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fined/-/fined-1.2.0.tgz", + "integrity": "sha512-ZYDqPLGxDkDhDZBjZBb+oD1+j0rA4E0pXY50eplAAOPg2N/gUBSSk5IM1/QhPfyVo19lJ+CvXpqfvk+b2p/8Ng==", + "dev": true, + "requires": { + "expand-tilde": "^2.0.2", + "is-plain-object": "^2.0.3", + "object.defaults": "^1.1.0", + "object.pick": "^1.2.0", + "parse-filepath": "^1.0.1" + } + }, + "first-chunk-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz", + "integrity": "sha1-Wb+1DNkF9g18OUzT2ayqtOatk04=", + "dev": true + }, + "flagged-respawn": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz", + "integrity": "sha512-lNaHNVymajmk0OJMBn8fVUAU1BtDeKIqKoVhk4xAALB57aALg6b4W0MfJ/cUE0g9YBXy5XhSlPIpYIJ7HaY/3Q==", + "dev": true + }, + "flat-cache": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.4.tgz", + "integrity": "sha512-VwyB3Lkgacfik2vhqR4uv2rvebqmDvFu4jlN/C1RzWoJEo8I7z4Q404oiqYCkq41mni8EzQnm95emU9seckwtg==", + "dev": true, + "requires": { + "circular-json": "^0.3.1", + "graceful-fs": "^4.1.2", + "rimraf": "~2.6.2", + "write": "^0.2.1" + } + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "dev": true + }, + "for-own": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz", + "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", + "dev": true, + "requires": { + "for-in": "^1.0.1" + } + }, + "fragment-cache": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", + "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", + "dev": true, + "requires": { + "map-cache": "^0.2.2" + } + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", + "dev": true + }, + "from": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", + "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", + "dev": true + }, + "fs-extra": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz", + "integrity": "sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "fsevents": { + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.9.tgz", + "integrity": "sha512-oeyj2H3EjjonWcFjD5NvZNE9Rqe4UW+nQBU2HNeKw0koVLEFIhtyETyAakeAM3de7Z/SW5kcA+fZUait9EApnw==", + "dev": true, + "optional": true, + "requires": { + "nan": "^2.12.1", + "node-pre-gyp": "^0.12.0" + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "aproba": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "balanced-match": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "brace-expansion": { + "version": "1.1.11", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "chownr": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true + }, + "concat-map": { + "version": "0.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "debug": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ms": "^2.1.1" + } + }, + "deep-extend": { + "version": "0.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "detect-libc": { + "version": "1.0.3", + "bundled": true, + "dev": true, + "optional": true + }, + "fs-minipass": { + "version": "1.2.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "glob": { + "version": "7.1.3", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "iconv-lite": { + "version": "0.4.24", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore-walk": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minimatch": "^3.0.4" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true, + "dev": true, + "optional": true + }, + "ini": { + "version": "1.3.5", + "bundled": true, + "dev": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "isarray": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true, + "dev": true, + "optional": true + }, + "minipass": { + "version": "2.3.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.2.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "needle": { + "version": "2.3.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "debug": "^4.1.0", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + } + }, + "node-pre-gyp": { + "version": "0.12.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.1", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.2.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + }, + "npm-bundled": { + "version": "1.0.6", + "bundled": true, + "dev": true, + "optional": true + }, + "npm-packlist": { + "version": "1.4.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" + } + }, + "npmlog": { + "version": "4.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "wrappy": "1" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "osenv": { + "version": "0.1.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "process-nextick-args": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "rc": { + "version": "1.2.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "readable-stream": { + "version": "2.3.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "rimraf": { + "version": "2.6.3", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "glob": "^7.1.3" + } + }, + "safe-buffer": { + "version": "5.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "safer-buffer": { + "version": "2.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "sax": { + "version": "1.2.4", + "bundled": true, + "dev": true, + "optional": true + }, + "semver": { + "version": "5.7.0", + "bundled": true, + "dev": true, + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "tar": { + "version": "4.4.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.3.4", + "minizlib": "^1.1.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.2" + } + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "wide-align": { + "version": "1.1.3", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "yallist": { + "version": "3.0.3", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "gaze": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz", + "integrity": "sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8=", + "dev": true, + "requires": { + "globule": "~0.1.0" + } + }, + "generate-function": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz", + "integrity": "sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==", + "dev": true, + "requires": { + "is-property": "^1.0.2" + } + }, + "generate-object-property": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", + "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", + "dev": true, + "requires": { + "is-property": "^1.0.0" + } + }, + "get-value": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", + "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", + "dev": true + }, + "gh-pages": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gh-pages/-/gh-pages-1.2.0.tgz", + "integrity": "sha512-cGLYAvxtlQ1iTwAS4g7FreZPXoE/g62Fsxln2mmR19mgs4zZI+XJ+wVVUhBFCF/0+Nmvbq+abyTWue1m1BSnmg==", + "dev": true, + "requires": { + "async": "2.6.1", + "commander": "2.15.1", + "filenamify-url": "^1.0.0", + "fs-extra": "^5.0.0", + "globby": "^6.1.0", + "graceful-fs": "4.1.11", + "rimraf": "^2.6.2" + } + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-parent": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", + "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "dev": true, + "requires": { + "is-glob": "^3.1.0", + "path-dirname": "^1.0.0" + } + }, + "glob-stream": { + "version": "3.1.18", + "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-3.1.18.tgz", + "integrity": "sha1-kXCl8St5Awb9/lmPMT+PeVT9FDs=", + "dev": true, + "requires": { + "glob": "^4.3.1", + "glob2base": "^0.0.12", + "minimatch": "^2.0.1", + "ordered-read-streams": "^0.1.0", + "through2": "^0.6.1", + "unique-stream": "^1.0.0" + }, + "dependencies": { + "glob": { + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", + "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", + "dev": true, + "requires": { + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^2.0.1", + "once": "^1.3.0" + } + }, + "minimatch": { + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", + "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", + "dev": true, + "requires": { + "brace-expansion": "^1.0.0" + } + }, + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "through2": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "dev": true, + "requires": { + "readable-stream": ">=1.0.33-1 <1.1.0-0", + "xtend": ">=4.0.0 <4.1.0-0" + } + } + } + }, + "glob-watcher": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.6.tgz", + "integrity": "sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs=", + "dev": true, + "requires": { + "gaze": "^0.5.1" + } + }, + "glob2base": { + "version": "0.0.12", + "resolved": "https://registry.npmjs.org/glob2base/-/glob2base-0.0.12.tgz", + "integrity": "sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY=", + "dev": true, + "requires": { + "find-index": "^0.1.1" + } + }, + "global-modules": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", + "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", + "dev": true, + "requires": { + "global-prefix": "^1.0.1", + "is-windows": "^1.0.1", + "resolve-dir": "^1.0.0" + } + }, + "global-prefix": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", + "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", + "dev": true, + "requires": { + "expand-tilde": "^2.0.2", + "homedir-polyfill": "^1.0.1", + "ini": "^1.3.4", + "is-windows": "^1.0.1", + "which": "^1.2.14" + } + }, + "globals": { + "version": "9.18.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", + "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==", + "dev": true + }, + "globby": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", + "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", + "dev": true, + "requires": { + "array-union": "^1.0.1", + "glob": "^7.0.3", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "globule": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/globule/-/globule-0.1.0.tgz", + "integrity": "sha1-2cjt3h2nnRJaFRt5UzuXhnY0auU=", + "dev": true, + "requires": { + "glob": "~3.1.21", + "lodash": "~1.0.1", + "minimatch": "~0.2.11" + }, + "dependencies": { + "glob": { + "version": "3.1.21", + "resolved": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz", + "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", + "dev": true, + "requires": { + "graceful-fs": "~1.2.0", + "inherits": "1", + "minimatch": "~0.2.11" + } + }, + "graceful-fs": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz", + "integrity": "sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=", + "dev": true + }, + "inherits": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-1.0.2.tgz", + "integrity": "sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js=", + "dev": true + }, + "lodash": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-1.0.2.tgz", + "integrity": "sha1-j1dWDIO1n8JwvT1WG2kAQ0MOJVE=", + "dev": true + }, + "minimatch": { + "version": "0.2.14", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", + "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", + "dev": true, + "requires": { + "lru-cache": "2", + "sigmund": "~1.0.0" + } + } + } + }, + "glogg": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.2.tgz", + "integrity": "sha512-5mwUoSuBk44Y4EshyiqcH95ZntbDdTQqA3QYSrxmzj28Ai0vXBGMH1ApSANH14j2sIRtqCEyg6PfsuP7ElOEDA==", + "dev": true, + "requires": { + "sparkles": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "gulp": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/gulp/-/gulp-3.9.1.tgz", + "integrity": "sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ=", + "dev": true, + "requires": { + "archy": "^1.0.0", + "chalk": "^1.0.0", + "deprecated": "^0.0.1", + "gulp-util": "^3.0.0", + "interpret": "^1.0.0", + "liftoff": "^2.1.0", + "minimist": "^1.1.0", + "orchestrator": "^0.3.0", + "pretty-hrtime": "^1.0.0", + "semver": "^4.1.0", + "tildify": "^1.0.0", + "v8flags": "^2.0.2", + "vinyl-fs": "^0.3.0" + } + }, + "gulp-eslint": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/gulp-eslint/-/gulp-eslint-3.0.1.tgz", + "integrity": "sha1-BOV+PhjGl0JnwSz2hV3HF9SjE70=", + "dev": true, + "requires": { + "bufferstreams": "^1.1.1", + "eslint": "^3.0.0", + "gulp-util": "^3.0.6" + } + }, + "gulp-jasmine": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/gulp-jasmine/-/gulp-jasmine-2.4.2.tgz", + "integrity": "sha1-Wn9H4nNww2GawKKkQr45lnFAnbM=", + "dev": true, + "requires": { + "arrify": "^1.0.0", + "gulp-util": "^3.0.0", + "jasmine": "^2.3.0", + "jasmine-terminal-reporter": "^1.0.0", + "through2": "^2.0.0" + } + }, + "gulp-util": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", + "dev": true, + "requires": { + "array-differ": "^1.0.0", + "array-uniq": "^1.0.2", + "beeper": "^1.0.0", + "chalk": "^1.0.0", + "dateformat": "^2.0.0", + "fancy-log": "^1.1.0", + "gulplog": "^1.0.0", + "has-gulplog": "^0.1.0", + "lodash._reescape": "^3.0.0", + "lodash._reevaluate": "^3.0.0", + "lodash._reinterpolate": "^3.0.0", + "lodash.template": "^3.0.0", + "minimist": "^1.1.0", + "multipipe": "^0.1.2", + "object-assign": "^3.0.0", + "replace-ext": "0.0.1", + "through2": "^2.0.0", + "vinyl": "^0.5.0" + }, + "dependencies": { + "object-assign": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", + "integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=", + "dev": true + } + } + }, + "gulplog": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz", + "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=", + "dev": true, + "requires": { + "glogg": "^1.0.0" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "has-gulplog": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz", + "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=", + "dev": true, + "requires": { + "sparkles": "^1.0.0" + } + }, + "has-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", + "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", + "dev": true, + "requires": { + "get-value": "^2.0.6", + "has-values": "^1.0.0", + "isobject": "^3.0.0" + } + }, + "has-values": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", + "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "kind-of": "^4.0.0" + }, + "dependencies": { + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "homedir-polyfill": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", + "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", + "dev": true, + "requires": { + "parse-passwd": "^1.0.0" + } + }, + "http-auth": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/http-auth/-/http-auth-3.1.3.tgz", + "integrity": "sha1-lFz63WZSHq+PfISRPTd9exXyTjE=", + "dev": true, + "requires": { + "apache-crypt": "^1.1.2", + "apache-md5": "^1.0.6", + "bcryptjs": "^2.3.0", + "uuid": "^3.0.0" + } + }, + "http-errors": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.3.tgz", + "integrity": "sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==", + "dev": true, + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "http-parser-js": { + "version": "0.4.10", + "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.4.10.tgz", + "integrity": "sha1-ksnBN0w1CF912zWexWzCV8u5P6Q=", + "dev": true + }, + "humanize-url": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/humanize-url/-/humanize-url-1.0.1.tgz", + "integrity": "sha1-9KuZ4NKIF0yk4eUEB8VfuuRk7/8=", + "dev": true, + "requires": { + "normalize-url": "^1.0.0", + "strip-url-auth": "^1.0.0" + } + }, + "ignore": { + "version": "3.3.10", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", + "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", + "dev": true + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "indent-string": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", + "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", + "dev": true, + "requires": { + "repeating": "^2.0.0" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", + "dev": true + }, + "inquirer": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz", + "integrity": "sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=", + "dev": true, + "requires": { + "ansi-escapes": "^1.1.0", + "ansi-regex": "^2.0.0", + "chalk": "^1.0.0", + "cli-cursor": "^1.0.1", + "cli-width": "^2.0.0", + "figures": "^1.3.5", + "lodash": "^4.3.0", + "readline2": "^1.0.1", + "run-async": "^0.1.0", + "rx-lite": "^3.1.2", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.0", + "through": "^2.3.6" + } + }, + "interpret": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.2.0.tgz", + "integrity": "sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw==", + "dev": true + }, + "is-absolute": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz", + "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", + "dev": true, + "requires": { + "is-relative": "^1.0.0", + "is-windows": "^1.0.1" + } + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-binary-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "dev": true, + "requires": { + "binary-extensions": "^1.0.0" + } + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "dev": true + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-finite": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", + "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "dev": true, + "requires": { + "is-extglob": "^2.1.0" + } + }, + "is-my-ip-valid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz", + "integrity": "sha512-gmh/eWXROncUzRnIa1Ubrt5b8ep/MGSnfAUI3aRp+sqTCs1tv1Isl8d8F6JmkN3dXKc3ehZMrtiPN9eL03NuaQ==", + "dev": true + }, + "is-my-json-valid": { + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.20.0.tgz", + "integrity": "sha512-XTHBZSIIxNsIsZXg7XB5l8z/OBFosl1Wao4tXLpeC7eKU4Vm/kdop2azkPqULwnfGQjmeDIyey9g7afMMtdWAA==", + "dev": true, + "requires": { + "generate-function": "^2.0.0", + "generate-object-property": "^1.1.0", + "is-my-ip-valid": "^1.0.0", + "jsonpointer": "^4.0.0", + "xtend": "^4.0.0" + } + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", + "dev": true + }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "is-property": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", + "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", + "dev": true + }, + "is-relative": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-1.0.0.tgz", + "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", + "dev": true, + "requires": { + "is-unc-path": "^1.0.0" + } + }, + "is-resolvable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", + "dev": true + }, + "is-unc-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-1.0.0.tgz", + "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", + "dev": true, + "requires": { + "unc-path-regex": "^0.1.2" + } + }, + "is-utf8": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", + "dev": true + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true + }, + "is-wsl": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", + "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=", + "dev": true + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "jasmine": { + "version": "2.99.0", + "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-2.99.0.tgz", + "integrity": "sha1-jKctEC5jm4Z8ZImFbg4YqceqQrc=", + "dev": true, + "requires": { + "exit": "^0.1.2", + "glob": "^7.0.6", + "jasmine-core": "~2.99.0" + } + }, + "jasmine-core": { + "version": "2.99.1", + "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.99.1.tgz", + "integrity": "sha1-5kAN8ea1bhMLYcS80JPap/boyhU=", + "dev": true + }, + "jasmine-terminal-reporter": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/jasmine-terminal-reporter/-/jasmine-terminal-reporter-1.0.3.tgz", + "integrity": "sha1-iW8eyP30v2rs3UHFA+2nNH9hUms=", + "dev": true, + "requires": { + "indent-string": "^2.1.0", + "pluralize": "^1.2.1" + } + }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "dev": true + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "js2xmlparser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-3.0.0.tgz", + "integrity": "sha1-P7YOqgicVED5MZ9RdgzNB+JJlzM=", + "dev": true, + "requires": { + "xmlcreate": "^1.0.1" + } + }, + "jsdoc": { + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.5.5.tgz", + "integrity": "sha512-6PxB65TAU4WO0Wzyr/4/YhlGovXl0EVYfpKbpSroSj0qBxT4/xod/l40Opkm38dRHRdQgdeY836M0uVnJQG7kg==", + "dev": true, + "requires": { + "babylon": "7.0.0-beta.19", + "bluebird": "~3.5.0", + "catharsis": "~0.8.9", + "escape-string-regexp": "~1.0.5", + "js2xmlparser": "~3.0.0", + "klaw": "~2.0.0", + "marked": "~0.3.6", + "mkdirp": "~0.5.1", + "requizzle": "~0.2.1", + "strip-json-comments": "~2.0.1", + "taffydb": "2.6.2", + "underscore": "~1.8.3" + } + }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dev": true, + "requires": { + "jsonify": "~0.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "dev": true + }, + "jsonpointer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", + "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", + "dev": true + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + }, + "klaw": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/klaw/-/klaw-2.0.0.tgz", + "integrity": "sha1-WcEo4Nxc5BAgEVEZTuucv4WGUPY=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.9" + } + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "liftoff": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-2.5.0.tgz", + "integrity": "sha1-IAkpG7Mc6oYbvxCnwVooyvdcMew=", + "dev": true, + "requires": { + "extend": "^3.0.0", + "findup-sync": "^2.0.0", + "fined": "^1.0.1", + "flagged-respawn": "^1.0.0", + "is-plain-object": "^2.0.4", + "object.map": "^1.0.0", + "rechoir": "^0.6.2", + "resolve": "^1.1.7" + } + }, + "live-server": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/live-server/-/live-server-1.2.1.tgz", + "integrity": "sha512-Yn2XCVjErTkqnM3FfTmM7/kWy3zP7+cEtC7x6u+wUzlQ+1UW3zEYbbyJrc0jNDwiMDZI0m4a0i3dxlGHVyXczw==", + "dev": true, + "requires": { + "chokidar": "^2.0.4", + "colors": "^1.3.3", + "connect": "^3.6.6", + "cors": "^2.8.5", + "event-stream": "3.3.4", + "faye-websocket": "0.11.x", + "http-auth": "3.1.x", + "morgan": "^1.9.1", + "object-assign": "^4.1.1", + "opn": "^6.0.0", + "proxy-middleware": "^0.15.0", + "send": "^0.17.1", + "serve-index": "^1.9.1" + }, + "dependencies": { + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + } + } + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "dev": true + }, + "lodash._basecopy": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", + "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", + "dev": true + }, + "lodash._basetostring": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", + "integrity": "sha1-0YYdh3+CSlL2aYMtyvPuFVZqB9U=", + "dev": true + }, + "lodash._basevalues": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz", + "integrity": "sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc=", + "dev": true + }, + "lodash._getnative": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", + "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", + "dev": true + }, + "lodash._isiterateecall": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", + "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", + "dev": true + }, + "lodash._reescape": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reescape/-/lodash._reescape-3.0.0.tgz", + "integrity": "sha1-Kx1vXf4HyKNVdT5fJ/rH8c3hYWo=", + "dev": true + }, + "lodash._reevaluate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz", + "integrity": "sha1-WLx0xAZklTrgsSTYBpltrKQx4u0=", + "dev": true + }, + "lodash._reinterpolate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", + "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", + "dev": true + }, + "lodash._root": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._root/-/lodash._root-3.0.1.tgz", + "integrity": "sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI=", + "dev": true + }, + "lodash.escape": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", + "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", + "dev": true, + "requires": { + "lodash._root": "^3.0.0" + } + }, + "lodash.isarguments": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", + "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", + "dev": true + }, + "lodash.isarray": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", + "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", + "dev": true + }, + "lodash.keys": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", + "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", + "dev": true, + "requires": { + "lodash._getnative": "^3.0.0", + "lodash.isarguments": "^3.0.0", + "lodash.isarray": "^3.0.0" + } + }, + "lodash.restparam": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", + "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=", + "dev": true + }, + "lodash.template": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz", + "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", + "dev": true, + "requires": { + "lodash._basecopy": "^3.0.0", + "lodash._basetostring": "^3.0.0", + "lodash._basevalues": "^3.0.0", + "lodash._isiterateecall": "^3.0.0", + "lodash._reinterpolate": "^3.0.0", + "lodash.escape": "^3.0.0", + "lodash.keys": "^3.0.0", + "lodash.restparam": "^3.0.0", + "lodash.templatesettings": "^3.0.0" + } + }, + "lodash.templatesettings": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz", + "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=", + "dev": true, + "requires": { + "lodash._reinterpolate": "^3.0.0", + "lodash.escape": "^3.0.0" + } + }, + "lru-cache": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", + "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", + "dev": true + }, + "make-iterator": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/make-iterator/-/make-iterator-1.0.1.tgz", + "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", + "dev": true, + "requires": { + "kind-of": "^6.0.2" + } + }, + "map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "dev": true + }, + "map-stream": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", + "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", + "dev": true + }, + "map-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", + "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", + "dev": true, + "requires": { + "object-visit": "^1.0.0" + } + }, + "marked": { + "version": "0.3.19", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.19.tgz", + "integrity": "sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg==", + "dev": true + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + } + }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "dev": true + }, + "mime-db": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", + "dev": true + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "dev": true, + "requires": { + "mime-db": "1.40.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + }, + "mixin-deep": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", + "dev": true, + "requires": { + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + } + } + }, + "morgan": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.1.tgz", + "integrity": "sha512-HQStPIV4y3afTiCYVxirakhlCfGkI161c76kKFca7Fk1JusM//Qeo1ej2XaMniiNeaZklMVrh3vTtIzpzwbpmA==", + "dev": true, + "requires": { + "basic-auth": "~2.0.0", + "debug": "2.6.9", + "depd": "~1.1.2", + "on-finished": "~2.3.0", + "on-headers": "~1.0.1" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "multipipe": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", + "integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=", + "dev": true, + "requires": { + "duplexer2": "0.0.2" + } + }, + "mute-stream": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", + "integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=", + "dev": true + }, + "nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", + "dev": true, + "optional": true + }, + "nanomatch": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", + "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "fragment-cache": "^0.2.1", + "is-windows": "^1.0.2", + "kind-of": "^6.0.2", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + } + }, + "natives": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.6.tgz", + "integrity": "sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA==", + "dev": true + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, + "negotiator": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", + "dev": true + }, + "next-tick": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", + "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", + "dev": true + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, + "normalize-url": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-1.9.1.tgz", + "integrity": "sha1-LMDWazHqIwNkWENuNiDYWVTGbDw=", + "dev": true, + "requires": { + "object-assign": "^4.0.1", + "prepend-http": "^1.0.0", + "query-string": "^4.1.0", + "sort-keys": "^1.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "object-copy": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", + "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "dev": true, + "requires": { + "copy-descriptor": "^0.1.0", + "define-property": "^0.2.5", + "kind-of": "^3.0.3" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "object-visit": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", + "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "dev": true, + "requires": { + "isobject": "^3.0.0" + } + }, + "object.defaults": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz", + "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=", + "dev": true, + "requires": { + "array-each": "^1.0.1", + "array-slice": "^1.0.0", + "for-own": "^1.0.0", + "isobject": "^3.0.0" + } + }, + "object.map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object.map/-/object.map-1.0.1.tgz", + "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=", + "dev": true, + "requires": { + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" + } + }, + "object.pick": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "dev": true, + "requires": { + "ee-first": "1.1.1" + } + }, + "on-headers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", + "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", + "dev": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", + "dev": true + }, + "opn": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/opn/-/opn-6.0.0.tgz", + "integrity": "sha512-I9PKfIZC+e4RXZ/qr1RhgyCnGgYX0UEIlXgWnCOVACIvFgaC9rz6Won7xbdhoHrd8IIhV7YEpHjreNUNkqCGkQ==", + "dev": true, + "requires": { + "is-wsl": "^1.1.0" + } + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "dev": true, + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" + } + }, + "orchestrator": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/orchestrator/-/orchestrator-0.3.8.tgz", + "integrity": "sha1-FOfp4nZPcxX7rBhOUGx6pt+UrX4=", + "dev": true, + "requires": { + "end-of-stream": "~0.1.5", + "sequencify": "~0.0.7", + "stream-consume": "~0.1.0" + } + }, + "ordered-read-streams": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz", + "integrity": "sha1-/VZamvjrRHO6abbtijQ1LLVS8SY=", + "dev": true + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "dev": true + }, + "parse-filepath": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz", + "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=", + "dev": true, + "requires": { + "is-absolute": "^1.0.0", + "map-cache": "^0.2.0", + "path-root": "^0.1.1" + } + }, + "parse-node-version": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz", + "integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==", + "dev": true + }, + "parse-passwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", + "dev": true + }, + "parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "dev": true + }, + "pascalcase": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", + "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "dev": true + }, + "path-dirname": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", + "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "path-root": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz", + "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", + "dev": true, + "requires": { + "path-root-regex": "^0.1.0" + } + }, + "path-root-regex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz", + "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=", + "dev": true + }, + "pause-stream": { + "version": "0.0.11", + "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", + "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", + "dev": true, + "requires": { + "through": "~2.3" + } + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, + "requires": { + "pinkie": "^2.0.0" + } + }, + "pluralize": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-1.2.1.tgz", + "integrity": "sha1-0aIUg/0iu0HlihL6NCGCMUCJfEU=", + "dev": true + }, + "posix-character-classes": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", + "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "dev": true + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "prepend-http": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", + "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=", + "dev": true + }, + "pretty-hrtime": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", + "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=", + "dev": true + }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true + }, + "progress": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", + "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", + "dev": true + }, + "proxy-middleware": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/proxy-middleware/-/proxy-middleware-0.15.0.tgz", + "integrity": "sha1-o/3xvvtzD5UZZYcqwvYHTGFHelY=", + "dev": true + }, + "query-string": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-4.3.4.tgz", + "integrity": "sha1-u7aTucqRXCMlFbIosaArYJBD2+s=", + "dev": true, + "requires": { + "object-assign": "^4.1.0", + "strict-uri-encode": "^1.0.0" + } + }, + "range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "dev": true + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "readdirp": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", + "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "micromatch": "^3.1.10", + "readable-stream": "^2.0.2" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "readline2": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz", + "integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "mute-stream": "0.0.5" + } + }, + "rechoir": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", + "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", + "dev": true, + "requires": { + "resolve": "^1.1.6" + } + }, + "regex-not": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", + "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", + "dev": true, + "requires": { + "extend-shallow": "^3.0.2", + "safe-regex": "^1.1.0" + } + }, + "remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "dev": true + }, + "repeat-element": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", + "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "repeating": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", + "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", + "dev": true, + "requires": { + "is-finite": "^1.0.0" + } + }, + "replace-ext": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz", + "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", + "dev": true + }, + "require-uncached": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", + "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", + "dev": true, + "requires": { + "caller-path": "^0.1.0", + "resolve-from": "^1.0.0" + } + }, + "requizzle": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.2.tgz", + "integrity": "sha512-oJ6y7JcUJkblRGhMByGNcszeLgU0qDxNKFCiUZR1XyzHyVsev+Mxb1tyygxLd1ORsKee1SA5BInFdUwY64GE/A==", + "dev": true, + "requires": { + "lodash": "^4.17.11" + } + }, + "resolve": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.11.1.tgz", + "integrity": "sha512-vIpgF6wfuJOZI7KKKSP+HmiKggadPQAdsp5HiC1mvqnfp0gF1vdwgBWZIdrVft9pgqoMFQN+R7BSWZiBxx+BBw==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "resolve-dir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", + "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", + "dev": true, + "requires": { + "expand-tilde": "^2.0.0", + "global-modules": "^1.0.0" + } + }, + "resolve-from": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", + "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", + "dev": true + }, + "resolve-url": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", + "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", + "dev": true + }, + "restore-cursor": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", + "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", + "dev": true, + "requires": { + "exit-hook": "^1.0.0", + "onetime": "^1.0.0" + } + }, + "ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "dev": true + }, + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "run-async": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz", + "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", + "dev": true, + "requires": { + "once": "^1.3.0" + } + }, + "rx-lite": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz", + "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=", + "dev": true + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "safe-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "dev": true, + "requires": { + "ret": "~0.1.10" + } + }, + "semver": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", + "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=", + "dev": true + }, + "send": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "dev": true, + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + }, + "dependencies": { + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + } + } + }, + "sequencify": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/sequencify/-/sequencify-0.0.7.tgz", + "integrity": "sha1-kM/xnQLgcCf9dn9erT57ldHnOAw=", + "dev": true + }, + "serve-index": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", + "integrity": "sha1-03aNabHn2C5c4FD/9bRTvqEqkjk=", + "dev": true, + "requires": { + "accepts": "~1.3.4", + "batch": "0.6.1", + "debug": "2.6.9", + "escape-html": "~1.0.3", + "http-errors": "~1.6.2", + "mime-types": "~2.1.17", + "parseurl": "~1.3.2" + }, + "dependencies": { + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "dev": true, + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==", + "dev": true + } + } + }, + "set-value": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.3", + "split-string": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", + "dev": true + }, + "shelljs": { + "version": "0.7.8", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.8.tgz", + "integrity": "sha1-3svPh0sNHl+3LhSxZKloMEjprLM=", + "dev": true, + "requires": { + "glob": "^7.0.0", + "interpret": "^1.0.0", + "rechoir": "^0.6.2" + } + }, + "sigmund": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", + "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", + "dev": true + }, + "slice-ansi": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", + "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", + "dev": true + }, + "snapdragon": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", + "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", + "dev": true, + "requires": { + "base": "^0.11.1", + "debug": "^2.2.0", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "map-cache": "^0.2.2", + "source-map": "^0.5.6", + "source-map-resolve": "^0.5.0", + "use": "^3.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "snapdragon-node": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", + "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", + "dev": true, + "requires": { + "define-property": "^1.0.0", + "isobject": "^3.0.0", + "snapdragon-util": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "snapdragon-util": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", + "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", + "dev": true, + "requires": { + "kind-of": "^3.2.0" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "sort-keys": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz", + "integrity": "sha1-RBttTTRnmPG05J6JIK37oOVD+a0=", + "dev": true, + "requires": { + "is-plain-obj": "^1.0.0" + } + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + }, + "source-map-resolve": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", + "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", + "dev": true, + "requires": { + "atob": "^2.1.1", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" + } + }, + "source-map-url": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", + "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", + "dev": true + }, + "sparkles": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.1.tgz", + "integrity": "sha512-dSO0DDYUahUt/0/pD/Is3VIm5TGJjludZ0HVymmhYF6eNA53PVLhnUk0znSYbH8IYBuJdCE+1luR22jNLMaQdw==", + "dev": true + }, + "split": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", + "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", + "dev": true, + "requires": { + "through": "2" + } + }, + "split-string": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", + "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", + "dev": true, + "requires": { + "extend-shallow": "^3.0.0" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "static-extend": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", + "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "dev": true, + "requires": { + "define-property": "^0.2.5", + "object-copy": "^0.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", + "dev": true + }, + "stream-combiner": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", + "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", + "dev": true, + "requires": { + "duplexer": "~0.1.1" + } + }, + "stream-consume": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.1.tgz", + "integrity": "sha512-tNa3hzgkjEP7XbCkbRXe1jpg+ievoa0O4SCFlMOYEscGSS4JJsckGL8swUyAa/ApGU3Ae4t6Honor4HhL+tRyg==", + "dev": true + }, + "strict-uri-encode": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", + "integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=", + "dev": true + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-bom": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz", + "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=", + "dev": true, + "requires": { + "first-chunk-stream": "^1.0.0", + "is-utf8": "^0.2.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "strip-outer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-outer/-/strip-outer-1.0.1.tgz", + "integrity": "sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg==", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.2" + } + }, + "strip-url-auth": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-url-auth/-/strip-url-auth-1.0.1.tgz", + "integrity": "sha1-IrD6OkE4WzO+PzMVUbu4N/oM164=", + "dev": true + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + }, + "table": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz", + "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=", + "dev": true, + "requires": { + "ajv": "^4.7.0", + "ajv-keywords": "^1.0.0", + "chalk": "^1.1.1", + "lodash": "^4.0.0", + "slice-ansi": "0.0.4", + "string-width": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "taffydb": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", + "integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=", + "dev": true + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, + "through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "dev": true, + "requires": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "tildify": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/tildify/-/tildify-1.2.0.tgz", + "integrity": "sha1-3OwD9V3Km3qj5bBPIYF+tW5jWIo=", + "dev": true, + "requires": { + "os-homedir": "^1.0.0" + } + }, + "time-stamp": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz", + "integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=", + "dev": true + }, + "to-object-path": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", + "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "to-regex": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", + "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", + "dev": true, + "requires": { + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + } + }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", + "dev": true + }, + "trim-repeated": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/trim-repeated/-/trim-repeated-1.0.0.tgz", + "integrity": "sha1-42RqLqTokTEr9+rObPsFOAvAHCE=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.2" + } + }, + "type": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/type/-/type-1.0.1.tgz", + "integrity": "sha512-MAM5dBMJCJNKs9E7JXo4CXRAansRfG0nlJxW7Wf6GZzSOvH31zClSaHdIMWLehe/EGMBkqeC55rrkaOr5Oo7Nw==", + "dev": true + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "dev": true + }, + "unc-path-regex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", + "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", + "dev": true + }, + "underscore": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", + "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=", + "dev": true + }, + "union-value": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "get-value": "^2.0.6", + "is-extendable": "^0.1.1", + "set-value": "^2.0.1" + } + }, + "unique-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz", + "integrity": "sha1-1ZpKdUJ0R9mqbJHnAmP40mpLEEs=", + "dev": true + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + }, + "unix-crypt-td-js": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unix-crypt-td-js/-/unix-crypt-td-js-1.0.0.tgz", + "integrity": "sha1-HAgkFQSBvHoB1J6Y8exmjYJBLzs=", + "dev": true + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "dev": true + }, + "unset-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", + "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", + "dev": true, + "requires": { + "has-value": "^0.3.1", + "isobject": "^3.0.0" + }, + "dependencies": { + "has-value": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", + "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", + "dev": true, + "requires": { + "get-value": "^2.0.3", + "has-values": "^0.1.4", + "isobject": "^2.0.0" + }, + "dependencies": { + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + } + } + }, + "has-values": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", + "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + } + } + }, + "upath": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.2.tgz", + "integrity": "sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q==", + "dev": true + }, + "urix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", + "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", + "dev": true + }, + "use": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", + "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", + "dev": true + }, + "user-home": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz", + "integrity": "sha1-K1viOjK2Onyd640PKNSFcko98ZA=", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", + "dev": true + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", + "dev": true + }, + "v8flags": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-2.1.1.tgz", + "integrity": "sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ=", + "dev": true, + "requires": { + "user-home": "^1.1.1" + } + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", + "dev": true + }, + "vinyl": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz", + "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", + "dev": true, + "requires": { + "clone": "^1.0.0", + "clone-stats": "^0.0.1", + "replace-ext": "0.0.1" + } + }, + "vinyl-fs": { + "version": "0.3.14", + "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-0.3.14.tgz", + "integrity": "sha1-mmhRzhysHBzqX+hsCTHWIMLPqeY=", + "dev": true, + "requires": { + "defaults": "^1.0.0", + "glob-stream": "^3.1.5", + "glob-watcher": "^0.0.6", + "graceful-fs": "^3.0.0", + "mkdirp": "^0.5.0", + "strip-bom": "^1.0.0", + "through2": "^0.6.1", + "vinyl": "^0.4.0" + }, + "dependencies": { + "clone": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz", + "integrity": "sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8=", + "dev": true + }, + "graceful-fs": { + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", + "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", + "dev": true, + "requires": { + "natives": "^1.1.0" + } + }, + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "through2": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "dev": true, + "requires": { + "readable-stream": ">=1.0.33-1 <1.1.0-0", + "xtend": ">=4.0.0 <4.1.0-0" + } + }, + "vinyl": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz", + "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", + "dev": true, + "requires": { + "clone": "^0.2.0", + "clone-stats": "^0.0.1" + } + } + } + }, + "websocket-driver": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.3.tgz", + "integrity": "sha512-bpxWlvbbB459Mlipc5GBzzZwhoZgGEZLuqPaR0INBGnPAY1vdBX6hPnoFXiw+3yWxDuHyQjO2oXTMyS8A5haFg==", + "dev": true, + "requires": { + "http-parser-js": ">=0.4.0 <0.4.11", + "safe-buffer": ">=5.1.0", + "websocket-extensions": ">=0.1.1" + } + }, + "websocket-extensions": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.3.tgz", + "integrity": "sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==", + "dev": true + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "write": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", + "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "dev": true, + "requires": { + "mkdirp": "^0.5.1" + } + }, + "xmlcreate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-1.0.2.tgz", + "integrity": "sha1-+mv3YqYKQT+z3Y9LA8WyaSONMI8=", + "dev": true + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } +} diff --git a/src/combinatorics/variations-repetition.js b/src/combinatorics/variations-repetition.js index 71c68f6a..22ba009c 100644 --- a/src/combinatorics/variations-repetition.js +++ b/src/combinatorics/variations-repetition.js @@ -1,7 +1,7 @@ (function (exports) { 'use strict'; - var variationsWithRepetion = (function () { + var variationsWithRepetition = (function () { var res; function variations(arr, k, index, current) { @@ -21,7 +21,7 @@ * * @example * var variations = require('path-to-algorithms/src/combinatorics/' + - * 'variations-repetition').variationsWithRepetion; + * 'variations-repetition').variationsWithRepetition; * var result = variations(['apple', 'orange', 'pear'], 2); * * // [['apple', 'apple'], @@ -50,6 +50,6 @@ }; }()); - exports.variationsWithRepetion = variationsWithRepetion; + exports.variationsWithRepetition = variationsWithRepetition; }((typeof window === 'undefined') ? module.exports : window)); diff --git a/src/compression/runlength/runlength.js b/src/compression/runlength/runlength.js index a530448d..f5cebb37 100644 --- a/src/compression/runlength/runlength.js +++ b/src/compression/runlength/runlength.js @@ -10,7 +10,7 @@ var runLengthEncoding = (function () { /** - * Convers a given string to sequence of numbers + * Converts a given string to sequence of numbers * This takes O(n). */ function convertToAscii(str) { diff --git a/src/graphics/graham.js b/src/graphics/graham.js index 019fd239..aa1d9862 100644 --- a/src/graphics/graham.js +++ b/src/graphics/graham.js @@ -10,7 +10,9 @@ const sb = slope(p, b); [[sa, a], [sb, b]].forEach(e => { const el = memo.get(e[0]); - if (!el || dist(p, el) < dist(p, e[1])) memo.set(e[0], e[1]); + if (!el || dist(p, el) < dist(p, e[1])) { + memo.set(e[0], e[1]); + } }); return sa - sb; }; @@ -40,12 +42,20 @@ * // { x: 0, y: 1 }] */ const convexHull = all => { - if (!all.length) return []; + if (!all.length) { + return []; + } const p = all.reduce((a, c) => { - if (a.y < c.y) return a; - if (a.y > c.y) return c; - if (a.x < c.x) return a; + if (a.y < c.y) { + return a; + } + if (a.y > c.y) { + return c; + } + if (a.x < c.x) { + return a; + } return c; }); @@ -56,8 +66,9 @@ .sort(sort.bind(null, p, memo)) .filter(c => memo.get(slope(p, c)) === c) .forEach(p => { - while (stack.length > 1 && ccw(stack[stack.length - 2], stack[stack.length - 1], p) < 0) + while (stack.length > 1 && ccw(stack[stack.length - 2], stack[stack.length - 1], p) < 0) { stack.pop(); + } stack.push(p); }); diff --git a/src/others/min-coins-change.js b/src/others/min-coins-change.js index f0f07933..fa9419d8 100644 --- a/src/others/min-coins-change.js +++ b/src/others/min-coins-change.js @@ -4,7 +4,7 @@ /** * Returns the minimum number of coins from given set, * which sum equals to given change. This is famous - * problem from the dymanic programming: + * problem from the dynamic programming: * {@link https://en.wikipedia.org/wiki/Change-making_problem} * * @public diff --git a/src/searching/recursive-binarysearch.js b/src/searching/recursive-binarysearch.js index 1344bacd..bf4aa952 100644 --- a/src/searching/recursive-binarysearch.js +++ b/src/searching/recursive-binarysearch.js @@ -3,7 +3,7 @@ var binarySearch = (function () { /** - * @pivate + * @private * @param {Array} array Array where we should find the index of the element * @param {Number} value Value of the element which index should be found * @param {Number} left Left index diff --git a/src/sorting/quicksort-middle.js b/src/sorting/quicksort-middle.js index 3e348765..88729ff4 100644 --- a/src/sorting/quicksort-middle.js +++ b/src/sorting/quicksort-middle.js @@ -17,7 +17,7 @@ /** * Partitions the array in two parts by the middle elements. - * All elemnts which are less than the chosen one goes left from it + * All elements which are less than the chosen one goes left from it * all which are greater goes right from it. * Uses Hoare's partitioning algorithm. * diff --git a/src/sorting/quicksort.js b/src/sorting/quicksort.js index b54a84df..be3f6664 100644 --- a/src/sorting/quicksort.js +++ b/src/sorting/quicksort.js @@ -20,7 +20,7 @@ * @param {array} array The array which contains the elements * @param {number} i The index of the first element * @param {number} j The index of the second element - * @returns {array} array The array with swaped elements + * @returns {array} array The array with swapped elements */ function swap(array, i, j) { var temp = array[i]; diff --git a/test/graphics/grapham.spec.js b/test/graphics/grapham.spec.js index 8b6db0e6..867b0875 100644 --- a/test/graphics/grapham.spec.js +++ b/test/graphics/grapham.spec.js @@ -8,7 +8,7 @@ const points = [ { x: 0.5, y: 0.5 } ]; -describe("Graham's algorithm for convex hull", function() { +describe('Graham\'s algorithm for convex hull', function() { 'use strict'; it('should not throw with empty list', () => { From 30a95f25c01be0fcc7b0ae14e08c1ff52c72f1c4 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 2 Jul 2019 14:44:29 -0700 Subject: [PATCH 579/613] Update readme --- readme.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/readme.md b/readme.md index af682e88..a26d2d1e 100644 --- a/readme.md +++ b/readme.md @@ -69,25 +69,25 @@ create a pull request. :---: |:---: |:---: |:---: |:---: |:---: | [mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[mik-laj](https://github.com/mik-laj) |[jeremyckahn](https://github.com/jeremyckahn) | -[krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) | +[krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[filipefalcaos](https://github.com/filipefalcaos) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) | :---: |:---: |:---: |:---: |:---: |:---: | -[krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) | +[krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[filipefalcaos](https://github.com/filipefalcaos) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) | -[deniskyashif](https://github.com/deniskyashif) |[filipefalcaos](https://github.com/filipefalcaos) |[brunohadlich](https://github.com/brunohadlich) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[pkerpedjiev](https://github.com/pkerpedjiev) | +[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[brunohadlich](https://github.com/brunohadlich) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[pkerpedjiev](https://github.com/pkerpedjiev) | :---: |:---: |:---: |:---: |:---: |:---: | -[deniskyashif](https://github.com/deniskyashif) |[filipefalcaos](https://github.com/filipefalcaos) |[brunohadlich](https://github.com/brunohadlich) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[pkerpedjiev](https://github.com/pkerpedjiev) | +[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[brunohadlich](https://github.com/brunohadlich) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[pkerpedjiev](https://github.com/pkerpedjiev) | -[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[emyarod](https://github.com/emyarod) |[liesislukas](https://github.com/liesislukas) |[alexjoverm](https://github.com/alexjoverm) |[BorislavBorisov22](https://github.com/BorislavBorisov22) |[ysharplanguage](https://github.com/ysharplanguage) | +[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) |[BorislavBorisov22](https://github.com/BorislavBorisov22) |[ysharplanguage](https://github.com/ysharplanguage) | :---: |:---: |:---: |:---: |:---: |:---: | -[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[emyarod](https://github.com/emyarod) |[liesislukas](https://github.com/liesislukas) |[alexjoverm](https://github.com/alexjoverm) |[BorislavBorisov22](https://github.com/BorislavBorisov22) |[ysharplanguage](https://github.com/ysharplanguage) | +[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) |[BorislavBorisov22](https://github.com/BorislavBorisov22) |[ysharplanguage](https://github.com/ysharplanguage) | -[jurassix](https://github.com/jurassix) |[contra](https://github.com/contra) |[amilajack](https://github.com/amilajack) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) |[DengYiping](https://github.com/DengYiping) | +[jurassix](https://github.com/jurassix) |[fisenkodv](https://github.com/fisenkodv) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) | :---: |:---: |:---: |:---: |:---: |:---: | -[jurassix](https://github.com/jurassix) |[contra](https://github.com/contra) |[amilajack](https://github.com/amilajack) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) |[DengYiping](https://github.com/DengYiping) | +[jurassix](https://github.com/jurassix) |[fisenkodv](https://github.com/fisenkodv) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) | -[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | -:---: |:---: |:---: | -[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | +[DengYiping](https://github.com/DengYiping) |[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | +:---: |:---: |:---: |:---: | +[DengYiping](https://github.com/DengYiping) |[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | ## License From 50cd07e5a645fcf27c16d5a31384f6969d306ae0 Mon Sep 17 00:00:00 2001 From: Bruno Bradach Date: Sun, 18 Aug 2019 21:10:27 -0300 Subject: [PATCH 580/613] Allow comparator function to remove complex data from LinkedList. Also, disable linebreak-style lint rule. (#155) --- .eslintrc.json | 2 +- src/data-structures/linked-list.js | 5 ++-- test/data-structures/linked-list.spec.js | 34 ++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 82ecf768..90b26d15 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -50,7 +50,7 @@ "no-empty": 2, "no-plusplus": 2, "no-undef": 2, - "linebreak-style": 2, + "linebreak-style": 0, "max-depth": [ 2, 4 diff --git a/src/data-structures/linked-list.js b/src/data-structures/linked-list.js index c8d22db5..9027f16e 100644 --- a/src/data-structures/linked-list.js +++ b/src/data-structures/linked-list.js @@ -134,7 +134,7 @@ * @param {Object} data Data which should be removed. * @return {Boolean} Returns true if data has been removed. */ - exports.LinkedList.prototype.remove = function (data) { + exports.LinkedList.prototype.remove = function (data, equals) { if (this.first === null) { return false; } @@ -142,7 +142,8 @@ var next; var prev; while (temp) { - if (temp.data === data) { + var dataFound = equals ? equals(temp.data, data) : temp.data === data; + if (dataFound) { next = temp.next; prev = temp.prev; if (next) { diff --git a/test/data-structures/linked-list.spec.js b/test/data-structures/linked-list.spec.js index 37ee7084..eb1d0e38 100644 --- a/test/data-structures/linked-list.spec.js +++ b/test/data-structures/linked-list.spec.js @@ -140,4 +140,38 @@ describe('Linked List', function () { } linkedList.inorder(callback); }); + it('should delete data properly', function () { + var linkedList = new LinkedList(); + linkedList.push(1); + linkedList.push(2); + linkedList.push(3); + linkedList.push(4); + linkedList.push(5); + linkedList.remove(3); + expect(linkedList.first.data).toBe(1); + expect(linkedList.first.next.data).toBe(2); + expect(linkedList.first.next.next.data).toBe(4); + expect(linkedList.first.next.next.next.data).toBe(5); + expect(linkedList.last.data).toBe(5); + }); + it('should delete complex data properly', function () { + var linkedList = new LinkedList(); + var item1 = {id: 1}; + var item2 = {id: 2}; + var item3 = {id: 3}; + var item4 = {id: 4}; + var item5 = {id: 5}; + linkedList.push(item1); + linkedList.push(item2); + linkedList.push(item3); + linkedList.push(item4); + linkedList.push(item5); + var equals = function(a, b) { return a.id === b.id }; + linkedList.remove({id: 3}, equals); + expect(linkedList.first.data).toBe(item1); + expect(linkedList.first.next.data).toBe(item2); + expect(linkedList.first.next.next.data).toBe(item4); + expect(linkedList.first.next.next.next.data).toBe(item5); + expect(linkedList.last.data).toBe(item5); + }); }); From 0a94c97932643cf04f7c67a5207f4517ab213a6d Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 16 Sep 2019 12:30:14 -0700 Subject: [PATCH 581/613] Update the list of contributors --- readme.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/readme.md b/readme.md index a26d2d1e..1235e2fd 100644 --- a/readme.md +++ b/readme.md @@ -77,17 +77,17 @@ create a pull request. :---: |:---: |:---: |:---: |:---: |:---: | [infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[brunohadlich](https://github.com/brunohadlich) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[pkerpedjiev](https://github.com/pkerpedjiev) | -[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) |[BorislavBorisov22](https://github.com/BorislavBorisov22) |[ysharplanguage](https://github.com/ysharplanguage) | +[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) |[BorislavBorisov22](https://github.com/BorislavBorisov22) |[brunob15](https://github.com/brunob15) | :---: |:---: |:---: |:---: |:---: |:---: | -[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) |[BorislavBorisov22](https://github.com/BorislavBorisov22) |[ysharplanguage](https://github.com/ysharplanguage) | +[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) |[BorislavBorisov22](https://github.com/BorislavBorisov22) |[brunob15](https://github.com/brunob15) | -[jurassix](https://github.com/jurassix) |[fisenkodv](https://github.com/fisenkodv) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) | +[ysharplanguage](https://github.com/ysharplanguage) |[jurassix](https://github.com/jurassix) |[fisenkodv](https://github.com/fisenkodv) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) | :---: |:---: |:---: |:---: |:---: |:---: | -[jurassix](https://github.com/jurassix) |[fisenkodv](https://github.com/fisenkodv) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) | +[ysharplanguage](https://github.com/ysharplanguage) |[jurassix](https://github.com/jurassix) |[fisenkodv](https://github.com/fisenkodv) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) | -[DengYiping](https://github.com/DengYiping) |[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | -:---: |:---: |:---: |:---: | -[DengYiping](https://github.com/DengYiping) |[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | +[xiedezhuo](https://github.com/xiedezhuo) |[DengYiping](https://github.com/DengYiping) |[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | +:---: |:---: |:---: |:---: |:---: | +[xiedezhuo](https://github.com/xiedezhuo) |[DengYiping](https://github.com/DengYiping) |[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | ## License From b8613951aaac132ca21ebaf07f05b61c83dc9fe9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 2 Nov 2019 16:13:39 -0700 Subject: [PATCH 582/613] Bump mixin-deep from 1.3.1 to 1.3.2 (#159) Bumps [mixin-deep](https://github.com/jonschlinkert/mixin-deep) from 1.3.1 to 1.3.2. - [Release notes](https://github.com/jonschlinkert/mixin-deep/releases) - [Commits](https://github.com/jonschlinkert/mixin-deep/compare/1.3.1...1.3.2) Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index cae998a0..4cd67db2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2091,9 +2091,9 @@ minizlib@^1.1.1: minipass "^2.2.1" mixin-deep@^1.2.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe" - integrity sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ== + version "1.3.2" + resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566" + integrity sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA== dependencies: for-in "^1.0.2" is-extendable "^1.0.1" From 21ad7006c2872aa280633c6eba43cd2c5bc20e1c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2019 10:28:27 -0800 Subject: [PATCH 583/613] Bump js-yaml from 3.13.0 to 3.13.1 (#160) Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 3.13.0 to 3.13.1. - [Release notes](https://github.com/nodeca/js-yaml/releases) - [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md) - [Commits](https://github.com/nodeca/js-yaml/compare/3.13.0...3.13.1) Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4cd67db2..57e8122a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1736,9 +1736,9 @@ js-tokens@^3.0.2: integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls= js-yaml@^3.5.1: - version "3.13.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.0.tgz#38ee7178ac0eea2c97ff6d96fff4b18c7d8cf98e" - integrity sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ== + version "3.13.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" + integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== dependencies: argparse "^1.0.7" esprima "^4.0.0" From fde6fd8058edcb24a27d62a37b8df90217c4610b Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 8 Nov 2019 21:22:25 +0530 Subject: [PATCH 584/613] Optimized Bubble sort (#163) --- src/sorting/bubblesort.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/sorting/bubblesort.js b/src/sorting/bubblesort.js index 7b5440ee..f39a18e2 100644 --- a/src/sorting/bubblesort.js +++ b/src/sorting/bubblesort.js @@ -25,14 +25,19 @@ function bubbleSort(array, cmp) { cmp = cmp || comparator; var temp; - for (var i = 0; i < array.length; i += 1) { - for (var j = i; j > 0; j -= 1) { - if (cmp(array[j], array[j - 1]) < 0) { + for (var i = 0; i < array.length - 1 ; i += 1) { + var swapCount = 0; + for (var j = 0; j < array.length - 1 - i; j += 1) { + if (cmp(array[j], array[j + 1 ]) > 0) { temp = array[j]; - array[j] = array[j - 1]; - array[j - 1] = temp; + array[j] = array[j + 1]; + array[j + 1] = temp; + swapCount += 1; } } + if (swapCount === 0){ + break; + } } return array; } From d66eccef5b7e6c76201db0c35ac0fc34595c6b36 Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 8 Nov 2019 21:22:52 +0530 Subject: [PATCH 585/613] selectionsort - decrease outer loop iteration and remove extra variable (#161) * decrease outer loop iteration. do not iterate for last element as it is last one and no comarison left * remove extra variable * add debug config for vscode * remove comment * remove lint error * remove vscode config file * Bump js-yaml from 3.13.0 to 3.13.1 (#160) Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 3.13.0 to 3.13.1. - [Release notes](https://github.com/nodeca/js-yaml/releases) - [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md) - [Commits](https://github.com/nodeca/js-yaml/compare/3.13.0...3.13.1) Signed-off-by: dependabot[bot] --- .gitignore | 1 + src/sorting/selectionsort.js | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 3fcdef0c..b563f830 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules +.vscode npm-debug.log debug dist diff --git a/src/sorting/selectionsort.js b/src/sorting/selectionsort.js index dab9e000..3f71ff5f 100644 --- a/src/sorting/selectionsort.js +++ b/src/sorting/selectionsort.js @@ -25,20 +25,17 @@ */ var selectionSort = function (array, cmp) { cmp = cmp || compare; - var min; var idx; var temp; - for (var i = 0; i < array.length; i += 1) { + for (var i = 0; i < array.length - 1; i += 1) { idx = i; - min = array[i]; for (var j = i + 1; j < array.length; j += 1) { - if (cmp(min, array[j]) > 0) { - min = array[j]; + if (cmp(array[idx], array[j]) > 0) { idx = j; } } temp = array[i]; - array[i] = min; + array[i] = array[idx]; array[idx] = temp; } return array; From 37b06435af05eafcf4d02b3cff8c0f11967abf6f Mon Sep 17 00:00:00 2001 From: BryanChan777 <43082778+BryanChan777@users.noreply.github.com> Date: Mon, 25 Nov 2019 06:53:50 -0800 Subject: [PATCH 586/613] Update readme.md (#164) --- readme.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index 1235e2fd..f566a610 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/mgechev/javascript-algorithms.svg?branch=Jakehp-patch-1)](https://travis-ci.org/mgechev/javascript-algorithms) -This repository contains JavaScript implementations of different famous Computer Science algorithms. +This repository contains JavaScript implementations of famous computer science algorithms. API reference with usage examples available here. @@ -37,7 +37,7 @@ Call: npm run test ``` -and all `*.spec.js` files will be executed. +This will execute all `*.spec.js` files. **To deploy documentation site** @@ -49,19 +49,17 @@ This requires you to have commit access to your Git remote. ## Contributions -Fork the repo and make required changes. After that push your changes in branch, which is named according to the changes -you did. Initiate the PR. +Fork the repo and make required changes. Afterwards, push your changes in branch. The name will be according to the changes you did. Initiate the pull request. -Make sure you're editor makes validations according to the `.jshintrc` in the root directory of the repository. +Make sure your editor makes validations according to the `.jshintrc` in the root directory of the repository. -Before pushing to the repository run: +Before pushing to the repository, run: ```bash npm run build ``` -If the build is not successful fix your code in order the tests and jshint validation to run successfully and after that -create a pull request. +If the build is not successful, fix your code in order for the tests and jshint validation to run successfully. Then create a pull request. ## Contributors From 73ecf25e0e5f1ec88feb947870faa5ace711389d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcelo=20Magalh=C3=A3es?= Date: Mon, 13 Jan 2020 14:42:55 -0300 Subject: [PATCH 587/613] Fix AVLTree remove (#139) (#165) --- src/data-structures/avl-tree.js | 6 ++---- test/data-structures/avl-tree.spec.js | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/data-structures/avl-tree.js b/src/data-structures/avl-tree.js index 6e65f904..b1d8b2d2 100644 --- a/src/data-structures/avl-tree.js +++ b/src/data-structures/avl-tree.js @@ -110,9 +110,7 @@ // y should be child of z with larger height // (cannot be ancestor of removed node) var y; - if (z._left !== null && z._right !== null){ - y = (z._left === y) ? z._right : z._left; - } else if (z._left !== null && z._right === null){ + if ((z._left !== null && z._right !== null) || (z._left !== null && z._right === null)){ y = z._left; } else if (z._right !== null && z._left === null){ y = z._right; @@ -602,7 +600,7 @@ var temp = node.value; node.value = min.value; min.value = temp; - return this.remove(min); + return this.remove(temp); } else { if (node._left) { this._replaceChild(node._parent, node, node._left); diff --git a/test/data-structures/avl-tree.spec.js b/test/data-structures/avl-tree.spec.js index dbe969be..6e35be24 100644 --- a/test/data-structures/avl-tree.spec.js +++ b/test/data-structures/avl-tree.spec.js @@ -163,4 +163,31 @@ describe('AVL Tree', function () { expect(avlTree._root._right.value).toBe(25); expect(avlTree._root._right._height).toBe(1); }); + it('should remove nodes and balance properly (3)', function () { + var avlTree = new AVLTree(); + avlTree.insert(55); + avlTree.insert(25); + avlTree.insert(11); + avlTree.insert(1); + avlTree.remove(55); + avlTree.insert(32); + avlTree.insert(37); + avlTree.insert(41); + avlTree.insert(8); + avlTree.insert(44); + avlTree.insert(6); + avlTree.remove(32); + avlTree.remove(11); + avlTree.remove(25); + + // depth 1 + expect(avlTree._root.value).toBe(37); + expect(avlTree._root._height).toBe(4); + // depth 2 + expect(avlTree._root._left.value).toBe(6); + expect(avlTree._root._left._height).toBe(3); + + expect(avlTree._root._right.value).toBe(41); + expect(avlTree._root._right._height).toBe(2); + }); }); From fc29658af6a87a1753ceb6d7766bf7ec80ac4279 Mon Sep 17 00:00:00 2001 From: mgechev Date: Mon, 13 Jan 2020 12:17:48 -0800 Subject: [PATCH 588/613] docs: update the list of contributors --- readme.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/readme.md b/readme.md index f566a610..b10aef31 100644 --- a/readme.md +++ b/readme.md @@ -71,21 +71,25 @@ If the build is not successful, fix your code in order for the tests and jshint :---: |:---: |:---: |:---: |:---: |:---: | [krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[filipefalcaos](https://github.com/filipefalcaos) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) | -[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[brunohadlich](https://github.com/brunohadlich) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[pkerpedjiev](https://github.com/pkerpedjiev) | +[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[brunohadlich](https://github.com/brunohadlich) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[Nirajkashyap](https://github.com/Nirajkashyap) | :---: |:---: |:---: |:---: |:---: |:---: | -[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[brunohadlich](https://github.com/brunohadlich) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[pkerpedjiev](https://github.com/pkerpedjiev) | +[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[brunohadlich](https://github.com/brunohadlich) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[Nirajkashyap](https://github.com/Nirajkashyap) | -[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) |[BorislavBorisov22](https://github.com/BorislavBorisov22) |[brunob15](https://github.com/brunob15) | +[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[dependabot[bot]](https://github.com/apps/dependabot) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) | :---: |:---: |:---: |:---: |:---: |:---: | -[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) |[BorislavBorisov22](https://github.com/BorislavBorisov22) |[brunob15](https://github.com/brunob15) | +[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[dependabot[bot]](https://github.com/apps/dependabot) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) | -[ysharplanguage](https://github.com/ysharplanguage) |[jurassix](https://github.com/jurassix) |[fisenkodv](https://github.com/fisenkodv) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) | +[BorislavBorisov22](https://github.com/BorislavBorisov22) |[brunob15](https://github.com/brunob15) |[BryanChan777](https://github.com/BryanChan777) |[ysharplanguage](https://github.com/ysharplanguage) |[jurassix](https://github.com/jurassix) |[fisenkodv](https://github.com/fisenkodv) | :---: |:---: |:---: |:---: |:---: |:---: | -[ysharplanguage](https://github.com/ysharplanguage) |[jurassix](https://github.com/jurassix) |[fisenkodv](https://github.com/fisenkodv) |[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[millerrach](https://github.com/millerrach) | +[BorislavBorisov22](https://github.com/BorislavBorisov22) |[brunob15](https://github.com/brunob15) |[BryanChan777](https://github.com/BryanChan777) |[ysharplanguage](https://github.com/ysharplanguage) |[jurassix](https://github.com/jurassix) |[fisenkodv](https://github.com/fisenkodv) | -[xiedezhuo](https://github.com/xiedezhuo) |[DengYiping](https://github.com/DengYiping) |[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | -:---: |:---: |:---: |:---: |:---: | -[xiedezhuo](https://github.com/xiedezhuo) |[DengYiping](https://github.com/DengYiping) |[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | +[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[marrcelo](https://github.com/marrcelo) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) |[DengYiping](https://github.com/DengYiping) | +:---: |:---: |:---: |:---: |:---: |:---: | +[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[marrcelo](https://github.com/marrcelo) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) |[DengYiping](https://github.com/DengYiping) | + +[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | +:---: |:---: |:---: | +[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | ## License From 888ad5188c8fb924e2850997f5a109f202125e34 Mon Sep 17 00:00:00 2001 From: Thomas Duffy Date: Tue, 7 Apr 2020 10:26:46 -0700 Subject: [PATCH 589/613] Add interpolation algo (#158) * Add interpolation algo * Update src/searching/interpolation-search.js Co-authored-by: Minko Gechev --- src/searching/interpolation-search.js | 54 +++++++++++++++++++++ test/searching/interpolation-search.spec.js | 22 +++++++++ 2 files changed, 76 insertions(+) create mode 100644 src/searching/interpolation-search.js create mode 100644 test/searching/interpolation-search.spec.js diff --git a/src/searching/interpolation-search.js b/src/searching/interpolation-search.js new file mode 100644 index 00000000..2241c74c --- /dev/null +++ b/src/searching/interpolation-search.js @@ -0,0 +1,54 @@ +(function(exports) { + 'use strict'; + /** + * Searches for specific element in a given array using + * the jump search algorithm.

+ * Time complexity: O(log N). + * + * @example + * + * var search = require('path-to-algorithms/src/searching/'+ + * 'interpolation-search').interpolationSearch; + * console.log(search([1, 2, 3, 4, 5], 4)); // 3 + * + * @public + * @module searching/interpolation-search + * @param {Array} sortedArray Input array. + * @param {Number} seekIndex of the element which index should be found. + * @returns {Number} Index of the element or -1 if not found. + */ + function interpolationSearch(sortedArray, seekIndex) { + let leftIndex = 0; + let rightIndex = sortedArray.length - 1; + + while (leftIndex <= rightIndex) { + const rangeDiff = sortedArray[rightIndex] - sortedArray[leftIndex]; + const indexDiff = rightIndex - leftIndex; + const valueDiff = seekIndex - sortedArray[leftIndex]; + + if (valueDiff < 0) { + return -1; + } + + if (!rangeDiff) { + return sortedArray[leftIndex] === seekIndex ? leftIndex : -1; + } + + const middleIndex = + leftIndex + Math.floor((valueDiff * indexDiff) / rangeDiff); + + if (sortedArray[middleIndex] === seekIndex) { + return middleIndex; + } + + if (sortedArray[middleIndex] < seekIndex) { + leftIndex = middleIndex + 1; + } else { + rightIndex = middleIndex - 1; + } + } + + return -1; + } + exports.interpolationSearch = interpolationSearch; +})(typeof window === 'undefined' ? module.exports : window); diff --git a/test/searching/interpolation-search.spec.js b/test/searching/interpolation-search.spec.js new file mode 100644 index 00000000..26757a4e --- /dev/null +++ b/test/searching/interpolation-search.spec.js @@ -0,0 +1,22 @@ +var interpolationSearch = require('../../src/searching/interpolation-search') + .interpolationSearch; + +describe('Interpolation search', function() { + 'use strict'; + + it('should find the element at position 0 ', function() { + expect(interpolationSearch([1, 2, 3, 4, 6, 8], 1)).toBe(0); + }); + + it('should find the element at position 4 ', function() { + expect(interpolationSearch([1, 2, 3, 4, 6, 8], 6)).toBe(4); + }); + + it('should return -1 if element is not found', function() { + expect(interpolationSearch([1, 2, 3, 4, 6, 8], 17)).toBe(-1); + }); + + it('should return -1 if array is empty', function() { + expect(interpolationSearch([], 10)).toBe(-1); + }); +}); From 9fd51ef1ed587941a9a7eaa7c83114ee302c2a70 Mon Sep 17 00:00:00 2001 From: Thomas Duffy Date: Tue, 7 Apr 2020 10:27:01 -0700 Subject: [PATCH 590/613] Add jump search algo (#157) * Add jump search algo * Update src/searching/jump-search.js Co-authored-by: Minko Gechev --- src/searching/jump-search.js | 56 ++++++++++++++++++++++++++++++ test/searching/jump-search.spec.js | 21 +++++++++++ 2 files changed, 77 insertions(+) create mode 100644 src/searching/jump-search.js create mode 100644 test/searching/jump-search.spec.js diff --git a/src/searching/jump-search.js b/src/searching/jump-search.js new file mode 100644 index 00000000..d697c94a --- /dev/null +++ b/src/searching/jump-search.js @@ -0,0 +1,56 @@ +(function(exports) { + 'use strict'; + /** + * Searches for specific element in a given array using + * the jump search algorithm.

+ * Time complexity: O(log N). + * + * @example + * + * var search = require('path-to-algorithms/src/searching/'+ + * 'jump-search').jumpSearch; + * console.log(search([1, 2, 3, 4, 5], 4)); // 3 + * + * @public + * @module searching/jumpsearch + * @param {Array} sortedArray Input array. + * @param {Number} seekIndex of the element which index should be found. + * @returns {Number} Index of the element or -1 if not found. + */ + function jumpSearch(sortedArray, seekIndex) { + // exit if array empty + const arrayLength = sortedArray.length; + if (!arrayLength) { + return -1; + } + + // set jumpSize + const jumpSize = Math.floor(Math.sqrt(arrayLength)); + + let blockStart = 0; + let blockEnd = jumpSize; + + while (seekIndex > sortedArray[Math.min(blockEnd, arrayLength) - 1]) { + blockStart = blockEnd; + blockEnd += jumpSize; + + // if out of array bounds exit + if (blockStart > arrayLength) { + return -1; + } + } + + let currentIndex = blockStart; + while (currentIndex < Math.min(blockEnd, arrayLength)) { + if (sortedArray[currentIndex] === seekIndex) { + return currentIndex; + } + + currentIndex += 1; + } + + return -1; + } + + exports.jumpSearch = jumpSearch; +})(typeof window === 'undefined' ? module.exports : window); diff --git a/test/searching/jump-search.spec.js b/test/searching/jump-search.spec.js new file mode 100644 index 00000000..3f9b2b76 --- /dev/null +++ b/test/searching/jump-search.spec.js @@ -0,0 +1,21 @@ +var jumpSearch = require('../../src/searching/jump-search').jumpSearch; + +describe('Jump search', function() { + 'use strict'; + + it('should find the element at position 0 ', function() { + expect(jumpSearch([1, 2, 3, 4, 6, 8], 1)).toBe(0); + }); + + it('should find the element at position 4 ', function() { + expect(jumpSearch([1, 2, 3, 4, 6, 8], 6)).toBe(4); + }); + + it('should return -1 ', function() { + expect(jumpSearch([1, 2, 3, 4, 6, 8], 10)).toBe(-1); + }); + + it('should return -1 ', function() { + expect(jumpSearch([], 10)).toBe(-1); + }); +}); From d5342122eb1506bb86d3e6ff80a0622d0ffd7830 Mon Sep 17 00:00:00 2001 From: Milko Venkov Date: Thu, 16 Apr 2020 20:44:36 +0300 Subject: [PATCH 591/613] Fix typo in interpolation search algorithm, #169 (#170) --- src/searching/interpolation-search.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/searching/interpolation-search.js b/src/searching/interpolation-search.js index 2241c74c..04202079 100644 --- a/src/searching/interpolation-search.js +++ b/src/searching/interpolation-search.js @@ -2,8 +2,9 @@ 'use strict'; /** * Searches for specific element in a given array using - * the jump search algorithm.

- * Time complexity: O(log N). + * the interpolation search algorithm.

+ * Time complexity: O(log log N) when elements are uniformly + * distributed, and O(N) in the worst case * * @example * From 01caa0dc875f0c5bc901473bab610ef6861ea25f Mon Sep 17 00:00:00 2001 From: Krzysztof Grzybek Date: Mon, 27 Apr 2020 19:47:09 +0200 Subject: [PATCH 592/613] Minimax implementation (#171) * minimax * remove blank line Co-Authored-By: Minko Gechev * cr fixes * simple game tests added Co-authored-by: Minko Gechev --- src/others/minimax.js | 120 +++++++++++ test/data-structures/avl-tree.spec.js | 4 +- test/others/minimax.spec.js | 277 ++++++++++++++++++++++++++ 3 files changed, 399 insertions(+), 2 deletions(-) create mode 100644 src/others/minimax.js create mode 100644 test/others/minimax.spec.js diff --git a/src/others/minimax.js b/src/others/minimax.js new file mode 100644 index 00000000..7cee9a37 --- /dev/null +++ b/src/others/minimax.js @@ -0,0 +1,120 @@ +(function (exports) { + 'use strict'; + /* eslint max-params: 0 */ + + /** + * @param {Function} getPossibleNextStatesFn Function which returns all possible next moves with states . + * @param {Function} isGameOverFn Function which returns if game is over. + * @param {Function} getScoreFn Function which returns score. + * @return {Function} minimax function + */ + function minimaxBuilder( + getPossibleNextStatesFn, + isGameOverFn, + getScoreFn + ) { + /** + * Minimax (sometimes MinMax, MM[1] or saddle point[2]) is a decision rule used in artificial intelligence, + * decision theory, game theory, statistics, and philosophy for minimizing the possible loss for a worst case (maximum loss) scenario. + * Optimized with alpha-beta pruning. + * {@link https://en.wikipedia.org/wiki/Minimax} + * {@link https://en.wikipedia.org/wiki/Alpha%E2%80%93beta_pruning} + * + * @public + * @module others/minimax + * + * @example + * + * var miniMax = + * require('path-to-algorithms/src/others/minimax').minimax; + * var result = minimax( + * [1, 2, 3], + * true, + * 5, + * -Infinity, + * Infinity, + * state => ({ move: 0, state: [2, 3, 4] }), + * state => state[1] < 3, + * state => state[1] + * ); + * + * @param {*} state Current game state + * @param {Boolean} maximize Defines if the result should be maximized or minimized + * @param {Number} depth Defines the maximum depth search + * @param {Number} alpha Maximum score that the minimizing player is assured + * @param {Number} beta Minimum score that the maximizing player is assured + * @return {{score: Number, move: *}} which contains the minimum coins from the given + * list, required for the change. + */ + const minimax = ( + state, + maximize, + depth, + alpha, + beta + ) => { + if (depth === 0 || isGameOverFn(state)) { + const score = getScoreFn(state); + return {score, move: null}; + } + + const possibleMoveResults = getPossibleNextStatesFn(state); + + if (maximize) { + + let maxResult = {score: -Infinity, move: null}; + + for (const next of possibleMoveResults) { + const result = minimax( + next.state, + false, + depth - 1, + alpha, + beta, + ); + + if (result.score > maxResult.score) { + maxResult = {score: result.score, move: next.move}; + } + + alpha = Math.max(alpha, result.score); + + if (alpha >= beta) { + break; + } + } + + return maxResult; + } else { + let minResult = {score: Infinity, move: null}; + + for (const next of possibleMoveResults) { + const result = minimax( + next.state, + true, + depth - 1, + alpha, + beta, + ); + + if (result.score < minResult.score) { + minResult = {score: result.score, move: next.move}; + } + + beta = Math.min(beta, result.score); + + if (beta <= alpha) { + break; + } + } + + return minResult; + } + } + + return minimax; + } + + exports.minimaxBuilder = minimaxBuilder; + +})(typeof window === 'undefined' ? module.exports : window); diff --git a/test/data-structures/avl-tree.spec.js b/test/data-structures/avl-tree.spec.js index 6e35be24..509b4906 100644 --- a/test/data-structures/avl-tree.spec.js +++ b/test/data-structures/avl-tree.spec.js @@ -178,8 +178,8 @@ describe('AVL Tree', function () { avlTree.insert(6); avlTree.remove(32); avlTree.remove(11); - avlTree.remove(25); - + avlTree.remove(25); + // depth 1 expect(avlTree._root.value).toBe(37); expect(avlTree._root._height).toBe(4); diff --git a/test/others/minimax.spec.js b/test/others/minimax.spec.js new file mode 100644 index 00000000..a867d893 --- /dev/null +++ b/test/others/minimax.spec.js @@ -0,0 +1,277 @@ +const minimaxBuilder = require('../../src/others/minimax.js').minimaxBuilder; + +describe('Minimax', function () { + 'use strict'; + + it('builder should be defined', function () { + expect(minimaxBuilder).toBeDefined(); + }); + + describe('with tic tac toe', function () { + let game = ticTacToe(); + + function getAllNextStates(state) { + const possibleMoves = game.emptyCells(state); + + return possibleMoves.map(move => ({ + move, + state: game.nextState(state, move), + })); + } + + const minimaxForX = minimaxBuilder( + getAllNextStates, + state => game.isGameOver(state), + state => game.getScore(state).x - game.getScore(state).o + ) + + const minimaxForO = minimaxBuilder( + getAllNextStates, + state => game.isGameOver(state), + state => game.getScore(state).o - game.getScore(state).x + ) + + it('should win versus dumb agent as first player', function () { + let state = game.newState('x'); + + while (!game.isGameOver(state)) { + if (state.turn === 'x') { + state = game.nextState(state, minimaxForX(state, true, 5, -Infinity, Infinity).move); + } else { + const move = game.emptyCells(state)[0]; + state = game.nextState(state, move); + } + } + + expect(game.isGameOver(state)).toBe(true); + expect(game.getScore(state)).toEqual({x: 1, o: 0}); + }); + + it('should win versus dumb agent as second player', function () { + let state = game.newState('x'); + + while (!game.isGameOver(state)) { + if (state.turn === 'o') { + state = game.nextState(state, minimaxForO(state, true, 5, -Infinity, Infinity).move); + } else { + const move = game.emptyCells(state)[0]; + state = game.nextState(state, move); + } + } + + expect(game.isGameOver(state)).toBe(true); + expect(game.getScore(state)).toEqual({x: 0, o: 1}); + }); + + + it('should be a tie for two minimax agents', function () { + let state = game.newState('x'); + + while (!game.isGameOver(state)) { + if (state.turn === 'o') { + state = game.nextState(state, minimaxForO(state, true, 5, -Infinity, Infinity).move); + } else { + state = game.nextState(state, minimaxForX(state, true, 5, -Infinity, Infinity).move); + } + } + expect(game.isGameOver(state)).toBe(true); + expect(game.getScore(state)).toEqual({x: 0, o: 0}); + }); + }); + + describe('with simple game', function () { + let game = simpleGame(); + + const minimaxForA = minimaxBuilder( + state => [true, false].map(move => ({ move, state: game.nextState(state, move)})), + state => game.isGameOver(state), + state => game.getScore(state).A - game.getScore(state).B + ); + const minimaxForB = minimaxBuilder( + state => [true, false].map(move => ({ move, state: game.nextState(state, move)})), + state => game.isGameOver(state), + state => game.getScore(state).B - game.getScore(state).A + ); + + it('should win versus dumb agent as a first player', function () { + /* o + / \ + o o + / \ / \ + o o o o + / \ / \ / \ / \ + -1 1 1 1 1 -1 1 -1 + */ + const binaryTree = [0, 0, 0, 0, 0, 0, 0, -1, 1, 1, 1, 1, -1, 1, -1]; + let state = game.newState(binaryTree); + + while (!game.isGameOver(state)) { + if (state.turn === 'A') { + state = game.nextState(state, minimaxForA(state, true, 5, -Infinity, Infinity).move); + } else { + state = game.nextState(state, false); + } + } + + expect(game.isGameOver(state)).toBe(true); + expect(game.getScore(state)).toEqual({A: 1, B: -1}); + }); + + it('should win versus dumb agent as a second player', function () { + /* o + / \ + o o + / \ / \ + -1 -1 -1 1 + */ + const binaryTree = [0, 0, 0, -1, -1, -1, 1]; + let state = game.newState(binaryTree); + + while (!game.isGameOver(state)) { + if (state.turn === 'B') { + state = game.nextState(state, minimaxForB(state, true, 5, -Infinity, Infinity).move); + } else { + state = game.nextState(state, false); + } + } + + expect(game.isGameOver(state)).toBe(true); + expect(game.getScore(state)).toEqual({A: -1, B: 1}); + }); + }); +}); + +function ticTacToe() { + 'use strict'; + + function newState(turn) { + return { + board: [[0, 0, 0], + [0, 0, 0], + [0, 0, 0]], + turn + }; + } + + function emptyCells(state) { + const result = []; + state.board.forEach((row, y) => { + row.forEach((cell, x) => { + if (cell === 0) { + result.push({x, y}) + } + }); + }); + + return result; + } + + function getWinner(state) { + const winVariants = [ + [{x: 0, y: 0}, {x: 0, y: 1}, {x: 0, y: 2}], + [{x: 1, y: 0}, {x: 1, y: 1}, {x: 1, y: 2}], + [{x: 2, y: 0}, {x: 2, y: 1}, {x: 2, y: 2}], + + [{x: 0, y: 0}, {x: 1, y: 0}, {x: 2, y: 0}], + [{x: 0, y: 1}, {x: 1, y: 1}, {x: 2, y: 1}], + [{x: 0, y: 2}, {x: 1, y: 0}, {x: 2, y: 2}], + + [{x: 0, y: 0}, {x: 1, y: 1}, {x: 2, y: 2}], + [{x: 2, y: 0}, {x: 1, y: 1}, {x: 2, y: 0}], + ]; + + for (const variant of winVariants) { + const combo = variant.map(cell => state.board[cell.y][cell.x]).join(''); + if (combo === 'xxx') { + return 'x'; + } else if (combo === 'ooo') { + return 'o'; + } + } + + return null; + } + + function allFieldsMarked(state) { + return state.board.every(row => row.every(cell => cell !== 0)); + } + + function isGameOver(state) { + return allFieldsMarked(state) || getWinner(state) !== null; + } + + function getScore(state) { + if (getWinner(state) === 'x') { + return {x: 1, o: 0}; + } else if (getWinner(state) === 'o') { + return {x: 0, o: 1}; + } + + return {x: 0, o: 0}; + } + + function nextState(state, move) { + const newBoard = state.board.map(row => row.slice()); + newBoard[move.y][move.x] = state.turn; + return { + board: newBoard, + turn: state.turn === 'x' ? 'o' : 'x', + }; + } + + return { + newState, + getScore, + nextState, + isGameOver, + emptyCells, + } +} + + +/* A simple game made for the purpose of minimax testing. The game has a binary tree with end values: 1 for player A win and -1 for player B win. + Game starts from the root node and each player has a binary choose - "false" moves to the left child and "true" moves to the right child. + The game ends when the very bottom leaf is reached. + o + / \ + o o + / \ / \ + 1 -1 -1 -1 + */ +function simpleGame() { + 'use strict'; + + function newState(binaryTree) { + return { + turn: 'A', + tree: binaryTree, + position: 0, + }; + } + + function nextState(state, move) { + return { + tree: state.tree, + position: move ? state.position * 2 + 2 : state.position * 2 + 1, + turn: state.turn === 'A' ? 'B' : 'A', + }; + } + + function isGameOver(state) { + return state.tree[state.position] !== 0; + } + + function getScore(state) { + return { + A: state.tree[state.position], + B: state.tree[state.position] === 0 ? 0 : -state.tree[state.position], + } + } + + return { + newState, + nextState, + isGameOver, + getScore, + } +} From 2732fdd3e5b519252880b98984e5215a3be3fbef Mon Sep 17 00:00:00 2001 From: mgechev Date: Sat, 30 May 2020 11:25:41 -0700 Subject: [PATCH 593/613] Update the list of contributors --- readme.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/readme.md b/readme.md index b10aef31..d1928f9e 100644 --- a/readme.md +++ b/readme.md @@ -63,33 +63,33 @@ If the build is not successful, fix your code in order for the tests and jshint ## Contributors -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[mik-laj](https://github.com/mik-laj) |[jeremyckahn](https://github.com/jeremyckahn) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[mik-laj](https://github.com/mik-laj) |[krzysztof-grzybek](https://github.com/krzysztof-grzybek) | :---: |:---: |:---: |:---: |:---: |:---: | -[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[mik-laj](https://github.com/mik-laj) |[jeremyckahn](https://github.com/jeremyckahn) | +[mgechev](https://github.com/mgechev) |[AndriiHeonia](https://github.com/AndriiHeonia) |[Jakehp](https://github.com/Jakehp) |[lygstate](https://github.com/lygstate) |[mik-laj](https://github.com/mik-laj) |[krzysztof-grzybek](https://github.com/krzysztof-grzybek) | -[krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[filipefalcaos](https://github.com/filipefalcaos) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) | +[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[filipefalcaos](https://github.com/filipefalcaos) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) | :---: |:---: |:---: |:---: |:---: |:---: | -[krzysztof-grzybek](https://github.com/krzysztof-grzybek) |[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[filipefalcaos](https://github.com/filipefalcaos) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) | +[pvoznenko](https://github.com/pvoznenko) |[jettcalleja](https://github.com/jettcalleja) |[filipefalcaos](https://github.com/filipefalcaos) |[kdamball](https://github.com/kdamball) |[lekkas](https://github.com/lekkas) |[infusion](https://github.com/infusion) | -[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[brunohadlich](https://github.com/brunohadlich) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[Nirajkashyap](https://github.com/Nirajkashyap) | +[deniskyashif](https://github.com/deniskyashif) |[brunohadlich](https://github.com/brunohadlich) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[Nirajkashyap](https://github.com/Nirajkashyap) |[pkerpedjiev](https://github.com/pkerpedjiev) | :---: |:---: |:---: |:---: |:---: |:---: | -[infusion](https://github.com/infusion) |[deniskyashif](https://github.com/deniskyashif) |[brunohadlich](https://github.com/brunohadlich) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[Nirajkashyap](https://github.com/Nirajkashyap) | +[deniskyashif](https://github.com/deniskyashif) |[brunohadlich](https://github.com/brunohadlich) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[Nirajkashyap](https://github.com/Nirajkashyap) |[pkerpedjiev](https://github.com/pkerpedjiev) | -[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[dependabot[bot]](https://github.com/apps/dependabot) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) | +[duffman85](https://github.com/duffman85) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[dependabot[bot]](https://github.com/apps/dependabot) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) | :---: |:---: |:---: |:---: |:---: |:---: | -[pkerpedjiev](https://github.com/pkerpedjiev) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[dependabot[bot]](https://github.com/apps/dependabot) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) | +[duffman85](https://github.com/duffman85) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[dependabot[bot]](https://github.com/apps/dependabot) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) | [BorislavBorisov22](https://github.com/BorislavBorisov22) |[brunob15](https://github.com/brunob15) |[BryanChan777](https://github.com/BryanChan777) |[ysharplanguage](https://github.com/ysharplanguage) |[jurassix](https://github.com/jurassix) |[fisenkodv](https://github.com/fisenkodv) | :---: |:---: |:---: |:---: |:---: |:---: | [BorislavBorisov22](https://github.com/BorislavBorisov22) |[brunob15](https://github.com/brunob15) |[BryanChan777](https://github.com/BryanChan777) |[ysharplanguage](https://github.com/ysharplanguage) |[jurassix](https://github.com/jurassix) |[fisenkodv](https://github.com/fisenkodv) | -[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[marrcelo](https://github.com/marrcelo) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) |[DengYiping](https://github.com/DengYiping) | +[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[marrcelo](https://github.com/marrcelo) |[wnvko](https://github.com/wnvko) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) | :---: |:---: |:---: |:---: |:---: |:---: | -[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[marrcelo](https://github.com/marrcelo) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) |[DengYiping](https://github.com/DengYiping) | +[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[marrcelo](https://github.com/marrcelo) |[wnvko](https://github.com/wnvko) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) | -[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | -:---: |:---: |:---: | -[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | +[DengYiping](https://github.com/DengYiping) |[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | +:---: |:---: |:---: |:---: | +[DengYiping](https://github.com/DengYiping) |[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | ## License From a9fb84ad53d4fe9f936ef0b2c4402f95bbf20096 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 Jun 2020 16:05:40 -0700 Subject: [PATCH 594/613] Bump websocket-extensions from 0.1.3 to 0.1.4 (#172) Bumps [websocket-extensions](https://github.com/faye/websocket-extensions-node) from 0.1.3 to 0.1.4. - [Release notes](https://github.com/faye/websocket-extensions-node/releases) - [Changelog](https://github.com/faye/websocket-extensions-node/blob/master/CHANGELOG.md) - [Commits](https://github.com/faye/websocket-extensions-node/compare/0.1.3...0.1.4) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 6 +++--- yarn.lock | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7474ed1c..f96b005d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4723,9 +4723,9 @@ } }, "websocket-extensions": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.3.tgz", - "integrity": "sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==", + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.4.tgz", + "integrity": "sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg==", "dev": true }, "which": { diff --git a/yarn.lock b/yarn.lock index 57e8122a..721b113b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3293,9 +3293,9 @@ websocket-driver@>=0.5.1: websocket-extensions ">=0.1.1" websocket-extensions@>=0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.3.tgz#5d2ff22977003ec687a4b87073dfbbac146ccf29" - integrity sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg== + version "0.1.4" + resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" + integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== which@^1.2.14: version "1.3.1" From c4e35f2e43ea846b24529918011e8d4ab95dfe3b Mon Sep 17 00:00:00 2001 From: Daniel Wasserlauf Date: Wed, 14 Oct 2020 17:28:24 -0400 Subject: [PATCH 595/613] [gulpUpdate]: Updated Gulp dependency to fix build failure --- gulpfile.js | 15 +- package-lock.json | 1691 +++++++++++++++++++++++++++++++++-------- package.json | 2 +- src/others/minimax.js | 4 +- 4 files changed, 1400 insertions(+), 312 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 81073a4d..47c08e1c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,18 +1,19 @@ -'use strict'; -var gulp = require('gulp'); -var eslint = require('gulp-eslint'); -var jasmine = require('gulp-jasmine'); +const gulp = require('gulp'); +const eslint = require('gulp-eslint'); +const jasmine = require('gulp-jasmine'); -gulp.task('test', function () { +gulp.task('test', () => { + 'use strict'; return gulp.src('test/**/*.spec.js') .pipe(jasmine()); }); -gulp.task('lint', function () { +gulp.task('lint', ()=> { + 'use strict'; return gulp.src(['src/**/*.js', 'test/**/*.js']) .pipe(eslint()) .pipe(eslint.format()) .pipe(eslint.failAfterError()); }); -gulp.task('build', ['lint', 'test']); +gulp.task('build', gulp.parallel(['lint', 'test'])); diff --git a/package-lock.json b/package-lock.json index f96b005d..4025d25e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -59,6 +59,15 @@ "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=", "dev": true }, + "ansi-colors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", + "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", + "dev": true, + "requires": { + "ansi-wrap": "^0.1.0" + } + }, "ansi-escapes": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", @@ -128,6 +137,15 @@ "integrity": "sha1-7klza2ObTxCLbp5ibG2pkwa0FpI=", "dev": true }, + "append-buffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/append-buffer/-/append-buffer-1.0.2.tgz", + "integrity": "sha1-2CIM9GYIFSXv6lBhTz3mUU36WPE=", + "dev": true, + "requires": { + "buffer-equal": "^1.0.0" + } + }, "archy": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", @@ -149,12 +167,30 @@ "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", "dev": true }, + "arr-filter": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/arr-filter/-/arr-filter-1.1.2.tgz", + "integrity": "sha1-Q/3d0JHo7xGqTEXZzcGOLf8XEe4=", + "dev": true, + "requires": { + "make-iterator": "^1.0.0" + } + }, "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, + "arr-map": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/arr-map/-/arr-map-2.0.2.tgz", + "integrity": "sha1-Onc0X/wc814qkYJWAfnljy4kysQ=", + "dev": true, + "requires": { + "make-iterator": "^1.0.0" + } + }, "arr-union": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", @@ -173,12 +209,66 @@ "integrity": "sha1-p5SvDAWrF1KEbudTofIRoFugxE8=", "dev": true }, + "array-initial": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/array-initial/-/array-initial-1.1.0.tgz", + "integrity": "sha1-L6dLJnOTccOUe9enrcc74zSz15U=", + "dev": true, + "requires": { + "array-slice": "^1.0.0", + "is-number": "^4.0.0" + }, + "dependencies": { + "is-number": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", + "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", + "dev": true + } + } + }, + "array-last": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/array-last/-/array-last-1.3.0.tgz", + "integrity": "sha512-eOCut5rXlI6aCOS7Z7kCplKRKyiFQ6dHFBem4PwlwKeNFk2/XxTrhRh5T9PyaEWGy/NHTZWbY+nsZlNFJu9rYg==", + "dev": true, + "requires": { + "is-number": "^4.0.0" + }, + "dependencies": { + "is-number": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", + "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", + "dev": true + } + } + }, "array-slice": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-1.1.0.tgz", "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==", "dev": true }, + "array-sort": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-sort/-/array-sort-1.0.0.tgz", + "integrity": "sha512-ihLeJkonmdiAsD7vpgN3CRcx2J2S0TiYW+IS/5zHBI7mKUq3ySvBdzzBfD236ubDBQFiiyG3SWCPc+msQ9KoYg==", + "dev": true, + "requires": { + "default-compare": "^1.0.0", + "get-value": "^2.0.6", + "kind-of": "^5.0.2" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, "array-union": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", @@ -221,12 +311,33 @@ "lodash": "^4.17.10" } }, + "async-done": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/async-done/-/async-done-1.3.2.tgz", + "integrity": "sha512-uYkTP8dw2og1tu1nmza1n1CMW0qb8gWWlwqMmLb7MhBVs4BXrFziT6HXUd+/RlRA/i4H9AkofYloUbs1fwMqlw==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.2", + "process-nextick-args": "^2.0.0", + "stream-exhaust": "^1.0.1" + } + }, "async-each": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", "dev": true }, + "async-settle": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-settle/-/async-settle-1.0.0.tgz", + "integrity": "sha1-HQqRS7Aldb7IqPOnTlCA9yssDGs=", + "dev": true, + "requires": { + "async-done": "^1.2.2" + } + }, "atob": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", @@ -250,6 +361,23 @@ "integrity": "sha512-Vg0C9s/REX6/WIXN37UKpv5ZhRi6A4pjHlpkE34+8/a6c2W1Q692n3hmc+SZG5lKRnaExLUbxtJ1SVT+KaCQ/A==", "dev": true }, + "bach": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/bach/-/bach-1.2.0.tgz", + "integrity": "sha1-Szzpa/JxNPeaG0FKUcFONMO9mIA=", + "dev": true, + "requires": { + "arr-filter": "^1.1.1", + "arr-flatten": "^1.0.1", + "arr-map": "^2.0.0", + "array-each": "^1.0.0", + "array-initial": "^1.0.0", + "array-last": "^1.1.1", + "async-done": "^1.2.2", + "async-settle": "^1.0.0", + "now-and-later": "^2.0.0" + } + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -389,6 +517,12 @@ } } }, + "buffer-equal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.0.tgz", + "integrity": "sha1-WWFrSYME1Var1GaWayLu2j7KX74=", + "dev": true + }, "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", @@ -468,6 +602,12 @@ "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", "dev": true }, + "camelcase": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=", + "dev": true + }, "catharsis": { "version": "0.8.10", "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.10.tgz", @@ -565,18 +705,78 @@ "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", "dev": true }, + "cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wrap-ansi": "^2.0.0" + } + }, "clone": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", "dev": true }, + "clone-buffer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz", + "integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg=", + "dev": true + }, "clone-stats": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=", "dev": true }, + "cloneable-readable": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.1.3.tgz", + "integrity": "sha512-2EF8zTQOxYq70Y4XKtorQupqF0m49MBz2/yf5Bj+MHjvpG3Hy7sImifnqD6UA+TKYxeSV+u6qqQPawN5UvnpKQ==", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "process-nextick-args": "^2.0.0", + "readable-stream": "^2.3.5" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -589,6 +789,17 @@ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "dev": true }, + "collection-map": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/collection-map/-/collection-map-1.0.0.tgz", + "integrity": "sha1-rqDwb40mx4DCt1SUOFVEsiVa8Yw=", + "dev": true, + "requires": { + "arr-map": "^2.0.2", + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" + } + }, "collection-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", @@ -685,12 +896,31 @@ "utils-merge": "1.0.1" } }, + "convert-source-map": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", + "integrity": "sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + } + }, "copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", "dev": true }, + "copy-props": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/copy-props/-/copy-props-2.0.4.tgz", + "integrity": "sha512-7cjuUME+p+S3HZlbllgsn2CDwS+5eCCX16qBgNC4jgSTf49qR1VKy/Zhl400m0IQXl/bPGEVqncgUUMjrr4s8A==", + "dev": true, + "requires": { + "each-props": "^1.3.0", + "is-plain-object": "^2.0.1" + } + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -732,6 +962,12 @@ "ms": "2.0.0" } }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, "decode-uri-component": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", @@ -744,13 +980,36 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, - "defaults": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", - "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", + "default-compare": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/default-compare/-/default-compare-1.0.0.tgz", + "integrity": "sha512-QWfXlM0EkAbqOCbD/6HjdwT19j7WCkMyiRhWilc4H9/5h/RzTF9gv5LYh1+CmDV5d1rki6KAWLtQale0xt20eQ==", + "dev": true, + "requires": { + "kind-of": "^5.0.2" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "default-resolution": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/default-resolution/-/default-resolution-2.0.0.tgz", + "integrity": "sha1-vLgrqnKtebQmp2cy8aga1t8m1oQ=", + "dev": true + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", "dev": true, "requires": { - "clone": "^1.0.2" + "object-keys": "^1.0.12" } }, "define-property": { @@ -800,12 +1059,6 @@ "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", "dev": true }, - "deprecated": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/deprecated/-/deprecated-0.0.1.tgz", - "integrity": "sha1-+cmvVGSvoeepcUWKi97yqpTVuxk=", - "dev": true - }, "destroy": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", @@ -842,6 +1095,60 @@ "readable-stream": "~1.1.9" } }, + "duplexify": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz", + "integrity": "sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==", + "dev": true, + "requires": { + "end-of-stream": "^1.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.0.0", + "stream-shift": "^1.0.0" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "each-props": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/each-props/-/each-props-1.3.2.tgz", + "integrity": "sha512-vV0Hem3zAGkJAyU7JSjixeU66rwdynTAa1vofCrSA5fEln+m67Az9CcnkVD776/fsN/UjIWmBDoNRS6t6G9RfA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.1", + "object.defaults": "^1.1.0" + } + }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -855,23 +1162,52 @@ "dev": true }, "end-of-stream": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-0.1.5.tgz", - "integrity": "sha1-jhdyBsPICDfYVjLouTWd/osvbq8=", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", "dev": true, "requires": { - "once": "~1.3.0" - }, - "dependencies": { - "once": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", - "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", - "dev": true, - "requires": { - "wrappy": "1" - } - } + "once": "^1.4.0" + } + }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "es-abstract": { + "version": "1.18.0-next.1", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0-next.1.tgz", + "integrity": "sha512-I4UGspA0wpZXWENrdA0uHbnhte683t3qT/1VFH9aX2dA5PPSf6QW5HHXf5HImaqPmjXaVeVk4RGWnaylmV7uAA==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.2.2", + "is-negative-zero": "^2.0.0", + "is-regex": "^1.1.1", + "object-inspect": "^1.8.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.1", + "string.prototype.trimend": "^1.0.1", + "string.prototype.trimstart": "^1.0.1" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" } }, "es5-ext": { @@ -1366,22 +1702,37 @@ "unpipe": "~1.0.0" } }, - "find-index": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/find-index/-/find-index-0.1.1.tgz", - "integrity": "sha1-Z101iyyjiS15Whq0cjL4tuLg3eQ=", - "dev": true + "find-up": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "dev": true, + "requires": { + "path-exists": "^2.0.0", + "pinkie-promise": "^2.0.0" + } }, "findup-sync": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-2.0.0.tgz", - "integrity": "sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-3.0.0.tgz", + "integrity": "sha512-YbffarhcicEhOrm4CtrwdKBdCuz576RLdhJDsIfvNtxUuhdRet1qZcsMjqbePtAseKdAnDyM/IyXbu7PRPRLYg==", "dev": true, "requires": { "detect-file": "^1.0.0", - "is-glob": "^3.1.0", + "is-glob": "^4.0.0", "micromatch": "^3.0.4", "resolve-dir": "^1.0.1" + }, + "dependencies": { + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + } } }, "fined": { @@ -1397,12 +1748,6 @@ "parse-filepath": "^1.0.1" } }, - "first-chunk-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz", - "integrity": "sha1-Wb+1DNkF9g18OUzT2ayqtOatk04=", - "dev": true - }, "flagged-respawn": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz", @@ -1421,14 +1766,56 @@ "write": "^0.2.1" } }, - "for-in": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true - }, - "for-own": { - "version": "1.0.0", + "flush-write-stream": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz", + "integrity": "sha512-3Z4XhFZ3992uIq0XOqb9AreonueSYphE6oYbpt5+3u06JWklbsPkNv3ZKkP9Bz/r+1MWCaMoSQ28P85+1Yc77w==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "readable-stream": "^2.3.6" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "dev": true + }, + "for-own": { + "version": "1.0.0", "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz", "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", "dev": true, @@ -1468,6 +1855,16 @@ "universalify": "^0.1.0" } }, + "fs-mkdirp-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz", + "integrity": "sha1-C3gV/DIBxqaeFNuYzgmMFpNSWes=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "through2": "^2.0.3" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -2022,14 +2419,11 @@ } } }, - "gaze": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz", - "integrity": "sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8=", - "dev": true, - "requires": { - "globule": "~0.1.0" - } + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true }, "generate-function": { "version": "2.3.1", @@ -2049,6 +2443,12 @@ "is-property": "^1.0.0" } }, + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "dev": true + }, "get-value": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", @@ -2095,80 +2495,68 @@ } }, "glob-stream": { - "version": "3.1.18", - "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-3.1.18.tgz", - "integrity": "sha1-kXCl8St5Awb9/lmPMT+PeVT9FDs=", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-6.1.0.tgz", + "integrity": "sha1-cEXJlBOz65SIjYOrRtC0BMx73eQ=", "dev": true, "requires": { - "glob": "^4.3.1", - "glob2base": "^0.0.12", - "minimatch": "^2.0.1", - "ordered-read-streams": "^0.1.0", - "through2": "^0.6.1", - "unique-stream": "^1.0.0" + "extend": "^3.0.0", + "glob": "^7.1.1", + "glob-parent": "^3.1.0", + "is-negated-glob": "^1.0.0", + "ordered-read-streams": "^1.0.0", + "pumpify": "^1.3.5", + "readable-stream": "^2.1.5", + "remove-trailing-separator": "^1.0.1", + "to-absolute-glob": "^2.0.0", + "unique-stream": "^2.0.2" }, "dependencies": { - "glob": { - "version": "4.5.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", - "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", - "dev": true, - "requires": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^2.0.1", - "once": "^1.3.0" - } - }, - "minimatch": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", - "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", - "dev": true, - "requires": { - "brace-expansion": "^1.0.0" - } + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true }, "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", "dev": true, "requires": { "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" } }, - "through2": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { - "readable-stream": ">=1.0.33-1 <1.1.0-0", - "xtend": ">=4.0.0 <4.1.0-0" + "safe-buffer": "~5.1.0" } } } }, "glob-watcher": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.6.tgz", - "integrity": "sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs=", - "dev": true, - "requires": { - "gaze": "^0.5.1" - } - }, - "glob2base": { - "version": "0.0.12", - "resolved": "https://registry.npmjs.org/glob2base/-/glob2base-0.0.12.tgz", - "integrity": "sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY=", + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-5.0.5.tgz", + "integrity": "sha512-zOZgGGEHPklZNjZQaZ9f41i7F2YwE+tS5ZHrDhbBCk3stwahn5vQxnFmBJZHoYdusR6R1bLSXeGUy/BhctwKzw==", "dev": true, "requires": { - "find-index": "^0.1.1" + "anymatch": "^2.0.0", + "async-done": "^1.2.0", + "chokidar": "^2.0.0", + "is-negated-glob": "^1.0.0", + "just-debounce": "^1.0.0", + "normalize-path": "^3.0.0", + "object.defaults": "^1.1.0" } }, "global-modules": { @@ -2214,58 +2602,6 @@ "pinkie-promise": "^2.0.0" } }, - "globule": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/globule/-/globule-0.1.0.tgz", - "integrity": "sha1-2cjt3h2nnRJaFRt5UzuXhnY0auU=", - "dev": true, - "requires": { - "glob": "~3.1.21", - "lodash": "~1.0.1", - "minimatch": "~0.2.11" - }, - "dependencies": { - "glob": { - "version": "3.1.21", - "resolved": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz", - "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", - "dev": true, - "requires": { - "graceful-fs": "~1.2.0", - "inherits": "1", - "minimatch": "~0.2.11" - } - }, - "graceful-fs": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz", - "integrity": "sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=", - "dev": true - }, - "inherits": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-1.0.2.tgz", - "integrity": "sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js=", - "dev": true - }, - "lodash": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-1.0.2.tgz", - "integrity": "sha1-j1dWDIO1n8JwvT1WG2kAQ0MOJVE=", - "dev": true - }, - "minimatch": { - "version": "0.2.14", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", - "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", - "dev": true, - "requires": { - "lru-cache": "2", - "sigmund": "~1.0.0" - } - } - } - }, "glogg": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.2.tgz", @@ -2282,24 +2618,49 @@ "dev": true }, "gulp": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/gulp/-/gulp-3.9.1.tgz", - "integrity": "sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ=", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/gulp/-/gulp-4.0.2.tgz", + "integrity": "sha512-dvEs27SCZt2ibF29xYgmnwwCYZxdxhQ/+LFWlbAW8y7jt68L/65402Lz3+CKy0Ov4rOs+NERmDq7YlZaDqUIfA==", "dev": true, "requires": { - "archy": "^1.0.0", - "chalk": "^1.0.0", - "deprecated": "^0.0.1", - "gulp-util": "^3.0.0", - "interpret": "^1.0.0", - "liftoff": "^2.1.0", - "minimist": "^1.1.0", - "orchestrator": "^0.3.0", - "pretty-hrtime": "^1.0.0", - "semver": "^4.1.0", - "tildify": "^1.0.0", - "v8flags": "^2.0.2", - "vinyl-fs": "^0.3.0" + "glob-watcher": "^5.0.3", + "gulp-cli": "^2.2.0", + "undertaker": "^1.2.1", + "vinyl-fs": "^3.0.0" + }, + "dependencies": { + "gulp-cli": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/gulp-cli/-/gulp-cli-2.3.0.tgz", + "integrity": "sha512-zzGBl5fHo0EKSXsHzjspp3y5CONegCm8ErO5Qh0UzFzk2y4tMvzLWhoDokADbarfZRL2pGpRp7yt6gfJX4ph7A==", + "dev": true, + "requires": { + "ansi-colors": "^1.0.1", + "archy": "^1.0.0", + "array-sort": "^1.0.0", + "color-support": "^1.1.3", + "concat-stream": "^1.6.0", + "copy-props": "^2.0.1", + "fancy-log": "^1.3.2", + "gulplog": "^1.0.0", + "interpret": "^1.4.0", + "isobject": "^3.0.1", + "liftoff": "^3.1.0", + "matchdep": "^2.0.0", + "mute-stdout": "^1.0.0", + "pretty-hrtime": "^1.0.0", + "replace-homedir": "^1.0.0", + "semver-greatest-satisfied-range": "^1.1.0", + "v8flags": "^3.2.0", + "yargs": "^7.1.0" + } + }, + "interpret": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", + "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==", + "dev": true + } } }, "gulp-eslint": { @@ -2369,6 +2730,15 @@ "glogg": "^1.0.0" } }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, "has-ansi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", @@ -2387,6 +2757,12 @@ "sparkles": "^1.0.0" } }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true + }, "has-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", @@ -2428,6 +2804,12 @@ "parse-passwd": "^1.0.0" } }, + "hosted-git-info": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", + "dev": true + }, "http-auth": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/http-auth/-/http-auth-3.1.3.tgz", @@ -2539,6 +2921,12 @@ "integrity": "sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw==", "dev": true }, + "invert-kv": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", + "dev": true + }, "is-absolute": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz", @@ -2569,6 +2957,12 @@ } } }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, "is-binary-path": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", @@ -2584,6 +2978,12 @@ "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, + "is-callable": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.2.tgz", + "integrity": "sha512-dnMqspv5nU3LoewK2N/y7KLtxtakvTuaCsU9FU50/QDmdbHNy/4/JuRtMHqRU22o3q+W89YQndQEeCVwK+3qrA==", + "dev": true + }, "is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", @@ -2604,6 +3004,12 @@ } } }, + "is-date-object": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", + "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", + "dev": true + }, "is-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", @@ -2681,6 +3087,18 @@ "xtend": "^4.0.0" } }, + "is-negated-glob": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-negated-glob/-/is-negated-glob-1.0.0.tgz", + "integrity": "sha1-aRC8pdqMleeEtXUbl2z1oQ/uNtI=", + "dev": true + }, + "is-negative-zero": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.0.tgz", + "integrity": "sha1-lVOxIbD6wohp2p7UWeIMdUN4hGE=", + "dev": true + }, "is-number": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", @@ -2722,6 +3140,15 @@ "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", "dev": true }, + "is-regex": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", + "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", + "dev": true, + "requires": { + "has-symbols": "^1.0.1" + } + }, "is-relative": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-1.0.0.tgz", @@ -2737,6 +3164,15 @@ "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, + "is-symbol": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", + "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", + "dev": true, + "requires": { + "has-symbols": "^1.0.1" + } + }, "is-unc-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-1.0.0.tgz", @@ -2752,6 +3188,12 @@ "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", "dev": true }, + "is-valid-glob": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-valid-glob/-/is-valid-glob-1.0.0.tgz", + "integrity": "sha1-Kb8+/3Ab4tTTFdusw5vDn+j2Aao=", + "dev": true + }, "is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", @@ -2863,6 +3305,12 @@ "jsonify": "~0.0.0" } }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, "jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -2884,6 +3332,12 @@ "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", "dev": true }, + "just-debounce": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/just-debounce/-/just-debounce-1.0.0.tgz", + "integrity": "sha1-h/zPrv/AtozRnVX2cilD+SnqNeo=", + "dev": true + }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", @@ -2899,6 +3353,75 @@ "graceful-fs": "^4.1.9" } }, + "last-run": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/last-run/-/last-run-1.1.1.tgz", + "integrity": "sha1-RblpQsF7HHnHchmCWbqUO+v4yls=", + "dev": true, + "requires": { + "default-resolution": "^2.0.0", + "es6-weak-map": "^2.0.1" + } + }, + "lazystream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lazystream/-/lazystream-1.0.0.tgz", + "integrity": "sha1-9plf4PggOS9hOWvolGJAe7dxaOQ=", + "dev": true, + "requires": { + "readable-stream": "^2.0.5" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "lcid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "dev": true, + "requires": { + "invert-kv": "^1.0.0" + } + }, + "lead": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lead/-/lead-1.0.0.tgz", + "integrity": "sha1-bxT5mje+Op3XhPVJVpDlkDRm7kI=", + "dev": true, + "requires": { + "flush-write-stream": "^1.0.2" + } + }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", @@ -2910,13 +3433,13 @@ } }, "liftoff": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-2.5.0.tgz", - "integrity": "sha1-IAkpG7Mc6oYbvxCnwVooyvdcMew=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-3.1.0.tgz", + "integrity": "sha512-DlIPlJUkCV0Ips2zf2pJP0unEoT1kwYhiiPUGF3s/jtxTCjziNLoiVVh+jqWOWeFi6mmwQ5fNxvAUyPad4Dfog==", "dev": true, "requires": { "extend": "^3.0.0", - "findup-sync": "^2.0.0", + "findup-sync": "^3.0.0", "fined": "^1.0.1", "flagged-respawn": "^1.0.0", "is-plain-object": "^2.0.4", @@ -2954,6 +3477,19 @@ } } }, + "load-json-file": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "strip-bom": "^2.0.0" + } + }, "lodash": { "version": "4.17.11", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", @@ -3079,12 +3615,6 @@ "lodash.escape": "^3.0.0" } }, - "lru-cache": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", - "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", - "dev": true - }, "make-iterator": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/make-iterator/-/make-iterator-1.0.1.tgz", @@ -3121,20 +3651,46 @@ "integrity": "sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg==", "dev": true }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "matchdep": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/matchdep/-/matchdep-2.0.0.tgz", + "integrity": "sha1-xvNINKDY28OzfCfui7yyfHd1WC4=", "dev": true, "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", + "findup-sync": "^2.0.0", + "micromatch": "^3.0.4", + "resolve": "^1.4.0", + "stack-trace": "0.0.10" + }, + "dependencies": { + "findup-sync": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-2.0.0.tgz", + "integrity": "sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw=", + "dev": true, + "requires": { + "detect-file": "^1.0.0", + "is-glob": "^3.1.0", + "micromatch": "^3.0.4", + "resolve-dir": "^1.0.1" + } + } + } + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", "nanomatch": "^1.2.9", "object.pick": "^1.3.0", "regex-not": "^1.0.0", @@ -3244,6 +3800,12 @@ "duplexer2": "0.0.2" } }, + "mute-stdout": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mute-stdout/-/mute-stdout-1.0.1.tgz", + "integrity": "sha512-kDcwXR4PS7caBpuRYYBUz9iVixUk3anO3f5OYFiIPwK/20vCzKCHyKoulbiDY1S53zD2bxUpxN/IJ+TnXjfvxg==", + "dev": true + }, "mute-stream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", @@ -3276,12 +3838,6 @@ "to-regex": "^3.0.1" } }, - "natives": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.6.tgz", - "integrity": "sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA==", - "dev": true - }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -3300,6 +3856,18 @@ "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", "dev": true }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, "normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -3318,6 +3886,15 @@ "sort-keys": "^1.0.0" } }, + "now-and-later": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/now-and-later/-/now-and-later-2.0.1.tgz", + "integrity": "sha512-KGvQ0cB70AQfg107Xvs/Fbu+dGmZoTRJp2TaPwcwQm3/7PteUyN2BCgk8KBMPGBUXZdVwyWS8fDCGFygBm19UQ==", + "dev": true, + "requires": { + "once": "^1.3.2" + } + }, "number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", @@ -3361,6 +3938,18 @@ } } }, + "object-inspect": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz", + "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==", + "dev": true + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + }, "object-visit": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", @@ -3370,6 +3959,18 @@ "isobject": "^3.0.0" } }, + "object.assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.1.tgz", + "integrity": "sha512-VT/cxmx5yaoHSOTSyrCygIDFco+RsibY2NM0a4RdEeY/4KgqezwFtK1yr3U67xYhqJSlASm2pKhLVzPj2lr4bA==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.18.0-next.0", + "has-symbols": "^1.0.1", + "object-keys": "^1.1.1" + } + }, "object.defaults": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz", @@ -3401,6 +4002,16 @@ "isobject": "^3.0.1" } }, + "object.reduce": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object.reduce/-/object.reduce-1.0.1.tgz", + "integrity": "sha1-b+NI8qx/oPlcpiEiZZkJaCW7A60=", + "dev": true, + "requires": { + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" + } + }, "on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", @@ -3454,29 +4065,62 @@ "wordwrap": "~1.0.0" } }, - "orchestrator": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/orchestrator/-/orchestrator-0.3.8.tgz", - "integrity": "sha1-FOfp4nZPcxX7rBhOUGx6pt+UrX4=", + "ordered-read-streams": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz", + "integrity": "sha1-d8DLN8QVJdZBZtmQ/61+xqDhNj4=", "dev": true, "requires": { - "end-of-stream": "~0.1.5", - "sequencify": "~0.0.7", - "stream-consume": "~0.1.0" + "readable-stream": "^2.0.1" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } } }, - "ordered-read-streams": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz", - "integrity": "sha1-/VZamvjrRHO6abbtijQ1LLVS8SY=", - "dev": true - }, "os-homedir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "dev": true }, + "os-locale": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", + "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", + "dev": true, + "requires": { + "lcid": "^1.0.0" + } + }, "parse-filepath": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz", @@ -3488,6 +4132,15 @@ "path-root": "^0.1.1" } }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "dev": true, + "requires": { + "error-ex": "^1.2.0" + } + }, "parse-node-version": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz", @@ -3518,6 +4171,15 @@ "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", "dev": true }, + "path-exists": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "dev": true, + "requires": { + "pinkie-promise": "^2.0.0" + } + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -3551,6 +4213,17 @@ "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=", "dev": true }, + "path-type": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", + "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, "pause-stream": { "version": "0.0.11", "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", @@ -3629,6 +4302,27 @@ "integrity": "sha1-o/3xvvtzD5UZZYcqwvYHTGFHelY=", "dev": true }, + "pump": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", + "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "pumpify": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.5.1.tgz", + "integrity": "sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ==", + "dev": true, + "requires": { + "duplexify": "^3.6.0", + "inherits": "^2.0.3", + "pump": "^2.0.0" + } + }, "query-string": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/query-string/-/query-string-4.3.4.tgz", @@ -3645,6 +4339,27 @@ "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", "dev": true }, + "read-pkg": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", + "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "dev": true, + "requires": { + "load-json-file": "^1.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^1.0.0" + } + }, + "read-pkg-up": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", + "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", + "dev": true, + "requires": { + "find-up": "^1.0.0", + "read-pkg": "^1.0.0" + } + }, "readable-stream": { "version": "1.1.14", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", @@ -3730,6 +4445,27 @@ "safe-regex": "^1.1.0" } }, + "remove-bom-buffer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/remove-bom-buffer/-/remove-bom-buffer-3.0.0.tgz", + "integrity": "sha512-8v2rWhaakv18qcvNeli2mZ/TMTL2nEyAKRvzo1WtnZBl15SHyEhrCu2/xKlJyUFKHiHgfXIyuY6g2dObJJycXQ==", + "dev": true, + "requires": { + "is-buffer": "^1.1.5", + "is-utf8": "^0.2.1" + } + }, + "remove-bom-stream": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/remove-bom-stream/-/remove-bom-stream-1.2.0.tgz", + "integrity": "sha1-BfGlk/FuQuH7kOv1nejlaVJflSM=", + "dev": true, + "requires": { + "remove-bom-buffer": "^3.0.0", + "safe-buffer": "^5.1.0", + "through2": "^2.0.3" + } + }, "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", @@ -3763,6 +4499,29 @@ "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", "dev": true }, + "replace-homedir": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/replace-homedir/-/replace-homedir-1.0.0.tgz", + "integrity": "sha1-6H9tUTuSjd6AgmDBK+f+xv9ueYw=", + "dev": true, + "requires": { + "homedir-polyfill": "^1.0.1", + "is-absolute": "^1.0.0", + "remove-trailing-separator": "^1.1.0" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true + }, "require-uncached": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", @@ -3807,6 +4566,15 @@ "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", "dev": true }, + "resolve-options": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/resolve-options/-/resolve-options-1.1.0.tgz", + "integrity": "sha1-MrueOcBtZzONyTeMDW1gdFZq0TE=", + "dev": true, + "requires": { + "value-or-function": "^3.0.0" + } + }, "resolve-url": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", @@ -3869,11 +4637,20 @@ } }, "semver": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", - "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=", + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", "dev": true }, + "semver-greatest-satisfied-range": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/semver-greatest-satisfied-range/-/semver-greatest-satisfied-range-1.1.0.tgz", + "integrity": "sha1-E+jCZYq5aRywzXEJMkAoDTb3els=", + "dev": true, + "requires": { + "sver-compat": "^1.5.0" + } + }, "send": { "version": "0.17.1", "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", @@ -3903,12 +4680,6 @@ } } }, - "sequencify": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/sequencify/-/sequencify-0.0.7.tgz", - "integrity": "sha1-kM/xnQLgcCf9dn9erT57ldHnOAw=", - "dev": true - }, "serve-index": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", @@ -3950,6 +4721,12 @@ } } }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, "set-value": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", @@ -3990,12 +4767,6 @@ "rechoir": "^0.6.2" } }, - "sigmund": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", - "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", - "dev": true - }, "slice-ansi": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", @@ -4149,6 +4920,38 @@ "integrity": "sha512-dSO0DDYUahUt/0/pD/Is3VIm5TGJjludZ0HVymmhYF6eNA53PVLhnUk0znSYbH8IYBuJdCE+1luR22jNLMaQdw==", "dev": true }, + "spdx-correct": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz", + "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==", + "dev": true, + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", + "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==", + "dev": true + }, + "spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "dev": true, + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.6.tgz", + "integrity": "sha512-+orQK83kyMva3WyPf59k1+Y525csj5JejicWut55zeTWANuN17qSiSLUXWtzHeNWORSvT7GLDJ/E/XiIWoXBTw==", + "dev": true + }, "split": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", @@ -4173,6 +4976,12 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, + "stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=", + "dev": true + }, "static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", @@ -4209,10 +5018,16 @@ "duplexer": "~0.1.1" } }, - "stream-consume": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.1.tgz", - "integrity": "sha512-tNa3hzgkjEP7XbCkbRXe1jpg+ievoa0O4SCFlMOYEscGSS4JJsckGL8swUyAa/ApGU3Ae4t6Honor4HhL+tRyg==", + "stream-exhaust": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/stream-exhaust/-/stream-exhaust-1.0.2.tgz", + "integrity": "sha512-b/qaq/GlBK5xaq1yrK9/zFcyRSTNxmcZwFLGSTG0mXgZl/4Z6GgiyYOXOvY7N3eEvFRAG1bkDRz5EPGSvPYQlw==", + "dev": true + }, + "stream-shift": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz", + "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==", "dev": true }, "strict-uri-encode": { @@ -4232,6 +5047,68 @@ "strip-ansi": "^3.0.0" } }, + "string.prototype.trimend": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz", + "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + }, + "dependencies": { + "es-abstract": { + "version": "1.17.7", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.7.tgz", + "integrity": "sha512-VBl/gnfcJ7OercKA9MVaegWsBHFjV492syMudcnQZvt/Dw8ezpcOHYZXa/J96O8vx+g4x65YKhxOwDUh63aS5g==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.2.2", + "is-regex": "^1.1.1", + "object-inspect": "^1.8.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.1", + "string.prototype.trimend": "^1.0.1", + "string.prototype.trimstart": "^1.0.1" + } + } + } + }, + "string.prototype.trimstart": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz", + "integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + }, + "dependencies": { + "es-abstract": { + "version": "1.17.7", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.7.tgz", + "integrity": "sha512-VBl/gnfcJ7OercKA9MVaegWsBHFjV492syMudcnQZvt/Dw8ezpcOHYZXa/J96O8vx+g4x65YKhxOwDUh63aS5g==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.2.2", + "is-regex": "^1.1.1", + "object-inspect": "^1.8.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.1", + "string.prototype.trimend": "^1.0.1", + "string.prototype.trimstart": "^1.0.1" + } + } + } + }, "string_decoder": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", @@ -4248,12 +5125,11 @@ } }, "strip-bom": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz", - "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", "dev": true, "requires": { - "first-chunk-stream": "^1.0.0", "is-utf8": "^0.2.0" } }, @@ -4284,6 +5160,16 @@ "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", "dev": true }, + "sver-compat": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/sver-compat/-/sver-compat-1.5.0.tgz", + "integrity": "sha1-PPh9/rTQe0o/FIJ7wYaz/QxkXNg=", + "dev": true, + "requires": { + "es6-iterator": "^2.0.1", + "es6-symbol": "^3.1.1" + } + }, "table": { "version": "3.8.3", "resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz", @@ -4391,13 +5277,14 @@ } } }, - "tildify": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/tildify/-/tildify-1.2.0.tgz", - "integrity": "sha1-3OwD9V3Km3qj5bBPIYF+tW5jWIo=", + "through2-filter": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/through2-filter/-/through2-filter-3.0.0.tgz", + "integrity": "sha512-jaRjI2WxN3W1V8/FMZ9HKIBXixtiqs3SQSX4/YGIiP3gL6djW48VoZq9tDqeCWs3MT8YY5wb/zli8VW8snY1CA==", "dev": true, "requires": { - "os-homedir": "^1.0.0" + "through2": "~2.0.0", + "xtend": "~4.0.0" } }, "time-stamp": { @@ -4406,6 +5293,16 @@ "integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=", "dev": true }, + "to-absolute-glob": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz", + "integrity": "sha1-GGX0PZ50sIItufFFt4z/fQ98hJs=", + "dev": true, + "requires": { + "is-absolute": "^1.0.0", + "is-negated-glob": "^1.0.0" + } + }, "to-object-path": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", @@ -4448,6 +5345,15 @@ "repeat-string": "^1.6.1" } }, + "to-through": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-through/-/to-through-2.0.0.tgz", + "integrity": "sha1-/JKtq6ByZHvAtn1rA2ZKoZUJOvY=", + "dev": true, + "requires": { + "through2": "^2.0.3" + } + }, "toidentifier": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", @@ -4496,6 +5402,38 @@ "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=", "dev": true }, + "undertaker": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.3.0.tgz", + "integrity": "sha512-/RXwi5m/Mu3H6IHQGww3GNt1PNXlbeCuclF2QYR14L/2CHPz3DFZkvB5hZ0N/QUkiXWCACML2jXViIQEQc2MLg==", + "dev": true, + "requires": { + "arr-flatten": "^1.0.1", + "arr-map": "^2.0.0", + "bach": "^1.0.0", + "collection-map": "^1.0.0", + "es6-weak-map": "^2.0.1", + "fast-levenshtein": "^1.0.0", + "last-run": "^1.1.0", + "object.defaults": "^1.0.0", + "object.reduce": "^1.0.0", + "undertaker-registry": "^1.0.0" + }, + "dependencies": { + "fast-levenshtein": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-1.1.4.tgz", + "integrity": "sha1-5qdUzI8V5YmHqpy9J69m/W9OWvk=", + "dev": true + } + } + }, + "undertaker-registry": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/undertaker-registry/-/undertaker-registry-1.0.1.tgz", + "integrity": "sha1-XkvaMI5KiirlhPm5pDWaSZglzFA=", + "dev": true + }, "union-value": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", @@ -4509,10 +5447,14 @@ } }, "unique-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz", - "integrity": "sha1-1ZpKdUJ0R9mqbJHnAmP40mpLEEs=", - "dev": true + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-2.3.1.tgz", + "integrity": "sha512-2nY4TnBE70yoxHkDli7DMazpWiP7xMdCYqU2nBRO0UB+ZpEkGsSija7MvmvnZFUeC+mrgiUfcHSr3LmRFIg4+A==", + "dev": true, + "requires": { + "json-stable-stringify-without-jsonify": "^1.0.1", + "through2-filter": "^3.0.0" + } }, "universalify": { "version": "0.1.2", @@ -4596,12 +5538,6 @@ "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", "dev": true }, - "user-home": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz", - "integrity": "sha1-K1viOjK2Onyd640PKNSFcko98ZA=", - "dev": true - }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -4621,14 +5557,30 @@ "dev": true }, "v8flags": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-2.1.1.tgz", - "integrity": "sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ=", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.2.0.tgz", + "integrity": "sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==", "dev": true, "requires": { - "user-home": "^1.1.1" + "homedir-polyfill": "^1.0.1" } }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "requires": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "value-or-function": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/value-or-function/-/value-or-function-3.0.0.tgz", + "integrity": "sha1-HCQ6ULWVwb5Up1S/7OhWO5/42BM=", + "dev": true + }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -4647,66 +5599,148 @@ } }, "vinyl-fs": { - "version": "0.3.14", - "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-0.3.14.tgz", - "integrity": "sha1-mmhRzhysHBzqX+hsCTHWIMLPqeY=", - "dev": true, - "requires": { - "defaults": "^1.0.0", - "glob-stream": "^3.1.5", - "glob-watcher": "^0.0.6", - "graceful-fs": "^3.0.0", - "mkdirp": "^0.5.0", - "strip-bom": "^1.0.0", - "through2": "^0.6.1", - "vinyl": "^0.4.0" + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-3.0.3.tgz", + "integrity": "sha512-vIu34EkyNyJxmP0jscNzWBSygh7VWhqun6RmqVfXePrOwi9lhvRs//dOaGOTRUQr4tx7/zd26Tk5WeSVZitgng==", + "dev": true, + "requires": { + "fs-mkdirp-stream": "^1.0.0", + "glob-stream": "^6.1.0", + "graceful-fs": "^4.0.0", + "is-valid-glob": "^1.0.0", + "lazystream": "^1.0.0", + "lead": "^1.0.0", + "object.assign": "^4.0.4", + "pumpify": "^1.3.5", + "readable-stream": "^2.3.3", + "remove-bom-buffer": "^3.0.0", + "remove-bom-stream": "^1.2.0", + "resolve-options": "^1.1.0", + "through2": "^2.0.0", + "to-through": "^2.0.0", + "value-or-function": "^3.0.0", + "vinyl": "^2.0.0", + "vinyl-sourcemap": "^1.1.0" }, "dependencies": { "clone": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz", - "integrity": "sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8=", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=", + "dev": true + }, + "clone-stats": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", + "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, - "graceful-fs": { - "version": "3.0.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", - "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", "dev": true, "requires": { - "natives": "^1.1.0" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" } }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "replace-ext": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.1.tgz", + "integrity": "sha512-yD5BHCe7quCgBph4rMQ+0KkIRKwWCrHDOX1p1Gp6HwjPM5kVoCdKGNhN7ydqqsX6lJEnQDKZ/tFMiEdQ1dvPEw==", + "dev": true + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" + "safe-buffer": "~5.1.0" + } + }, + "vinyl": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.1.tgz", + "integrity": "sha512-LII3bXRFBZLlezoG5FfZVcXflZgWP/4dCwKtxd5ky9+LOtM4CS3bIRQsmR1KMnMW07jpE8fqR2lcxPZ+8sJIcw==", + "dev": true, + "requires": { + "clone": "^2.1.1", + "clone-buffer": "^1.0.0", + "clone-stats": "^1.0.0", + "cloneable-readable": "^1.0.0", + "remove-trailing-separator": "^1.0.1", + "replace-ext": "^1.0.0" } + } + } + }, + "vinyl-sourcemap": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/vinyl-sourcemap/-/vinyl-sourcemap-1.1.0.tgz", + "integrity": "sha1-kqgAWTo4cDqM2xHYswCtS+Y7PhY=", + "dev": true, + "requires": { + "append-buffer": "^1.0.2", + "convert-source-map": "^1.5.0", + "graceful-fs": "^4.1.6", + "normalize-path": "^2.1.1", + "now-and-later": "^2.0.0", + "remove-bom-buffer": "^3.0.0", + "vinyl": "^2.0.0" + }, + "dependencies": { + "clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=", + "dev": true + }, + "clone-stats": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", + "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=", + "dev": true }, - "through2": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true, "requires": { - "readable-stream": ">=1.0.33-1 <1.1.0-0", - "xtend": ">=4.0.0 <4.1.0-0" + "remove-trailing-separator": "^1.0.1" } }, + "replace-ext": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.1.tgz", + "integrity": "sha512-yD5BHCe7quCgBph4rMQ+0KkIRKwWCrHDOX1p1Gp6HwjPM5kVoCdKGNhN7ydqqsX6lJEnQDKZ/tFMiEdQ1dvPEw==", + "dev": true + }, "vinyl": { - "version": "0.4.6", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz", - "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.1.tgz", + "integrity": "sha512-LII3bXRFBZLlezoG5FfZVcXflZgWP/4dCwKtxd5ky9+LOtM4CS3bIRQsmR1KMnMW07jpE8fqR2lcxPZ+8sJIcw==", "dev": true, "requires": { - "clone": "^0.2.0", - "clone-stats": "^0.0.1" + "clone": "^2.1.1", + "clone-buffer": "^1.0.0", + "clone-stats": "^1.0.0", + "cloneable-readable": "^1.0.0", + "remove-trailing-separator": "^1.0.1", + "replace-ext": "^1.0.0" } } } @@ -4737,12 +5771,28 @@ "isexe": "^2.0.0" } }, + "which-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz", + "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=", + "dev": true + }, "wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", "dev": true }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + } + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", @@ -4769,6 +5819,43 @@ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", "dev": true + }, + "y18n": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", + "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=", + "dev": true + }, + "yargs": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-7.1.1.tgz", + "integrity": "sha512-huO4Fr1f9PmiJJdll5kwoS2e4GqzGSsMT3PPMpOwoVkOK8ckqAewMTZyA6LXVQWflleb/Z8oPBEvNsMft0XE+g==", + "dev": true, + "requires": { + "camelcase": "^3.0.0", + "cliui": "^3.2.0", + "decamelize": "^1.1.1", + "get-caller-file": "^1.0.1", + "os-locale": "^1.4.0", + "read-pkg-up": "^1.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^1.0.2", + "which-module": "^1.0.0", + "y18n": "^3.2.1", + "yargs-parser": "5.0.0-security.0" + } + }, + "yargs-parser": { + "version": "5.0.0-security.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-5.0.0-security.0.tgz", + "integrity": "sha512-T69y4Ps64LNesYxeYGYPvfoMTt/7y1XtfpIslUeK4um+9Hu7hlGoRtaDLvdXb7+/tfq4opVa2HRY5xGip022rQ==", + "dev": true, + "requires": { + "camelcase": "^3.0.0", + "object.assign": "^4.1.0" + } } } } diff --git a/package.json b/package.json index 5e9ea3f4..190c1a5f 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "devDependencies": { "@jeremyckahn/minami": "^1.3.1", "gh-pages": "^1.1.0", - "gulp": "^3.8.10", + "gulp": "^4.0.2", "gulp-eslint": "^3.0.1", "gulp-jasmine": "^2.0.1", "jsdoc": "3.5.5", diff --git a/src/others/minimax.js b/src/others/minimax.js index 7cee9a37..b48fdb0b 100644 --- a/src/others/minimax.js +++ b/src/others/minimax.js @@ -70,7 +70,7 @@ false, depth - 1, alpha, - beta, + beta ); if (result.score > maxResult.score) { @@ -94,7 +94,7 @@ true, depth - 1, alpha, - beta, + beta ); if (result.score < minResult.score) { From b53f82c858e766186e15fdf2572a6823eebbff21 Mon Sep 17 00:00:00 2001 From: Daniel Wasserlauf Date: Wed, 14 Oct 2020 17:36:11 -0400 Subject: [PATCH 596/613] [gulpUpdate]: yarn lock update --- yarn.lock | 1241 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 980 insertions(+), 261 deletions(-) diff --git a/yarn.lock b/yarn.lock index 721b113b..a9b710ec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -50,6 +50,13 @@ ajv@^4.7.0: co "^4.6.0" json-stable-stringify "^1.0.1" +ansi-colors@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-1.1.0.tgz#6374b4dd5d4718ff3ce27a671a3b1cad077132a9" + integrity sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA== + dependencies: + ansi-wrap "^0.1.0" + ansi-escapes@^1.1.0: version "1.4.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" @@ -77,7 +84,7 @@ ansi-styles@^2.2.1: resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" integrity sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4= -ansi-wrap@0.1.0: +ansi-wrap@0.1.0, ansi-wrap@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/ansi-wrap/-/ansi-wrap-0.1.0.tgz#a82250ddb0015e9a27ca82e82ea603bbfa45efaf" integrity sha1-qCJQ3bABXponyoLoLqYDu/pF768= @@ -102,6 +109,13 @@ apache-md5@^1.0.6: resolved "https://registry.yarnpkg.com/apache-md5/-/apache-md5-1.1.2.tgz#ee49736b639b4f108b6e9e626c6da99306b41692" integrity sha1-7klza2ObTxCLbp5ibG2pkwa0FpI= +append-buffer@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/append-buffer/-/append-buffer-1.0.2.tgz#d8220cf466081525efea50614f3de6514dfa58f1" + integrity sha1-2CIM9GYIFSXv6lBhTz3mUU36WPE= + dependencies: + buffer-equal "^1.0.0" + aproba@^1.0.3: version "1.2.0" resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" @@ -132,11 +146,25 @@ arr-diff@^4.0.0: resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" integrity sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA= -arr-flatten@^1.1.0: +arr-filter@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/arr-filter/-/arr-filter-1.1.2.tgz#43fdddd091e8ef11aa4c45d9cdc18e2dff1711ee" + integrity sha1-Q/3d0JHo7xGqTEXZzcGOLf8XEe4= + dependencies: + make-iterator "^1.0.0" + +arr-flatten@^1.0.1, arr-flatten@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" integrity sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg== +arr-map@^2.0.0, arr-map@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/arr-map/-/arr-map-2.0.2.tgz#3a77345ffc1cf35e2a91825601f9e58f2e24cac4" + integrity sha1-Onc0X/wc814qkYJWAfnljy4kysQ= + dependencies: + make-iterator "^1.0.0" + arr-union@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" @@ -147,16 +175,40 @@ array-differ@^1.0.0: resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-1.0.0.tgz#eff52e3758249d33be402b8bb8e564bb2b5d4031" integrity sha1-7/UuN1gknTO+QCuLuOVkuytdQDE= -array-each@^1.0.1: +array-each@^1.0.0, array-each@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/array-each/-/array-each-1.0.1.tgz#a794af0c05ab1752846ee753a1f211a05ba0c44f" integrity sha1-p5SvDAWrF1KEbudTofIRoFugxE8= +array-initial@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/array-initial/-/array-initial-1.1.0.tgz#2fa74b26739371c3947bd7a7adc73be334b3d795" + integrity sha1-L6dLJnOTccOUe9enrcc74zSz15U= + dependencies: + array-slice "^1.0.0" + is-number "^4.0.0" + +array-last@^1.1.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/array-last/-/array-last-1.3.0.tgz#7aa77073fec565ddab2493f5f88185f404a9d336" + integrity sha512-eOCut5rXlI6aCOS7Z7kCplKRKyiFQ6dHFBem4PwlwKeNFk2/XxTrhRh5T9PyaEWGy/NHTZWbY+nsZlNFJu9rYg== + dependencies: + is-number "^4.0.0" + array-slice@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/array-slice/-/array-slice-1.1.0.tgz#e368ea15f89bc7069f7ffb89aec3a6c7d4ac22d4" integrity sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w== +array-sort@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-sort/-/array-sort-1.0.0.tgz#e4c05356453f56f53512a7d1d6123f2c54c0a88a" + integrity sha512-ihLeJkonmdiAsD7vpgN3CRcx2J2S0TiYW+IS/5zHBI7mKUq3ySvBdzzBfD236ubDBQFiiyG3SWCPc+msQ9KoYg== + dependencies: + default-compare "^1.0.0" + get-value "^2.0.6" + kind-of "^5.0.2" + array-union@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" @@ -184,11 +236,28 @@ assign-symbols@^1.0.0: resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c= +async-done@^1.2.0, async-done@^1.2.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/async-done/-/async-done-1.3.2.tgz#5e15aa729962a4b07414f528a88cdf18e0b290a2" + integrity sha512-uYkTP8dw2og1tu1nmza1n1CMW0qb8gWWlwqMmLb7MhBVs4BXrFziT6HXUd+/RlRA/i4H9AkofYloUbs1fwMqlw== + dependencies: + end-of-stream "^1.1.0" + once "^1.3.2" + process-nextick-args "^2.0.0" + stream-exhaust "^1.0.1" + async-each@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.2.tgz#8b8a7ca2a658f927e9f307d6d1a42f4199f0f735" integrity sha512-6xrbvN0MOBKSJDdonmSSz2OwFSgxRaVtBDes26mj9KIGtDo+g9xosFRSC+i1gQh2oAN/tQ62AI/pGZGQjVOiRg== +async-settle@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/async-settle/-/async-settle-1.0.0.tgz#1d0a914bb02575bec8a8f3a74e5080f72b2c0c6b" + integrity sha1-HQqRS7Aldb7IqPOnTlCA9yssDGs= + dependencies: + async-done "^1.2.2" + async@2.6.1: version "2.6.1" resolved "https://registry.yarnpkg.com/async/-/async-2.6.1.tgz#b245a23ca71930044ec53fa46aa00a3e87c6a610" @@ -215,6 +284,21 @@ babylon@7.0.0-beta.19: resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.19.tgz#e928c7e807e970e0536b078ab3e0c48f9e052503" integrity sha512-Vg0C9s/REX6/WIXN37UKpv5ZhRi6A4pjHlpkE34+8/a6c2W1Q692n3hmc+SZG5lKRnaExLUbxtJ1SVT+KaCQ/A== +bach@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/bach/-/bach-1.2.0.tgz#4b3ce96bf27134f79a1b414a51c14e34c3bd9880" + integrity sha1-Szzpa/JxNPeaG0FKUcFONMO9mIA= + dependencies: + arr-filter "^1.1.1" + arr-flatten "^1.0.1" + arr-map "^2.0.0" + array-each "^1.0.0" + array-initial "^1.0.0" + array-last "^1.1.1" + async-done "^1.2.2" + async-settle "^1.0.0" + now-and-later "^2.0.0" + balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" @@ -265,7 +349,7 @@ bluebird@~3.5.0: resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.3.tgz#7d01c6f9616c9a51ab0f8c549a79dfe6ec33efa7" integrity sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw== -brace-expansion@^1.0.0, brace-expansion@^1.1.7: +brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== @@ -289,6 +373,11 @@ braces@^2.3.1, braces@^2.3.2: split-string "^3.0.2" to-regex "^3.0.1" +buffer-equal@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-equal/-/buffer-equal-1.0.0.tgz#59616b498304d556abd466966b22eeda3eca5fbe" + integrity sha1-WWFrSYME1Var1GaWayLu2j7KX74= + buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -328,6 +417,11 @@ callsites@^0.2.0: resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca" integrity sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo= +camelcase@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-3.0.0.tgz#32fc4b9fcdaf845fcdf7e73bb97cac2261f0ab0a" + integrity sha1-MvxLn82vhF/N9+c7uXysImHwqwo= + catharsis@~0.8.9: version "0.8.9" resolved "https://registry.yarnpkg.com/catharsis/-/catharsis-0.8.9.tgz#98cc890ca652dd2ef0e70b37925310ff9e90fc8b" @@ -346,6 +440,25 @@ chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" +chokidar@^2.0.0: + version "2.1.8" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.1.8.tgz#804b3a7b6a99358c3c5c61e71d8728f041cff917" + integrity sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg== + dependencies: + anymatch "^2.0.0" + async-each "^1.0.1" + braces "^2.3.2" + glob-parent "^3.1.0" + inherits "^2.0.3" + is-binary-path "^1.0.0" + is-glob "^4.0.0" + normalize-path "^3.0.0" + path-is-absolute "^1.0.0" + readdirp "^2.2.1" + upath "^1.1.1" + optionalDependencies: + fsevents "^1.2.7" + chokidar@^2.0.4: version "2.1.5" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.1.5.tgz#0ae8434d962281a5f56c72869e79cb6d9d86ad4d" @@ -397,21 +510,49 @@ cli-width@^2.0.0: resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk= +cliui@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d" + integrity sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0= + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + wrap-ansi "^2.0.0" + +clone-buffer@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/clone-buffer/-/clone-buffer-1.0.0.tgz#e3e25b207ac4e701af721e2cb5a16792cac3dc58" + integrity sha1-4+JbIHrE5wGvch4staFnksrD3Fg= + clone-stats@^0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/clone-stats/-/clone-stats-0.0.1.tgz#b88f94a82cf38b8791d58046ea4029ad88ca99d1" integrity sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE= -clone@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/clone/-/clone-0.2.0.tgz#c6126a90ad4f72dbf5acdb243cc37724fe93fc1f" - integrity sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8= +clone-stats@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/clone-stats/-/clone-stats-1.0.0.tgz#b3782dff8bb5474e18b9b6bf0fdfe782f8777680" + integrity sha1-s3gt/4u1R04Yuba/D9/ngvh3doA= -clone@^1.0.0, clone@^1.0.2: +clone@^1.0.0: version "1.0.4" resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" integrity sha1-2jCcwmPfFZlMaIypAheco8fNfH4= +clone@^2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f" + integrity sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18= + +cloneable-readable@^1.0.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/cloneable-readable/-/cloneable-readable-1.1.3.tgz#120a00cb053bfb63a222e709f9683ea2e11d8cec" + integrity sha512-2EF8zTQOxYq70Y4XKtorQupqF0m49MBz2/yf5Bj+MHjvpG3Hy7sImifnqD6UA+TKYxeSV+u6qqQPawN5UvnpKQ== + dependencies: + inherits "^2.0.1" + process-nextick-args "^2.0.0" + readable-stream "^2.3.5" + co@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" @@ -422,6 +563,15 @@ code-point-at@^1.0.0: resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= +collection-map@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/collection-map/-/collection-map-1.0.0.tgz#aea0f06f8d26c780c2b75494385544b2255af18c" + integrity sha1-rqDwb40mx4DCt1SUOFVEsiVa8Yw= + dependencies: + arr-map "^2.0.2" + for-own "^1.0.0" + make-iterator "^1.0.0" + collection-visit@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0" @@ -455,7 +605,7 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= -concat-stream@^1.5.2: +concat-stream@^1.5.2, concat-stream@^1.6.0: version "1.6.2" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== @@ -480,11 +630,26 @@ console-control-strings@^1.0.0, console-control-strings@~1.1.0: resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4= +convert-source-map@^1.5.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.7.0.tgz#17a2cb882d7f77d3490585e2ce6c524424a3a442" + integrity sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA== + dependencies: + safe-buffer "~5.1.1" + copy-descriptor@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= +copy-props@^2.0.1: + version "2.0.4" + resolved "https://registry.yarnpkg.com/copy-props/-/copy-props-2.0.4.tgz#93bb1cadfafd31da5bb8a9d4b41f471ec3a72dfe" + integrity sha512-7cjuUME+p+S3HZlbllgsn2CDwS+5eCCX16qBgNC4jgSTf49qR1VKy/Zhl400m0IQXl/bPGEVqncgUUMjrr4s8A== + dependencies: + each-props "^1.3.0" + is-plain-object "^2.0.1" + core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -517,6 +682,11 @@ debug@2.6.9, debug@^2.1.1, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3: dependencies: ms "2.0.0" +decamelize@^1.1.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= + decode-uri-component@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" @@ -532,12 +702,24 @@ deep-is@~0.1.3: resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= -defaults@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d" - integrity sha1-xlYFHpgX2f8I7YgUd/P+QBnz730= +default-compare@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/default-compare/-/default-compare-1.0.0.tgz#cb61131844ad84d84788fb68fd01681ca7781a2f" + integrity sha512-QWfXlM0EkAbqOCbD/6HjdwT19j7WCkMyiRhWilc4H9/5h/RzTF9gv5LYh1+CmDV5d1rki6KAWLtQale0xt20eQ== dependencies: - clone "^1.0.2" + kind-of "^5.0.2" + +default-resolution@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/default-resolution/-/default-resolution-2.0.0.tgz#bcb82baa72ad79b426a76732f1a81ad6df26d684" + integrity sha1-vLgrqnKtebQmp2cy8aga1t8m1oQ= + +define-properties@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" + integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== + dependencies: + object-keys "^1.0.12" define-property@^0.2.5: version "0.2.5" @@ -571,11 +753,6 @@ depd@~1.1.2: resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= -deprecated@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/deprecated/-/deprecated-0.0.1.tgz#f9c9af5464afa1e7a971458a8bdef2aa94d5bb19" - integrity sha1-+cmvVGSvoeepcUWKi97yqpTVuxk= - destroy@~1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" @@ -610,6 +787,24 @@ duplexer@~0.1.1: resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" integrity sha1-rOb/gIwc5mtX0ev5eXessCM0z8E= +duplexify@^3.6.0: + version "3.7.1" + resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-3.7.1.tgz#2a4df5317f6ccfd91f86d6fd25d8d8a103b88309" + integrity sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g== + dependencies: + end-of-stream "^1.0.0" + inherits "^2.0.1" + readable-stream "^2.0.0" + stream-shift "^1.0.0" + +each-props@^1.3.0: + version "1.3.2" + resolved "https://registry.yarnpkg.com/each-props/-/each-props-1.3.2.tgz#ea45a414d16dd5cfa419b1a81720d5ca06892333" + integrity sha512-vV0Hem3zAGkJAyU7JSjixeU66rwdynTAa1vofCrSA5fEln+m67Az9CcnkVD776/fsN/UjIWmBDoNRS6t6G9RfA== + dependencies: + is-plain-object "^2.0.1" + object.defaults "^1.1.0" + ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" @@ -620,12 +815,63 @@ encodeurl@~1.0.1, encodeurl@~1.0.2: resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k= -end-of-stream@~0.1.5: - version "0.1.5" - resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-0.1.5.tgz#8e177206c3c80837d85632e8b9359dfe8b2f6eaf" - integrity sha1-jhdyBsPICDfYVjLouTWd/osvbq8= +end-of-stream@^1.0.0, end-of-stream@^1.1.0: + version "1.4.4" + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" + integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== dependencies: - once "~1.3.0" + once "^1.4.0" + +error-ex@^1.2.0: + version "1.3.2" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" + integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== + dependencies: + is-arrayish "^0.2.1" + +es-abstract@^1.17.5: + version "1.17.7" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.7.tgz#a4de61b2f66989fc7421676c1cb9787573ace54c" + integrity sha512-VBl/gnfcJ7OercKA9MVaegWsBHFjV492syMudcnQZvt/Dw8ezpcOHYZXa/J96O8vx+g4x65YKhxOwDUh63aS5g== + dependencies: + es-to-primitive "^1.2.1" + function-bind "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.1" + is-callable "^1.2.2" + is-regex "^1.1.1" + object-inspect "^1.8.0" + object-keys "^1.1.1" + object.assign "^4.1.1" + string.prototype.trimend "^1.0.1" + string.prototype.trimstart "^1.0.1" + +es-abstract@^1.18.0-next.0: + version "1.18.0-next.1" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.0-next.1.tgz#6e3a0a4bda717e5023ab3b8e90bec36108d22c68" + integrity sha512-I4UGspA0wpZXWENrdA0uHbnhte683t3qT/1VFH9aX2dA5PPSf6QW5HHXf5HImaqPmjXaVeVk4RGWnaylmV7uAA== + dependencies: + es-to-primitive "^1.2.1" + function-bind "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.1" + is-callable "^1.2.2" + is-negative-zero "^2.0.0" + is-regex "^1.1.1" + object-inspect "^1.8.0" + object-keys "^1.1.1" + object.assign "^4.1.1" + string.prototype.trimend "^1.0.1" + string.prototype.trimstart "^1.0.1" + +es-to-primitive@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" + integrity sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA== + dependencies: + is-callable "^1.1.4" + is-date-object "^1.0.1" + is-symbol "^1.0.2" es5-ext@^0.10.14, es5-ext@^0.10.35, es5-ext@^0.10.9, es5-ext@~0.10.14: version "0.10.49" @@ -874,7 +1120,7 @@ extglob@^2.0.4: snapdragon "^0.8.1" to-regex "^3.0.1" -fancy-log@^1.1.0: +fancy-log@^1.1.0, fancy-log@^1.3.2: version "1.3.3" resolved "https://registry.yarnpkg.com/fancy-log/-/fancy-log-1.3.3.tgz#dbc19154f558690150a23953a0adbd035be45fc7" integrity sha512-k9oEhlyc0FrVh25qYuSELjr8oxsCoc4/LEZfg2iJJrfEk/tZL9bCoJE47gqAvI2m/AUjluCS4+3I0eTx8n3AEw== @@ -884,6 +1130,11 @@ fancy-log@^1.1.0: parse-node-version "^1.0.0" time-stamp "^1.0.0" +fast-levenshtein@^1.0.0: + version "1.1.4" + resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-1.1.4.tgz#e6a754cc8f15e58987aa9cbd27af66fd6f4e5af9" + integrity sha1-5qdUzI8V5YmHqpy9J69m/W9OWvk= + fast-levenshtein@~2.0.4: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" @@ -957,10 +1208,13 @@ finalhandler@1.1.0: statuses "~1.3.1" unpipe "~1.0.0" -find-index@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/find-index/-/find-index-0.1.1.tgz#675d358b2ca3892d795a1ab47232f8b6e2e0dde4" - integrity sha1-Z101iyyjiS15Whq0cjL4tuLg3eQ= +find-up@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" + integrity sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8= + dependencies: + path-exists "^2.0.0" + pinkie-promise "^2.0.0" findup-sync@^2.0.0: version "2.0.0" @@ -972,6 +1226,16 @@ findup-sync@^2.0.0: micromatch "^3.0.4" resolve-dir "^1.0.1" +findup-sync@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-3.0.0.tgz#17b108f9ee512dfb7a5c7f3c8b27ea9e1a9c08d1" + integrity sha512-YbffarhcicEhOrm4CtrwdKBdCuz576RLdhJDsIfvNtxUuhdRet1qZcsMjqbePtAseKdAnDyM/IyXbu7PRPRLYg== + dependencies: + detect-file "^1.0.0" + is-glob "^4.0.0" + micromatch "^3.0.4" + resolve-dir "^1.0.1" + fined@^1.0.1: version "1.1.1" resolved "https://registry.yarnpkg.com/fined/-/fined-1.1.1.tgz#95d88ff329123dd1a6950fdfcd321f746271e01f" @@ -983,11 +1247,6 @@ fined@^1.0.1: object.pick "^1.2.0" parse-filepath "^1.0.1" -first-chunk-stream@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz#59bfb50cd905f60d7c394cd3d9acaab4e6ad934e" - integrity sha1-Wb+1DNkF9g18OUzT2ayqtOatk04= - flagged-respawn@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/flagged-respawn/-/flagged-respawn-1.0.1.tgz#e7de6f1279ddd9ca9aac8a5971d618606b3aab41" @@ -1003,6 +1262,14 @@ flat-cache@^1.2.1: rimraf "~2.6.2" write "^0.2.1" +flush-write-stream@^1.0.2: + version "1.1.1" + resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.1.1.tgz#8dd7d873a1babc207d94ead0c2e0e44276ebf2e8" + integrity sha512-3Z4XhFZ3992uIq0XOqb9AreonueSYphE6oYbpt5+3u06JWklbsPkNv3ZKkP9Bz/r+1MWCaMoSQ28P85+1Yc77w== + dependencies: + inherits "^2.0.3" + readable-stream "^2.3.6" + for-in@^1.0.1, for-in@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" @@ -1048,6 +1315,14 @@ fs-minipass@^1.2.5: dependencies: minipass "^2.2.1" +fs-mkdirp-stream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz#0b7815fc3201c6a69e14db98ce098c16935259eb" + integrity sha1-C3gV/DIBxqaeFNuYzgmMFpNSWes= + dependencies: + graceful-fs "^4.1.11" + through2 "^2.0.3" + fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" @@ -1061,6 +1336,11 @@ fsevents@^1.2.7: nan "^2.9.2" node-pre-gyp "^0.10.0" +function-bind@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" + integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== + gauge@~2.7.3: version "2.7.4" resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" @@ -1075,13 +1355,6 @@ gauge@~2.7.3: strip-ansi "^3.0.1" wide-align "^1.1.0" -gaze@^0.5.1: - version "0.5.2" - resolved "https://registry.yarnpkg.com/gaze/-/gaze-0.5.2.tgz#40b709537d24d1d45767db5a908689dfe69ac44f" - integrity sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8= - dependencies: - globule "~0.1.0" - generate-function@^2.0.0: version "2.3.1" resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.3.1.tgz#f069617690c10c868e73b8465746764f97c3479f" @@ -1096,6 +1369,11 @@ generate-object-property@^1.1.0: dependencies: is-property "^1.0.0" +get-caller-file@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" + integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w== + get-value@^2.0.3, get-value@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" @@ -1122,41 +1400,34 @@ glob-parent@^3.1.0: is-glob "^3.1.0" path-dirname "^1.0.0" -glob-stream@^3.1.5: - version "3.1.18" - resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-3.1.18.tgz#9170a5f12b790306fdfe598f313f8f7954fd143b" - integrity sha1-kXCl8St5Awb9/lmPMT+PeVT9FDs= - dependencies: - glob "^4.3.1" - glob2base "^0.0.12" - minimatch "^2.0.1" - ordered-read-streams "^0.1.0" - through2 "^0.6.1" - unique-stream "^1.0.0" - -glob-watcher@^0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/glob-watcher/-/glob-watcher-0.0.6.tgz#b95b4a8df74b39c83298b0c05c978b4d9a3b710b" - integrity sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs= - dependencies: - gaze "^0.5.1" - -glob2base@^0.0.12: - version "0.0.12" - resolved "https://registry.yarnpkg.com/glob2base/-/glob2base-0.0.12.tgz#9d419b3e28f12e83a362164a277055922c9c0d56" - integrity sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY= +glob-stream@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-6.1.0.tgz#7045c99413b3eb94888d83ab46d0b404cc7bdde4" + integrity sha1-cEXJlBOz65SIjYOrRtC0BMx73eQ= dependencies: - find-index "^0.1.1" + extend "^3.0.0" + glob "^7.1.1" + glob-parent "^3.1.0" + is-negated-glob "^1.0.0" + ordered-read-streams "^1.0.0" + pumpify "^1.3.5" + readable-stream "^2.1.5" + remove-trailing-separator "^1.0.1" + to-absolute-glob "^2.0.0" + unique-stream "^2.0.2" -glob@^4.3.1: - version "4.5.3" - resolved "https://registry.yarnpkg.com/glob/-/glob-4.5.3.tgz#c6cb73d3226c1efef04de3c56d012f03377ee15f" - integrity sha1-xstz0yJsHv7wTePFbQEvAzd+4V8= +glob-watcher@^5.0.3: + version "5.0.5" + resolved "https://registry.yarnpkg.com/glob-watcher/-/glob-watcher-5.0.5.tgz#aa6bce648332924d9a8489be41e3e5c52d4186dc" + integrity sha512-zOZgGGEHPklZNjZQaZ9f41i7F2YwE+tS5ZHrDhbBCk3stwahn5vQxnFmBJZHoYdusR6R1bLSXeGUy/BhctwKzw== dependencies: - inflight "^1.0.4" - inherits "2" - minimatch "^2.0.1" - once "^1.3.0" + anymatch "^2.0.0" + async-done "^1.2.0" + chokidar "^2.0.0" + is-negated-glob "^1.0.0" + just-debounce "^1.0.0" + normalize-path "^3.0.0" + object.defaults "^1.1.0" glob@^7.0.0, glob@^7.0.3, glob@^7.0.6, glob@^7.1.3: version "7.1.3" @@ -1170,14 +1441,17 @@ glob@^7.0.0, glob@^7.0.3, glob@^7.0.6, glob@^7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" -glob@~3.1.21: - version "3.1.21" - resolved "https://registry.yarnpkg.com/glob/-/glob-3.1.21.tgz#d29e0a055dea5138f4d07ed40e8982e83c2066cd" - integrity sha1-0p4KBV3qUTj00H7UDomC6DwgZs0= +glob@^7.1.1: + version "7.1.6" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" + integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== dependencies: - graceful-fs "~1.2.0" - inherits "1" - minimatch "~0.2.11" + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" global-modules@^1.0.0: version "1.0.0" @@ -1215,15 +1489,6 @@ globby@^6.1.0: pify "^2.0.0" pinkie-promise "^2.0.0" -globule@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/globule/-/globule-0.1.0.tgz#d9c8edde1da79d125a151b79533b978676346ae5" - integrity sha1-2cjt3h2nnRJaFRt5UzuXhnY0auU= - dependencies: - glob "~3.1.21" - lodash "~1.0.1" - minimatch "~0.2.11" - glogg@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/glogg/-/glogg-1.0.2.tgz#2d7dd702beda22eb3bffadf880696da6d846313f" @@ -1236,22 +1501,39 @@ graceful-fs@4.1.11: resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" integrity sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg= -graceful-fs@^3.0.0: - version "3.0.11" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.11.tgz#7613c778a1afea62f25c630a086d7f3acbbdd818" - integrity sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg= - dependencies: - natives "^1.1.0" +graceful-fs@^4.0.0: + version "4.2.4" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" + integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: version "4.1.15" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00" integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA== -graceful-fs@~1.2.0: - version "1.2.3" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-1.2.3.tgz#15a4806a57547cb2d2dbf27f42e89a8c3451b364" - integrity sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q= +gulp-cli@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/gulp-cli/-/gulp-cli-2.3.0.tgz#ec0d380e29e52aa45e47977f0d32e18fd161122f" + integrity sha512-zzGBl5fHo0EKSXsHzjspp3y5CONegCm8ErO5Qh0UzFzk2y4tMvzLWhoDokADbarfZRL2pGpRp7yt6gfJX4ph7A== + dependencies: + ansi-colors "^1.0.1" + archy "^1.0.0" + array-sort "^1.0.0" + color-support "^1.1.3" + concat-stream "^1.6.0" + copy-props "^2.0.1" + fancy-log "^1.3.2" + gulplog "^1.0.0" + interpret "^1.4.0" + isobject "^3.0.1" + liftoff "^3.1.0" + matchdep "^2.0.0" + mute-stdout "^1.0.0" + pretty-hrtime "^1.0.0" + replace-homedir "^1.0.0" + semver-greatest-satisfied-range "^1.1.0" + v8flags "^3.2.0" + yargs "^7.1.0" gulp-eslint@^3.0.1: version "3.0.1" @@ -1297,24 +1579,15 @@ gulp-util@^3.0.0, gulp-util@^3.0.6: through2 "^2.0.0" vinyl "^0.5.0" -gulp@^3.8.10: - version "3.9.1" - resolved "https://registry.yarnpkg.com/gulp/-/gulp-3.9.1.tgz#571ce45928dd40af6514fc4011866016c13845b4" - integrity sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ= +gulp@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/gulp/-/gulp-4.0.2.tgz#543651070fd0f6ab0a0650c6a3e6ff5a7cb09caa" + integrity sha512-dvEs27SCZt2ibF29xYgmnwwCYZxdxhQ/+LFWlbAW8y7jt68L/65402Lz3+CKy0Ov4rOs+NERmDq7YlZaDqUIfA== dependencies: - archy "^1.0.0" - chalk "^1.0.0" - deprecated "^0.0.1" - gulp-util "^3.0.0" - interpret "^1.0.0" - liftoff "^2.1.0" - minimist "^1.1.0" - orchestrator "^0.3.0" - pretty-hrtime "^1.0.0" - semver "^4.1.0" - tildify "^1.0.0" - v8flags "^2.0.2" - vinyl-fs "^0.3.0" + glob-watcher "^5.0.3" + gulp-cli "^2.2.0" + undertaker "^1.2.1" + vinyl-fs "^3.0.0" gulplog@^1.0.0: version "1.0.0" @@ -1337,6 +1610,11 @@ has-gulplog@^0.1.0: dependencies: sparkles "^1.0.0" +has-symbols@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.1.tgz#9f5214758a44196c406d9bd76cebf81ec2dd31e8" + integrity sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg== + has-unicode@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" @@ -1373,6 +1651,13 @@ has-values@^1.0.0: is-number "^3.0.0" kind-of "^4.0.0" +has@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" + integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== + dependencies: + function-bind "^1.1.1" + homedir-polyfill@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8" @@ -1380,6 +1665,11 @@ homedir-polyfill@^1.0.1: dependencies: parse-passwd "^1.0.0" +hosted-git-info@^2.1.4: + version "2.8.8" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" + integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg== + http-auth@3.1.x: version "3.1.3" resolved "https://registry.yarnpkg.com/http-auth/-/http-auth-3.1.3.tgz#945cfadd66521eaf8f7c84913d377d7b15f24e31" @@ -1452,16 +1742,16 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-1.0.2.tgz#ca4309dadee6b54cc0b8d247e8d7c7a0975bdc9b" - integrity sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js= - inherits@2, inherits@2.0.3, inherits@^2.0.3, inherits@~2.0.1, inherits@~2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= +inherits@^2.0.1: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + ini@^1.3.4, ini@~1.3.0: version "1.3.5" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" @@ -1491,6 +1781,16 @@ interpret@^1.0.0: resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.2.0.tgz#d5061a6224be58e8083985f5014d844359576296" integrity sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw== +interpret@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.4.0.tgz#665ab8bc4da27a774a40584e812e3e0fa45b1a1e" + integrity sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA== + +invert-kv@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" + integrity sha1-EEqOSqym09jNFXqO+L+rLXo//bY= + is-absolute@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-absolute/-/is-absolute-1.0.0.tgz#395e1ae84b11f26ad1795e73c17378e48a301576" @@ -1513,6 +1813,11 @@ is-accessor-descriptor@^1.0.0: dependencies: kind-of "^6.0.0" +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= + is-binary-path@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" @@ -1525,6 +1830,11 @@ is-buffer@^1.1.5: resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== +is-callable@^1.1.4, is-callable@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.2.tgz#c7c6715cd22d4ddb48d3e19970223aceabb080d9" + integrity sha512-dnMqspv5nU3LoewK2N/y7KLtxtakvTuaCsU9FU50/QDmdbHNy/4/JuRtMHqRU22o3q+W89YQndQEeCVwK+3qrA== + is-data-descriptor@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" @@ -1539,6 +1849,11 @@ is-data-descriptor@^1.0.0: dependencies: kind-of "^6.0.0" +is-date-object@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.2.tgz#bda736f2cd8fd06d32844e7743bfa7494c3bfd7e" + integrity sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g== + is-descriptor@^0.1.0: version "0.1.6" resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca" @@ -1623,6 +1938,16 @@ is-my-json-valid@^2.10.0: jsonpointer "^4.0.0" xtend "^4.0.0" +is-negated-glob@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-negated-glob/-/is-negated-glob-1.0.0.tgz#6910bca5da8c95e784b5751b976cf5a10fee36d2" + integrity sha1-aRC8pdqMleeEtXUbl2z1oQ/uNtI= + +is-negative-zero@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.0.tgz#9553b121b0fac28869da9ed459e20c7543788461" + integrity sha1-lVOxIbD6wohp2p7UWeIMdUN4hGE= + is-number@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" @@ -1630,6 +1955,11 @@ is-number@^3.0.0: dependencies: kind-of "^3.0.2" +is-number@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-4.0.0.tgz#0026e37f5454d73e356dfe6564699867c6a7f0ff" + integrity sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ== + is-plain-obj@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" @@ -1647,6 +1977,13 @@ is-property@^1.0.0, is-property@^1.0.2: resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" integrity sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ= +is-regex@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.1.tgz#c6f98aacc546f6cec5468a07b7b153ab564a57b9" + integrity sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg== + dependencies: + has-symbols "^1.0.1" + is-relative@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-relative/-/is-relative-1.0.0.tgz#a1bb6935ce8c5dba1e8b9754b9b2dcc020e2260d" @@ -1659,6 +1996,13 @@ is-resolvable@^1.0.0: resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.1.0.tgz#fb18f87ce1feb925169c9a407c19318a3206ed88" integrity sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg== +is-symbol@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.3.tgz#38e1014b9e6329be0de9d24a414fd7441ec61937" + integrity sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ== + dependencies: + has-symbols "^1.0.1" + is-unc-path@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-unc-path/-/is-unc-path-1.0.0.tgz#d731e8898ed090a12c352ad2eaed5095ad322c9d" @@ -1666,11 +2010,16 @@ is-unc-path@^1.0.0: dependencies: unc-path-regex "^0.1.2" -is-utf8@^0.2.0: +is-utf8@^0.2.0, is-utf8@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI= +is-valid-glob@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-valid-glob/-/is-valid-glob-1.0.0.tgz#29bf3eff701be2d4d315dbacc39bc39fe8f601aa" + integrity sha1-Kb8+/3Ab4tTTFdusw5vDn+j2Aao= + is-windows@^1.0.1, is-windows@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" @@ -1768,6 +2117,11 @@ jsdoc@3.5.5: taffydb "2.6.2" underscore "~1.8.3" +json-stable-stringify-without-jsonify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" + integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= + json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" @@ -1792,6 +2146,11 @@ jsonpointer@^4.0.0: resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" integrity sha1-T9kss04OnbPInIYi7PUfm5eMbLk= +just-debounce@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/just-debounce/-/just-debounce-1.0.0.tgz#87fccfaeffc0b68cd19d55f6722943f929ea35ea" + integrity sha1-h/zPrv/AtozRnVX2cilD+SnqNeo= + kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: version "3.2.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" @@ -1806,7 +2165,7 @@ kind-of@^4.0.0: dependencies: is-buffer "^1.1.5" -kind-of@^5.0.0: +kind-of@^5.0.0, kind-of@^5.0.2: version "5.1.0" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw== @@ -1823,6 +2182,35 @@ klaw@~2.0.0: dependencies: graceful-fs "^4.1.9" +last-run@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/last-run/-/last-run-1.1.1.tgz#45b96942c17b1c79c772198259ba943bebf8ca5b" + integrity sha1-RblpQsF7HHnHchmCWbqUO+v4yls= + dependencies: + default-resolution "^2.0.0" + es6-weak-map "^2.0.1" + +lazystream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lazystream/-/lazystream-1.0.0.tgz#f6995fe0f820392f61396be89462407bb77168e4" + integrity sha1-9plf4PggOS9hOWvolGJAe7dxaOQ= + dependencies: + readable-stream "^2.0.5" + +lcid@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" + integrity sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU= + dependencies: + invert-kv "^1.0.0" + +lead@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lead/-/lead-1.0.0.tgz#6f14f99a37be3a9dd784f5495690e5903466ee42" + integrity sha1-bxT5mje+Op3XhPVJVpDlkDRm7kI= + dependencies: + flush-write-stream "^1.0.2" + levn@^0.3.0, levn@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" @@ -1831,13 +2219,13 @@ levn@^0.3.0, levn@~0.3.0: prelude-ls "~1.1.2" type-check "~0.3.2" -liftoff@^2.1.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/liftoff/-/liftoff-2.5.0.tgz#2009291bb31cea861bbf10a7c15a28caf75c31ec" - integrity sha1-IAkpG7Mc6oYbvxCnwVooyvdcMew= +liftoff@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/liftoff/-/liftoff-3.1.0.tgz#c9ba6081f908670607ee79062d700df062c52ed3" + integrity sha512-DlIPlJUkCV0Ips2zf2pJP0unEoT1kwYhiiPUGF3s/jtxTCjziNLoiVVh+jqWOWeFi6mmwQ5fNxvAUyPad4Dfog== dependencies: extend "^3.0.0" - findup-sync "^2.0.0" + findup-sync "^3.0.0" fined "^1.0.1" flagged-respawn "^1.0.0" is-plain-object "^2.0.4" @@ -1864,6 +2252,17 @@ live-server@^1.2.0: send latest serve-index "^1.9.1" +load-json-file@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" + integrity sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA= + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + pinkie-promise "^2.0.0" + strip-bom "^2.0.0" + lodash._basecopy@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" @@ -1968,16 +2367,6 @@ lodash@^4.0.0, lodash@^4.17.10, lodash@^4.3.0: resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== -lodash@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-1.0.2.tgz#8f57560c83b59fc270bd3d561b690043430e2551" - integrity sha1-j1dWDIO1n8JwvT1WG2kAQ0MOJVE= - -lru-cache@2: - version "2.7.3" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952" - integrity sha1-bUUk6LlV+V1PW1iFHOId1y+06VI= - make-iterator@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/make-iterator/-/make-iterator-1.0.1.tgz#29b33f312aa8f547c4a5e490f56afcec99133ad6" @@ -2007,6 +2396,16 @@ marked@~0.3.6: resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.19.tgz#5d47f709c4c9fc3c216b6d46127280f40b39d790" integrity sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg== +matchdep@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/matchdep/-/matchdep-2.0.0.tgz#c6f34834a0d8dbc3b37c27ee8bbcb27c7775582e" + integrity sha1-xvNINKDY28OzfCfui7yyfHd1WC4= + dependencies: + findup-sync "^2.0.0" + micromatch "^3.0.4" + resolve "^1.4.0" + stack-trace "0.0.10" + micromatch@^3.0.4, micromatch@^3.1.10, micromatch@^3.1.4: version "3.1.10" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" @@ -2043,13 +2442,6 @@ mime@1.4.1: resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6" integrity sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ== -minimatch@^2.0.1: - version "2.0.10" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-2.0.10.tgz#8d087c39c6b38c001b97fca7ce6d0e1e80afbac7" - integrity sha1-jQh8OcazjAAbl/ynzm0OHoCvusc= - dependencies: - brace-expansion "^1.0.0" - minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" @@ -2057,14 +2449,6 @@ minimatch@^3.0.4: dependencies: brace-expansion "^1.1.7" -minimatch@~0.2.11: - version "0.2.14" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.2.14.tgz#c74e780574f63c6f9a090e90efbe6ef53a6a756a" - integrity sha1-x054BXT2PG+aCQ6Q775u9TpqdWo= - dependencies: - lru-cache "2" - sigmund "~1.0.0" - minimist@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" @@ -2128,6 +2512,11 @@ multipipe@^0.1.2: dependencies: duplexer2 "0.0.2" +mute-stdout@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/mute-stdout/-/mute-stdout-1.0.1.tgz#acb0300eb4de23a7ddeec014e3e96044b3472331" + integrity sha512-kDcwXR4PS7caBpuRYYBUz9iVixUk3anO3f5OYFiIPwK/20vCzKCHyKoulbiDY1S53zD2bxUpxN/IJ+TnXjfvxg== + mute-stream@0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.5.tgz#8fbfabb0a98a253d3184331f9e8deb7372fac6c0" @@ -2155,11 +2544,6 @@ nanomatch@^1.2.9: snapdragon "^0.8.1" to-regex "^3.0.1" -natives@^1.1.0: - version "1.1.6" - resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.6.tgz#a603b4a498ab77173612b9ea1acdec4d980f00bb" - integrity sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA== - natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" @@ -2208,6 +2592,16 @@ nopt@^4.0.1: abbrev "1" osenv "^0.1.4" +normalize-package-data@^2.3.2: + version "2.5.0" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" + integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== + dependencies: + hosted-git-info "^2.1.4" + resolve "^1.10.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" + normalize-path@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" @@ -2230,6 +2624,13 @@ normalize-url@^1.0.0: query-string "^4.1.0" sort-keys "^1.0.0" +now-and-later@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/now-and-later/-/now-and-later-2.0.1.tgz#8e579c8685764a7cc02cb680380e94f43ccb1f7c" + integrity sha512-KGvQ0cB70AQfg107Xvs/Fbu+dGmZoTRJp2TaPwcwQm3/7PteUyN2BCgk8KBMPGBUXZdVwyWS8fDCGFygBm19UQ== + dependencies: + once "^1.3.2" + npm-bundled@^1.0.1: version "1.0.6" resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.0.6.tgz#e7ba9aadcef962bb61248f91721cd932b3fe6bdd" @@ -2277,6 +2678,16 @@ object-copy@^0.1.0: define-property "^0.2.5" kind-of "^3.0.3" +object-inspect@^1.8.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.8.0.tgz#df807e5ecf53a609cc6bfe93eac3cc7be5b3a9d0" + integrity sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA== + +object-keys@^1.0.12, object-keys@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" + integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== + object-visit@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" @@ -2284,7 +2695,17 @@ object-visit@^1.0.0: dependencies: isobject "^3.0.0" -object.defaults@^1.1.0: +object.assign@^4.0.4, object.assign@^4.1.0, object.assign@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.1.tgz#303867a666cdd41936ecdedfb1f8f3e32a478cdd" + integrity sha512-VT/cxmx5yaoHSOTSyrCygIDFco+RsibY2NM0a4RdEeY/4KgqezwFtK1yr3U67xYhqJSlASm2pKhLVzPj2lr4bA== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.18.0-next.0" + has-symbols "^1.0.1" + object-keys "^1.1.1" + +object.defaults@^1.0.0, object.defaults@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/object.defaults/-/object.defaults-1.1.0.tgz#3a7f868334b407dea06da16d88d5cd29e435fecf" integrity sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8= @@ -2309,6 +2730,14 @@ object.pick@^1.2.0, object.pick@^1.3.0: dependencies: isobject "^3.0.1" +object.reduce@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/object.reduce/-/object.reduce-1.0.1.tgz#6fe348f2ac7fa0f95ca621226599096825bb03ad" + integrity sha1-b+NI8qx/oPlcpiEiZZkJaCW7A60= + dependencies: + for-own "^1.0.0" + make-iterator "^1.0.0" + on-finished@~2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" @@ -2321,20 +2750,13 @@ on-headers@~1.0.1: resolved "https://registry.yarnpkg.com/on-headers/-/on-headers-1.0.2.tgz#772b0ae6aaa525c399e489adfad90c403eb3c28f" integrity sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA== -once@^1.3.0: +once@^1.3.0, once@^1.3.1, once@^1.3.2, once@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= dependencies: wrappy "1" -once@~1.3.0: - version "1.3.3" - resolved "https://registry.yarnpkg.com/once/-/once-1.3.3.tgz#b2e261557ce4c314ec8304f3fa82663e4297ca20" - integrity sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA= - dependencies: - wrappy "1" - onetime@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789" @@ -2359,25 +2781,25 @@ optionator@^0.8.2: type-check "~0.3.2" wordwrap "~1.0.0" -orchestrator@^0.3.0: - version "0.3.8" - resolved "https://registry.yarnpkg.com/orchestrator/-/orchestrator-0.3.8.tgz#14e7e9e2764f7315fbac184e506c7aa6df94ad7e" - integrity sha1-FOfp4nZPcxX7rBhOUGx6pt+UrX4= +ordered-read-streams@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz#77c0cb37c41525d64166d990ffad7ec6a0e1363e" + integrity sha1-d8DLN8QVJdZBZtmQ/61+xqDhNj4= dependencies: - end-of-stream "~0.1.5" - sequencify "~0.0.7" - stream-consume "~0.1.0" - -ordered-read-streams@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz#fd565a9af8eb4473ba69b6ed8a34352cb552f126" - integrity sha1-/VZamvjrRHO6abbtijQ1LLVS8SY= + readable-stream "^2.0.1" os-homedir@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= +os-locale@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-1.4.0.tgz#20f9f17ae29ed345e8bde583b13d2009803c14d9" + integrity sha1-IPnxeuKe00XoveWDsT0gCYA8FNk= + dependencies: + lcid "^1.0.0" + os-tmpdir@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" @@ -2400,6 +2822,13 @@ parse-filepath@^1.0.1: map-cache "^0.2.0" path-root "^0.1.1" +parse-json@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" + integrity sha1-9ID0BDTvgHQfhGkJn43qGPVaTck= + dependencies: + error-ex "^1.2.0" + parse-node-version@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/parse-node-version/-/parse-node-version-1.0.1.tgz#e2b5dbede00e7fa9bc363607f53327e8b073189b" @@ -2425,6 +2854,13 @@ path-dirname@^1.0.0: resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" integrity sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA= +path-exists@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" + integrity sha1-D+tsZPD8UY2adU3V77YscCJ2H0s= + dependencies: + pinkie-promise "^2.0.0" + path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" @@ -2452,6 +2888,15 @@ path-root@^0.1.1: dependencies: path-root-regex "^0.1.0" +path-type@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" + integrity sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE= + dependencies: + graceful-fs "^4.1.2" + pify "^2.0.0" + pinkie-promise "^2.0.0" + pause-stream@0.0.11: version "0.0.11" resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445" @@ -2501,6 +2946,11 @@ pretty-hrtime@^1.0.0: resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" integrity sha1-t+PqQkNaTJsnWdmeDyAesZWALuE= +process-nextick-args@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" + integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== + process-nextick-args@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" @@ -2516,6 +2966,23 @@ proxy-middleware@latest: resolved "https://registry.yarnpkg.com/proxy-middleware/-/proxy-middleware-0.15.0.tgz#a3fdf1befb730f951965872ac2f6074c61477a56" integrity sha1-o/3xvvtzD5UZZYcqwvYHTGFHelY= +pump@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pump/-/pump-2.0.1.tgz#12399add6e4cf7526d973cbc8b5ce2e2908b3909" + integrity sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA== + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + +pumpify@^1.3.5: + version "1.5.1" + resolved "https://registry.yarnpkg.com/pumpify/-/pumpify-1.5.1.tgz#36513be246ab27570b1a374a5ce278bfd74370ce" + integrity sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ== + dependencies: + duplexify "^3.6.0" + inherits "^2.0.3" + pump "^2.0.0" + query-string@^4.1.0: version "4.3.4" resolved "https://registry.yarnpkg.com/query-string/-/query-string-4.3.4.tgz#bbb693b9ca915c232515b228b1a02b609043dbeb" @@ -2539,15 +3006,35 @@ rc@^1.2.7: minimist "^1.2.0" strip-json-comments "~2.0.1" -"readable-stream@>=1.0.33-1 <1.1.0-0": - version "1.0.34" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" - integrity sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw= +read-pkg-up@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" + integrity sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI= + dependencies: + find-up "^1.0.0" + read-pkg "^1.0.0" + +read-pkg@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" + integrity sha1-9f+qXs0pyzHAR0vKfXVra7KePyg= + dependencies: + load-json-file "^1.0.0" + normalize-package-data "^2.3.2" + path-type "^1.0.0" + +readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.5, readable-stream@^2.1.5, readable-stream@^2.3.3, readable-stream@^2.3.5, readable-stream@^2.3.6: + version "2.3.7" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" + integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== dependencies: core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "0.0.1" - string_decoder "~0.10.x" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.2.2, readable-stream@~2.3.6: version "2.3.6" @@ -2605,7 +3092,24 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" -remove-trailing-separator@^1.0.1: +remove-bom-buffer@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/remove-bom-buffer/-/remove-bom-buffer-3.0.0.tgz#c2bf1e377520d324f623892e33c10cac2c252b53" + integrity sha512-8v2rWhaakv18qcvNeli2mZ/TMTL2nEyAKRvzo1WtnZBl15SHyEhrCu2/xKlJyUFKHiHgfXIyuY6g2dObJJycXQ== + dependencies: + is-buffer "^1.1.5" + is-utf8 "^0.2.1" + +remove-bom-stream@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/remove-bom-stream/-/remove-bom-stream-1.2.0.tgz#05f1a593f16e42e1fb90ebf59de8e569525f9523" + integrity sha1-BfGlk/FuQuH7kOv1nejlaVJflSM= + dependencies: + remove-bom-buffer "^3.0.0" + safe-buffer "^5.1.0" + through2 "^2.0.3" + +remove-trailing-separator@^1.0.1, remove-trailing-separator@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" integrity sha1-wkvOKig62tW8P1jg1IJJuSN52O8= @@ -2632,6 +3136,30 @@ replace-ext@0.0.1: resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-0.0.1.tgz#29bbd92078a739f0bcce2b4ee41e837953522924" integrity sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ= +replace-ext@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-1.0.1.tgz#2d6d996d04a15855d967443631dd5f77825b016a" + integrity sha512-yD5BHCe7quCgBph4rMQ+0KkIRKwWCrHDOX1p1Gp6HwjPM5kVoCdKGNhN7ydqqsX6lJEnQDKZ/tFMiEdQ1dvPEw== + +replace-homedir@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/replace-homedir/-/replace-homedir-1.0.0.tgz#e87f6d513b928dde808260c12be7fec6ff6e798c" + integrity sha1-6H9tUTuSjd6AgmDBK+f+xv9ueYw= + dependencies: + homedir-polyfill "^1.0.1" + is-absolute "^1.0.0" + remove-trailing-separator "^1.1.0" + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= + +require-main-filename@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" + integrity sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE= + require-uncached@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3" @@ -2660,6 +3188,13 @@ resolve-from@^1.0.0: resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" integrity sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY= +resolve-options@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/resolve-options/-/resolve-options-1.1.0.tgz#32bb9e39c06d67338dc9378c0d6d6074566ad131" + integrity sha1-MrueOcBtZzONyTeMDW1gdFZq0TE= + dependencies: + value-or-function "^3.0.0" + resolve-url@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" @@ -2672,6 +3207,13 @@ resolve@^1.1.6, resolve@^1.1.7: dependencies: path-parse "^1.0.6" +resolve@^1.10.0, resolve@^1.4.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" + integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== + dependencies: + path-parse "^1.0.6" + restore-cursor@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" @@ -2709,6 +3251,11 @@ safe-buffer@5.1.2, safe-buffer@^5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== +safe-buffer@^5.1.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + safe-regex@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" @@ -2726,10 +3273,17 @@ sax@^1.2.4: resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== -semver@^4.1.0: - version "4.3.6" - resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da" - integrity sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto= +semver-greatest-satisfied-range@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/semver-greatest-satisfied-range/-/semver-greatest-satisfied-range-1.1.0.tgz#13e8c2658ab9691cb0cd71093240280d36f77a5b" + integrity sha1-E+jCZYq5aRywzXEJMkAoDTb3els= + dependencies: + sver-compat "^1.5.0" + +"semver@2 || 3 || 4 || 5": + version "5.7.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" + integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== semver@^5.3.0: version "5.6.0" @@ -2755,11 +3309,6 @@ send@latest: range-parser "~1.2.0" statuses "~1.4.0" -sequencify@~0.0.7: - version "0.0.7" - resolved "https://registry.yarnpkg.com/sequencify/-/sequencify-0.0.7.tgz#90cff19d02e07027fd767f5ead3e7b95d1e7380c" - integrity sha1-kM/xnQLgcCf9dn9erT57ldHnOAw= - serve-index@^1.9.1: version "1.9.1" resolved "https://registry.yarnpkg.com/serve-index/-/serve-index-1.9.1.tgz#d3768d69b1e7d82e5ce050fff5b453bea12a9239" @@ -2773,7 +3322,7 @@ serve-index@^1.9.1: mime-types "~2.1.17" parseurl "~1.3.2" -set-blocking@~2.0.0: +set-blocking@^2.0.0, set-blocking@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= @@ -2812,11 +3361,6 @@ shelljs@^0.7.5: interpret "^1.0.0" rechoir "^0.6.2" -sigmund@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590" - integrity sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA= - signal-exit@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" @@ -2890,6 +3434,32 @@ sparkles@^1.0.0: resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.1.tgz#008db65edce6c50eec0c5e228e1945061dd0437c" integrity sha512-dSO0DDYUahUt/0/pD/Is3VIm5TGJjludZ0HVymmhYF6eNA53PVLhnUk0znSYbH8IYBuJdCE+1luR22jNLMaQdw== +spdx-correct@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" + integrity sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w== + dependencies: + spdx-expression-parse "^3.0.0" + spdx-license-ids "^3.0.0" + +spdx-exceptions@^2.1.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d" + integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== + +spdx-expression-parse@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" + integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== + dependencies: + spdx-exceptions "^2.1.0" + spdx-license-ids "^3.0.0" + +spdx-license-ids@^3.0.0: + version "3.0.6" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.6.tgz#c80757383c28abf7296744998cbc106ae8b854ce" + integrity sha512-+orQK83kyMva3WyPf59k1+Y525csj5JejicWut55zeTWANuN17qSiSLUXWtzHeNWORSvT7GLDJ/E/XiIWoXBTw== + split-string@^3.0.1, split-string@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" @@ -2909,6 +3479,11 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= +stack-trace@0.0.10: + version "0.0.10" + resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0" + integrity sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA= + static-extend@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" @@ -2939,17 +3514,22 @@ stream-combiner@~0.0.4: dependencies: duplexer "~0.1.1" -stream-consume@~0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/stream-consume/-/stream-consume-0.1.1.tgz#d3bdb598c2bd0ae82b8cac7ac50b1107a7996c48" - integrity sha512-tNa3hzgkjEP7XbCkbRXe1jpg+ievoa0O4SCFlMOYEscGSS4JJsckGL8swUyAa/ApGU3Ae4t6Honor4HhL+tRyg== +stream-exhaust@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/stream-exhaust/-/stream-exhaust-1.0.2.tgz#acdac8da59ef2bc1e17a2c0ccf6c320d120e555d" + integrity sha512-b/qaq/GlBK5xaq1yrK9/zFcyRSTNxmcZwFLGSTG0mXgZl/4Z6GgiyYOXOvY7N3eEvFRAG1bkDRz5EPGSvPYQlw== + +stream-shift@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.1.tgz#d7088281559ab2778424279b0877da3c392d5a3d" + integrity sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ== strict-uri-encode@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713" integrity sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM= -string-width@^1.0.1: +string-width@^1.0.1, string-width@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" integrity sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M= @@ -2966,6 +3546,22 @@ string-width@^1.0.1: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" +string.prototype.trimend@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz#85812a6b847ac002270f5808146064c995fb6913" + integrity sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.5" + +string.prototype.trimstart@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz#14af6d9f34b053f7cfc89b72f8f2ee14b9039a54" + integrity sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.5" + string_decoder@~0.10.x: version "0.10.31" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" @@ -2992,12 +3588,11 @@ strip-ansi@^4.0.0: dependencies: ansi-regex "^3.0.0" -strip-bom@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-1.0.0.tgz#85b8862f3844b5a6d5ec8467a93598173a36f794" - integrity sha1-hbiGLzhEtabV7IRnqTWYFzo295Q= +strip-bom@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" + integrity sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4= dependencies: - first-chunk-stream "^1.0.0" is-utf8 "^0.2.0" strip-bom@^3.0.0: @@ -3027,6 +3622,14 @@ supports-color@^2.0.0: resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc= +sver-compat@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/sver-compat/-/sver-compat-1.5.0.tgz#3cf87dfeb4d07b4a3f14827bc186b3fd0c645cd8" + integrity sha1-PPh9/rTQe0o/FIJ7wYaz/QxkXNg= + dependencies: + es6-iterator "^2.0.1" + es6-symbol "^3.1.1" + table@^3.7.8: version "3.8.3" resolved "https://registry.yarnpkg.com/table/-/table-3.8.3.tgz#2bbc542f0fda9861a755d3947fefd8b3f513855f" @@ -3062,15 +3665,15 @@ text-table@~0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= -through2@^0.6.1: - version "0.6.5" - resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48" - integrity sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg= +through2-filter@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/through2-filter/-/through2-filter-3.0.0.tgz#700e786df2367c2c88cd8aa5be4cf9c1e7831254" + integrity sha512-jaRjI2WxN3W1V8/FMZ9HKIBXixtiqs3SQSX4/YGIiP3gL6djW48VoZq9tDqeCWs3MT8YY5wb/zli8VW8snY1CA== dependencies: - readable-stream ">=1.0.33-1 <1.1.0-0" - xtend ">=4.0.0 <4.1.0-0" + through2 "~2.0.0" + xtend "~4.0.0" -through2@^2.0.0: +through2@^2.0.0, through2@^2.0.3, through2@~2.0.0: version "2.0.5" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd" integrity sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ== @@ -3083,18 +3686,19 @@ through@2, through@^2.3.6, through@~2.3, through@~2.3.1: resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= -tildify@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/tildify/-/tildify-1.2.0.tgz#dcec03f55dca9b7aa3e5b04f21817eb56e63588a" - integrity sha1-3OwD9V3Km3qj5bBPIYF+tW5jWIo= - dependencies: - os-homedir "^1.0.0" - time-stamp@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/time-stamp/-/time-stamp-1.1.0.tgz#764a5a11af50561921b133f3b44e618687e0f5c3" integrity sha1-dkpaEa9QVhkhsTPztE5hhofg9cM= +to-absolute-glob@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz#1865f43d9e74b0822db9f145b78cff7d0f7c849b" + integrity sha1-GGX0PZ50sIItufFFt4z/fQ98hJs= + dependencies: + is-absolute "^1.0.0" + is-negated-glob "^1.0.0" + to-object-path@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" @@ -3120,6 +3724,13 @@ to-regex@^3.0.1, to-regex@^3.0.2: regex-not "^1.0.2" safe-regex "^1.1.0" +to-through@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/to-through/-/to-through-2.0.0.tgz#fc92adaba072647bc0b67d6b03664aa195093af6" + integrity sha1-/JKtq6ByZHvAtn1rA2ZKoZUJOvY= + dependencies: + through2 "^2.0.3" + trim-repeated@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/trim-repeated/-/trim-repeated-1.0.0.tgz#e3646a2ea4e891312bf7eace6cfb05380bc01c21" @@ -3161,6 +3772,27 @@ underscore@~1.8.3: resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" integrity sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI= +undertaker-registry@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/undertaker-registry/-/undertaker-registry-1.0.1.tgz#5e4bda308e4a8a2ae584f9b9a4359a499825cc50" + integrity sha1-XkvaMI5KiirlhPm5pDWaSZglzFA= + +undertaker@^1.2.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/undertaker/-/undertaker-1.3.0.tgz#363a6e541f27954d5791d6fa3c1d321666f86d18" + integrity sha512-/RXwi5m/Mu3H6IHQGww3GNt1PNXlbeCuclF2QYR14L/2CHPz3DFZkvB5hZ0N/QUkiXWCACML2jXViIQEQc2MLg== + dependencies: + arr-flatten "^1.0.1" + arr-map "^2.0.0" + bach "^1.0.0" + collection-map "^1.0.0" + es6-weak-map "^2.0.1" + fast-levenshtein "^1.0.0" + last-run "^1.1.0" + object.defaults "^1.0.0" + object.reduce "^1.0.0" + undertaker-registry "^1.0.0" + union-value@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4" @@ -3171,10 +3803,13 @@ union-value@^1.0.0: is-extendable "^0.1.1" set-value "^0.4.3" -unique-stream@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-1.0.0.tgz#d59a4a75427447d9aa6c91e70263f8d26a4b104b" - integrity sha1-1ZpKdUJ0R9mqbJHnAmP40mpLEEs= +unique-stream@^2.0.2: + version "2.3.1" + resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-2.3.1.tgz#c65d110e9a4adf9a6c5948b28053d9a8d04cbeac" + integrity sha512-2nY4TnBE70yoxHkDli7DMazpWiP7xMdCYqU2nBRO0UB+ZpEkGsSija7MvmvnZFUeC+mrgiUfcHSr3LmRFIg4+A== + dependencies: + json-stable-stringify-without-jsonify "^1.0.1" + through2-filter "^3.0.0" universalify@^0.1.0: version "0.1.2" @@ -3214,11 +3849,6 @@ use@^3.1.0: resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== -user-home@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" - integrity sha1-K1viOjK2Onyd640PKNSFcko98ZA= - user-home@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/user-home/-/user-home-2.0.0.tgz#9c70bfd8169bc1dcbf48604e0f04b8b49cde9e9f" @@ -3241,39 +3871,66 @@ uuid@^3.0.0: resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA== -v8flags@^2.0.2: - version "2.1.1" - resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" - integrity sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ= +v8flags@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-3.2.0.tgz#b243e3b4dfd731fa774e7492128109a0fe66d656" + integrity sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg== + dependencies: + homedir-polyfill "^1.0.1" + +validate-npm-package-license@^3.0.1: + version "3.0.4" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" + integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== dependencies: - user-home "^1.1.1" + spdx-correct "^3.0.0" + spdx-expression-parse "^3.0.0" + +value-or-function@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/value-or-function/-/value-or-function-3.0.0.tgz#1c243a50b595c1be54a754bfece8563b9ff8d813" + integrity sha1-HCQ6ULWVwb5Up1S/7OhWO5/42BM= vary@^1: version "1.1.2" resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw= -vinyl-fs@^0.3.0: - version "0.3.14" - resolved "https://registry.yarnpkg.com/vinyl-fs/-/vinyl-fs-0.3.14.tgz#9a6851ce1cac1c1cea5fe86c0931d620c2cfa9e6" - integrity sha1-mmhRzhysHBzqX+hsCTHWIMLPqeY= - dependencies: - defaults "^1.0.0" - glob-stream "^3.1.5" - glob-watcher "^0.0.6" - graceful-fs "^3.0.0" - mkdirp "^0.5.0" - strip-bom "^1.0.0" - through2 "^0.6.1" - vinyl "^0.4.0" +vinyl-fs@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/vinyl-fs/-/vinyl-fs-3.0.3.tgz#c85849405f67428feabbbd5c5dbdd64f47d31bc7" + integrity sha512-vIu34EkyNyJxmP0jscNzWBSygh7VWhqun6RmqVfXePrOwi9lhvRs//dOaGOTRUQr4tx7/zd26Tk5WeSVZitgng== + dependencies: + fs-mkdirp-stream "^1.0.0" + glob-stream "^6.1.0" + graceful-fs "^4.0.0" + is-valid-glob "^1.0.0" + lazystream "^1.0.0" + lead "^1.0.0" + object.assign "^4.0.4" + pumpify "^1.3.5" + readable-stream "^2.3.3" + remove-bom-buffer "^3.0.0" + remove-bom-stream "^1.2.0" + resolve-options "^1.1.0" + through2 "^2.0.0" + to-through "^2.0.0" + value-or-function "^3.0.0" + vinyl "^2.0.0" + vinyl-sourcemap "^1.1.0" -vinyl@^0.4.0: - version "0.4.6" - resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-0.4.6.tgz#2f356c87a550a255461f36bbeb2a5ba8bf784847" - integrity sha1-LzVsh6VQolVGHza76ypbqL94SEc= +vinyl-sourcemap@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/vinyl-sourcemap/-/vinyl-sourcemap-1.1.0.tgz#92a800593a38703a8cdb11d8b300ad4be63b3e16" + integrity sha1-kqgAWTo4cDqM2xHYswCtS+Y7PhY= dependencies: - clone "^0.2.0" - clone-stats "^0.0.1" + append-buffer "^1.0.2" + convert-source-map "^1.5.0" + graceful-fs "^4.1.6" + normalize-path "^2.1.1" + now-and-later "^2.0.0" + remove-bom-buffer "^3.0.0" + vinyl "^2.0.0" vinyl@^0.5.0: version "0.5.3" @@ -3284,6 +3941,18 @@ vinyl@^0.5.0: clone-stats "^0.0.1" replace-ext "0.0.1" +vinyl@^2.0.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-2.2.1.tgz#23cfb8bbab5ece3803aa2c0a1eb28af7cbba1974" + integrity sha512-LII3bXRFBZLlezoG5FfZVcXflZgWP/4dCwKtxd5ky9+LOtM4CS3bIRQsmR1KMnMW07jpE8fqR2lcxPZ+8sJIcw== + dependencies: + clone "^2.1.1" + clone-buffer "^1.0.0" + clone-stats "^1.0.0" + cloneable-readable "^1.0.0" + remove-trailing-separator "^1.0.1" + replace-ext "^1.0.0" + websocket-driver@>=0.5.1: version "0.7.0" resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.0.tgz#0caf9d2d755d93aee049d4bdd0d3fe2cca2a24eb" @@ -3297,6 +3966,11 @@ websocket-extensions@>=0.1.1: resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== +which-module@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f" + integrity sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8= + which@^1.2.14: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" @@ -3316,6 +3990,14 @@ wordwrap@~1.0.0: resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" integrity sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus= +wrap-ansi@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" + integrity sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU= + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" @@ -3333,12 +4015,49 @@ xmlcreate@^1.0.1: resolved "https://registry.yarnpkg.com/xmlcreate/-/xmlcreate-1.0.2.tgz#fa6bf762a60a413fb3dd8f4b03c5b269238d308f" integrity sha1-+mv3YqYKQT+z3Y9LA8WyaSONMI8= -"xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@~4.0.1: +xtend@^4.0.0, xtend@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" integrity sha1-pcbVMr5lbiPbgg77lDofBJmNY68= +xtend@~4.0.0: + version "4.0.2" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" + integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== + +y18n@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" + integrity sha1-bRX7qITAhnnA136I53WegR4H+kE= + yallist@^3.0.0, yallist@^3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9" integrity sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A== + +yargs-parser@5.0.0-security.0: + version "5.0.0-security.0" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-5.0.0-security.0.tgz#4ff7271d25f90ac15643b86076a2ab499ec9ee24" + integrity sha512-T69y4Ps64LNesYxeYGYPvfoMTt/7y1XtfpIslUeK4um+9Hu7hlGoRtaDLvdXb7+/tfq4opVa2HRY5xGip022rQ== + dependencies: + camelcase "^3.0.0" + object.assign "^4.1.0" + +yargs@^7.1.0: + version "7.1.1" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-7.1.1.tgz#67f0ef52e228d4ee0d6311acede8850f53464df6" + integrity sha512-huO4Fr1f9PmiJJdll5kwoS2e4GqzGSsMT3PPMpOwoVkOK8ckqAewMTZyA6LXVQWflleb/Z8oPBEvNsMft0XE+g== + dependencies: + camelcase "^3.0.0" + cliui "^3.2.0" + decamelize "^1.1.1" + get-caller-file "^1.0.1" + os-locale "^1.4.0" + read-pkg-up "^1.0.1" + require-directory "^2.1.1" + require-main-filename "^1.0.1" + set-blocking "^2.0.0" + string-width "^1.0.2" + which-module "^1.0.0" + y18n "^3.2.1" + yargs-parser "5.0.0-security.0" From 5a83422c41cffac1fcfde6f07c497f8e2ab2469c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2020 13:11:50 +0000 Subject: [PATCH 597/613] Bump lodash from 4.17.11 to 4.17.20 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.20. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.11...4.17.20) Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- yarn.lock | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4025d25e..1bc2dde3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3491,9 +3491,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", "dev": true }, "lodash._basecopy": { diff --git a/yarn.lock b/yarn.lock index a9b710ec..45595186 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2363,9 +2363,9 @@ lodash.templatesettings@^3.0.0: lodash.escape "^3.0.0" lodash@^4.0.0, lodash@^4.17.10, lodash@^4.3.0: - version "4.17.11" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" - integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== + version "4.17.20" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" + integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== make-iterator@^1.0.0: version "1.0.1" From 9e074b1fa468650a38632b0f67d152c1cee24f74 Mon Sep 17 00:00:00 2001 From: mgechev Date: Fri, 30 Oct 2020 14:44:43 +0200 Subject: [PATCH 598/613] Update the list of contributors --- readme.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/readme.md b/readme.md index d1928f9e..e61af141 100644 --- a/readme.md +++ b/readme.md @@ -75,21 +75,21 @@ If the build is not successful, fix your code in order for the tests and jshint :---: |:---: |:---: |:---: |:---: |:---: | [deniskyashif](https://github.com/deniskyashif) |[brunohadlich](https://github.com/brunohadlich) |[designeng](https://github.com/designeng) |[Microfed](https://github.com/Microfed) |[Nirajkashyap](https://github.com/Nirajkashyap) |[pkerpedjiev](https://github.com/pkerpedjiev) | -[duffman85](https://github.com/duffman85) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[dependabot[bot]](https://github.com/apps/dependabot) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) | +[duffman85](https://github.com/duffman85) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) |[BorislavBorisov22](https://github.com/BorislavBorisov22) | :---: |:---: |:---: |:---: |:---: |:---: | -[duffman85](https://github.com/duffman85) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[dependabot[bot]](https://github.com/apps/dependabot) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) | +[duffman85](https://github.com/duffman85) |[Xuefeng-Zhu](https://github.com/Xuefeng-Zhu) |[emyarod](https://github.com/emyarod) |[alexjoverm](https://github.com/alexjoverm) |[amilajack](https://github.com/amilajack) |[BorislavBorisov22](https://github.com/BorislavBorisov22) | -[BorislavBorisov22](https://github.com/BorislavBorisov22) |[brunob15](https://github.com/brunob15) |[BryanChan777](https://github.com/BryanChan777) |[ysharplanguage](https://github.com/ysharplanguage) |[jurassix](https://github.com/jurassix) |[fisenkodv](https://github.com/fisenkodv) | +[brunob15](https://github.com/brunob15) |[BryanChan777](https://github.com/BryanChan777) |[ysharplanguage](https://github.com/ysharplanguage) |[jurassix](https://github.com/jurassix) |[fisenkodv](https://github.com/fisenkodv) |[contra](https://github.com/contra) | :---: |:---: |:---: |:---: |:---: |:---: | -[BorislavBorisov22](https://github.com/BorislavBorisov22) |[brunob15](https://github.com/brunob15) |[BryanChan777](https://github.com/BryanChan777) |[ysharplanguage](https://github.com/ysharplanguage) |[jurassix](https://github.com/jurassix) |[fisenkodv](https://github.com/fisenkodv) | +[brunob15](https://github.com/brunob15) |[BryanChan777](https://github.com/BryanChan777) |[ysharplanguage](https://github.com/ysharplanguage) |[jurassix](https://github.com/jurassix) |[fisenkodv](https://github.com/fisenkodv) |[contra](https://github.com/contra) | -[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[marrcelo](https://github.com/marrcelo) |[wnvko](https://github.com/wnvko) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) | +[liesislukas](https://github.com/liesislukas) |[marrcelo](https://github.com/marrcelo) |[wnvko](https://github.com/wnvko) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) |[DengYiping](https://github.com/DengYiping) | :---: |:---: |:---: |:---: |:---: |:---: | -[contra](https://github.com/contra) |[liesislukas](https://github.com/liesislukas) |[marrcelo](https://github.com/marrcelo) |[wnvko](https://github.com/wnvko) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) | +[liesislukas](https://github.com/liesislukas) |[marrcelo](https://github.com/marrcelo) |[wnvko](https://github.com/wnvko) |[millerrach](https://github.com/millerrach) |[xiedezhuo](https://github.com/xiedezhuo) |[DengYiping](https://github.com/DengYiping) | -[DengYiping](https://github.com/DengYiping) |[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | -:---: |:---: |:---: |:---: | -[DengYiping](https://github.com/DengYiping) |[fanixk](https://github.com/fanixk) |[miyes90](https://github.com/miyes90) |[shaunak1111](https://github.com/shaunak1111) | +[fanixk](https://github.com/fanixk) |[wlx199x](https://github.com/wlx199x) |[shaunak1111](https://github.com/shaunak1111) | +:---: |:---: |:---: | +[fanixk](https://github.com/fanixk) |[wlx199x](https://github.com/wlx199x) |[shaunak1111](https://github.com/shaunak1111) | ## License From 2bb8d32cd5fb26a3465c67b6982bedb5989cedc9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Dec 2020 03:35:34 +0000 Subject: [PATCH 599/613] Bump ini from 1.3.5 to 1.3.7 Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.7. - [Release notes](https://github.com/isaacs/ini/releases) - [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.7) Signed-off-by: dependabot[bot] --- package-lock.json | 12 +++--------- yarn.lock | 6 +++--- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1bc2dde3..d13a486b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2068,12 +2068,6 @@ "dev": true, "optional": true }, - "ini": { - "version": "1.3.5", - "bundled": true, - "dev": true, - "optional": true - }, "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, @@ -2889,9 +2883,9 @@ "dev": true }, "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.7.tgz", + "integrity": "sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ==", "dev": true }, "inquirer": { diff --git a/yarn.lock b/yarn.lock index 45595186..0f7657aa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1753,9 +1753,9 @@ inherits@^2.0.1: integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== ini@^1.3.4, ini@~1.3.0: - version "1.3.5" - resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" - integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== + version "1.3.7" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.7.tgz#a09363e1911972ea16d7a8851005d84cf09a9a84" + integrity sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ== inquirer@^0.12.0: version "0.12.0" From c5d7fb844aa4fc0fba7ed26b719ef2f79017cd11 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 May 2021 22:47:18 +0000 Subject: [PATCH 600/613] Bump hosted-git-info from 2.8.8 to 2.8.9 Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9. - [Release notes](https://github.com/npm/hosted-git-info/releases) - [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md) - [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9) Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- yarn.lock | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index d13a486b..2c787499 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2799,9 +2799,9 @@ } }, "hosted-git-info": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", - "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", "dev": true }, "http-auth": { diff --git a/yarn.lock b/yarn.lock index 0f7657aa..840aae35 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1666,9 +1666,9 @@ homedir-polyfill@^1.0.1: parse-passwd "^1.0.0" hosted-git-info@^2.1.4: - version "2.8.8" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" - integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg== + version "2.8.9" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9" + integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw== http-auth@3.1.x: version "3.1.3" From ed3122501e53eb50933a6d14c127e0744cad77a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 8 May 2021 10:27:48 +0000 Subject: [PATCH 601/613] Bump lodash from 4.17.20 to 4.17.21 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.20...4.17.21) Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- yarn.lock | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2c787499..021a6018 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3485,9 +3485,9 @@ } }, "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, "lodash._basecopy": { diff --git a/yarn.lock b/yarn.lock index 840aae35..3cf75757 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2363,9 +2363,9 @@ lodash.templatesettings@^3.0.0: lodash.escape "^3.0.0" lodash@^4.0.0, lodash@^4.17.10, lodash@^4.3.0: - version "4.17.20" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" - integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== make-iterator@^1.0.0: version "1.0.1" From 396d83c6496ccd5f9e2a4a4d7e6b331014df6ab5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 31 Mar 2021 17:28:17 +0000 Subject: [PATCH 602/613] Bump y18n from 3.2.1 to 3.2.2 Bumps [y18n](https://github.com/yargs/y18n) from 3.2.1 to 3.2.2. - [Release notes](https://github.com/yargs/y18n/releases) - [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md) - [Commits](https://github.com/yargs/y18n/commits) Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- yarn.lock | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 021a6018..bf84e08e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5815,9 +5815,9 @@ "dev": true }, "y18n": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", - "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.2.tgz", + "integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==", "dev": true }, "yargs": { diff --git a/yarn.lock b/yarn.lock index 3cf75757..16e41e1a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4026,9 +4026,9 @@ xtend@~4.0.0: integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== y18n@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" - integrity sha1-bRX7qITAhnnA136I53WegR4H+kE= + version "3.2.2" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.2.tgz#85c901bd6470ce71fc4bb723ad209b70f7f28696" + integrity sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ== yallist@^3.0.0, yallist@^3.0.2: version "3.0.3" From bfc1287428c6d79b57911cea1c365f2117f4108f Mon Sep 17 00:00:00 2001 From: Bernhard Fritz Date: Sat, 9 Oct 2021 13:58:26 +0200 Subject: [PATCH 603/613] add bezier curve algorithm --- src/graphics/bezier.js | 19 +++++++++++++ test/graphics/bezier.spec.js | 54 ++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 src/graphics/bezier.js create mode 100644 test/graphics/bezier.spec.js diff --git a/src/graphics/bezier.js b/src/graphics/bezier.js new file mode 100644 index 00000000..1e0ccf80 --- /dev/null +++ b/src/graphics/bezier.js @@ -0,0 +1,19 @@ +(function (exports) { + 'use strict'; + + function linearBezier(p0, p1, t) { + return p0 + t * (p1 - p0); + } + + function quadraticBezier(p0, p1, p2, t) { + return linearBezier(linearBezier(p0, p1, t), linearBezier(p1, p2, t), t); + } + + function cubicBezier(p0, p1, p2, p3, t) { + return linearBezier(quadraticBezier(p0, p1, p2, t), quadraticBezier(p1, p2, p3, t), t); + } + + exports.linearBezier = linearBezier; + exports.quadraticBezier = quadraticBezier; + exports.cubicBezier = cubicBezier; +})(typeof exports === 'undefined' ? window : exports); diff --git a/test/graphics/bezier.spec.js b/test/graphics/bezier.spec.js new file mode 100644 index 00000000..56f83ff2 --- /dev/null +++ b/test/graphics/bezier.spec.js @@ -0,0 +1,54 @@ +var bezier = require('../../src/graphics/bezier'); +var linearBezier = bezier.linearBezier; +var quadraticBezier = bezier.quadraticBezier; +var cubicBezier = bezier.cubicBezier; + +// see https://www.geogebra.org/m/ek7RHvuc for graphical representation of test values + +describe('linearBezier', function () { + 'use strict'; + + it('should return 0.5 for p0=0 p1=1 t=0.5', function () { + expect(linearBezier(0, 1, 0.5)).toEqual(0.5); + }); + + it('should return -2.8 for p0=-4.67 p1=-0.7 t=0.47', function () { + expect(linearBezier(-4.67, -0.7, 0.47)).toBeCloseTo(-2.8, 1); + }); + + it('should return 2.67 for p0=-0.6 p1=6.33 t=0.47', function () { + expect(linearBezier(-0.6, 6.33, 0.47)).toBeCloseTo(2.67, 1); + }); +}); + +describe('quadraticBezier', function () { + 'use strict'; + + it('should return 1 for p0=0 p1=1 p2=2 t=0.5', function () { + expect(quadraticBezier(0, 1, 2, 0.5)).toEqual(1); + }); + + it('should return 7.15 for p0=2.33 p1=8.23 p2=10.77 t=0.47', function () { + expect(quadraticBezier(2.33, 8.23, 10.77, 0.47)).toBeCloseTo(7.15, 1); + }); + + it('should return 6.84 for p0=4.67 p1=8.93 p2=4.9 t=0.47', function () { + expect(quadraticBezier(4.67, 8.93, 4.9, 0.47)).toBeCloseTo(6.84, 1); + }); +}); + +describe('cubicBezier', function () { + 'use strict'; + + it('should return 1.5 for p0=0 p1=1 p2=2 p3=3 t=0.5', function () { + expect(cubicBezier(0, 1, 2, 3, 0.5)).toEqual(1.5); + }); + + it('should return 9.78 for p0=2.4 p1=1.33 p2=19.87 p3=18.13 t=0.47', function () { + expect(cubicBezier(2.4, 1.33, 19.87, 18.13, 0.47)).toBeCloseTo(9.78, 1); + }); + + it('should return -4.87 for p0=-7.03 p1=-1.4 p2=-10.63 p3=4.5 t=0.47', function () { + expect(cubicBezier(-7.03, -1.4, -10.63, 4.5, 0.47)).toBeCloseTo(-4.87, 1); + }); +}); From 43250c73aa781f50335137d168278ba67bdf3150 Mon Sep 17 00:00:00 2001 From: Syed Fasiuddin Date: Wed, 13 Oct 2021 12:05:35 +0530 Subject: [PATCH 604/613] added linear search algorithm --- src/searching/linearSearch.js | 24 ++++++++++++++++++++++++ test/searching/linearSearch.spec.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 src/searching/linearSearch.js create mode 100644 test/searching/linearSearch.spec.js diff --git a/src/searching/linearSearch.js b/src/searching/linearSearch.js new file mode 100644 index 00000000..7338a82f --- /dev/null +++ b/src/searching/linearSearch.js @@ -0,0 +1,24 @@ +(function (exports) { + 'use strict'; + + /** + * Searches for specific element in a given array + * using the linear search algorithm + * Time complexity: O(n) + * + * @param {Array} array Input array + * @param {Number} key the number whose index is to be found + * @returns {Number} the index of the first instance of number or else -1 if not found + */ + + const linearSearch = (array, key) => { + for (let i = 0; i < array.length; i++) { + if (array[i] == key) { + return i; + } + } + return -1; + } + + exports.linearSearch = linearSearch; +})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file diff --git a/test/searching/linearSearch.spec.js b/test/searching/linearSearch.spec.js new file mode 100644 index 00000000..6540bf5a --- /dev/null +++ b/test/searching/linearSearch.spec.js @@ -0,0 +1,28 @@ +var linearSearch = + require('../../src/searching/linearSearch').linearSearch; + +describe('Linear Search', function () { + 'use strict'; + + it('should find the element at position 0 ', function () { + expect(linearSearch([1, 2, 3, 4, 6, 8], 1)).toBe(0); + }); + + it('should find the element in position arr.length - 1', function () { + var arr = [1, 2, 3, 4, 6, 8]; + expect(linearSearch(arr, 8)).toBe(arr.length - 1); + }); + + it('should work with arrays with 2 elements', function () { + expect(linearSearch([1, 8], 1)).toBe(0); + expect(linearSearch([1, 8], 8)).toBe(1); + }); + + it('should return a negative number for missing elements', function () { + expect(linearSearch([1, 2, 3], 4)).toBeLessThan(0); + }); + + it('should work with empty arrays', function () { + expect(linearSearch([], 4)).toBe(-1); + }); +}); From 531260498496640b136070cee7ba3229697f6a30 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Sep 2021 02:32:21 +0000 Subject: [PATCH 605/613] Bump tar from 4.4.8 to 4.4.19 Bumps [tar](https://github.com/npm/node-tar) from 4.4.8 to 4.4.19. - [Release notes](https://github.com/npm/node-tar/releases) - [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/node-tar/compare/v4.4.8...v4.4.19) --- updated-dependencies: - dependency-name: tar dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 113 ++++++++++++++++++++++++++++++++++++---------- yarn.lock | 90 ++++++++++++++++++------------------ 2 files changed, 133 insertions(+), 70 deletions(-) diff --git a/package-lock.json b/package-lock.json index bf84e08e..adf0c920 100644 --- a/package-lock.json +++ b/package-lock.json @@ -661,6 +661,13 @@ } } }, + "chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", + "dev": true, + "optional": true + }, "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", @@ -1855,6 +1862,16 @@ "universalify": "^0.1.0" } }, + "fs-minipass": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", + "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", + "dev": true, + "optional": true, + "requires": { + "minipass": "^2.6.0" + } + }, "fs-mkdirp-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz", @@ -1928,9 +1945,7 @@ }, "chownr": { "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true + "bundled": true }, "code-point-at": { "version": "1.1.0", @@ -1986,8 +2001,6 @@ "fs-minipass": { "version": "1.2.5", "bundled": true, - "dev": true, - "optional": true, "requires": { "minipass": "^2.2.1" } @@ -2101,7 +2114,6 @@ "minipass": { "version": "2.3.5", "bundled": true, - "dev": true, "optional": true, "requires": { "safe-buffer": "^5.1.2", @@ -2111,8 +2123,6 @@ "minizlib": { "version": "1.2.1", "bundled": true, - "dev": true, - "optional": true, "requires": { "minipass": "^2.2.1" } @@ -2301,7 +2311,6 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, "optional": true }, "safer-buffer": { @@ -2369,21 +2378,6 @@ "dev": true, "optional": true }, - "tar": { - "version": "4.4.8", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "chownr": "^1.1.1", - "fs-minipass": "^1.2.5", - "minipass": "^2.3.4", - "minizlib": "^1.1.1", - "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.2", - "yallist": "^3.0.2" - } - }, "util-deprecate": { "version": "1.0.2", "bundled": true, @@ -2408,7 +2402,6 @@ "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, "optional": true } } @@ -3728,6 +3721,27 @@ "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true }, + "minipass": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", + "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz", + "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", + "dev": true, + "optional": true, + "requires": { + "minipass": "^2.9.0" + } + }, "mixin-deep": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", @@ -5217,6 +5231,48 @@ "integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=", "dev": true }, + "tar": { + "version": "4.4.19", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.19.tgz", + "integrity": "sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA==", + "dev": true, + "optional": true, + "requires": { + "chownr": "^1.1.4", + "fs-minipass": "^1.2.7", + "minipass": "^2.9.0", + "minizlib": "^1.3.3", + "mkdirp": "^0.5.5", + "safe-buffer": "^5.2.1", + "yallist": "^3.1.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true, + "optional": true + }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "optional": true, + "requires": { + "minimist": "^1.2.5" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "optional": true + } + } + }, "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -5820,6 +5876,13 @@ "integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==", "dev": true }, + "yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true, + "optional": true + }, "yargs": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/yargs/-/yargs-7.1.1.tgz", diff --git a/yarn.lock b/yarn.lock index 16e41e1a..ed2c2195 100644 --- a/yarn.lock +++ b/yarn.lock @@ -478,10 +478,10 @@ chokidar@^2.0.4: optionalDependencies: fsevents "^1.2.7" -chownr@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.1.tgz#54726b8b8fff4df053c42187e801fb4412df1494" - integrity sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g== +chownr@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b" + integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== circular-json@^0.3.1: version "0.3.3" @@ -1308,12 +1308,12 @@ fs-extra@^5.0.0: jsonfile "^4.0.0" universalify "^0.1.0" -fs-minipass@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d" - integrity sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ== +fs-minipass@^1.2.7: + version "1.2.7" + resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7" + integrity sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA== dependencies: - minipass "^2.2.1" + minipass "^2.6.0" fs-mkdirp-stream@^1.0.0: version "1.0.0" @@ -2449,30 +2449,30 @@ minimatch@^3.0.4: dependencies: brace-expansion "^1.1.7" -minimist@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" - integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0= - minimist@^1.1.0, minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= -minipass@^2.2.1, minipass@^2.3.4: - version "2.3.5" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.3.5.tgz#cacebe492022497f656b0f0f51e2682a9ed2d848" - integrity sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA== +minimist@^1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" + integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== + +minipass@^2.6.0, minipass@^2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.9.0.tgz#e713762e7d3e32fed803115cf93e04bca9fcc9a6" + integrity sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg== dependencies: safe-buffer "^5.1.2" yallist "^3.0.0" -minizlib@^1.1.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.2.1.tgz#dd27ea6136243c7c880684e8672bb3a45fd9b614" - integrity sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA== +minizlib@^1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.3.3.tgz#2290de96818a34c29551c8a8d301216bd65a861d" + integrity sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q== dependencies: - minipass "^2.2.1" + minipass "^2.9.0" mixin-deep@^1.2.0: version "1.3.2" @@ -2482,12 +2482,12 @@ mixin-deep@^1.2.0: for-in "^1.0.2" is-extendable "^1.0.1" -mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" - integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM= +mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@^0.5.5, mkdirp@~0.5.1: + version "0.5.5" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" + integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== dependencies: - minimist "0.0.8" + minimist "^1.2.5" morgan@^1.9.1: version "1.9.1" @@ -3246,12 +3246,12 @@ rx-lite@^3.1.2: resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-3.1.2.tgz#19ce502ca572665f3b647b10939f97fd1615f102" integrity sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI= -safe-buffer@5.1.2, safe-buffer@^5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: +safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-buffer@^5.1.0: +safe-buffer@^5.1.0, safe-buffer@^5.1.2, safe-buffer@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -3648,17 +3648,17 @@ taffydb@2.6.2: integrity sha1-fLy2S1oUG2ou/CxdLGe04VCyomg= tar@^4: - version "4.4.8" - resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.8.tgz#b19eec3fde2a96e64666df9fdb40c5ca1bc3747d" - integrity sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ== - dependencies: - chownr "^1.1.1" - fs-minipass "^1.2.5" - minipass "^2.3.4" - minizlib "^1.1.1" - mkdirp "^0.5.0" - safe-buffer "^5.1.2" - yallist "^3.0.2" + version "4.4.19" + resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.19.tgz#2e4d7263df26f2b914dee10c825ab132123742f3" + integrity sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA== + dependencies: + chownr "^1.1.4" + fs-minipass "^1.2.7" + minipass "^2.9.0" + minizlib "^1.3.3" + mkdirp "^0.5.5" + safe-buffer "^5.2.1" + yallist "^3.1.1" text-table@~0.2.0: version "0.2.0" @@ -4030,10 +4030,10 @@ y18n@^3.2.1: resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.2.tgz#85c901bd6470ce71fc4bb723ad209b70f7f28696" integrity sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ== -yallist@^3.0.0, yallist@^3.0.2: - version "3.0.3" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9" - integrity sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A== +yallist@^3.0.0, yallist@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" + integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== yargs-parser@5.0.0-security.0: version "5.0.0-security.0" From f3e1607a2372e78619834034bad6bf7749d7280f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Aug 2021 22:50:43 +0000 Subject: [PATCH 606/613] Bump path-parse from 1.0.6 to 1.0.7 Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- yarn.lock | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index adf0c920..ff260f12 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4201,9 +4201,9 @@ "dev": true }, "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, "path-root": { diff --git a/yarn.lock b/yarn.lock index ed2c2195..3867b4bb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2872,9 +2872,9 @@ path-is-inside@^1.0.1: integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM= path-parse@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" - integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== + version "1.0.7" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" + integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== path-root-regex@^0.1.0: version "0.1.2" From a621820d3d2d024bc57365cf0e2cc6be17059cc4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Jan 2022 17:39:30 +0000 Subject: [PATCH 607/613] Bump copy-props from 2.0.4 to 2.0.5 Bumps [copy-props](https://github.com/gulpjs/copy-props) from 2.0.4 to 2.0.5. - [Release notes](https://github.com/gulpjs/copy-props/releases) - [Changelog](https://github.com/gulpjs/copy-props/blob/master/CHANGELOG.md) - [Commits](https://github.com/gulpjs/copy-props/compare/2.0.4...2.0.5) --- updated-dependencies: - dependency-name: copy-props dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 18 +++++++++++++----- yarn.lock | 17 +++++++++++------ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index ff260f12..ff8a81a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -919,13 +919,21 @@ "dev": true }, "copy-props": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/copy-props/-/copy-props-2.0.4.tgz", - "integrity": "sha512-7cjuUME+p+S3HZlbllgsn2CDwS+5eCCX16qBgNC4jgSTf49qR1VKy/Zhl400m0IQXl/bPGEVqncgUUMjrr4s8A==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/copy-props/-/copy-props-2.0.5.tgz", + "integrity": "sha512-XBlx8HSqrT0ObQwmSzM7WE5k8FxTV75h1DX1Z3n6NhQ/UYYAvInWYmG06vFt7hQZArE2fuO62aihiWIVQwh1sw==", "dev": true, "requires": { - "each-props": "^1.3.0", - "is-plain-object": "^2.0.1" + "each-props": "^1.3.2", + "is-plain-object": "^5.0.0" + }, + "dependencies": { + "is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", + "dev": true + } } }, "core-util-is": { diff --git a/yarn.lock b/yarn.lock index 3867b4bb..95706006 100644 --- a/yarn.lock +++ b/yarn.lock @@ -643,12 +643,12 @@ copy-descriptor@^0.1.0: integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= copy-props@^2.0.1: - version "2.0.4" - resolved "https://registry.yarnpkg.com/copy-props/-/copy-props-2.0.4.tgz#93bb1cadfafd31da5bb8a9d4b41f471ec3a72dfe" - integrity sha512-7cjuUME+p+S3HZlbllgsn2CDwS+5eCCX16qBgNC4jgSTf49qR1VKy/Zhl400m0IQXl/bPGEVqncgUUMjrr4s8A== + version "2.0.5" + resolved "https://registry.yarnpkg.com/copy-props/-/copy-props-2.0.5.tgz#03cf9ae328d4ebb36f8f1d804448a6af9ee3f2d2" + integrity sha512-XBlx8HSqrT0ObQwmSzM7WE5k8FxTV75h1DX1Z3n6NhQ/UYYAvInWYmG06vFt7hQZArE2fuO62aihiWIVQwh1sw== dependencies: - each-props "^1.3.0" - is-plain-object "^2.0.1" + each-props "^1.3.2" + is-plain-object "^5.0.0" core-util-is@~1.0.0: version "1.0.2" @@ -797,7 +797,7 @@ duplexify@^3.6.0: readable-stream "^2.0.0" stream-shift "^1.0.0" -each-props@^1.3.0: +each-props@^1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/each-props/-/each-props-1.3.2.tgz#ea45a414d16dd5cfa419b1a81720d5ca06892333" integrity sha512-vV0Hem3zAGkJAyU7JSjixeU66rwdynTAa1vofCrSA5fEln+m67Az9CcnkVD776/fsN/UjIWmBDoNRS6t6G9RfA== @@ -1972,6 +1972,11 @@ is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: dependencies: isobject "^3.0.1" +is-plain-object@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" + integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== + is-property@^1.0.0, is-property@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" From 213636fc58768364fd60ae959c61e1b136a5e85e Mon Sep 17 00:00:00 2001 From: Rajratna Maitry <49335238+rajratnamaitry@users.noreply.github.com> Date: Mon, 11 Jul 2022 12:54:55 +0530 Subject: [PATCH 608/613] fibonacci optimize with Memory pattern --- src/others/fibonacciMemory.js | 32 +++++++++++++++++++++++++++++ test/others/fibonacciMemory.spec.js | 28 +++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/others/fibonacciMemory.js create mode 100644 test/others/fibonacciMemory.spec.js diff --git a/src/others/fibonacciMemory.js b/src/others/fibonacciMemory.js new file mode 100644 index 00000000..256979bd --- /dev/null +++ b/src/others/fibonacciMemory.js @@ -0,0 +1,32 @@ +/** + * Nth number of fibonacciMemory's sequence + * + * Returns the nth number of fibonacciMemory's sequence. + * + * @public + * + * @example + * var fibonacciMemory = require('path-to-algorithms/src/others/fibonacciMemory').fibonacciMemory; + * var nth = fibonacciMemory(20); + * + * console.log(nth); // 6765 + * + * @param {Number} n The nth position in fibonacciMemory's sequence + * + * @module others/fibonacciMemory +*/ +(function (exports) { + 'use strict'; + + function fibonacciMemory(n) { + var i = 0; + var aux = [0, 1]; + while (n != i) { + aux[i + 2] = aux[i] + aux[i + 1]; + i++; + } + return aux[i]; + } + + exports.fibonacciMemory = fibonacciMemory; +})(typeof window === 'undefined' ? module.exports : window); diff --git a/test/others/fibonacciMemory.spec.js b/test/others/fibonacciMemory.spec.js new file mode 100644 index 00000000..a2c5c118 --- /dev/null +++ b/test/others/fibonacciMemory.spec.js @@ -0,0 +1,28 @@ +var mod = require('../../src/others/fibonacciMemory.js'); +var fibonacci = mod.fibonacciMemory; + +describe('fibonacci with Memory algorithm', function () { + 'use strict'; + + it('should return value 1 with input 1.', function () { + expect(fibonacci(1)).toBe(1); + }); + it('should return value 6 with input 8.', function () { + expect(fibonacci(6)).toBe(8); + }); + it('should return value 7 with input 13.', function () { + expect(fibonacci(7)).toBe(13); + }); + it('should return value 8 with input 21.', function () { + expect(fibonacci(8)).toBe(21); + }); + it('should return value 9 with input 34.', function () { + expect(fibonacci(9)).toBe(34); + }); + it('should return value 10 with input 55.', function () { + expect(fibonacci(10)).toBe(55); + }); + it('should be 135301852344706760000 with input 98.', function () { + expect(fibonacci(98)).toBe(135301852344706760000); + }); +}); From cf8aa67f67d5fbf5e246245ac42277a88c1e512b Mon Sep 17 00:00:00 2001 From: cHaLkdusT Date: Tue, 4 Oct 2022 13:50:21 +0800 Subject: [PATCH 609/613] :rotating_light: Fix linter errors --- src/others/fibonacci.js | 4 +-- src/others/fibonacciMemory.js | 22 ++++++++--------- src/searching/linearSearch.js | 38 ++++++++++++++--------------- test/others/fibonacciMemory.spec.js | 2 +- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/others/fibonacci.js b/src/others/fibonacci.js index 1b56562e..324c32cd 100644 --- a/src/others/fibonacci.js +++ b/src/others/fibonacci.js @@ -14,11 +14,11 @@ * @param {Number} n The nth position in fibonacci's sequence * * @module others/fibonacci -*/ + */ (function (exports) { 'use strict'; - function fibonacci (n) { + function fibonacci(n) { if (n > 97) { throw 'Input too large, results in inaccurate fibonacci value.'; } diff --git a/src/others/fibonacciMemory.js b/src/others/fibonacciMemory.js index 256979bd..1bbfc6a1 100644 --- a/src/others/fibonacciMemory.js +++ b/src/others/fibonacciMemory.js @@ -14,19 +14,19 @@ * @param {Number} n The nth position in fibonacciMemory's sequence * * @module others/fibonacciMemory -*/ + */ (function (exports) { - 'use strict'; + 'use strict'; - function fibonacciMemory(n) { - var i = 0; - var aux = [0, 1]; - while (n != i) { - aux[i + 2] = aux[i] + aux[i + 1]; - i++; - } - return aux[i]; + function fibonacciMemory(n) { + var i = 0; + var aux = [0, 1]; + while (n !== i) { + aux[i + 2] = aux[i] + aux[i + 1]; + i += 1; } + return aux[i]; + } - exports.fibonacciMemory = fibonacciMemory; + exports.fibonacciMemory = fibonacciMemory; })(typeof window === 'undefined' ? module.exports : window); diff --git a/src/searching/linearSearch.js b/src/searching/linearSearch.js index 7338a82f..9a95dfa4 100644 --- a/src/searching/linearSearch.js +++ b/src/searching/linearSearch.js @@ -1,24 +1,24 @@ (function (exports) { - 'use strict'; + 'use strict'; - /** - * Searches for specific element in a given array - * using the linear search algorithm - * Time complexity: O(n) - * - * @param {Array} array Input array - * @param {Number} key the number whose index is to be found - * @returns {Number} the index of the first instance of number or else -1 if not found - */ + /** + * Searches for specific element in a given array + * using the linear search algorithm + * Time complexity: O(n) + * + * @param {Array} array Input array + * @param {Number} key the number whose index is to be found + * @returns {Number} the index of the first instance of number or else -1 if not found + */ - const linearSearch = (array, key) => { - for (let i = 0; i < array.length; i++) { - if (array[i] == key) { - return i; - } - } - return -1; + const linearSearch = (array, key) => { + for (let i = 0; i < array.length; i += 1) { + if (array[i] === key) { + return i; + } } + return -1; + }; - exports.linearSearch = linearSearch; -})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file + exports.linearSearch = linearSearch; +})(typeof window === 'undefined' ? module.exports : window); diff --git a/test/others/fibonacciMemory.spec.js b/test/others/fibonacciMemory.spec.js index a2c5c118..f90ac1df 100644 --- a/test/others/fibonacciMemory.spec.js +++ b/test/others/fibonacciMemory.spec.js @@ -21,7 +21,7 @@ describe('fibonacci with Memory algorithm', function () { }); it('should return value 10 with input 55.', function () { expect(fibonacci(10)).toBe(55); - }); + }); it('should be 135301852344706760000 with input 98.', function () { expect(fibonacci(98)).toBe(135301852344706760000); }); From df6d6ea20e8a433bbcd5c95d5140b84abc657aeb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Mar 2023 12:12:34 +0000 Subject: [PATCH 610/613] Bump minimist and mkdirp Bumps [minimist](https://github.com/minimistjs/minimist), [minimist](https://github.com/minimistjs/minimist) and [mkdirp](https://github.com/isaacs/node-mkdirp). These dependencies needed to be updated together. Updates `minimist` from 1.2.0 to 1.2.8 - [Release notes](https://github.com/minimistjs/minimist/releases) - [Changelog](https://github.com/minimistjs/minimist/blob/main/CHANGELOG.md) - [Commits](https://github.com/minimistjs/minimist/compare/v1.2.0...v1.2.8) Updates `minimist` from 1.2.5 to 1.2.8 - [Release notes](https://github.com/minimistjs/minimist/releases) - [Changelog](https://github.com/minimistjs/minimist/blob/main/CHANGELOG.md) - [Commits](https://github.com/minimistjs/minimist/compare/v1.2.0...v1.2.8) Updates `mkdirp` from 0.5.1 to 0.5.6 - [Release notes](https://github.com/isaacs/node-mkdirp/releases) - [Changelog](https://github.com/isaacs/node-mkdirp/blob/main/CHANGELOG.md) - [Commits](https://github.com/isaacs/node-mkdirp/compare/0.5.1...v0.5.6) --- updated-dependencies: - dependency-name: minimist dependency-type: indirect - dependency-name: minimist dependency-type: indirect - dependency-name: mkdirp dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 62 ++++++----------------------------------------- yarn.lock | 21 ++++++---------- 2 files changed, 15 insertions(+), 68 deletions(-) diff --git a/package-lock.json b/package-lock.json index ff8a81a1..2c4ce167 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2113,12 +2113,6 @@ "brace-expansion": "^1.1.7" } }, - "minimist": { - "version": "0.0.8", - "bundled": true, - "dev": true, - "optional": true - }, "minipass": { "version": "2.3.5", "bundled": true, @@ -2135,15 +2129,6 @@ "minipass": "^2.2.1" } }, - "mkdirp": { - "version": "0.5.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minimist": "0.0.8" - } - }, "ms": { "version": "2.1.1", "bundled": true, @@ -2282,14 +2267,6 @@ "ini": "~1.3.0", "minimist": "^1.2.0", "strip-json-comments": "~2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true - } } }, "readable-stream": { @@ -3724,9 +3701,9 @@ } }, "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", "dev": true }, "minipass": { @@ -3772,20 +3749,12 @@ } }, "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "requires": { - "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - } + "minimist": "^1.2.6" } }, "morgan": { @@ -5255,23 +5224,6 @@ "yallist": "^3.1.1" }, "dependencies": { - "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true, - "optional": true - }, - "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "optional": true, - "requires": { - "minimist": "^1.2.5" - } - }, "safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", diff --git a/yarn.lock b/yarn.lock index 95706006..068ad093 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2454,15 +2454,10 @@ minimatch@^3.0.4: dependencies: brace-expansion "^1.1.7" -minimist@^1.1.0, minimist@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" - integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= - -minimist@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" - integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== +minimist@^1.1.0, minimist@^1.2.0, minimist@^1.2.6: + version "1.2.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" + integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== minipass@^2.6.0, minipass@^2.9.0: version "2.9.0" @@ -2488,11 +2483,11 @@ mixin-deep@^1.2.0: is-extendable "^1.0.1" mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@^0.5.5, mkdirp@~0.5.1: - version "0.5.5" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" - integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== + version "0.5.6" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" + integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== dependencies: - minimist "^1.2.5" + minimist "^1.2.6" morgan@^1.9.1: version "1.9.1" From eb8c6d11173000797dd0db27f39253a3ac1ae91e Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Sun, 15 Oct 2023 14:03:24 -0700 Subject: [PATCH 611/613] Remove package-lock.json and use only yarn.lock --- package-lock.json | 5878 --------------------------------------------- 1 file changed, 5878 deletions(-) delete mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 2c4ce167..00000000 --- a/package-lock.json +++ /dev/null @@ -1,5878 +0,0 @@ -{ - "name": "javascript-algorithms", - "version": "0.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@jeremyckahn/minami": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@jeremyckahn/minami/-/minami-1.3.1.tgz", - "integrity": "sha512-jeOFPfq3zLxnQ0dhlhrZd5J0qZDdF1wkrNlr6ErVaGtjPTq9gn/NIK0GDOmGcAJgN/6yKwRdMxPy33u12lQWiQ==", - "dev": true - }, - "accepts": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", - "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", - "dev": true, - "requires": { - "mime-types": "~2.1.24", - "negotiator": "0.6.2" - } - }, - "acorn": { - "version": "5.7.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", - "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==", - "dev": true - }, - "acorn-jsx": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", - "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", - "dev": true, - "requires": { - "acorn": "^3.0.4" - }, - "dependencies": { - "acorn": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", - "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", - "dev": true - } - } - }, - "ajv": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", - "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", - "dev": true, - "requires": { - "co": "^4.6.0", - "json-stable-stringify": "^1.0.1" - } - }, - "ajv-keywords": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz", - "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=", - "dev": true - }, - "ansi-colors": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", - "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", - "dev": true, - "requires": { - "ansi-wrap": "^0.1.0" - } - }, - "ansi-escapes": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", - "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", - "dev": true - }, - "ansi-gray": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/ansi-gray/-/ansi-gray-0.1.1.tgz", - "integrity": "sha1-KWLPVOyXksSFEKPetSRDaGHvclE=", - "dev": true, - "requires": { - "ansi-wrap": "0.1.0" - } - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "ansi-wrap": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz", - "integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=", - "dev": true - }, - "anymatch": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", - "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", - "dev": true, - "requires": { - "micromatch": "^3.1.4", - "normalize-path": "^2.1.1" - }, - "dependencies": { - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true, - "requires": { - "remove-trailing-separator": "^1.0.1" - } - } - } - }, - "apache-crypt": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/apache-crypt/-/apache-crypt-1.2.1.tgz", - "integrity": "sha1-1vxyqm0n2ZyVqU/RiNcx7v/6Zjw=", - "dev": true, - "requires": { - "unix-crypt-td-js": "^1.0.0" - } - }, - "apache-md5": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/apache-md5/-/apache-md5-1.1.2.tgz", - "integrity": "sha1-7klza2ObTxCLbp5ibG2pkwa0FpI=", - "dev": true - }, - "append-buffer": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/append-buffer/-/append-buffer-1.0.2.tgz", - "integrity": "sha1-2CIM9GYIFSXv6lBhTz3mUU36WPE=", - "dev": true, - "requires": { - "buffer-equal": "^1.0.0" - } - }, - "archy": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", - "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", - "dev": true - }, - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "requires": { - "sprintf-js": "~1.0.2" - } - }, - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true - }, - "arr-filter": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/arr-filter/-/arr-filter-1.1.2.tgz", - "integrity": "sha1-Q/3d0JHo7xGqTEXZzcGOLf8XEe4=", - "dev": true, - "requires": { - "make-iterator": "^1.0.0" - } - }, - "arr-flatten": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "dev": true - }, - "arr-map": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/arr-map/-/arr-map-2.0.2.tgz", - "integrity": "sha1-Onc0X/wc814qkYJWAfnljy4kysQ=", - "dev": true, - "requires": { - "make-iterator": "^1.0.0" - } - }, - "arr-union": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true - }, - "array-differ": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", - "integrity": "sha1-7/UuN1gknTO+QCuLuOVkuytdQDE=", - "dev": true - }, - "array-each": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/array-each/-/array-each-1.0.1.tgz", - "integrity": "sha1-p5SvDAWrF1KEbudTofIRoFugxE8=", - "dev": true - }, - "array-initial": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/array-initial/-/array-initial-1.1.0.tgz", - "integrity": "sha1-L6dLJnOTccOUe9enrcc74zSz15U=", - "dev": true, - "requires": { - "array-slice": "^1.0.0", - "is-number": "^4.0.0" - }, - "dependencies": { - "is-number": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", - "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", - "dev": true - } - } - }, - "array-last": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/array-last/-/array-last-1.3.0.tgz", - "integrity": "sha512-eOCut5rXlI6aCOS7Z7kCplKRKyiFQ6dHFBem4PwlwKeNFk2/XxTrhRh5T9PyaEWGy/NHTZWbY+nsZlNFJu9rYg==", - "dev": true, - "requires": { - "is-number": "^4.0.0" - }, - "dependencies": { - "is-number": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", - "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", - "dev": true - } - } - }, - "array-slice": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-1.1.0.tgz", - "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==", - "dev": true - }, - "array-sort": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-sort/-/array-sort-1.0.0.tgz", - "integrity": "sha512-ihLeJkonmdiAsD7vpgN3CRcx2J2S0TiYW+IS/5zHBI7mKUq3ySvBdzzBfD236ubDBQFiiyG3SWCPc+msQ9KoYg==", - "dev": true, - "requires": { - "default-compare": "^1.0.0", - "get-value": "^2.0.6", - "kind-of": "^5.0.2" - }, - "dependencies": { - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - } - } - }, - "array-union": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", - "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", - "dev": true, - "requires": { - "array-uniq": "^1.0.1" - } - }, - "array-uniq": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", - "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", - "dev": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true - }, - "arrify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", - "dev": true - }, - "assign-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", - "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "dev": true - }, - "async": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", - "integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==", - "dev": true, - "requires": { - "lodash": "^4.17.10" - } - }, - "async-done": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/async-done/-/async-done-1.3.2.tgz", - "integrity": "sha512-uYkTP8dw2og1tu1nmza1n1CMW0qb8gWWlwqMmLb7MhBVs4BXrFziT6HXUd+/RlRA/i4H9AkofYloUbs1fwMqlw==", - "dev": true, - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.2", - "process-nextick-args": "^2.0.0", - "stream-exhaust": "^1.0.1" - } - }, - "async-each": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", - "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", - "dev": true - }, - "async-settle": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/async-settle/-/async-settle-1.0.0.tgz", - "integrity": "sha1-HQqRS7Aldb7IqPOnTlCA9yssDGs=", - "dev": true, - "requires": { - "async-done": "^1.2.2" - } - }, - "atob": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", - "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", - "dev": true - }, - "babel-code-frame": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", - "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", - "dev": true, - "requires": { - "chalk": "^1.1.3", - "esutils": "^2.0.2", - "js-tokens": "^3.0.2" - } - }, - "babylon": { - "version": "7.0.0-beta.19", - "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.19.tgz", - "integrity": "sha512-Vg0C9s/REX6/WIXN37UKpv5ZhRi6A4pjHlpkE34+8/a6c2W1Q692n3hmc+SZG5lKRnaExLUbxtJ1SVT+KaCQ/A==", - "dev": true - }, - "bach": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/bach/-/bach-1.2.0.tgz", - "integrity": "sha1-Szzpa/JxNPeaG0FKUcFONMO9mIA=", - "dev": true, - "requires": { - "arr-filter": "^1.1.1", - "arr-flatten": "^1.0.1", - "arr-map": "^2.0.0", - "array-each": "^1.0.0", - "array-initial": "^1.0.0", - "array-last": "^1.1.1", - "async-done": "^1.2.2", - "async-settle": "^1.0.0", - "now-and-later": "^2.0.0" - } - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "base": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", - "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", - "dev": true, - "requires": { - "cache-base": "^1.0.1", - "class-utils": "^0.3.5", - "component-emitter": "^1.2.1", - "define-property": "^1.0.0", - "isobject": "^3.0.1", - "mixin-deep": "^1.2.0", - "pascalcase": "^0.1.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "basic-auth": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", - "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", - "dev": true, - "requires": { - "safe-buffer": "5.1.2" - } - }, - "batch": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", - "integrity": "sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY=", - "dev": true - }, - "bcryptjs": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", - "integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=", - "dev": true - }, - "beeper": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/beeper/-/beeper-1.1.1.tgz", - "integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=", - "dev": true - }, - "binary-extensions": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", - "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", - "dev": true - }, - "bluebird": { - "version": "3.5.5", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz", - "integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==", - "dev": true - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, - "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "buffer-equal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.0.tgz", - "integrity": "sha1-WWFrSYME1Var1GaWayLu2j7KX74=", - "dev": true - }, - "buffer-from": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", - "dev": true - }, - "bufferstreams": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/bufferstreams/-/bufferstreams-1.1.3.tgz", - "integrity": "sha512-HaJnVuslRF4g2kSDeyl++AaVizoitCpL9PglzCYwy0uHHyvWerfvEb8jWmYbF1z4kiVFolGomnxSGl+GUQp2jg==", - "dev": true, - "requires": { - "readable-stream": "^2.0.2" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, - "cache-base": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", - "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", - "dev": true, - "requires": { - "collection-visit": "^1.0.0", - "component-emitter": "^1.2.1", - "get-value": "^2.0.6", - "has-value": "^1.0.0", - "isobject": "^3.0.1", - "set-value": "^2.0.0", - "to-object-path": "^0.3.0", - "union-value": "^1.0.0", - "unset-value": "^1.0.0" - } - }, - "caller-path": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", - "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", - "dev": true, - "requires": { - "callsites": "^0.2.0" - } - }, - "callsites": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", - "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", - "dev": true - }, - "camelcase": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", - "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=", - "dev": true - }, - "catharsis": { - "version": "0.8.10", - "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.10.tgz", - "integrity": "sha512-l2OUaz/3PU3MZylspVFJvwHCVfWyvcduPq4lv3AzZ2pJzZCo7kNKFNyatwujD7XgvGkNAE/Jhhbh2uARNwNkfw==", - "dev": true, - "requires": { - "lodash": "^4.17.11" - } - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "chokidar": { - "version": "2.1.6", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.6.tgz", - "integrity": "sha512-V2jUo67OKkc6ySiRpJrjlpJKl9kDuG+Xb8VgsGzb+aEouhgS1D0weyPU4lEzdAcsCAvrih2J2BqyXqHWvVLw5g==", - "dev": true, - "requires": { - "anymatch": "^2.0.0", - "async-each": "^1.0.1", - "braces": "^2.3.2", - "fsevents": "^1.2.7", - "glob-parent": "^3.1.0", - "inherits": "^2.0.3", - "is-binary-path": "^1.0.0", - "is-glob": "^4.0.0", - "normalize-path": "^3.0.0", - "path-is-absolute": "^1.0.0", - "readdirp": "^2.2.1", - "upath": "^1.1.1" - }, - "dependencies": { - "is-glob": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", - "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", - "dev": true, - "requires": { - "is-extglob": "^2.1.1" - } - } - } - }, - "chownr": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", - "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", - "dev": true, - "optional": true - }, - "circular-json": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", - "dev": true - }, - "class-utils": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", - "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", - "dev": true, - "requires": { - "arr-union": "^3.1.0", - "define-property": "^0.2.5", - "isobject": "^3.0.0", - "static-extend": "^0.1.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - } - } - }, - "cli-cursor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", - "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", - "dev": true, - "requires": { - "restore-cursor": "^1.0.1" - } - }, - "cli-width": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", - "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", - "dev": true - }, - "cliui": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", - "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", - "dev": true, - "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wrap-ansi": "^2.0.0" - } - }, - "clone": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", - "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", - "dev": true - }, - "clone-buffer": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz", - "integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg=", - "dev": true - }, - "clone-stats": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", - "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=", - "dev": true - }, - "cloneable-readable": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.1.3.tgz", - "integrity": "sha512-2EF8zTQOxYq70Y4XKtorQupqF0m49MBz2/yf5Bj+MHjvpG3Hy7sImifnqD6UA+TKYxeSV+u6qqQPawN5UvnpKQ==", - "dev": true, - "requires": { - "inherits": "^2.0.1", - "process-nextick-args": "^2.0.0", - "readable-stream": "^2.3.5" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", - "dev": true - }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true - }, - "collection-map": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/collection-map/-/collection-map-1.0.0.tgz", - "integrity": "sha1-rqDwb40mx4DCt1SUOFVEsiVa8Yw=", - "dev": true, - "requires": { - "arr-map": "^2.0.2", - "for-own": "^1.0.0", - "make-iterator": "^1.0.0" - } - }, - "collection-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", - "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", - "dev": true, - "requires": { - "map-visit": "^1.0.0", - "object-visit": "^1.0.0" - } - }, - "color-support": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", - "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", - "dev": true - }, - "colors": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz", - "integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==", - "dev": true - }, - "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", - "dev": true - }, - "component-emitter": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", - "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^2.2.2", - "typedarray": "^0.0.6" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, - "connect": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/connect/-/connect-3.7.0.tgz", - "integrity": "sha512-ZqRXc+tZukToSNmh5C2iWMSoV3X1YUcPbqEM4DkEG5tNQXrQUZCNVGGv3IuicnkMtPfGf3Xtp8WCXs295iQ1pQ==", - "dev": true, - "requires": { - "debug": "2.6.9", - "finalhandler": "1.1.2", - "parseurl": "~1.3.3", - "utils-merge": "1.0.1" - } - }, - "convert-source-map": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", - "integrity": "sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.1" - } - }, - "copy-descriptor": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", - "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", - "dev": true - }, - "copy-props": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/copy-props/-/copy-props-2.0.5.tgz", - "integrity": "sha512-XBlx8HSqrT0ObQwmSzM7WE5k8FxTV75h1DX1Z3n6NhQ/UYYAvInWYmG06vFt7hQZArE2fuO62aihiWIVQwh1sw==", - "dev": true, - "requires": { - "each-props": "^1.3.2", - "is-plain-object": "^5.0.0" - }, - "dependencies": { - "is-plain-object": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", - "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", - "dev": true - } - } - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "cors": { - "version": "2.8.5", - "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", - "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", - "dev": true, - "requires": { - "object-assign": "^4", - "vary": "^1" - } - }, - "d": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", - "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", - "dev": true, - "requires": { - "es5-ext": "^0.10.50", - "type": "^1.0.1" - } - }, - "dateformat": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.2.0.tgz", - "integrity": "sha1-QGXiATz5+5Ft39gu+1Bq1MZ2kGI=", - "dev": true - }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true - }, - "decode-uri-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", - "dev": true - }, - "deep-is": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", - "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", - "dev": true - }, - "default-compare": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/default-compare/-/default-compare-1.0.0.tgz", - "integrity": "sha512-QWfXlM0EkAbqOCbD/6HjdwT19j7WCkMyiRhWilc4H9/5h/RzTF9gv5LYh1+CmDV5d1rki6KAWLtQale0xt20eQ==", - "dev": true, - "requires": { - "kind-of": "^5.0.2" - }, - "dependencies": { - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - } - } - }, - "default-resolution": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/default-resolution/-/default-resolution-2.0.0.tgz", - "integrity": "sha1-vLgrqnKtebQmp2cy8aga1t8m1oQ=", - "dev": true - }, - "define-properties": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", - "dev": true, - "requires": { - "object-keys": "^1.0.12" - } - }, - "define-property": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", - "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", - "dev": true, - "requires": { - "is-descriptor": "^1.0.2", - "isobject": "^3.0.1" - }, - "dependencies": { - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", - "dev": true - }, - "destroy": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", - "dev": true - }, - "detect-file": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", - "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", - "dev": true - }, - "doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", - "dev": true, - "requires": { - "esutils": "^2.0.2" - } - }, - "duplexer": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", - "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", - "dev": true - }, - "duplexer2": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", - "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", - "dev": true, - "requires": { - "readable-stream": "~1.1.9" - } - }, - "duplexify": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz", - "integrity": "sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==", - "dev": true, - "requires": { - "end-of-stream": "^1.0.0", - "inherits": "^2.0.1", - "readable-stream": "^2.0.0", - "stream-shift": "^1.0.0" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, - "each-props": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/each-props/-/each-props-1.3.2.tgz", - "integrity": "sha512-vV0Hem3zAGkJAyU7JSjixeU66rwdynTAa1vofCrSA5fEln+m67Az9CcnkVD776/fsN/UjIWmBDoNRS6t6G9RfA==", - "dev": true, - "requires": { - "is-plain-object": "^2.0.1", - "object.defaults": "^1.1.0" - } - }, - "ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", - "dev": true - }, - "encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", - "dev": true - }, - "end-of-stream": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", - "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", - "dev": true, - "requires": { - "once": "^1.4.0" - } - }, - "error-ex": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", - "dev": true, - "requires": { - "is-arrayish": "^0.2.1" - } - }, - "es-abstract": { - "version": "1.18.0-next.1", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0-next.1.tgz", - "integrity": "sha512-I4UGspA0wpZXWENrdA0uHbnhte683t3qT/1VFH9aX2dA5PPSf6QW5HHXf5HImaqPmjXaVeVk4RGWnaylmV7uAA==", - "dev": true, - "requires": { - "es-to-primitive": "^1.2.1", - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.2.2", - "is-negative-zero": "^2.0.0", - "is-regex": "^1.1.1", - "object-inspect": "^1.8.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.1", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, - "es5-ext": { - "version": "0.10.50", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.50.tgz", - "integrity": "sha512-KMzZTPBkeQV/JcSQhI5/z6d9VWJ3EnQ194USTUwIYZ2ZbpN8+SGXQKt1h68EX44+qt+Fzr8DO17vnxrw7c3agw==", - "dev": true, - "requires": { - "es6-iterator": "~2.0.3", - "es6-symbol": "~3.1.1", - "next-tick": "^1.0.0" - } - }, - "es6-iterator": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", - "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", - "dev": true, - "requires": { - "d": "1", - "es5-ext": "^0.10.35", - "es6-symbol": "^3.1.1" - } - }, - "es6-map": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/es6-map/-/es6-map-0.1.5.tgz", - "integrity": "sha1-kTbgUD3MBqMBaQ8LsU/042TpSfA=", - "dev": true, - "requires": { - "d": "1", - "es5-ext": "~0.10.14", - "es6-iterator": "~2.0.1", - "es6-set": "~0.1.5", - "es6-symbol": "~3.1.1", - "event-emitter": "~0.3.5" - } - }, - "es6-set": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", - "integrity": "sha1-0rPsXU2ADO2BjbU40ol02wpzzLE=", - "dev": true, - "requires": { - "d": "1", - "es5-ext": "~0.10.14", - "es6-iterator": "~2.0.1", - "es6-symbol": "3.1.1", - "event-emitter": "~0.3.5" - } - }, - "es6-symbol": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", - "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", - "dev": true, - "requires": { - "d": "1", - "es5-ext": "~0.10.14" - } - }, - "es6-weak-map": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz", - "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", - "dev": true, - "requires": { - "d": "1", - "es5-ext": "^0.10.46", - "es6-iterator": "^2.0.3", - "es6-symbol": "^3.1.1" - } - }, - "escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", - "dev": true - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, - "escope": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/escope/-/escope-3.6.0.tgz", - "integrity": "sha1-4Bl16BJ4GhY6ba392AOY3GTIicM=", - "dev": true, - "requires": { - "es6-map": "^0.1.3", - "es6-weak-map": "^2.0.1", - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" - } - }, - "eslint": { - "version": "3.19.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-3.19.0.tgz", - "integrity": "sha1-yPxiAcf0DdCJQbh8CFdnOGpnmsw=", - "dev": true, - "requires": { - "babel-code-frame": "^6.16.0", - "chalk": "^1.1.3", - "concat-stream": "^1.5.2", - "debug": "^2.1.1", - "doctrine": "^2.0.0", - "escope": "^3.6.0", - "espree": "^3.4.0", - "esquery": "^1.0.0", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "file-entry-cache": "^2.0.0", - "glob": "^7.0.3", - "globals": "^9.14.0", - "ignore": "^3.2.0", - "imurmurhash": "^0.1.4", - "inquirer": "^0.12.0", - "is-my-json-valid": "^2.10.0", - "is-resolvable": "^1.0.0", - "js-yaml": "^3.5.1", - "json-stable-stringify": "^1.0.0", - "levn": "^0.3.0", - "lodash": "^4.0.0", - "mkdirp": "^0.5.0", - "natural-compare": "^1.4.0", - "optionator": "^0.8.2", - "path-is-inside": "^1.0.1", - "pluralize": "^1.2.1", - "progress": "^1.1.8", - "require-uncached": "^1.0.2", - "shelljs": "^0.7.5", - "strip-bom": "^3.0.0", - "strip-json-comments": "~2.0.1", - "table": "^3.7.8", - "text-table": "~0.2.0", - "user-home": "^2.0.0" - }, - "dependencies": { - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true - }, - "user-home": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", - "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=", - "dev": true, - "requires": { - "os-homedir": "^1.0.0" - } - } - } - }, - "espree": { - "version": "3.5.4", - "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", - "dev": true, - "requires": { - "acorn": "^5.5.0", - "acorn-jsx": "^3.0.0" - } - }, - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true - }, - "esquery": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", - "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", - "dev": true, - "requires": { - "estraverse": "^4.0.0" - } - }, - "esrecurse": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", - "dev": true, - "requires": { - "estraverse": "^4.1.0" - } - }, - "estraverse": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", - "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", - "dev": true - }, - "esutils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", - "dev": true - }, - "etag": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", - "dev": true - }, - "event-emitter": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", - "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", - "dev": true, - "requires": { - "d": "1", - "es5-ext": "~0.10.14" - } - }, - "event-stream": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", - "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", - "dev": true, - "requires": { - "duplexer": "~0.1.1", - "from": "~0", - "map-stream": "~0.1.0", - "pause-stream": "0.0.11", - "split": "0.3", - "stream-combiner": "~0.0.4", - "through": "~2.3.1" - } - }, - "exit": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", - "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", - "dev": true - }, - "exit-hook": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz", - "integrity": "sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=", - "dev": true - }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "requires": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "expand-tilde": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", - "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", - "dev": true, - "requires": { - "homedir-polyfill": "^1.0.1" - } - }, - "extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", - "dev": true - }, - "extend-shallow": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", - "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", - "dev": true, - "requires": { - "assign-symbols": "^1.0.0", - "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "requires": { - "is-plain-object": "^2.0.4" - } - } - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "requires": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "fancy-log": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.3.tgz", - "integrity": "sha512-k9oEhlyc0FrVh25qYuSELjr8oxsCoc4/LEZfg2iJJrfEk/tZL9bCoJE47gqAvI2m/AUjluCS4+3I0eTx8n3AEw==", - "dev": true, - "requires": { - "ansi-gray": "^0.1.1", - "color-support": "^1.1.3", - "parse-node-version": "^1.0.0", - "time-stamp": "^1.0.0" - } - }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", - "dev": true - }, - "faye-websocket": { - "version": "0.11.3", - "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.3.tgz", - "integrity": "sha512-D2y4bovYpzziGgbHYtGCMjlJM36vAl/y+xUyn1C+FVx8szd1E+86KwVw6XvYSzOP8iMpm1X0I4xJD+QtUb36OA==", - "dev": true, - "requires": { - "websocket-driver": ">=0.5.1" - } - }, - "figures": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", - "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.5", - "object-assign": "^4.1.0" - } - }, - "file-entry-cache": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", - "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", - "dev": true, - "requires": { - "flat-cache": "^1.2.1", - "object-assign": "^4.0.1" - } - }, - "filename-reserved-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/filename-reserved-regex/-/filename-reserved-regex-1.0.0.tgz", - "integrity": "sha1-5hz4BfDeHJhFZ9A4bcXfUO5a9+Q=", - "dev": true - }, - "filenamify": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/filenamify/-/filenamify-1.2.1.tgz", - "integrity": "sha1-qfL/0RxQO+0wABUCknI3jx8TZaU=", - "dev": true, - "requires": { - "filename-reserved-regex": "^1.0.0", - "strip-outer": "^1.0.0", - "trim-repeated": "^1.0.0" - } - }, - "filenamify-url": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/filenamify-url/-/filenamify-url-1.0.0.tgz", - "integrity": "sha1-syvYExnvWGO3MHi+1Q9GpPeXX1A=", - "dev": true, - "requires": { - "filenamify": "^1.0.0", - "humanize-url": "^1.0.0" - } - }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "finalhandler": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", - "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", - "dev": true, - "requires": { - "debug": "2.6.9", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "on-finished": "~2.3.0", - "parseurl": "~1.3.3", - "statuses": "~1.5.0", - "unpipe": "~1.0.0" - } - }, - "find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "dev": true, - "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "findup-sync": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-3.0.0.tgz", - "integrity": "sha512-YbffarhcicEhOrm4CtrwdKBdCuz576RLdhJDsIfvNtxUuhdRet1qZcsMjqbePtAseKdAnDyM/IyXbu7PRPRLYg==", - "dev": true, - "requires": { - "detect-file": "^1.0.0", - "is-glob": "^4.0.0", - "micromatch": "^3.0.4", - "resolve-dir": "^1.0.1" - }, - "dependencies": { - "is-glob": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", - "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", - "dev": true, - "requires": { - "is-extglob": "^2.1.1" - } - } - } - }, - "fined": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/fined/-/fined-1.2.0.tgz", - "integrity": "sha512-ZYDqPLGxDkDhDZBjZBb+oD1+j0rA4E0pXY50eplAAOPg2N/gUBSSk5IM1/QhPfyVo19lJ+CvXpqfvk+b2p/8Ng==", - "dev": true, - "requires": { - "expand-tilde": "^2.0.2", - "is-plain-object": "^2.0.3", - "object.defaults": "^1.1.0", - "object.pick": "^1.2.0", - "parse-filepath": "^1.0.1" - } - }, - "flagged-respawn": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz", - "integrity": "sha512-lNaHNVymajmk0OJMBn8fVUAU1BtDeKIqKoVhk4xAALB57aALg6b4W0MfJ/cUE0g9YBXy5XhSlPIpYIJ7HaY/3Q==", - "dev": true - }, - "flat-cache": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.4.tgz", - "integrity": "sha512-VwyB3Lkgacfik2vhqR4uv2rvebqmDvFu4jlN/C1RzWoJEo8I7z4Q404oiqYCkq41mni8EzQnm95emU9seckwtg==", - "dev": true, - "requires": { - "circular-json": "^0.3.1", - "graceful-fs": "^4.1.2", - "rimraf": "~2.6.2", - "write": "^0.2.1" - } - }, - "flush-write-stream": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz", - "integrity": "sha512-3Z4XhFZ3992uIq0XOqb9AreonueSYphE6oYbpt5+3u06JWklbsPkNv3ZKkP9Bz/r+1MWCaMoSQ28P85+1Yc77w==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "readable-stream": "^2.3.6" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, - "for-in": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true - }, - "for-own": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz", - "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", - "dev": true, - "requires": { - "for-in": "^1.0.1" - } - }, - "fragment-cache": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", - "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", - "dev": true, - "requires": { - "map-cache": "^0.2.2" - } - }, - "fresh": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", - "dev": true - }, - "from": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", - "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", - "dev": true - }, - "fs-extra": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz", - "integrity": "sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "fs-minipass": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", - "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", - "dev": true, - "optional": true, - "requires": { - "minipass": "^2.6.0" - } - }, - "fs-mkdirp-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz", - "integrity": "sha1-C3gV/DIBxqaeFNuYzgmMFpNSWes=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.11", - "through2": "^2.0.3" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "fsevents": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.9.tgz", - "integrity": "sha512-oeyj2H3EjjonWcFjD5NvZNE9Rqe4UW+nQBU2HNeKw0koVLEFIhtyETyAakeAM3de7Z/SW5kcA+fZUait9EApnw==", - "dev": true, - "optional": true, - "requires": { - "nan": "^2.12.1", - "node-pre-gyp": "^0.12.0" - }, - "dependencies": { - "abbrev": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "ansi-regex": { - "version": "2.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "aproba": { - "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true - }, - "are-we-there-yet": { - "version": "1.1.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, - "balanced-match": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "brace-expansion": { - "version": "1.1.11", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "chownr": { - "version": "1.1.1", - "bundled": true - }, - "code-point-at": { - "version": "1.1.0", - "bundled": true, - "dev": true, - "optional": true - }, - "concat-map": { - "version": "0.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "console-control-strings": { - "version": "1.1.0", - "bundled": true, - "dev": true, - "optional": true - }, - "core-util-is": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "debug": { - "version": "4.1.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ms": "^2.1.1" - } - }, - "deep-extend": { - "version": "0.6.0", - "bundled": true, - "dev": true, - "optional": true - }, - "delegates": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "detect-libc": { - "version": "1.0.3", - "bundled": true, - "dev": true, - "optional": true - }, - "fs-minipass": { - "version": "1.2.5", - "bundled": true, - "requires": { - "minipass": "^2.2.1" - } - }, - "fs.realpath": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "gauge": { - "version": "2.7.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - } - }, - "glob": { - "version": "7.1.3", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "has-unicode": { - "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "iconv-lite": { - "version": "0.4.24", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "ignore-walk": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minimatch": "^3.0.4" - } - }, - "inflight": { - "version": "1.0.6", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "bundled": true, - "dev": true, - "optional": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "isarray": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "minimatch": { - "version": "3.0.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minipass": { - "version": "2.3.5", - "bundled": true, - "optional": true, - "requires": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" - } - }, - "minizlib": { - "version": "1.2.1", - "bundled": true, - "requires": { - "minipass": "^2.2.1" - } - }, - "ms": { - "version": "2.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "needle": { - "version": "2.3.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "debug": "^4.1.0", - "iconv-lite": "^0.4.4", - "sax": "^1.2.4" - } - }, - "node-pre-gyp": { - "version": "0.12.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "detect-libc": "^1.0.2", - "mkdirp": "^0.5.1", - "needle": "^2.2.1", - "nopt": "^4.0.1", - "npm-packlist": "^1.1.6", - "npmlog": "^4.0.2", - "rc": "^1.2.7", - "rimraf": "^2.6.1", - "semver": "^5.3.0", - "tar": "^4" - } - }, - "nopt": { - "version": "4.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "abbrev": "1", - "osenv": "^0.1.4" - } - }, - "npm-bundled": { - "version": "1.0.6", - "bundled": true, - "dev": true, - "optional": true - }, - "npm-packlist": { - "version": "1.4.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ignore-walk": "^3.0.1", - "npm-bundled": "^1.0.1" - } - }, - "npmlog": { - "version": "4.1.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "object-assign": { - "version": "4.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "once": { - "version": "1.4.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "wrappy": "1" - } - }, - "os-homedir": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "os-tmpdir": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "osenv": { - "version": "0.1.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "process-nextick-args": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "rc": { - "version": "1.2.8", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - } - }, - "readable-stream": { - "version": "2.3.6", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "rimraf": { - "version": "2.6.3", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "glob": "^7.1.3" - } - }, - "safe-buffer": { - "version": "5.1.2", - "bundled": true, - "optional": true - }, - "safer-buffer": { - "version": "2.1.2", - "bundled": true, - "dev": true, - "optional": true - }, - "sax": { - "version": "1.2.4", - "bundled": true, - "dev": true, - "optional": true - }, - "semver": { - "version": "5.7.0", - "bundled": true, - "dev": true, - "optional": true - }, - "set-blocking": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "signal-exit": { - "version": "3.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "string-width": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "string_decoder": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "util-deprecate": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "wide-align": { - "version": "1.1.3", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "string-width": "^1.0.2 || 2" - } - }, - "wrappy": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "yallist": { - "version": "3.0.3", - "bundled": true, - "optional": true - } - } - }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, - "generate-function": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz", - "integrity": "sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==", - "dev": true, - "requires": { - "is-property": "^1.0.2" - } - }, - "generate-object-property": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", - "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", - "dev": true, - "requires": { - "is-property": "^1.0.0" - } - }, - "get-caller-file": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", - "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", - "dev": true - }, - "get-value": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", - "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", - "dev": true - }, - "gh-pages": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/gh-pages/-/gh-pages-1.2.0.tgz", - "integrity": "sha512-cGLYAvxtlQ1iTwAS4g7FreZPXoE/g62Fsxln2mmR19mgs4zZI+XJ+wVVUhBFCF/0+Nmvbq+abyTWue1m1BSnmg==", - "dev": true, - "requires": { - "async": "2.6.1", - "commander": "2.15.1", - "filenamify-url": "^1.0.0", - "fs-extra": "^5.0.0", - "globby": "^6.1.0", - "graceful-fs": "4.1.11", - "rimraf": "^2.6.2" - } - }, - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "glob-parent": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", - "dev": true, - "requires": { - "is-glob": "^3.1.0", - "path-dirname": "^1.0.0" - } - }, - "glob-stream": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-6.1.0.tgz", - "integrity": "sha1-cEXJlBOz65SIjYOrRtC0BMx73eQ=", - "dev": true, - "requires": { - "extend": "^3.0.0", - "glob": "^7.1.1", - "glob-parent": "^3.1.0", - "is-negated-glob": "^1.0.0", - "ordered-read-streams": "^1.0.0", - "pumpify": "^1.3.5", - "readable-stream": "^2.1.5", - "remove-trailing-separator": "^1.0.1", - "to-absolute-glob": "^2.0.0", - "unique-stream": "^2.0.2" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, - "glob-watcher": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-5.0.5.tgz", - "integrity": "sha512-zOZgGGEHPklZNjZQaZ9f41i7F2YwE+tS5ZHrDhbBCk3stwahn5vQxnFmBJZHoYdusR6R1bLSXeGUy/BhctwKzw==", - "dev": true, - "requires": { - "anymatch": "^2.0.0", - "async-done": "^1.2.0", - "chokidar": "^2.0.0", - "is-negated-glob": "^1.0.0", - "just-debounce": "^1.0.0", - "normalize-path": "^3.0.0", - "object.defaults": "^1.1.0" - } - }, - "global-modules": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", - "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", - "dev": true, - "requires": { - "global-prefix": "^1.0.1", - "is-windows": "^1.0.1", - "resolve-dir": "^1.0.0" - } - }, - "global-prefix": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", - "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", - "dev": true, - "requires": { - "expand-tilde": "^2.0.2", - "homedir-polyfill": "^1.0.1", - "ini": "^1.3.4", - "is-windows": "^1.0.1", - "which": "^1.2.14" - } - }, - "globals": { - "version": "9.18.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", - "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==", - "dev": true - }, - "globby": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", - "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", - "dev": true, - "requires": { - "array-union": "^1.0.1", - "glob": "^7.0.3", - "object-assign": "^4.0.1", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "glogg": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.2.tgz", - "integrity": "sha512-5mwUoSuBk44Y4EshyiqcH95ZntbDdTQqA3QYSrxmzj28Ai0vXBGMH1ApSANH14j2sIRtqCEyg6PfsuP7ElOEDA==", - "dev": true, - "requires": { - "sparkles": "^1.0.0" - } - }, - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - }, - "gulp": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/gulp/-/gulp-4.0.2.tgz", - "integrity": "sha512-dvEs27SCZt2ibF29xYgmnwwCYZxdxhQ/+LFWlbAW8y7jt68L/65402Lz3+CKy0Ov4rOs+NERmDq7YlZaDqUIfA==", - "dev": true, - "requires": { - "glob-watcher": "^5.0.3", - "gulp-cli": "^2.2.0", - "undertaker": "^1.2.1", - "vinyl-fs": "^3.0.0" - }, - "dependencies": { - "gulp-cli": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/gulp-cli/-/gulp-cli-2.3.0.tgz", - "integrity": "sha512-zzGBl5fHo0EKSXsHzjspp3y5CONegCm8ErO5Qh0UzFzk2y4tMvzLWhoDokADbarfZRL2pGpRp7yt6gfJX4ph7A==", - "dev": true, - "requires": { - "ansi-colors": "^1.0.1", - "archy": "^1.0.0", - "array-sort": "^1.0.0", - "color-support": "^1.1.3", - "concat-stream": "^1.6.0", - "copy-props": "^2.0.1", - "fancy-log": "^1.3.2", - "gulplog": "^1.0.0", - "interpret": "^1.4.0", - "isobject": "^3.0.1", - "liftoff": "^3.1.0", - "matchdep": "^2.0.0", - "mute-stdout": "^1.0.0", - "pretty-hrtime": "^1.0.0", - "replace-homedir": "^1.0.0", - "semver-greatest-satisfied-range": "^1.1.0", - "v8flags": "^3.2.0", - "yargs": "^7.1.0" - } - }, - "interpret": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", - "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==", - "dev": true - } - } - }, - "gulp-eslint": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/gulp-eslint/-/gulp-eslint-3.0.1.tgz", - "integrity": "sha1-BOV+PhjGl0JnwSz2hV3HF9SjE70=", - "dev": true, - "requires": { - "bufferstreams": "^1.1.1", - "eslint": "^3.0.0", - "gulp-util": "^3.0.6" - } - }, - "gulp-jasmine": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/gulp-jasmine/-/gulp-jasmine-2.4.2.tgz", - "integrity": "sha1-Wn9H4nNww2GawKKkQr45lnFAnbM=", - "dev": true, - "requires": { - "arrify": "^1.0.0", - "gulp-util": "^3.0.0", - "jasmine": "^2.3.0", - "jasmine-terminal-reporter": "^1.0.0", - "through2": "^2.0.0" - } - }, - "gulp-util": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", - "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", - "dev": true, - "requires": { - "array-differ": "^1.0.0", - "array-uniq": "^1.0.2", - "beeper": "^1.0.0", - "chalk": "^1.0.0", - "dateformat": "^2.0.0", - "fancy-log": "^1.1.0", - "gulplog": "^1.0.0", - "has-gulplog": "^0.1.0", - "lodash._reescape": "^3.0.0", - "lodash._reevaluate": "^3.0.0", - "lodash._reinterpolate": "^3.0.0", - "lodash.template": "^3.0.0", - "minimist": "^1.1.0", - "multipipe": "^0.1.2", - "object-assign": "^3.0.0", - "replace-ext": "0.0.1", - "through2": "^2.0.0", - "vinyl": "^0.5.0" - }, - "dependencies": { - "object-assign": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", - "integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=", - "dev": true - } - } - }, - "gulplog": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz", - "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=", - "dev": true, - "requires": { - "glogg": "^1.0.0" - } - }, - "has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "requires": { - "function-bind": "^1.1.1" - } - }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "has-gulplog": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz", - "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=", - "dev": true, - "requires": { - "sparkles": "^1.0.0" - } - }, - "has-symbols": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", - "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", - "dev": true - }, - "has-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", - "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", - "dev": true, - "requires": { - "get-value": "^2.0.6", - "has-values": "^1.0.0", - "isobject": "^3.0.0" - } - }, - "has-values": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", - "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", - "dev": true, - "requires": { - "is-number": "^3.0.0", - "kind-of": "^4.0.0" - }, - "dependencies": { - "kind-of": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "homedir-polyfill": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", - "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", - "dev": true, - "requires": { - "parse-passwd": "^1.0.0" - } - }, - "hosted-git-info": { - "version": "2.8.9", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", - "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", - "dev": true - }, - "http-auth": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/http-auth/-/http-auth-3.1.3.tgz", - "integrity": "sha1-lFz63WZSHq+PfISRPTd9exXyTjE=", - "dev": true, - "requires": { - "apache-crypt": "^1.1.2", - "apache-md5": "^1.0.6", - "bcryptjs": "^2.3.0", - "uuid": "^3.0.0" - } - }, - "http-errors": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.3.tgz", - "integrity": "sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==", - "dev": true, - "requires": { - "depd": "~1.1.2", - "inherits": "2.0.4", - "setprototypeof": "1.1.1", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" - } - }, - "http-parser-js": { - "version": "0.4.10", - "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.4.10.tgz", - "integrity": "sha1-ksnBN0w1CF912zWexWzCV8u5P6Q=", - "dev": true - }, - "humanize-url": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/humanize-url/-/humanize-url-1.0.1.tgz", - "integrity": "sha1-9KuZ4NKIF0yk4eUEB8VfuuRk7/8=", - "dev": true, - "requires": { - "normalize-url": "^1.0.0", - "strip-url-auth": "^1.0.0" - } - }, - "ignore": { - "version": "3.3.10", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", - "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", - "dev": true - }, - "imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", - "dev": true - }, - "indent-string": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", - "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", - "dev": true, - "requires": { - "repeating": "^2.0.0" - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "ini": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.7.tgz", - "integrity": "sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ==", - "dev": true - }, - "inquirer": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz", - "integrity": "sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=", - "dev": true, - "requires": { - "ansi-escapes": "^1.1.0", - "ansi-regex": "^2.0.0", - "chalk": "^1.0.0", - "cli-cursor": "^1.0.1", - "cli-width": "^2.0.0", - "figures": "^1.3.5", - "lodash": "^4.3.0", - "readline2": "^1.0.1", - "run-async": "^0.1.0", - "rx-lite": "^3.1.2", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.0", - "through": "^2.3.6" - } - }, - "interpret": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.2.0.tgz", - "integrity": "sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw==", - "dev": true - }, - "invert-kv": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", - "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", - "dev": true - }, - "is-absolute": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz", - "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", - "dev": true, - "requires": { - "is-relative": "^1.0.0", - "is-windows": "^1.0.1" - } - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", - "dev": true - }, - "is-binary-path": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", - "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", - "dev": true, - "requires": { - "binary-extensions": "^1.0.0" - } - }, - "is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "dev": true - }, - "is-callable": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.2.tgz", - "integrity": "sha512-dnMqspv5nU3LoewK2N/y7KLtxtakvTuaCsU9FU50/QDmdbHNy/4/JuRtMHqRU22o3q+W89YQndQEeCVwK+3qrA==", - "dev": true - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-date-object": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", - "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", - "dev": true - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - }, - "dependencies": { - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - } - } - }, - "is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true - }, - "is-finite": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", - "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", - "dev": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "dev": true, - "requires": { - "is-extglob": "^2.1.0" - } - }, - "is-my-ip-valid": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz", - "integrity": "sha512-gmh/eWXROncUzRnIa1Ubrt5b8ep/MGSnfAUI3aRp+sqTCs1tv1Isl8d8F6JmkN3dXKc3ehZMrtiPN9eL03NuaQ==", - "dev": true - }, - "is-my-json-valid": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.20.0.tgz", - "integrity": "sha512-XTHBZSIIxNsIsZXg7XB5l8z/OBFosl1Wao4tXLpeC7eKU4Vm/kdop2azkPqULwnfGQjmeDIyey9g7afMMtdWAA==", - "dev": true, - "requires": { - "generate-function": "^2.0.0", - "generate-object-property": "^1.1.0", - "is-my-ip-valid": "^1.0.0", - "jsonpointer": "^4.0.0", - "xtend": "^4.0.0" - } - }, - "is-negated-glob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-negated-glob/-/is-negated-glob-1.0.0.tgz", - "integrity": "sha1-aRC8pdqMleeEtXUbl2z1oQ/uNtI=", - "dev": true - }, - "is-negative-zero": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.0.tgz", - "integrity": "sha1-lVOxIbD6wohp2p7UWeIMdUN4hGE=", - "dev": true - }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-plain-obj": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", - "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", - "dev": true - }, - "is-plain-object": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "dev": true, - "requires": { - "isobject": "^3.0.1" - } - }, - "is-property": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", - "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", - "dev": true - }, - "is-regex": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", - "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", - "dev": true, - "requires": { - "has-symbols": "^1.0.1" - } - }, - "is-relative": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-1.0.0.tgz", - "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", - "dev": true, - "requires": { - "is-unc-path": "^1.0.0" - } - }, - "is-resolvable": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", - "dev": true - }, - "is-symbol": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", - "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", - "dev": true, - "requires": { - "has-symbols": "^1.0.1" - } - }, - "is-unc-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-1.0.0.tgz", - "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", - "dev": true, - "requires": { - "unc-path-regex": "^0.1.2" - } - }, - "is-utf8": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", - "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", - "dev": true - }, - "is-valid-glob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-valid-glob/-/is-valid-glob-1.0.0.tgz", - "integrity": "sha1-Kb8+/3Ab4tTTFdusw5vDn+j2Aao=", - "dev": true - }, - "is-windows": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true - }, - "is-wsl": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", - "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=", - "dev": true - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, - "jasmine": { - "version": "2.99.0", - "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-2.99.0.tgz", - "integrity": "sha1-jKctEC5jm4Z8ZImFbg4YqceqQrc=", - "dev": true, - "requires": { - "exit": "^0.1.2", - "glob": "^7.0.6", - "jasmine-core": "~2.99.0" - } - }, - "jasmine-core": { - "version": "2.99.1", - "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.99.1.tgz", - "integrity": "sha1-5kAN8ea1bhMLYcS80JPap/boyhU=", - "dev": true - }, - "jasmine-terminal-reporter": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/jasmine-terminal-reporter/-/jasmine-terminal-reporter-1.0.3.tgz", - "integrity": "sha1-iW8eyP30v2rs3UHFA+2nNH9hUms=", - "dev": true, - "requires": { - "indent-string": "^2.1.0", - "pluralize": "^1.2.1" - } - }, - "js-tokens": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", - "dev": true - }, - "js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", - "dev": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, - "js2xmlparser": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-3.0.0.tgz", - "integrity": "sha1-P7YOqgicVED5MZ9RdgzNB+JJlzM=", - "dev": true, - "requires": { - "xmlcreate": "^1.0.1" - } - }, - "jsdoc": { - "version": "3.5.5", - "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.5.5.tgz", - "integrity": "sha512-6PxB65TAU4WO0Wzyr/4/YhlGovXl0EVYfpKbpSroSj0qBxT4/xod/l40Opkm38dRHRdQgdeY836M0uVnJQG7kg==", - "dev": true, - "requires": { - "babylon": "7.0.0-beta.19", - "bluebird": "~3.5.0", - "catharsis": "~0.8.9", - "escape-string-regexp": "~1.0.5", - "js2xmlparser": "~3.0.0", - "klaw": "~2.0.0", - "marked": "~0.3.6", - "mkdirp": "~0.5.1", - "requizzle": "~0.2.1", - "strip-json-comments": "~2.0.1", - "taffydb": "2.6.2", - "underscore": "~1.8.3" - } - }, - "json-stable-stringify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", - "dev": true, - "requires": { - "jsonify": "~0.0.0" - } - }, - "json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", - "dev": true - }, - "jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6" - } - }, - "jsonify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", - "dev": true - }, - "jsonpointer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", - "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", - "dev": true - }, - "just-debounce": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/just-debounce/-/just-debounce-1.0.0.tgz", - "integrity": "sha1-h/zPrv/AtozRnVX2cilD+SnqNeo=", - "dev": true - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - }, - "klaw": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-2.0.0.tgz", - "integrity": "sha1-WcEo4Nxc5BAgEVEZTuucv4WGUPY=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.9" - } - }, - "last-run": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/last-run/-/last-run-1.1.1.tgz", - "integrity": "sha1-RblpQsF7HHnHchmCWbqUO+v4yls=", - "dev": true, - "requires": { - "default-resolution": "^2.0.0", - "es6-weak-map": "^2.0.1" - } - }, - "lazystream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lazystream/-/lazystream-1.0.0.tgz", - "integrity": "sha1-9plf4PggOS9hOWvolGJAe7dxaOQ=", - "dev": true, - "requires": { - "readable-stream": "^2.0.5" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, - "lcid": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", - "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", - "dev": true, - "requires": { - "invert-kv": "^1.0.0" - } - }, - "lead": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lead/-/lead-1.0.0.tgz", - "integrity": "sha1-bxT5mje+Op3XhPVJVpDlkDRm7kI=", - "dev": true, - "requires": { - "flush-write-stream": "^1.0.2" - } - }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - } - }, - "liftoff": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-3.1.0.tgz", - "integrity": "sha512-DlIPlJUkCV0Ips2zf2pJP0unEoT1kwYhiiPUGF3s/jtxTCjziNLoiVVh+jqWOWeFi6mmwQ5fNxvAUyPad4Dfog==", - "dev": true, - "requires": { - "extend": "^3.0.0", - "findup-sync": "^3.0.0", - "fined": "^1.0.1", - "flagged-respawn": "^1.0.0", - "is-plain-object": "^2.0.4", - "object.map": "^1.0.0", - "rechoir": "^0.6.2", - "resolve": "^1.1.7" - } - }, - "live-server": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/live-server/-/live-server-1.2.1.tgz", - "integrity": "sha512-Yn2XCVjErTkqnM3FfTmM7/kWy3zP7+cEtC7x6u+wUzlQ+1UW3zEYbbyJrc0jNDwiMDZI0m4a0i3dxlGHVyXczw==", - "dev": true, - "requires": { - "chokidar": "^2.0.4", - "colors": "^1.3.3", - "connect": "^3.6.6", - "cors": "^2.8.5", - "event-stream": "3.3.4", - "faye-websocket": "0.11.x", - "http-auth": "3.1.x", - "morgan": "^1.9.1", - "object-assign": "^4.1.1", - "opn": "^6.0.0", - "proxy-middleware": "^0.15.0", - "send": "^0.17.1", - "serve-index": "^1.9.1" - }, - "dependencies": { - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - } - } - }, - "load-json-file": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" - } - }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, - "lodash._basecopy": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", - "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", - "dev": true - }, - "lodash._basetostring": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", - "integrity": "sha1-0YYdh3+CSlL2aYMtyvPuFVZqB9U=", - "dev": true - }, - "lodash._basevalues": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz", - "integrity": "sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc=", - "dev": true - }, - "lodash._getnative": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", - "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", - "dev": true - }, - "lodash._isiterateecall": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", - "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", - "dev": true - }, - "lodash._reescape": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._reescape/-/lodash._reescape-3.0.0.tgz", - "integrity": "sha1-Kx1vXf4HyKNVdT5fJ/rH8c3hYWo=", - "dev": true - }, - "lodash._reevaluate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz", - "integrity": "sha1-WLx0xAZklTrgsSTYBpltrKQx4u0=", - "dev": true - }, - "lodash._reinterpolate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", - "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", - "dev": true - }, - "lodash._root": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/lodash._root/-/lodash._root-3.0.1.tgz", - "integrity": "sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI=", - "dev": true - }, - "lodash.escape": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", - "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", - "dev": true, - "requires": { - "lodash._root": "^3.0.0" - } - }, - "lodash.isarguments": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", - "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", - "dev": true - }, - "lodash.isarray": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", - "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", - "dev": true - }, - "lodash.keys": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", - "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", - "dev": true, - "requires": { - "lodash._getnative": "^3.0.0", - "lodash.isarguments": "^3.0.0", - "lodash.isarray": "^3.0.0" - } - }, - "lodash.restparam": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", - "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=", - "dev": true - }, - "lodash.template": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz", - "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", - "dev": true, - "requires": { - "lodash._basecopy": "^3.0.0", - "lodash._basetostring": "^3.0.0", - "lodash._basevalues": "^3.0.0", - "lodash._isiterateecall": "^3.0.0", - "lodash._reinterpolate": "^3.0.0", - "lodash.escape": "^3.0.0", - "lodash.keys": "^3.0.0", - "lodash.restparam": "^3.0.0", - "lodash.templatesettings": "^3.0.0" - } - }, - "lodash.templatesettings": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz", - "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=", - "dev": true, - "requires": { - "lodash._reinterpolate": "^3.0.0", - "lodash.escape": "^3.0.0" - } - }, - "make-iterator": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/make-iterator/-/make-iterator-1.0.1.tgz", - "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", - "dev": true, - "requires": { - "kind-of": "^6.0.2" - } - }, - "map-cache": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true - }, - "map-stream": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", - "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", - "dev": true - }, - "map-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", - "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", - "dev": true, - "requires": { - "object-visit": "^1.0.0" - } - }, - "marked": { - "version": "0.3.19", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.19.tgz", - "integrity": "sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg==", - "dev": true - }, - "matchdep": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/matchdep/-/matchdep-2.0.0.tgz", - "integrity": "sha1-xvNINKDY28OzfCfui7yyfHd1WC4=", - "dev": true, - "requires": { - "findup-sync": "^2.0.0", - "micromatch": "^3.0.4", - "resolve": "^1.4.0", - "stack-trace": "0.0.10" - }, - "dependencies": { - "findup-sync": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-2.0.0.tgz", - "integrity": "sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw=", - "dev": true, - "requires": { - "detect-file": "^1.0.0", - "is-glob": "^3.1.0", - "micromatch": "^3.0.4", - "resolve-dir": "^1.0.1" - } - } - } - }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - } - }, - "mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "dev": true - }, - "mime-db": { - "version": "1.40.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", - "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", - "dev": true - }, - "mime-types": { - "version": "2.1.24", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", - "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", - "dev": true, - "requires": { - "mime-db": "1.40.0" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "dev": true - }, - "minipass": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", - "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", - "dev": true, - "optional": true, - "requires": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" - } - }, - "minizlib": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz", - "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", - "dev": true, - "optional": true, - "requires": { - "minipass": "^2.9.0" - } - }, - "mixin-deep": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", - "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", - "dev": true, - "requires": { - "for-in": "^1.0.2", - "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "requires": { - "is-plain-object": "^2.0.4" - } - } - } - }, - "mkdirp": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", - "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", - "dev": true, - "requires": { - "minimist": "^1.2.6" - } - }, - "morgan": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.1.tgz", - "integrity": "sha512-HQStPIV4y3afTiCYVxirakhlCfGkI161c76kKFca7Fk1JusM//Qeo1ej2XaMniiNeaZklMVrh3vTtIzpzwbpmA==", - "dev": true, - "requires": { - "basic-auth": "~2.0.0", - "debug": "2.6.9", - "depd": "~1.1.2", - "on-finished": "~2.3.0", - "on-headers": "~1.0.1" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "multipipe": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", - "integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=", - "dev": true, - "requires": { - "duplexer2": "0.0.2" - } - }, - "mute-stdout": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mute-stdout/-/mute-stdout-1.0.1.tgz", - "integrity": "sha512-kDcwXR4PS7caBpuRYYBUz9iVixUk3anO3f5OYFiIPwK/20vCzKCHyKoulbiDY1S53zD2bxUpxN/IJ+TnXjfvxg==", - "dev": true - }, - "mute-stream": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", - "integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=", - "dev": true - }, - "nan": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", - "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", - "dev": true, - "optional": true - }, - "nanomatch": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", - "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", - "dev": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "fragment-cache": "^0.2.1", - "is-windows": "^1.0.2", - "kind-of": "^6.0.2", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - } - }, - "natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", - "dev": true - }, - "negotiator": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", - "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", - "dev": true - }, - "next-tick": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", - "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", - "dev": true - }, - "normalize-package-data": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", - "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", - "dev": true, - "requires": { - "hosted-git-info": "^2.1.4", - "resolve": "^1.10.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" - } - }, - "normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true - }, - "normalize-url": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-1.9.1.tgz", - "integrity": "sha1-LMDWazHqIwNkWENuNiDYWVTGbDw=", - "dev": true, - "requires": { - "object-assign": "^4.0.1", - "prepend-http": "^1.0.0", - "query-string": "^4.1.0", - "sort-keys": "^1.0.0" - } - }, - "now-and-later": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/now-and-later/-/now-and-later-2.0.1.tgz", - "integrity": "sha512-KGvQ0cB70AQfg107Xvs/Fbu+dGmZoTRJp2TaPwcwQm3/7PteUyN2BCgk8KBMPGBUXZdVwyWS8fDCGFygBm19UQ==", - "dev": true, - "requires": { - "once": "^1.3.2" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - }, - "object-copy": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", - "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", - "dev": true, - "requires": { - "copy-descriptor": "^0.1.0", - "define-property": "^0.2.5", - "kind-of": "^3.0.3" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "object-inspect": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz", - "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==", - "dev": true - }, - "object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "dev": true - }, - "object-visit": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", - "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", - "dev": true, - "requires": { - "isobject": "^3.0.0" - } - }, - "object.assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.1.tgz", - "integrity": "sha512-VT/cxmx5yaoHSOTSyrCygIDFco+RsibY2NM0a4RdEeY/4KgqezwFtK1yr3U67xYhqJSlASm2pKhLVzPj2lr4bA==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.18.0-next.0", - "has-symbols": "^1.0.1", - "object-keys": "^1.1.1" - } - }, - "object.defaults": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz", - "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=", - "dev": true, - "requires": { - "array-each": "^1.0.1", - "array-slice": "^1.0.0", - "for-own": "^1.0.0", - "isobject": "^3.0.0" - } - }, - "object.map": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/object.map/-/object.map-1.0.1.tgz", - "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=", - "dev": true, - "requires": { - "for-own": "^1.0.0", - "make-iterator": "^1.0.0" - } - }, - "object.pick": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", - "dev": true, - "requires": { - "isobject": "^3.0.1" - } - }, - "object.reduce": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/object.reduce/-/object.reduce-1.0.1.tgz", - "integrity": "sha1-b+NI8qx/oPlcpiEiZZkJaCW7A60=", - "dev": true, - "requires": { - "for-own": "^1.0.0", - "make-iterator": "^1.0.0" - } - }, - "on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", - "dev": true, - "requires": { - "ee-first": "1.1.1" - } - }, - "on-headers": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", - "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", - "dev": true - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "onetime": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", - "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", - "dev": true - }, - "opn": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/opn/-/opn-6.0.0.tgz", - "integrity": "sha512-I9PKfIZC+e4RXZ/qr1RhgyCnGgYX0UEIlXgWnCOVACIvFgaC9rz6Won7xbdhoHrd8IIhV7YEpHjreNUNkqCGkQ==", - "dev": true, - "requires": { - "is-wsl": "^1.1.0" - } - }, - "optionator": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", - "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", - "dev": true, - "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.4", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "wordwrap": "~1.0.0" - } - }, - "ordered-read-streams": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz", - "integrity": "sha1-d8DLN8QVJdZBZtmQ/61+xqDhNj4=", - "dev": true, - "requires": { - "readable-stream": "^2.0.1" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, - "os-homedir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", - "dev": true - }, - "os-locale": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", - "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", - "dev": true, - "requires": { - "lcid": "^1.0.0" - } - }, - "parse-filepath": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz", - "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=", - "dev": true, - "requires": { - "is-absolute": "^1.0.0", - "map-cache": "^0.2.0", - "path-root": "^0.1.1" - } - }, - "parse-json": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", - "dev": true, - "requires": { - "error-ex": "^1.2.0" - } - }, - "parse-node-version": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz", - "integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==", - "dev": true - }, - "parse-passwd": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", - "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", - "dev": true - }, - "parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "dev": true - }, - "pascalcase": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", - "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "dev": true - }, - "path-dirname": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", - "dev": true - }, - "path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, - "requires": { - "pinkie-promise": "^2.0.0" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-is-inside": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", - "dev": true - }, - "path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true - }, - "path-root": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz", - "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", - "dev": true, - "requires": { - "path-root-regex": "^0.1.0" - } - }, - "path-root-regex": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz", - "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=", - "dev": true - }, - "path-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "pause-stream": { - "version": "0.0.11", - "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", - "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", - "dev": true, - "requires": { - "through": "~2.3" - } - }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - }, - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "dev": true, - "requires": { - "pinkie": "^2.0.0" - } - }, - "pluralize": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-1.2.1.tgz", - "integrity": "sha1-0aIUg/0iu0HlihL6NCGCMUCJfEU=", - "dev": true - }, - "posix-character-classes": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", - "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "dev": true - }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "dev": true - }, - "prepend-http": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", - "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=", - "dev": true - }, - "pretty-hrtime": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", - "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=", - "dev": true - }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true - }, - "progress": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", - "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", - "dev": true - }, - "proxy-middleware": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/proxy-middleware/-/proxy-middleware-0.15.0.tgz", - "integrity": "sha1-o/3xvvtzD5UZZYcqwvYHTGFHelY=", - "dev": true - }, - "pump": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", - "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", - "dev": true, - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, - "pumpify": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.5.1.tgz", - "integrity": "sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ==", - "dev": true, - "requires": { - "duplexify": "^3.6.0", - "inherits": "^2.0.3", - "pump": "^2.0.0" - } - }, - "query-string": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-4.3.4.tgz", - "integrity": "sha1-u7aTucqRXCMlFbIosaArYJBD2+s=", - "dev": true, - "requires": { - "object-assign": "^4.1.0", - "strict-uri-encode": "^1.0.0" - } - }, - "range-parser": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", - "dev": true - }, - "read-pkg": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", - "dev": true, - "requires": { - "load-json-file": "^1.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^1.0.0" - } - }, - "read-pkg-up": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", - "dev": true, - "requires": { - "find-up": "^1.0.0", - "read-pkg": "^1.0.0" - } - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "readdirp": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", - "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.11", - "micromatch": "^3.1.10", - "readable-stream": "^2.0.2" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, - "readline2": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz", - "integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=", - "dev": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "mute-stream": "0.0.5" - } - }, - "rechoir": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", - "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", - "dev": true, - "requires": { - "resolve": "^1.1.6" - } - }, - "regex-not": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", - "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", - "dev": true, - "requires": { - "extend-shallow": "^3.0.2", - "safe-regex": "^1.1.0" - } - }, - "remove-bom-buffer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remove-bom-buffer/-/remove-bom-buffer-3.0.0.tgz", - "integrity": "sha512-8v2rWhaakv18qcvNeli2mZ/TMTL2nEyAKRvzo1WtnZBl15SHyEhrCu2/xKlJyUFKHiHgfXIyuY6g2dObJJycXQ==", - "dev": true, - "requires": { - "is-buffer": "^1.1.5", - "is-utf8": "^0.2.1" - } - }, - "remove-bom-stream": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/remove-bom-stream/-/remove-bom-stream-1.2.0.tgz", - "integrity": "sha1-BfGlk/FuQuH7kOv1nejlaVJflSM=", - "dev": true, - "requires": { - "remove-bom-buffer": "^3.0.0", - "safe-buffer": "^5.1.0", - "through2": "^2.0.3" - } - }, - "remove-trailing-separator": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", - "dev": true - }, - "repeat-element": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", - "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", - "dev": true - }, - "repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true - }, - "repeating": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", - "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", - "dev": true, - "requires": { - "is-finite": "^1.0.0" - } - }, - "replace-ext": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz", - "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", - "dev": true - }, - "replace-homedir": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/replace-homedir/-/replace-homedir-1.0.0.tgz", - "integrity": "sha1-6H9tUTuSjd6AgmDBK+f+xv9ueYw=", - "dev": true, - "requires": { - "homedir-polyfill": "^1.0.1", - "is-absolute": "^1.0.0", - "remove-trailing-separator": "^1.1.0" - } - }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "dev": true - }, - "require-main-filename": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", - "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", - "dev": true - }, - "require-uncached": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", - "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", - "dev": true, - "requires": { - "caller-path": "^0.1.0", - "resolve-from": "^1.0.0" - } - }, - "requizzle": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.2.tgz", - "integrity": "sha512-oJ6y7JcUJkblRGhMByGNcszeLgU0qDxNKFCiUZR1XyzHyVsev+Mxb1tyygxLd1ORsKee1SA5BInFdUwY64GE/A==", - "dev": true, - "requires": { - "lodash": "^4.17.11" - } - }, - "resolve": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.11.1.tgz", - "integrity": "sha512-vIpgF6wfuJOZI7KKKSP+HmiKggadPQAdsp5HiC1mvqnfp0gF1vdwgBWZIdrVft9pgqoMFQN+R7BSWZiBxx+BBw==", - "dev": true, - "requires": { - "path-parse": "^1.0.6" - } - }, - "resolve-dir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", - "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", - "dev": true, - "requires": { - "expand-tilde": "^2.0.0", - "global-modules": "^1.0.0" - } - }, - "resolve-from": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", - "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", - "dev": true - }, - "resolve-options": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/resolve-options/-/resolve-options-1.1.0.tgz", - "integrity": "sha1-MrueOcBtZzONyTeMDW1gdFZq0TE=", - "dev": true, - "requires": { - "value-or-function": "^3.0.0" - } - }, - "resolve-url": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "dev": true - }, - "restore-cursor": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", - "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", - "dev": true, - "requires": { - "exit-hook": "^1.0.0", - "onetime": "^1.0.0" - } - }, - "ret": { - "version": "0.1.15", - "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", - "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", - "dev": true - }, - "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - }, - "run-async": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz", - "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", - "dev": true, - "requires": { - "once": "^1.3.0" - } - }, - "rx-lite": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz", - "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=", - "dev": true - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "safe-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", - "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", - "dev": true, - "requires": { - "ret": "~0.1.10" - } - }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - }, - "semver-greatest-satisfied-range": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/semver-greatest-satisfied-range/-/semver-greatest-satisfied-range-1.1.0.tgz", - "integrity": "sha1-E+jCZYq5aRywzXEJMkAoDTb3els=", - "dev": true, - "requires": { - "sver-compat": "^1.5.0" - } - }, - "send": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", - "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", - "dev": true, - "requires": { - "debug": "2.6.9", - "depd": "~1.1.2", - "destroy": "~1.0.4", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "fresh": "0.5.2", - "http-errors": "~1.7.2", - "mime": "1.6.0", - "ms": "2.1.1", - "on-finished": "~2.3.0", - "range-parser": "~1.2.1", - "statuses": "~1.5.0" - }, - "dependencies": { - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", - "dev": true - } - } - }, - "serve-index": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", - "integrity": "sha1-03aNabHn2C5c4FD/9bRTvqEqkjk=", - "dev": true, - "requires": { - "accepts": "~1.3.4", - "batch": "0.6.1", - "debug": "2.6.9", - "escape-html": "~1.0.3", - "http-errors": "~1.6.2", - "mime-types": "~2.1.17", - "parseurl": "~1.3.2" - }, - "dependencies": { - "http-errors": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", - "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", - "dev": true, - "requires": { - "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.0", - "statuses": ">= 1.4.0 < 2" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "setprototypeof": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", - "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==", - "dev": true - } - } - }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", - "dev": true - }, - "set-value": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", - "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.3", - "split-string": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "setprototypeof": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", - "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", - "dev": true - }, - "shelljs": { - "version": "0.7.8", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.8.tgz", - "integrity": "sha1-3svPh0sNHl+3LhSxZKloMEjprLM=", - "dev": true, - "requires": { - "glob": "^7.0.0", - "interpret": "^1.0.0", - "rechoir": "^0.6.2" - } - }, - "slice-ansi": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", - "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", - "dev": true - }, - "snapdragon": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", - "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", - "dev": true, - "requires": { - "base": "^0.11.1", - "debug": "^2.2.0", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "map-cache": "^0.2.2", - "source-map": "^0.5.6", - "source-map-resolve": "^0.5.0", - "use": "^3.1.0" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "snapdragon-node": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", - "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", - "dev": true, - "requires": { - "define-property": "^1.0.0", - "isobject": "^3.0.0", - "snapdragon-util": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "snapdragon-util": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", - "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", - "dev": true, - "requires": { - "kind-of": "^3.2.0" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "sort-keys": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz", - "integrity": "sha1-RBttTTRnmPG05J6JIK37oOVD+a0=", - "dev": true, - "requires": { - "is-plain-obj": "^1.0.0" - } - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - }, - "source-map-resolve": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", - "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", - "dev": true, - "requires": { - "atob": "^2.1.1", - "decode-uri-component": "^0.2.0", - "resolve-url": "^0.2.1", - "source-map-url": "^0.4.0", - "urix": "^0.1.0" - } - }, - "source-map-url": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", - "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", - "dev": true - }, - "sparkles": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.1.tgz", - "integrity": "sha512-dSO0DDYUahUt/0/pD/Is3VIm5TGJjludZ0HVymmhYF6eNA53PVLhnUk0znSYbH8IYBuJdCE+1luR22jNLMaQdw==", - "dev": true - }, - "spdx-correct": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz", - "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==", - "dev": true, - "requires": { - "spdx-expression-parse": "^3.0.0", - "spdx-license-ids": "^3.0.0" - } - }, - "spdx-exceptions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", - "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==", - "dev": true - }, - "spdx-expression-parse": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", - "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", - "dev": true, - "requires": { - "spdx-exceptions": "^2.1.0", - "spdx-license-ids": "^3.0.0" - } - }, - "spdx-license-ids": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.6.tgz", - "integrity": "sha512-+orQK83kyMva3WyPf59k1+Y525csj5JejicWut55zeTWANuN17qSiSLUXWtzHeNWORSvT7GLDJ/E/XiIWoXBTw==", - "dev": true - }, - "split": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", - "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", - "dev": true, - "requires": { - "through": "2" - } - }, - "split-string": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", - "dev": true, - "requires": { - "extend-shallow": "^3.0.0" - } - }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, - "stack-trace": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", - "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=", - "dev": true - }, - "static-extend": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", - "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", - "dev": true, - "requires": { - "define-property": "^0.2.5", - "object-copy": "^0.1.0" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - } - } - }, - "statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", - "dev": true - }, - "stream-combiner": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", - "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", - "dev": true, - "requires": { - "duplexer": "~0.1.1" - } - }, - "stream-exhaust": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/stream-exhaust/-/stream-exhaust-1.0.2.tgz", - "integrity": "sha512-b/qaq/GlBK5xaq1yrK9/zFcyRSTNxmcZwFLGSTG0mXgZl/4Z6GgiyYOXOvY7N3eEvFRAG1bkDRz5EPGSvPYQlw==", - "dev": true - }, - "stream-shift": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz", - "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==", - "dev": true - }, - "strict-uri-encode": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", - "integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=", - "dev": true - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "string.prototype.trimend": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz", - "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.5" - }, - "dependencies": { - "es-abstract": { - "version": "1.17.7", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.7.tgz", - "integrity": "sha512-VBl/gnfcJ7OercKA9MVaegWsBHFjV492syMudcnQZvt/Dw8ezpcOHYZXa/J96O8vx+g4x65YKhxOwDUh63aS5g==", - "dev": true, - "requires": { - "es-to-primitive": "^1.2.1", - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.2.2", - "is-regex": "^1.1.1", - "object-inspect": "^1.8.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.1", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" - } - } - } - }, - "string.prototype.trimstart": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz", - "integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.5" - }, - "dependencies": { - "es-abstract": { - "version": "1.17.7", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.7.tgz", - "integrity": "sha512-VBl/gnfcJ7OercKA9MVaegWsBHFjV492syMudcnQZvt/Dw8ezpcOHYZXa/J96O8vx+g4x65YKhxOwDUh63aS5g==", - "dev": true, - "requires": { - "es-to-primitive": "^1.2.1", - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.2.2", - "is-regex": "^1.1.1", - "object-inspect": "^1.8.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.1", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" - } - } - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "dev": true, - "requires": { - "is-utf8": "^0.2.0" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true - }, - "strip-outer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/strip-outer/-/strip-outer-1.0.1.tgz", - "integrity": "sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg==", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.2" - } - }, - "strip-url-auth": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/strip-url-auth/-/strip-url-auth-1.0.1.tgz", - "integrity": "sha1-IrD6OkE4WzO+PzMVUbu4N/oM164=", - "dev": true - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - }, - "sver-compat": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/sver-compat/-/sver-compat-1.5.0.tgz", - "integrity": "sha1-PPh9/rTQe0o/FIJ7wYaz/QxkXNg=", - "dev": true, - "requires": { - "es6-iterator": "^2.0.1", - "es6-symbol": "^3.1.1" - } - }, - "table": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz", - "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=", - "dev": true, - "requires": { - "ajv": "^4.7.0", - "ajv-keywords": "^1.0.0", - "chalk": "^1.1.1", - "lodash": "^4.0.0", - "slice-ansi": "0.0.4", - "string-width": "^2.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - } - } - }, - "taffydb": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", - "integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=", - "dev": true - }, - "tar": { - "version": "4.4.19", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.19.tgz", - "integrity": "sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA==", - "dev": true, - "optional": true, - "requires": { - "chownr": "^1.1.4", - "fs-minipass": "^1.2.7", - "minipass": "^2.9.0", - "minizlib": "^1.3.3", - "mkdirp": "^0.5.5", - "safe-buffer": "^5.2.1", - "yallist": "^3.1.1" - }, - "dependencies": { - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true, - "optional": true - } - } - }, - "text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", - "dev": true - }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true - }, - "through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", - "dev": true, - "requires": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, - "through2-filter": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/through2-filter/-/through2-filter-3.0.0.tgz", - "integrity": "sha512-jaRjI2WxN3W1V8/FMZ9HKIBXixtiqs3SQSX4/YGIiP3gL6djW48VoZq9tDqeCWs3MT8YY5wb/zli8VW8snY1CA==", - "dev": true, - "requires": { - "through2": "~2.0.0", - "xtend": "~4.0.0" - } - }, - "time-stamp": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz", - "integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=", - "dev": true - }, - "to-absolute-glob": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz", - "integrity": "sha1-GGX0PZ50sIItufFFt4z/fQ98hJs=", - "dev": true, - "requires": { - "is-absolute": "^1.0.0", - "is-negated-glob": "^1.0.0" - } - }, - "to-object-path": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", - "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "to-regex": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", - "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", - "dev": true, - "requires": { - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "regex-not": "^1.0.2", - "safe-regex": "^1.1.0" - } - }, - "to-regex-range": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", - "dev": true, - "requires": { - "is-number": "^3.0.0", - "repeat-string": "^1.6.1" - } - }, - "to-through": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-through/-/to-through-2.0.0.tgz", - "integrity": "sha1-/JKtq6ByZHvAtn1rA2ZKoZUJOvY=", - "dev": true, - "requires": { - "through2": "^2.0.3" - } - }, - "toidentifier": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", - "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", - "dev": true - }, - "trim-repeated": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/trim-repeated/-/trim-repeated-1.0.0.tgz", - "integrity": "sha1-42RqLqTokTEr9+rObPsFOAvAHCE=", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.2" - } - }, - "type": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/type/-/type-1.0.1.tgz", - "integrity": "sha512-MAM5dBMJCJNKs9E7JXo4CXRAansRfG0nlJxW7Wf6GZzSOvH31zClSaHdIMWLehe/EGMBkqeC55rrkaOr5Oo7Nw==", - "dev": true - }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2" - } - }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true - }, - "unc-path-regex": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", - "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", - "dev": true - }, - "underscore": { - "version": "1.8.3", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", - "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=", - "dev": true - }, - "undertaker": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.3.0.tgz", - "integrity": "sha512-/RXwi5m/Mu3H6IHQGww3GNt1PNXlbeCuclF2QYR14L/2CHPz3DFZkvB5hZ0N/QUkiXWCACML2jXViIQEQc2MLg==", - "dev": true, - "requires": { - "arr-flatten": "^1.0.1", - "arr-map": "^2.0.0", - "bach": "^1.0.0", - "collection-map": "^1.0.0", - "es6-weak-map": "^2.0.1", - "fast-levenshtein": "^1.0.0", - "last-run": "^1.1.0", - "object.defaults": "^1.0.0", - "object.reduce": "^1.0.0", - "undertaker-registry": "^1.0.0" - }, - "dependencies": { - "fast-levenshtein": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-1.1.4.tgz", - "integrity": "sha1-5qdUzI8V5YmHqpy9J69m/W9OWvk=", - "dev": true - } - } - }, - "undertaker-registry": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/undertaker-registry/-/undertaker-registry-1.0.1.tgz", - "integrity": "sha1-XkvaMI5KiirlhPm5pDWaSZglzFA=", - "dev": true - }, - "union-value": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", - "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", - "dev": true, - "requires": { - "arr-union": "^3.1.0", - "get-value": "^2.0.6", - "is-extendable": "^0.1.1", - "set-value": "^2.0.1" - } - }, - "unique-stream": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-2.3.1.tgz", - "integrity": "sha512-2nY4TnBE70yoxHkDli7DMazpWiP7xMdCYqU2nBRO0UB+ZpEkGsSija7MvmvnZFUeC+mrgiUfcHSr3LmRFIg4+A==", - "dev": true, - "requires": { - "json-stable-stringify-without-jsonify": "^1.0.1", - "through2-filter": "^3.0.0" - } - }, - "universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true - }, - "unix-crypt-td-js": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unix-crypt-td-js/-/unix-crypt-td-js-1.0.0.tgz", - "integrity": "sha1-HAgkFQSBvHoB1J6Y8exmjYJBLzs=", - "dev": true - }, - "unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", - "dev": true - }, - "unset-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", - "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", - "dev": true, - "requires": { - "has-value": "^0.3.1", - "isobject": "^3.0.0" - }, - "dependencies": { - "has-value": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", - "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", - "dev": true, - "requires": { - "get-value": "^2.0.3", - "has-values": "^0.1.4", - "isobject": "^2.0.0" - }, - "dependencies": { - "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "1.0.0" - } - } - } - }, - "has-values": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", - "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - } - } - }, - "upath": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.2.tgz", - "integrity": "sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q==", - "dev": true - }, - "urix": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "dev": true - }, - "use": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", - "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", - "dev": true - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "utils-merge": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", - "dev": true - }, - "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", - "dev": true - }, - "v8flags": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.2.0.tgz", - "integrity": "sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==", - "dev": true, - "requires": { - "homedir-polyfill": "^1.0.1" - } - }, - "validate-npm-package-license": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", - "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", - "dev": true, - "requires": { - "spdx-correct": "^3.0.0", - "spdx-expression-parse": "^3.0.0" - } - }, - "value-or-function": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/value-or-function/-/value-or-function-3.0.0.tgz", - "integrity": "sha1-HCQ6ULWVwb5Up1S/7OhWO5/42BM=", - "dev": true - }, - "vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", - "dev": true - }, - "vinyl": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz", - "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", - "dev": true, - "requires": { - "clone": "^1.0.0", - "clone-stats": "^0.0.1", - "replace-ext": "0.0.1" - } - }, - "vinyl-fs": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-3.0.3.tgz", - "integrity": "sha512-vIu34EkyNyJxmP0jscNzWBSygh7VWhqun6RmqVfXePrOwi9lhvRs//dOaGOTRUQr4tx7/zd26Tk5WeSVZitgng==", - "dev": true, - "requires": { - "fs-mkdirp-stream": "^1.0.0", - "glob-stream": "^6.1.0", - "graceful-fs": "^4.0.0", - "is-valid-glob": "^1.0.0", - "lazystream": "^1.0.0", - "lead": "^1.0.0", - "object.assign": "^4.0.4", - "pumpify": "^1.3.5", - "readable-stream": "^2.3.3", - "remove-bom-buffer": "^3.0.0", - "remove-bom-stream": "^1.2.0", - "resolve-options": "^1.1.0", - "through2": "^2.0.0", - "to-through": "^2.0.0", - "value-or-function": "^3.0.0", - "vinyl": "^2.0.0", - "vinyl-sourcemap": "^1.1.0" - }, - "dependencies": { - "clone": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", - "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=", - "dev": true - }, - "clone-stats": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", - "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "replace-ext": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.1.tgz", - "integrity": "sha512-yD5BHCe7quCgBph4rMQ+0KkIRKwWCrHDOX1p1Gp6HwjPM5kVoCdKGNhN7ydqqsX6lJEnQDKZ/tFMiEdQ1dvPEw==", - "dev": true - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "vinyl": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.1.tgz", - "integrity": "sha512-LII3bXRFBZLlezoG5FfZVcXflZgWP/4dCwKtxd5ky9+LOtM4CS3bIRQsmR1KMnMW07jpE8fqR2lcxPZ+8sJIcw==", - "dev": true, - "requires": { - "clone": "^2.1.1", - "clone-buffer": "^1.0.0", - "clone-stats": "^1.0.0", - "cloneable-readable": "^1.0.0", - "remove-trailing-separator": "^1.0.1", - "replace-ext": "^1.0.0" - } - } - } - }, - "vinyl-sourcemap": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/vinyl-sourcemap/-/vinyl-sourcemap-1.1.0.tgz", - "integrity": "sha1-kqgAWTo4cDqM2xHYswCtS+Y7PhY=", - "dev": true, - "requires": { - "append-buffer": "^1.0.2", - "convert-source-map": "^1.5.0", - "graceful-fs": "^4.1.6", - "normalize-path": "^2.1.1", - "now-and-later": "^2.0.0", - "remove-bom-buffer": "^3.0.0", - "vinyl": "^2.0.0" - }, - "dependencies": { - "clone": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", - "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=", - "dev": true - }, - "clone-stats": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", - "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=", - "dev": true - }, - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true, - "requires": { - "remove-trailing-separator": "^1.0.1" - } - }, - "replace-ext": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.1.tgz", - "integrity": "sha512-yD5BHCe7quCgBph4rMQ+0KkIRKwWCrHDOX1p1Gp6HwjPM5kVoCdKGNhN7ydqqsX6lJEnQDKZ/tFMiEdQ1dvPEw==", - "dev": true - }, - "vinyl": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.1.tgz", - "integrity": "sha512-LII3bXRFBZLlezoG5FfZVcXflZgWP/4dCwKtxd5ky9+LOtM4CS3bIRQsmR1KMnMW07jpE8fqR2lcxPZ+8sJIcw==", - "dev": true, - "requires": { - "clone": "^2.1.1", - "clone-buffer": "^1.0.0", - "clone-stats": "^1.0.0", - "cloneable-readable": "^1.0.0", - "remove-trailing-separator": "^1.0.1", - "replace-ext": "^1.0.0" - } - } - } - }, - "websocket-driver": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.3.tgz", - "integrity": "sha512-bpxWlvbbB459Mlipc5GBzzZwhoZgGEZLuqPaR0INBGnPAY1vdBX6hPnoFXiw+3yWxDuHyQjO2oXTMyS8A5haFg==", - "dev": true, - "requires": { - "http-parser-js": ">=0.4.0 <0.4.11", - "safe-buffer": ">=5.1.0", - "websocket-extensions": ">=0.1.1" - } - }, - "websocket-extensions": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.4.tgz", - "integrity": "sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg==", - "dev": true - }, - "which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - }, - "which-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz", - "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=", - "dev": true - }, - "wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", - "dev": true - }, - "wrap-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", - "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", - "dev": true, - "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1" - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "write": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", - "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", - "dev": true, - "requires": { - "mkdirp": "^0.5.1" - } - }, - "xmlcreate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-1.0.2.tgz", - "integrity": "sha1-+mv3YqYKQT+z3Y9LA8WyaSONMI8=", - "dev": true - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true - }, - "y18n": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.2.tgz", - "integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==", - "dev": true - }, - "yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", - "dev": true, - "optional": true - }, - "yargs": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-7.1.1.tgz", - "integrity": "sha512-huO4Fr1f9PmiJJdll5kwoS2e4GqzGSsMT3PPMpOwoVkOK8ckqAewMTZyA6LXVQWflleb/Z8oPBEvNsMft0XE+g==", - "dev": true, - "requires": { - "camelcase": "^3.0.0", - "cliui": "^3.2.0", - "decamelize": "^1.1.1", - "get-caller-file": "^1.0.1", - "os-locale": "^1.4.0", - "read-pkg-up": "^1.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^1.0.2", - "which-module": "^1.0.0", - "y18n": "^3.2.1", - "yargs-parser": "5.0.0-security.0" - } - }, - "yargs-parser": { - "version": "5.0.0-security.0", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-5.0.0-security.0.tgz", - "integrity": "sha512-T69y4Ps64LNesYxeYGYPvfoMTt/7y1XtfpIslUeK4um+9Hu7hlGoRtaDLvdXb7+/tfq4opVa2HRY5xGip022rQ==", - "dev": true, - "requires": { - "camelcase": "^3.0.0", - "object.assign": "^4.1.0" - } - } - } -} From 21a621c1e45c386e59ab878f77ce1668ac69c559 Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Sun, 15 Oct 2023 14:08:24 -0700 Subject: [PATCH 612/613] Setup CI via GitHub actions main.yml --- .github/workflows/main.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..16f9bad5 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,17 @@ +name: Node.js CI + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '17.7.x' + - run: yarn --frozen-lockfile + - run: npm test From 405279c52e6a0afc30b7646d7a44d757722a3f3b Mon Sep 17 00:00:00 2001 From: Minko Gechev Date: Sun, 15 Oct 2023 14:10:36 -0700 Subject: [PATCH 613/613] Remove stale travis banner --- readme.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/readme.md b/readme.md index e61af141..945b4238 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,5 @@ ## About -[![Build Status](https://travis-ci.org/mgechev/javascript-algorithms.svg?branch=Jakehp-patch-1)](https://travis-ci.org/mgechev/javascript-algorithms) - This repository contains JavaScript implementations of famous computer science algorithms. API reference with usage examples available