Skip to content

Commit f032f19

Browse files
authored
Merge pull request loiane#40 from loiane/third-edition
Third edition
2 parents 208b757 + d4c49da commit f032f19

File tree

503 files changed

+20605
-5331
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

503 files changed

+20605
-5331
lines changed

.babelrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"presets": ["env"],
3+
"plugins": [
4+
"add-module-exports",
5+
"transform-es2015-modules-umd"
6+
]
7+
}

.bithoundrc

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"ignore": [
3+
"**/.vscode/**",
4+
"**/node_modules/**",
5+
"**/dist/**",
6+
"**/examples/**"
7+
],
8+
"test": [
9+
"**/test/**"
10+
],
11+
"critics": {
12+
"lint": {
13+
"engine": "eslint"
14+
},
15+
"wc": {
16+
"limit": 1000
17+
}
18+
}
19+
}

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = LF
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.eslintrc.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"commonjs": true,
5+
"es6": true,
6+
"node": true
7+
},
8+
"globals": {
9+
"expect": true,
10+
"it": true,
11+
"describe": true,
12+
"beforeEach": true,
13+
"afterEach": true,
14+
"document": false,
15+
"navigator": false,
16+
"window": false
17+
},
18+
"parser": "babel-eslint",
19+
"extends": "airbnb-base",
20+
"rules": {
21+
"class-methods-use-this": 0,
22+
"no-plusplus": 0,
23+
"arrow-parens": 0,
24+
"no-console": 0,
25+
"import/prefer-default-export": 0,
26+
"comma-dangle": 0,
27+
"no-underscore-dangle": 0,
28+
"no-param-reassign": 0,
29+
"no-return-assign": 0,
30+
"no-restricted-globals": 0,
31+
"no-multi-assign": 0,
32+
"prefer-destructuring": ["error", {"object": true, "array": false}]
33+
}
34+
}

.firebaserc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"projects": {
3+
"default": "javascript-ds-algorithms-book"
4+
}
5+
}

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@
22
*.log
33
node_modules
44
coverage
5+
.nyc_output
6+
coverage.lcov
7+
mochawesome-report/*
8+
dist/js/*
9+
dist/ts/*
10+
snippet.js

.travis.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
language: node_js
2+
node_js:
3+
- node
4+
before_script:
5+
- npm install -g --silent firebase-tools
6+
install:
7+
- npm install
8+
script:
9+
- npm run go
10+
after_success:
11+
- npm run coverage
12+
- test $TRAVIS_BRANCH = "third-edition" && firebase deploy --token $FIREBASE_TOKEN --non-interactive
13+
notifications:
14+
email:
15+
on_failure: change
16+
on_success: change

.vscode/launch.json

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "chrome",
9+
"request": "launch",
10+
"name": "Chrome",
11+
"url": "http://127.0.0.1:8887/examples",
12+
"webRoot": "${workspaceRoot}"
13+
},
14+
{
15+
"type": "node",
16+
"request": "launch",
17+
"name": "Mocha JS",
18+
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
19+
"args": [
20+
"-u",
21+
"tdd",
22+
"--timeout",
23+
"999999",
24+
"--compilers",
25+
"js:babel-core/register",
26+
"--colors",
27+
"${workspaceRoot}/test/js/**/*.spec.js"
28+
],
29+
"internalConsoleOptions": "openOnSessionStart"
30+
},
31+
{
32+
"type": "node",
33+
"request": "launch",
34+
"name": "Mocha TS",
35+
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
36+
"args": [
37+
"-u",
38+
"tdd",
39+
"--timeout",
40+
"999999",
41+
"-r",
42+
"ts-node/register",
43+
"--colors",
44+
"${workspaceRoot}/test/ts/**/**/*.spec.ts"
45+
],
46+
"protocol": "auto",
47+
"internalConsoleOptions": "openOnSessionStart"
48+
}
49+
]
50+
}

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib"
3+
}

.vscode/tasks.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"type": "npm",
8+
"script": "go",
9+
"group": {
10+
"kind": "build",
11+
"isDefault": true
12+
}
13+
},
14+
{
15+
"type": "npm",
16+
"script": "dev",
17+
"group": {
18+
"kind": "test",
19+
"isDefault": true
20+
}
21+
}
22+
]
23+
}

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Change Log
2+
All notable changes to the "javascript-datastructures-algorithms" third edition source code bundle will be documented in this file.
3+
4+
Based on [Keep a Changelog](http://keepachangelog.com/).
5+
6+
## [Unreleased]
7+
- Initial release

README.md

+83-23
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,87 @@
11
Learning JavaScript Data Structures and Algorithms
22
====================================
33

4-
Source code of **Learning JavaScript Data Structures and Algorithms** book.
4+
[![Build Status](https://travis-ci.org/loiane/javascript-datastructures-algorithms.svg?branch=third-edition)](https://travis-ci.org/loiane/javascript-datastructures-algorithms)
5+
[![codecov](https://codecov.io/gh/loiane/javascript-datastructures-algorithms/branch/third-edition/graph/badge.svg)](https://codecov.io/gh/loiane/javascript-datastructures-algorithms)
56

6-
| 1st edition | 2nd edition |
7-
| ------------- |:-------------:|
8-
| ![1st edition](https://d1ldz4te4covpm.cloudfront.net/sites/default/files/imagecache/ppv4_main_book_cover/4874OS_Learning%20JavaScript%20Data%20Structures%20and%20Algorithms.jpg) | ![2nd edition](https://d255esdrn735hr.cloudfront.net/sites/default/files/imagecache/ppv4_main_book_cover/5493OS_5348_Learning%20JavaScript%20Data%20Structures%20and%20Algorithms,%20Second%20Edition.jpg) |
9-
| [Book link](http://amzn.to/1Y1OWPx)| [Book link](http://amzn.to/1TSkcA1)|
7+
Source code of **Learning JavaScript Data Structures and Algorithms** book, third edition.
8+
9+
Work in Progress.
10+
11+
## List of available chapters:
12+
13+
* 01: [JavaScript, ECMAScript and TypeScript: a quick overview](https://github.com/loiane/javascript-datastructures-algorithms/tree/third-edition/examples/chapter01)
14+
* 02: [Arrays](https://github.com/loiane/javascript-datastructures-algorithms/tree/third-edition/examples/chapter02)
15+
* 03: [Stacks](https://github.com/loiane/javascript-datastructures-algorithms/tree/third-edition/examples/chapter03)
16+
* 04: [Queues and Deques](https://github.com/loiane/javascript-datastructures-algorithms/tree/third-edition/examples/chapter04)
17+
* 05: [LinkedLists](https://github.com/loiane/javascript-datastructures-algorithms/tree/third-edition/examples/chapter05)
18+
* 06: [Sets](https://github.com/loiane/javascript-datastructures-algorithms/tree/third-edition/examples/chapter06)
19+
* 07: [Dictionaries and Hashes](https://github.com/loiane/javascript-datastructures-algorithms/tree/third-edition/examples/chapter07)
20+
* 08: [Recursion](https://github.com/loiane/javascript-datastructures-algorithms/tree/third-edition/examples/chapter08)
21+
* 09: [Trees](https://github.com/loiane/javascript-datastructures-algorithms/tree/third-edition/examples/chapter09)
22+
* 10: [Heap](https://github.com/loiane/javascript-datastructures-algorithms/tree/third-edition/examples/chapter10)
23+
* 11: [Graphs](https://github.com/loiane/javascript-datastructures-algorithms/tree/third-edition/examples/chapter11)
24+
* 12: [Sorting and Searching Algorithms](https://github.com/loiane/javascript-datastructures-algorithms/tree/third-edition/examples/chapter12)
25+
* 13: [String and Math Algorithms](https://github.com/loiane/javascript-datastructures-algorithms/tree/third-edition/examples/chapter13)
26+
* 14: [Algorithm Design and Techniques](https://github.com/loiane/javascript-datastructures-algorithms/tree/third-edition/examples/chapter14)
27+
* 15: [Algorithm Complexity](https://github.com/loiane/javascript-datastructures-algorithms/tree/third-edition/examples/chapter15)
28+
29+
### Third Edition Updates
30+
31+
* Algorithms using ES2015+ (ES6+)
32+
* New data structures and algorithms
33+
* All chapters rewritten and reviewed
34+
* Three (3) new chapters
35+
* Creation of a Data Structures and Algorithms library that can be used in the browser or with Node.js
36+
* Algorithms tested with Mocha + Chai (test code available in `test` directory)
37+
* **TypeScript** version of the source code included (library and tests)
38+
39+
## Project Structure
40+
41+
`src/js/index.js` file contains all the data structures and algorithms listed by chapter.
42+
43+
```
44+
|_examples (how to use each data structure and algorithm, organized by chapter)
45+
|_src
46+
|___js (source code: JavaScript version)
47+
|_____data-structures
48+
|_______models (classes used by DS: Node, ValuePair, ...)
49+
|_____others (other algorithms such as palindome checker, hanoi tower)
50+
|___ts (source code: TypeScript version)
51+
|_____data-structures
52+
|_______models
53+
|_____others
54+
|_test (unit tests with Mocha and Chai for src)
55+
|___js (tests for JavaScript code)
56+
|___ts (tests for TypeScript code)
57+
```
58+
59+
## Installing and running the book examples With Node
60+
61+
* Install [Node](https://nodejs.org)
62+
* Open terminal/cmd and change directoty to this project folder: `cd /Users/.../javascript-datastructures-algorithms` (Linux/Max) or `cd C:/.../javascript-datastructures-algorithms`
63+
* run `npm install` to install all depencies
64+
* To see the examples, run `http-server html` or `npm run serve`. Open your browser `http:\\localhost:8080` to see the book examples
65+
* Or `cd html/chapter01` and run each javascript file with node: `node 02-Variables`
66+
67+
## Running the examples in the browser
68+
69+
* Right click on the html file you would like to see the examples, right click and 'Open with Chrome (or any other browser)'
70+
71+
* Or open the `examples/index.html` file to easily nagivate through all examples:
72+
73+
* Demo: [https://javascript-ds-algorithms-book.firebaseapp.com](https://javascript-ds-algorithms-book.firebaseapp.com)
74+
75+
<img src="examples/examples-screenshot.png">
76+
77+
Happy Coding!
78+
79+
## Other editions
80+
81+
| 1st edition | 2nd edition | 3rd edition |
82+
| ------------- |:-------------:|:-------------:|
83+
| ![1st edition](https://d1ldz4te4covpm.cloudfront.net/sites/default/files/imagecache/ppv4_main_book_cover/4874OS_Learning%20JavaScript%20Data%20Structures%20and%20Algorithms.jpg) | ![2nd edition](https://d255esdrn735hr.cloudfront.net/sites/default/files/imagecache/ppv4_main_book_cover/5493OS_5348_Learning%20JavaScript%20Data%20Structures%20and%20Algorithms,%20Second%20Edition.jpg) | ![2nd edition](https://d1ldz4te4covpm.cloudfront.net/sites/default/files/imagecache/ppv4_main_book_cover/B09377_MockupCover_0.png) |
84+
| [Book link](http://amzn.to/1Y1OWPx)| [Book link](http://amzn.to/1TSkcA1)| [Book link](http://a.co/cbMlYmJ)|
1085

1186
Book link - first edition:
1287
- [Packt](https://www.packtpub.com/application-development/learning-javascript-data-structures-and-algorithms)
@@ -19,24 +94,9 @@ Book link - second edition:
1994
- [Amazon](http://amzn.to/1TSkcA1)
2095
- [Brazilian Portuguese version](https://novatec.com.br/livros/estruturas-de-dados-algoritmos-em-javascript/)
2196

22-
### List of Chapters:
23-
24-
* 01: [JavaScript: a quick overview](https://github.com/loiane/javascript-datastructures-algorithms/tree/second-edition/chapter01)
25-
* 02: [Arrays](https://github.com/loiane/javascript-datastructures-algorithms/tree/second-edition/chapter02)
26-
* 03: [Stacks](https://github.com/loiane/javascript-datastructures-algorithms/tree/second-edition/chapter03)
27-
* 04: [Queues](https://github.com/loiane/javascript-datastructures-algorithms/tree/second-edition/chapter04)
28-
* 05: [Linked Lists](https://github.com/loiane/javascript-datastructures-algorithms/tree/second-edition/chapter05)
29-
* 06: [Sets](https://github.com/loiane/javascript-datastructures-algorithms/tree/second-edition/chapter06)
30-
* 07: [Dictionaries and Hashes](https://github.com/loiane/javascript-datastructures-algorithms/tree/second-edition/chapter07)
31-
* 08: [Trees](https://github.com/loiane/javascript-datastructures-algorithms/tree/second-edition/chapter08)
32-
* 09: [Graphs](https://github.com/loiane/javascript-datastructures-algorithms/tree/second-edition/chapter09)
33-
* 10: [Sorting and searching algorithms](https://github.com/loiane/javascript-datastructures-algorithms/tree/second-edition/chapter10)
34-
* 11: [Pattern of algorithms](https://github.com/loiane/javascript-datastructures-algorithms/tree/second-edition/chapter11)
35-
* 12: [Algorithm Complexity](https://github.com/loiane/javascript-datastructures-algorithms/tree/second-edition/chapter12)
36-
37-
### First Edition source code:
38-
39-
Please refer to [this link](https://github.com/loiane/javascript-datastructures-algorithms/tree/master)
97+
Book link - third edition:
98+
- [Packt](https://www.packtpub.com/web-development/learning-javascript-data-structures-and-algorithms-third-edition)
99+
- [Amazon](http://a.co/cbMlYmJ)
40100

41101
### Found an issue or have a question?
42102

chapter01/02-Variables.js

-37
This file was deleted.

0 commit comments

Comments
 (0)