Skip to content

Eslint fixes #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/runtimes/**
src/data-structures/maps/hash-maps/hashing.js
src/data-structures/maps/hash-maps/*-test.js
src/data-structures/maps/hash-maps/hash-map-*.js
src/data-structures/linked-lists/linked-list-*.js
src/data-structures/custom/lru-cache-*.js
18 changes: 9 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
module.exports = {
"extends": "airbnb-base",
"env": {
"jest": true
extends: 'airbnb-base',
env: {
jest: true
},
globals: {
BigInt: true,
},
rules: {
// https://github.com/airbnb/javascript/issues/1089

// https://stackoverflow.com/a/35637900/684957
// allow to add properties to arguments
"no-param-reassign": [2, { "props": false }],
'no-param-reassign': [2, { 'props': false }],

// https://eslint.org/docs/rules/no-plusplus
// allows unary operators ++ and -- in the afterthought (final expression) of a for loop.
"no-plusplus": [2, { "allowForLoopAfterthoughts": true }],
'no-plusplus': [2, { 'allowForLoopAfterthoughts': true }],

// Allow for..of
"no-restricted-syntax": [0, "ForOfStatement"],
},
globals: {
BigInt: true,
'no-restricted-syntax': [0, 'ForOfStatement'],
}
};
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: node_js
script: npm run ci
node_js:
- "node"
- "lts/*"
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"workbench.colorCustomizations": {
"titleBar.activeBackground": "#f9e64f",
"titleBar.inactiveBackground": "#f9e64f99",
"titleBar.activeForeground": "#15202b",
"titleBar.inactiveForeground": "#15202b99"
}
}
25 changes: 19 additions & 6 deletions src/changelog.md → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,51 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Fix picture on https://www.npmjs.com/package/dsa.js
### Added
- CI: travis
### Removed
-

### Breaking changes

### New Features
- Added Eslint and Travis ci

### Patches
- Readme improvements
- Badges for npm versions and build status

## [1.1.0] - 2019-03-29

### Added

- README.md added because NPM packages doesn't read README.adoc
- Public API to use the package `dsa.js`
- This changelog

### Changed

- Updated dependencies (removed lodash since is not needed)

### Removed

-

## [1.0.0] - 2019-03-29

### Added

- Started the project
- Book released
- npm package published

### Changed

-

### Removed

-


Expand Down
95 changes: 57 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
# Data Structures and Algorithms in JavaScript

[![Build Status](https://travis-ci.com/amejiarosario/dsa.js.svg?branch=master)](https://travis-ci.com/amejiarosario/dsa.js)
[![npm version](https://badge.fury.io/js/dsa.js.svg)](https://badge.fury.io/js/dsa.js)

This repository covers the implementation of the classical algorithms and data structures in JavaScript.

<!-- This goes along with [these posts series](https://adrianmejia.com/tags/tutorial-algorithms/) that explain each implementation in details and also this [book](https://gum.co/dsajs) that explain these topics and some with more examples and illustrations. -->
## Usage

You can clone the repo or install the code from NPM:

```sh
npm install dsa.js
```

and then you can import it into your programs or CLI

```js
const { LinkedList, Queue, Stack } = require('dsa.js');
```

For a full list of all the exposed data structures and algorithms [see](https://github.com/amejiarosario/dsa.js/blob/master/src/index.js).

## Book

You can check out the book that goes deeper into each topic and provide addtional illustrations and explanations.
You can check out the book that goes deeper into each topic and provide additional illustrations and explanations.

- Algorithmic toolbox to avoid getting stuck while coding.
- Explains data structures similarities and differences.
Expand All @@ -21,65 +38,67 @@ We are covering the following data structures.
[![Interactive Data Structures](https://user-images.githubusercontent.com/418605/46118890-ba721180-c1d6-11e8-82bc-6a671428b422.png)](https://embed.kumu.io/85f1a4de5fb8430a10a1bf9c5118e015)

### Linear Data Structures
1. **Arrays**: Built-in in most languages so not implemented here.

1. **Arrays**: Built-in in most languages so not implemented here.
[Post](https://adrianmejia.com/blog/2018/04/28/data-structures-time-complexity-for-beginners-arrays-hashmaps-linked-lists-stacks-queues-tutorial/#Array).

2. **Linked Lists**: each data node has a link to the next (and
2. **Linked Lists**: each data node has a link to the next (and
previous).
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/data-structures/linked-lists/linked-list.js)
|
[Post](https://adrianmejia.com/blog/2018/04/28/data-structures-time-complexity-for-beginners-arrays-hashmaps-linked-lists-stacks-queues-tutorial/#Linked-Lists).

3. **Queue**: data flows in a "first-in, first-out" (FIFO) manner.
3. **Queue**: data flows in a "first-in, first-out" (FIFO) manner.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/data-structures/queues/queue.js)
|
[Post](https://adrianmejia.com/blog/2018/04/28/data-structures-time-complexity-for-beginners-arrays-hashmaps-linked-lists-stacks-queues-tutorial/#Queues)

4. **Stacks**: data flows in a "last-in, first-out" (LIFO) manner.
4. **Stacks**: data flows in a "last-in, first-out" (LIFO) manner.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/data-structures/stacks/stack.js)
|
[Post](https://adrianmejia.com/blog/2018/04/28/data-structures-time-complexity-for-beginners-arrays-hashmaps-linked-lists-stacks-queues-tutorial/#Stacks).

### Non-Linear Data Structures
1. **Trees**: data nodes has zero or more adjacent nodes a.k.a.

1. **Trees**: data nodes has zero or more adjacent nodes a.k.a.
children. Each node can only have one parent node otherwise is a
graph not a tree.
[Code](https://github.com/amejiarosario/algorithms.js/tree/master/src/data-structures/trees)
|
[Post](https://adrianmejia.com/blog/2018/06/11/data-structures-for-beginners-trees-binary-search-tree-tutorial/)

1. **Binary Trees**: same as tree but only can have two children at
1. **Binary Trees**: same as tree but only can have two children at
most.
[Code](https://github.com/amejiarosario/algorithms.js/tree/master/src/data-structures/trees)
|
[Post](https://adrianmejia.com/blog/2018/06/11/data-structures-for-beginners-trees-binary-search-tree-tutorial/#Binary-Trees)

2. **Binary Search Trees** (BST): same as binary tree, but the
2. **Binary Search Trees** (BST): same as binary tree, but the
nodes value keep this order `left < parent < rigth`.
[Code](https://github.com/amejiarosario/algorithms.js/blob/master/src/data-structures/trees/binary-search-tree.js)
|
[Post](https://adrianmejia.com/blog/2018/06/11/data-structures-for-beginners-trees-binary-search-tree-tutorial/#Binary-Search-Tree-BST)

3. **AVL Trees**: Self-balanced BST to maximize look up time.
3. **AVL Trees**: Self-balanced BST to maximize look up time.
[Code](https://github.com/amejiarosario/algorithms.js/blob/master/src/data-structures/trees/avl-tree.js)
|
[Post](https://adrianmejia.com/blog/2018/07/16/self-balanced-binary-search-trees-with-avl-tree-data-structure-for-beginners/)

4. **Red-Black Trees**: Self-balanced BST more loose than AVL to
4. **Red-Black Trees**: Self-balanced BST more loose than AVL to
maximize insertion speed.
[Code](https://github.com/amejiarosario/algorithms.js/blob/master/src/data-structures/trees/red-black-tree.js)

2. **Maps**: key-value store.
2. **Maps**: key-value store.

1. **Hash Maps**: implements map using a hash function.
1. **Hash Maps**: implements map using a hash function.
[Code](https://github.com/amejiarosario/algorithms.js/blob/master/src/data-structures/hash-maps/hashmap.js)
|
[Post](https://adrianmejia.com/blog/2018/04/28/data-structures-time-complexity-for-beginners-arrays-hashmaps-linked-lists-stacks-queues-tutorial/#HashMaps)

2. **Tree Maps**: implement map using a self-balanced BST.
2. **Tree Maps**: implement map using a self-balanced BST.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/data-structures/maps/tree-maps/tree-map.js)

3. **Graphs**: data **nodes** that can have a connection or **edge** to
3. **Graphs**: data **nodes** that can have a connection or **edge** to
zero or more adjacent nodes. Unlike trees, nodes can have multiple
parents, loops.
[Code](https://github.com/amejiarosario/algorithms.js/blob/master/src/data-structures/graphs/graph.js)
Expand All @@ -88,39 +107,39 @@ We are covering the following data structures.

## Algorithms

- Sorting algorithms
- Sorting algorithms

- Bubble Sort.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/sorting/bubble-sort.js)
- Bubble Sort.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/sorting/bubble-sort.js)

- Insertion Sort.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/sorting/insertion-sort.js)
- Insertion Sort.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/sorting/insertion-sort.js)

- Selection Sort.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/sorting/selection-sort.js)
- Selection Sort.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/sorting/selection-sort.js)

- Merge Sort.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/sorting/merge-sort.js)
- Merge Sort.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/sorting/merge-sort.js)

- Quicksort.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/sorting/quick-sort.js)
- Quick sort.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/sorting/quick-sort.js)

- Greedy Algorithms
- Greedy Algorithms

- Fractional Knapsack Problem.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/knapsack-fractional.js)
- Fractional Knapsack Problem.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/knapsack-fractional.js)

- Divide and Conquer
- Divide and Conquer

- Fibonacci Numbers.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/fibonacci-recursive.js)
- Fibonacci Numbers.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/fibonacci-recursive.js)

- Dynamic Programming
- Dynamic Programming

- Fibonacci with memoization.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/fibanacci-dynamic-programming.js)
- Fibonacci with memoization.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/fibanacci-dynamic-programming.js)

- Backtracking algorithms
- Backtracking algorithms

- Word permutations.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/permutations-backtracking.js)
- Word permutations.
[Code](https://github.com/amejiarosario/dsa.js/blob/master/src/algorithms/permutations-backtracking.js)
3 changes: 3 additions & 0 deletions README.adoc → deprecated-README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
:toclevels: 2
Adrian Mejia <https://github.com/amejiarosario[@amejiarosario]>

image:https://travis-ci.com/amejiarosario/dsa.js.svg?branch=master["Build Status", link="https://travis-ci.com/amejiarosario/dsa.js"]
image:https://badge.fury.io/js/dsa.js.svg["npm version", link="https://badge.fury.io/js/dsa.js"]

This repository covers the implementation of the classical algorithms and data structures in JavaScript.

toc::[]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading