GithubHelp home page GithubHelp logo

loiane / javascript-datastructures-algorithms Goto Github PK

View Code? Open in Web Editor NEW
4.5K 137.0 1.2K 13.85 MB

:books: collection of JavaScript and TypeScript data structures and algorithms for education purposes. Source code bundle of JavaScript algorithms and data structures book

Home Page: https://goo.gl/hrb00r

JavaScript 47.54% TypeScript 52.46%
javascript-algorithms algorithm data-structures typescript typescript-algorithms stack queue deque priority-queue linked-list

javascript-datastructures-algorithms's Introduction

Learning JavaScript Data Structures and Algorithms

Build Status codecov devDependencies Status dependencies Status Greenkeeper badge

Source code of Learning JavaScript Data Structures and Algorithms book, third edition.

List of available chapters:

Third Edition Updates

  • Algorithms using ES2015+ (ES6+)
  • New data structures and algorithms
  • All chapters rewritten and reviewed
  • Three (3) new chapters
  • Creation of a Data Structures and Algorithms library that can be used in the browser or with Node.js
  • Algorithms tested with Mocha + Chai (test code available in test directory)
  • TypeScript version of the source code included (library and tests)

Project Structure

src/js/index.js file contains all the data structures and algorithms listed by chapter.

|_examples (how to use each data structure and algorithm, organized by chapter)
|_src 
|___js (source code: JavaScript version)
|_____data-structures
|_______models (classes used by DS: Node, ValuePair, ...)
|_____others (other algorithms such as palindome checker, hanoi tower)
|___ts (source code: TypeScript version)
|_____data-structures
|_______models
|_____others
|_test (unit tests with Mocha and Chai for src)
|___js (tests for JavaScript code)
|___ts (tests for TypeScript code)

Installing and running the book examples With Node

  • Install Node
  • Open terminal/cmd and change directory to this project folder: cd /Users/.../javascript-datastructures-algorithms (Linux/Max) or cd C:/.../javascript-datastructures-algorithms
  • run npm install to install all dependencies
  • To see the examples, run http-server html or npm run serve. Open your browser http:\\localhost:8080 to see the book examples
  • Or cd html/chapter01 and run each javascript file with node: node 02-Variables

Running the examples in the browser

Happy Coding!

Other editions

1st edition 2nd edition 3rd edition
1st edition 2nd edition 3rd edition
Book link Book link Book link

Book link - first edition:

Book link - second edition:

Book link - third edition:

Found an issue or have a question?

Please create an Issue or Pull Request

javascript-datastructures-algorithms's People

Contributors

anthonycampbell avatar ayomel avatar beizhedenglong avatar christianbender avatar dependabot[bot] avatar fernanda-freitas avatar greenkeeper[bot] avatar helderberto avatar jackzong avatar jaygood avatar jeff-zhenz avatar loiane avatar nmtuan1612 avatar os-moussao avatar rookie-mr avatar satsczar avatar shockyng avatar sojinsamuel avatar terryx avatar victoraugdb avatar wruth avatar yamiqu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

javascript-datastructures-algorithms's Issues

chapter 11.2.2 the knapsack algorithm

when I see function findValues
k = k - kS[i][k];
why use the weight k reduce kS[i][k]?
In my mind, the kS[i][k] just a value....
hope for reply~
Thx~~

An in-range update of @types/mocha is breaking the build 🚨

Version 5.1.0 of @types/mocha was just published.

Branch Build failing 🚨
Dependency @types/mocha
Current Version 5.0.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

@types/mocha is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build passed Details
  • codecov/project 64.61% (-0.73%) compared to 6e9eb98 Details
  • codecov/patch Coverage not affected when comparing 6e9eb98...f72e948 Details
  • bitHound - Dependencies No failing dependencies. Details
  • bitHound - Code No failing files. Details

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint-plugin-import is breaking the build 🚨

☝️ Greenkeeper’s updated Terms of Service will come into effect on April 6th, 2018.

Version 2.11.0 of eslint-plugin-import was just published.

Branch Build failing 🚨
Dependency eslint-plugin-import
Current Version 2.10.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-import is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build passed Details
  • bitHound - Code No failing files. Details
  • bitHound - Dependencies No failing dependencies. Details
  • codecov/patch Coverage not affected when comparing 6e9eb98...27653ed Details
  • codecov/project 61.73% (-3.62%) compared to 6e9eb98 Details

Commits

The new version differs by 21 commits.

  • e0dcfbd Merge branch 'fix-perf' into release-2.10.1 (fixes #1058)
  • 774ea8d changelog note for #1058
  • 7bd2775 perf: no AST nodes in caches
  • 83c85fc bump to v2.11.0 for #880 (semver-minor)
  • 54e3013 changelog for #880
  • 0ff8f23 bump to v2.10.1
  • f0b4f3e Merge pull request #1069 from ljharb/resolve
  • fb8e1e5 [patch] use resolve instead of builtin-modules
  • d8077c8 Merge pull request #1064 from ljharb/fix_no_cycle
  • 80d1ceb Merge pull request #1065 from sharmilajesupaul/minor-typo-fix
  • f13f18e minor typo in import/no-cycle rule docs
  • 19fc3df [Fix] no-cycle: create must always return an object, even if there’s no listeners
  • ee15fa4 Merge pull request #880 from futpib/no-commonjs-allow-require
  • 48d0a8a changelog note for #1046
  • a2acbde add fixer for first (#1046)

There are 21 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of webpack is breaking the build 🚨

Version 4.6.0 of webpack was just published.

Branch Build failing 🚨
Dependency webpack
Current Version 4.5.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

webpack is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build passed Details
  • bitHound - Dependencies No failing dependencies. Details
  • bitHound - Code No failing files. Details
  • codecov/project 63.57% (-1.78%) compared to 6e9eb98 Details
  • codecov/patch Coverage not affected when comparing 6e9eb98...1ee3d6b Details

Release Notes v4.6.0

Features

  • improve stats output alignment
  • improve stats text output when all exports are used
  • add webpackPrefetch/webpackPreload magic comments to import()
  • add stats.entrypoints[].children and stats.entrypoints[].childAssets to stats json
  • add prefetched/preloaded chunks and assets to stats text output
  • Performance improvements

Bugfixes

  • Escape chunk ids for target: "webworker"
  • fix this to undefined ESM replacement in function default values
  • new require(...) is weird, but now behaves like in node.js
  • fix behavior of export * from "commonjs" with partial override
  • fixed build time output in current locale in stats text output
  • fixed ChunkModuleIdRangePlugin and add tests
  • avoid race condition when using the loadModule loader API
  • fix default value of output.globalObject in target: "node-webkit"
  • fix a bug with loadModules and dependencies in these modules
  • fix hot.accept parser plugin to allow defined values as argument
  • print unknown size when size is unknown
  • fix a bug where some chunks were missing in the "single" runtime chunk
  • fix cloning of optimization configuration

Internal changes

  • Set up infrastructure for linting typings with TypeScript
Commits

The new version differs by 161 commits.

  • e7c8fa4 4.6.0
  • 941be29 Merge pull request #7063 from webpack/bugfix/clone-optimization
  • 3a5fda9 Merge pull request #7062 from webpack/bugfix/issue-6931
  • c47150c Clone optimization config in Defaulter
  • 3f99517 Merge pull request #6905 from xtuc/fix-handle-unknown-size
  • aee2491 Merge pull request #6962 from justinhelmer/bug/6919
  • ec4ec8e Merge pull request #7056 from webpack/feature/preload
  • 0ff2901 Merge pull request #7060 from webpack/test/any-comment-in-import
  • 58ba91d fix bug which prevented some chunks to show up in Chunk.getAllAsyncChunks
  • 946c4df add test case for comments in import()
  • 8e2e19b fix unstable sorting of ChunkGroups and add test
  • 205ca62 fix reversed order in Chunk.compareTo
  • babc8a4 Merge pull request #7059 from bastimeyer/bugfix/loaderplugin-recursive
  • be79d6d add mixed test case which also tests equal order sorting
  • 873d7d4 show preload and prefetch in stats

There are 161 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

verifyRemoveSideEffect possible simplification

Hi Loiane!

Thank you for this excellent book! I enjoy reading it a lot!

The question is regarding hash-table-linear-probing.js:

Can we simplify the function verifyRemoveSideEffect?

It's original version in the file is:

 verifyRemoveSideEffect(key, removedPosition) {
    const hash = this.hashCode(key);
    let index = removedPosition + 1;
    while (this.table[index] != null) {
      const posHash = this.hashCode(this.table[index].key);
      if (posHash <= hash || posHash <= removedPosition) { // QUESTION IS ABOUT THIS LINE
        this.table[removedPosition] = this.table[index];
        delete this.table[index];
        removedPosition = index;
      }
      index++;
    }
  }

However, since hash is always less than removedPosition, can we just check for posHash <= removedPosition instead of posHash <= hash || posHash <= removedPosition?

This way the function would look like:

  verifyRemoveSideEffect(key, removedPosition) {
    const hash = this.hashCode(key);
    let index = removedPosition + 1;
    while (this.table[index] != null) {
      const posHash = this.hashCode(this.table[index].key);
      if (posHash <= removedPosition) { // THIS LINE IS CHANGED
        this.table[removedPosition] = this.table[index];
        delete this.table[index];
        removedPosition = index;
      }
      index++;
    }
  }

I tried this change and it passes all your tests.

Also, this way we do not need const hash = this.hashCode(key); and subsequently key param of the function:

verifyRemoveSideEffect(removedPosition) { // THIS LINE IS CHANGED
    // const hash = this.hashCode(key); - THIS LINE IS REMOVED
    let index = removedPosition + 1;
    while (this.table[index] != null) {
      const posHash = this.hashCode(this.table[index].key);
      if (posHash <= removedPosition) { // THIS LINE IS CHANGED
        this.table[removedPosition] = this.table[index];
        delete this.table[index];
        removedPosition = index;
      }
      index++;
    }
  }

(of course we would need to change the remove function as well, so it calls this.verifyRemoveSideEffect(position); instead of this.verifyRemoveSideEffect(key, position);

With those changes it also passes all tests.

Does it make sense or there are some edge cases that I do not see and they need this check for both possibilities (posHash <= hash || posHash <= removedPosition)?

Thank you again for sharing your wisdom :)

07-HashCollisionLinearProbing.js

In line 49, you are checking for a position that contains an element, so I guess you would like to break the while loop if there is no value for that position
so

while (table[index] === undefined || table[index].key !== key)

should be

while (table[index] !== undefined || table[index].key !== key)

Deletion of a key in hash table (with linear probing) is wrong

First of all, liked the simplicity of the book and its neat for beginners.

So the issue is about the deletion in hash table being described in the book.

Deletion of a key in hash table (with linear probing) is not straightforward.

To clarify, consider this example:

Let's say we have an array of length 2 as hash table and a simple bad hash function.
function hash(n) { return n % 2; }

and lets have two keys 2, 4.
At first, 2 goes into 0th index.
Then 4 has collision and will go into 1st index.

Now deleting 2 will mark 0th index as undefined and then searching for key 4 will not work because we search only till undefined or the value.

while (table[index] !== undefined && (table[index] && table[index].key !== key)){

To fix it, my suggestion would be to use soft deletion like replacing 0th index with some special value to mark as empty, otherwise the probing will stop over there.

For clarification pls refer Deletion section in https://en.wikipedia.org/wiki/Linear_probing.

about minCoinChange.js

javascript-datastructures-algorithms/src/js/algorithms/dynamic-programing/min-coin-change.js

In this file,cache shoule be a object {} better than array []

Add more Pseudo code

I'm a DevCamp student trying to learn DataStructures. Your code is great but is hard to learn conceptually because of the lack of Pseudocode.

Chapter 10: Possible error found within the code of method fixTreeProperties(node) on page 264

The following while condition is not valid as method isRed() shouldn't be invokable through .color.

while (node && node.parent && node.parent.color.isRed() && node.color !== Colors.BLACK){
//rest of the code block in here
}

By the way, I couldn't find the code for chapter 10's RedBlackTree and RedBlackNode anywhere in the downloaded code or in the git repo here. Please advise. Thank You.

HashCollisionLinearProbing cannot remove elements with same hash

1.Very similar to #23

hash.remove('Jonathan')
hash.remove('Jamie')

As the position Jonathan being undefined, Jamie cannot be removed.

2.There is an endless loop in testcase 08-UsingHashCollisionLinearProbing.js

hashLinearProbing.remove('Gandalf');
hashLinearProbing.get('Gandalf')

The position of Gandalf was undefined, but the loop will continue till find Gandalf.

Chapter 10: Self-Balancing Tree - bug in the removeNode(node, key) method

Attempted a removeNode using both the github's and site's downloadable code for the Self-balancing tree.

Error received are as follows:

const tmp = node.right;
TypeError: Cannot read property 'right' of undefined

Insertion of keys were carried out first, as reflected below:

const avltree = new AVLTree(); //used the AVLTree class
avltree.insert(10);
avltree.insert(30);
avltree.insert(20);
avltree.insert(15);
avltree.insert(35);
avltree.insert(25);
avltree.insert(28);

avltree.remove(30);

Converting binary numbers to decimal

Hello, Loiane!
I'm having difficulty understanding the meaning of 'rem' within the algorithm present in the decimalToBinary () function.

Attention:
Page 125, Language: Portuguese.

Thanks for the collaboration.

An in-range update of mocha is breaking the build 🚨

☝️ Greenkeeper’s updated Terms of Service will come into effect on April 6th, 2018.

Version 5.1.0 of mocha was just published.

Branch Build failing 🚨
Dependency mocha
Current Version 5.0.5
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

mocha is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build passed Details
  • codecov/patch Coverage not affected when comparing 6e9eb98...3239fbe Details
  • codecov/project 61.73% (-3.62%) compared to 6e9eb98 Details
  • bitHound - Code No failing files. Details
  • bitHound - Dependencies No failing dependencies. Details

Release Notes v5.1.0

5.1.0 / 2018-04-12

🎉 Enhancements

🐛 Fixes

📖 Documentation

🔩 Other

Commits

The new version differs by 23 commits ahead by 23, behind by 2.

  • 40d9ea3 Release v5.1.0
  • bf34e42 update CHANGELOG for v5.1.0 [ci skip]
  • 63462dd Implement API documentation using npm:documantation.
  • 741b0bd fix circular objects in json reporter; closes #2433 (#3318)
  • 8010501 fix wrong version in package.json! [ci skip]
  • 94e7289 doc precision for exclusive tests
  • 8b6c957 optimize package-scripts.js
  • d71b80a PATH workaround for Travis CI bug
  • 7544bd3 further build improvements (#3315)
  • 88b9882 update package-lock.json for v5.0.5 [ci skip]
  • 4ae26b2 improve caching performance in CI (#3310)
  • ff9f3cf update stages and build matrices (#3308)
  • f2560e7 add update-contributors script; closes #3289 (#3290)
  • cd1c835 upgrade eslint; lint
  • 35dac3e use build stages for Travis CI (#3302)

There are 23 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Ch. 2 Array.from

Thanks for the excellent book!

I'm a bit puzzled by the Array.from() usage example at the bottom of Page 63 in 2nd version. It was said that the returned array will be the even values, while the second param of the Array.from() function is actually a map function instead of a filter function. So the resulting array will be [true, false, true, ..., ].

Is my assumption correct?

Understanding Quick Sort

Thanks for your great work and for second edition. I'm stuck on Quick Sort section.

Code:

function ArrayList() {
	var array = []
	var swap = function(array, index1, index2) {
		var aux = array[index1]
		array[index1] = array[index2]
		array[index2] = aux
	}
	this.insert = function(item) {
		array.push(item)
	}
	this.toString = function() {
		return array.join()
	}
	this.quickSort = function() {
		quick(array, 0, array.length - 1);
	};
	var quick = function(array, left, right) {
		var index;
		if (array.length > 1) {
			index = partition(array, left, right);
			if (left < index - 1) {
				quick(array, left, index - 1); // {5}
			}
			if (index < right) {
				quick(array, index, right); // {7}
			}
		}
	};
	var partition = function(array, left, right) {
		var pivot = array[Math.floor((right + left) / 2)],
			i = left,
			j = right;
		while (i <= j) {
			while (array[i] < pivot) {
				i++;
			}
			while (array[j] > pivot) {
				j--;
			}
			if (i <= j) {
				swap(array, i, j);
				i++;
				j--;
			}
		}
		return i;
	};
}

function createNonSortedArray(size) {
	var array = new ArrayList();
	for (var i = size; i > 0; i--) {
		array.insert(i);
	}
	return array;
}

var array = new ArrayList()

array.insert(3)
array.insert(5)
array.insert(1)
array.insert(6)
array.insert(4)
array.insert(7)
array.insert(2) // [3, 5, 1, 6, 4, 7, 2]

array.quickSort()

console.log(array.toString())

My own step by step explanation of work with array [3, 5, 1, 6, 4, 7, 2] (Identical to array from quick sort section in book):

// first step:
// index = partition([3, 5, 1, 6, 4, 7, 2], 0, 6) = 5
// if (left < index - 1) = if (0 < 5 - 1) = if (0 < 4)[true] : quick([3, 5, 1, 2, 4, 7, 6], 0, 4)

// second step:
// index = partition([3, 5, 1, 2, 4, 7, 6], 0, 4) = 1
// if (left < index - 1) = if (0 < 1 - 1) = if (0 < 0)[false]
// if (index < right) = if (1 < 4)[true] : quick([1, 5, 3, 2, 4, 7, 6], 1, 4)

// third step:
// index = partition([1, 5, 3, 2, 4, 7, 6], 1, 4) = 3
// if (left < index - 1) = if (1 < 3 - 1) = if (1 < 2)[true] : quick([1, 2, 3, 5, 4, 7, 6], 1, 2)

Next the part that is confusing to me:

// fourth step:
// index = partition([1, 2, 3, 5, 4, 7, 6], 1, 2) = 2
// if (left < index - 1) = if (1 < 2 - 1) = if (1 < 1)[false] // here false and we can not use line {5} of algorithm
// if (index < right) = if (2 < 2)[false] // and here false and we can not use line {7} of algorithm

// what happens next?

how in this case we are going to indexes 3 and 4 of array and then to 5 and 6?

some codes can be optimization!

https://www.packtpub.com/application-development/learning-javascript-data-structures-and-algorithms

not too good

image

https://github.com/loiane/javascript-datastructures-algorithms/blob/first-edition/chapter06/01-Set.js

https://github.com/loiane/javascript-datastructures-algorithms/blob/master/chapter06/01-Set.js

https://github.com/loiane/javascript-datastructures-algorithms/blob/master/chapter06/01-Set2.js

    this.intersection = function(otherSet){
        var intersectionSet = new Set(); //{1}

        var values = this.values();
        for (var i=0; i<values.length; i++){ //{2}
            if (otherSet.has(values[i])){    //{3}
                intersectionSet.add(values[i]); //{4}
            }
        }

        return intersectionSet;
    };


    this.intersection = function(otherSet){
        let intersectionSet = new Set(); //{1}

        let values = this.values();
        for (let i=0; i<values.length; i++){ //{2}
            if (otherSet.has(values[i])){    //{3}
                intersectionSet.add(values[i]); //{4}
            }
        }

        return intersectionSet;
    };



        intersection(otherSet){
            let intersectionSet = new Set();

            let values = this.values();
            for (let i=0; i<values.length; i++){
                if (otherSet.has(values[i])){
                    intersectionSet.add(values[i]);
                }
            }

            return intersectionSet;
        }

good

image

    this.intersection = (otherSet) => {
        let intersectionSet = new Set();
        // self
        let values = this.values();
        let othervalues = otherSet.values();
        let small_size = ((othervalues.length - values.length) > 0 ? values : othervalues);
        // small & reduce iterate times 
        for (var i = 0; i < small_size.length; i++) {
            if (small_size.has(values[i])) {
                intersectionSet.add(values[i]);
            }
        }
        return intersectionSet;
    };

javascript-datastructures-algorithms

https://github.com/loiane/javascript-datastructures-algorithms

https://github.com/gildata/RAIO/issues/167#issuecomment-330818729

A minor mistake in Chapter 5

Thanks for the excellent book!
I found a minor mistake in chapter05/03-DoublyLinkedList2.js :

insert(){
if () {
if () {
...
} else if (position === this.size()) {
//error
current = tail;
//ok
current = this.getTail();
} else {
...
}
}
}

An in-range update of webpack is breaking the build 🚨

Version 4.17.3 of webpack was just published.

Branch Build failing 🚨
Dependency webpack
Current Version 4.17.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

webpack is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build passed (Details).
  • codecov/project: 88.71% (-0.68%) compared to 44cdb55 (Details).
  • codecov/patch: Coverage not affected when comparing 44cdb55...996f422 (Details).

Release Notes v4.17.3

Bugfixes

  • Fix exit code when multiple CLIs are installed
  • No longer recommend installing webpack-command, but still support it when installed
Commits

The new version differs by 7 commits.

  • ee27d36 4.17.3
  • 4430524 Merge pull request #7966 from webpack/refactor-remove-webpack-command-from-clis
  • b717aad Show only webpack-cli in the list
  • c5eab67 Merge pull request #8001 from webpack/bugfix/exit-code
  • 943aa6b Fix exit code when multiple CLIs are installed
  • 691cc94 Spelling
  • 898462d refactor: remove webpack-command from CLIs

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Chapter 6 Sets code does not work

I have the following code that I have get till page 94 of the first edition:

function Set() {
    var items = {};
    
    this.has = function(value) {
        return items.hasOwnProperty(value);
    }
    this.add = function(value){
        if(!this.has(value)){
            items[value] = value;
            return true;
        }
        return false;
    }    
}

var set = new Set();
set.add(1);
set.add(5);
set.add(10);
console.log(set.items); //undefined

The console.log outputs undefined. I'm using Google Chrome Version 62.0.3202.75 64 bit on Ubuntu linux and my files structure is two files:

  1. index.html
  2. js.js

An in-range update of babel-plugin-add-module-exports is breaking the build 🚨

The devDependency babel-plugin-add-module-exports was updated from 1.0.0 to 1.0.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

babel-plugin-add-module-exports is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 5 commits.

  • 38e2e68 v1.0.1
  • df47a0a [patch] Add module.exports to files using es3 member literals
  • e8e5be0 docs: tweaks [ci skip]
  • d0001d5 docs(README): add webpack notes(refs #68) & tweaks [ci skip]
  • 753d945 chore: tweak postversion script [ci skip]

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of webpack-cli is breaking the build 🚨

Version 2.0.15 of webpack-cli was just published.

Branch Build failing 🚨
Dependency webpack-cli
Current Version 2.0.14
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

webpack-cli is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build passed Details
  • codecov/patch Coverage not affected when comparing 6e9eb98...995ca89 Details
  • codecov/project 61.73% (-3.62%) compared to 6e9eb98 Details
  • bitHound - Dependencies No failing dependencies. Details
  • bitHound - Code No failing files. Details

Commits

The new version differs by 14 commits.

  • cc64373 chore(versioning): push new package version
  • f9fe061 chore(versioning): v 2.0.15
  • 0354db8 cli(entry): quotes sanitization (#337)
  • f42bdbd fix(ast): checks validity of an identifier (#360)
  • f5b661e Add NoEmitOnErrorsPlugin transformation (#399)
  • 3bbd428 cli(init): webpack4 ready (#356)
  • c94888d cli(migrate): Update migration question (#402)
  • c1c0df0 fix(init): output file name for single output (#403)
  • 12ee2bf cli(add): write configuration to yeoman file (#348)
  • df2a92f Retrieve information for CLI option from webpack schema options file (#392)
  • 1077003 cli(init): use extractMiniCSSPlugin (#363)
  • ab16b4f cli(bugfix): Allow mode "none" in CLI (#381)
  • c487032 cli(init): mode support to config (#364)
  • cc217cb Add break as commit type and listed the type of commit in the documentation (#379)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Don't need to re-set `items` array

Hi Loiane:

I was just glancing through some of your new ES6 based code — cool stuff! I just learned about this idea of using a WeakMap for private data today, partly from your example. I will make one observation in the usage of this in your 01-Stack3.js file however. In push() and pop() you have a pattern where you re-set the array on the items WeakMap after manipulating it, for instance:

            let s = items.get(this);
            s.push(element);
            items.set(this, s);

Pretty sure it is unnecessary to set the array s after having gotten the reference to it. You didn't delete it, so you're just sharing that pointer s with the items WeakMap. That is, it's a pointer (really), not a copy of the array. So you should be able to omit the statement items.set(this, s);.

Cheers!

Circular linked list if statement evaluation

I was wondering if anyone could explain to me why in the circular linked list example, on the insert method, why is it necessary to check if current.next is null. When exactly could node.next be null, if the tail of the linked list always keeps a reference to head?

if (node.next === null){ //update in case last element
  node.next = head;
}

Ch.3 Linked Lists indexOf

Hello Loiane, I think there's a small bug in the indexOf function in page 112 in the 2nd edition book.

let index = -1 should be let index = 0, so that in the while loop later, when the element is found, the function returns the correct index. Otherwise the function will return -1 if the first element is found.

What would you think?

Truthy and falsy - Result of value type(string) is wrong

On topic 'Truthy and falsy' chapter 1, both editions;

The description of value type(string) which you can see on example:

The result is false if the string is empty (length is 0); otherwise, the result is true (length > 1).

Can be verify on output as true when val.length is 1. Using the same function example, below the table of truthy and falsy, we can see:

function testTruthy(val){
    return val ? console.log('truthy') : console.log('falsy');
}

testTruthy('a');  //true

HashCollisionLinearProbing will be unable to retrieve values after initial collision element is removed

In Chapter 7 it seems like there is a serious issue with the way that LinearProbing has been implemented but it could be my lack of knowledge as I'm learning about these things for the first time with your book! In the example code from the book we get:

19 - Gandalf
29 - John
16 - Tyrion
16 - Aaron
13 - Donnie
13 - Ana
5 - Jonathan
5 - Jamie
5 - Sue
32 - Mindy
32 - Paul
10 - Nathan
**** Printing Hash ****
5 -> [Jonathan - [email protected]]
6 -> [Jamie - [email protected]]
7 -> [Sue - [email protected]]
10 -> [Nathan - [email protected]]
13 -> [Donnie - [email protected]]
14 -> [Ana - [email protected]]
16 -> [Tyrion - [email protected]]
17 -> [Aaron - [email protected]]
19 -> [Gandalf - [email protected]]
29 -> [John - [email protected]]
32 -> [Mindy - [email protected]]
33 -> [Paul - [email protected]]

If at this point we do the following:

hash.remove('Jonathan')
Now index 5 is assigned to undefined

console.log(hash.get('Jamie'))

we will get undefined because of line 44 which doesn't continue searching because the original table[position] returns undefined.

So it seems like any later entries that we created from a collision cannot be retrieved after the original key is removed.

Naming in single rotations in AVL tree representation

I think the naming of the functions

var rotationLL = function(node) {
    var tmp = node.left;
    node.left = tmp.right;
    tmp.right = node;

    return tmp;
};

var rotationRR = function(node) {
    var tmp = node.right;
    node.right = tmp.left;
    tmp.left = node;

    return tmp;
};

is wrong. By my understanding of AVL rotations, the names of the functions actually need to be swapped. So the function rotationLL will be rotationRR and vice versa. If this is confirmed I don't mind making a PR.

Typo in 2nd edition, Chapter 8 page 191

The diagram of the single rotation to the right:

screen shot 2016-08-30 at 11 20 32 am

the unbalanced tree has 60 on the left. Which is wrong because all values larger than 50 go on the right. You seem to have noticed because the balanced tree has 40 instead of 60. So just need to fix the unbalanced tree and change 60 to 40.

Question about your merge sort!

Hello and congrats on your upcoming book! I look forward to it, and am delighted to see that you are a a woman :)

I am just working with merge sort algos for the first time, and see you've got a slightly different thing going on here - the

result.push(left[il++]);

instead of using result.push(left.shift()) - which seems to be what I've seen elsewhere. Does eliminating the shift() help performance?

thanks for all your samples and best of luck w/ the book launch.

Obrigada desde Alaska
Stacey

chapter 12 topological sort

there is a for loop with a count variable that is incremented, but not referenced in the following code. if you have the time, would you mind leaving comments on the code explaining the process. the book didn't go into it very deeply. thank you.

Capítulo 7 - Método remove (sondagem linear)

Na página 171, da primeira edição, pede para substituir as duas linhas pelo código table[index] = undefined quando na primeira ocorrência poderia ser table[position] = undefined

Pode ter havido algum equívoco na hora de digitar ou o trecho no livro também é válido?

An in-range update of nyc is breaking the build 🚨

Version 11.7.1 of nyc was just published.

Branch Build failing 🚨
Dependency nyc
Current Version 11.7.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

nyc is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build passed Details
  • bitHound - Dependencies No failing dependencies. Details
  • bitHound - Code No failing files. Details
  • codecov/patch Coverage not affected when comparing 6e9eb98...47c4c7a Details
  • codecov/project 61.73% (-3.62%) compared to 6e9eb98 Details

Commits

The new version differs by 2 commits.

  • 5e40c7c chore(release): 11.7.1
  • 5c0adb5 chore: explicit upgrade of istanbul-reports (#816)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint-plugin-import is breaking the build 🚨

The devDependency eslint-plugin-import was updated from 2.16.0 to 2.17.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-import is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 61 commits.

  • 0499050 bump to v2.17.0
  • f479635 [webpack] v0.11.1
  • 8a4226d Merge pull request #1320 from bradzacher/export-ts-namespaces
  • 988e12b fix(export): Support typescript namespaces
  • 70c3679 [docs] make rule names consistent
  • 6ab25ea [Tests] skip a TS test in eslint < 4
  • 405900e [Tests] fix tests from #1319
  • 2098797 [fix] export: false positives for typescript type + value export
  • 70a59fe [fix] Fix overwriting of dynamic import() CallExpression
  • e4850df [ExportMap] fix condition for checking if block comment
  • 918567d [fix] namespace: add check for null ExportMap
  • 2d21c4c Merge pull request #1297 from echenley/ech/fix-isBuiltIn-local-aliases
  • 0ff1c83 [dev deps] lock typescript to ~, since it doesn’t follow semver
  • 40bf40a [*] [deps] update resolve
  • 28dd614 Merge pull request #1304 from bradennapier/feature/typescript-export-type

There are 61 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of webpack is breaking the build 🚨

The devDependency webpack was updated from 4.35.3 to 4.36.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

webpack is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v4.36.0

Features

  • SourceMapDevToolPlugin append option now supports the default placeholders in addition to [url]
  • Arrays in resolve and parser options (Rule and Loader API) support backreferences with "..." when overriding options.
Commits

The new version differs by 42 commits.

  • 95d21bb 4.36.0
  • aa1216c Merge pull request #9422 from webpack/feature/dot-dot-dot-merge
  • b3ec775 improve merging of resolve and parsing options
  • 53a5ae2 Merge pull request #9419 from vankop/remove-valid-jsdoc-rule
  • ab75240 Merge pull request #9413 from webpack/dependabot/npm_and_yarn/ajv-6.10.2
  • 0bdabf4 Merge pull request #9418 from webpack/dependabot/npm_and_yarn/eslint-plugin-jsdoc-15.5.2
  • f207cdc remove valid jsdoc rule in favour of eslint-plugin-jsdoc
  • 31333a6 chore(deps-dev): bump eslint-plugin-jsdoc from 15.3.9 to 15.5.2
  • 036adf0 Merge pull request #9417 from webpack/dependabot/npm_and_yarn/eslint-plugin-jest-22.8.0
  • 37d4480 Merge pull request #9411 from webpack/dependabot/npm_and_yarn/simple-git-1.121.0
  • ce2a183 chore(deps-dev): bump eslint-plugin-jest from 22.7.2 to 22.8.0
  • 0beeb7e Merge pull request #9391 from vankop/create-hash-typescript
  • bf1a24a #9391 resolve super call discussion
  • bd7d95b #9391 resolve discussions, AbstractMethodError
  • 4190638 chore(deps): bump ajv from 6.10.1 to 6.10.2

There are 42 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.