Skip to content

Commit 8d1fae0

Browse files
committed
Updating project
1 parent 8b5eb13 commit 8d1fae0

29 files changed

+3675
-3623
lines changed

.babelrc

-11
This file was deleted.

.github/workflows/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88

99
jobs:
1010
test:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
node-version: [ 16.x, 18.x ]
14+
node-version: [16.x, 18.x]
1515

1616
steps:
1717
- name: Checkout repository
@@ -29,4 +29,4 @@ jobs:
2929
run: npm t
3030

3131
- name: Upload coverage to Codecov
32-
uses: codecov/codecov-action@v3
32+
uses: codecov/codecov-action@v3

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ yarn-debug.log*
1010
yarn-error.log*
1111
lerna-debug.log*
1212
.pnpm-debug.log*
13+
.venv
1314

1415
# Diagnostic reports (https://nodejs.org/api/report.html)
1516
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

.mocharc.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require:
2+
- "@babel/register"

.nycrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "@istanbuljs/nyc-config-babel"
3+
}

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore artifacts:
2+
build
3+
coverage
4+
.venv

.prettierrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

.vscode/launch.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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": "node",
9+
"request": "launch",
10+
"name": "Launch Program",
11+
"skipFiles": ["<node_internals>/**"],
12+
"program": "${workspaceFolder}/index.js"
13+
}
14+
]
15+
}

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,56 @@
11
# Data Structures and Algorithms
2+
23
[![codecov](https://codecov.io/gh/mesirendon/datastructures-and-algorithms-js/branch/main/graph/badge.svg?token=G7ACV97AFD)](https://codecov.io/gh/mesirendon/datastructures-and-algorithms-js)
34
[![CI](https://github.com/mesirendon/datastructures-and-algorithms-js/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/mesirendon/datastructures-and-algorithms-js/actions/workflows/ci.yml)
45

56
This repository written in JavaScript is a compilation of the most-known data structures and algorithms.
67

78
## Why JavaScript?
9+
810
It's usual to see data structures and algorithms taught in Java. However, getting a Java development environment might be troublesome, whereas JavaScript can be run with no more than a few steps.
911

1012
JavaScript is also a flexible language that allows performing actions that could save time and helps explain a concept. If you want to transpile this knowledge to any other language, it might be easier for you after understanding what's presented here.
1113

1214
## The Book
15+
1316
Read all the content of [**Data Structures and Algorithms** here](content.md)
1417

1518
## Using this repository
1619

1720
### Prerequisites
21+
1822
You will need to have node installed. I recommend using the [nvm installer script](https://github.com/nvm-sh/nvm#install--update-script), and following their [instructions](https://github.com/nvm-sh/nvm#usage). I recommend using an LTS version.
1923

2024
### Clone
25+
2126
```bash
2227
git clone [email protected]:mesirendon/datastructures-and-algorithms-js.git
2328
```
2429

2530
### Install dependencies
31+
2632
```bash
2733
npm ci
2834
```
2935

3036
### Run tests
3137

3238
#### All Tests
39+
3340
Running all tests will show a coverage report.
41+
3442
```bash
3543
npm test
3644
```
3745

3846
#### Specific
47+
3948
```bash
4049
npm run test:case src/singly-linked-lists/__test__/linked-lists.spec.js
4150
```
4251

4352
### Start the app
53+
4454
You can use the provided index.js as a playground by running in a console the following command.
4555

4656
```bash
@@ -50,7 +60,9 @@ npm start
5060
When you modify the [index.js](index.js) file and save it, the service will be reloaded.
5161

5262
## Disclaimer ⚠️
63+
5364
This repository is meant to be used as an educational and research tool. Therefore, you should think twice before copying and pasting the code seen here in your production developments. Also, remember this code is licensed under [MIT License](LICENSE), thus limiting any warranty or liability for its use.
5465

5566
## Acknowledgement
56-
[Trekhleb](https://github.com/trekhleb)'s [JavaScript Algorithms](https://github.com/trekhleb/javascript-algorithms) repository heavily inspires this repository.
67+
68+
[Trekhleb](https://github.com/trekhleb)'s [JavaScript Algorithms](https://github.com/trekhleb/javascript-algorithms) repository heavily inspires this repository.

babel.config.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"presets": ["@babel/preset-env"],
3+
"plugins": [
4+
"@babel/plugin-syntax-dynamic-import",
5+
"@babel/plugin-syntax-import-meta",
6+
"@babel/plugin-proposal-class-properties",
7+
"@babel/plugin-proposal-json-strings",
8+
"istanbul"
9+
],
10+
"env": {
11+
"test": {
12+
"plugins": [
13+
"istanbul"
14+
]
15+
}
16+
}
17+
}

content.md

+21-17
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
[Back to README](README.md)
2+
23
# Content
3-
* [Algorithmic Complexity](src/algorithmic-complexity/Algorithmic%20Complexity.ipynb)
4-
* [Data Structures](src/data-structures/README.md)
5-
* [Singly Linked List](src/data-structures/singly-linked-lists/Linked%20Lists.ipynb)
6-
* Implementation
7-
* [Singly Linked List Node](src/data-structures/singly-linked-lists/LinkedListNode.js)
8-
* [Singly Linked List Wrapper](src/data-structures/singly-linked-lists/LinkedList.js)
9-
* Tests
10-
* [Singly Linked List Node and Wrapper](src/data-structures/singly-linked-lists/__test__/linked-lists.spec.js)
11-
* [List of Exercises](src/data-structures/singly-linked-lists/exercises/README.md)
124

13-
* [Doubly Linked List](src/data-structures/doubly-linked-lists/Doubly%20Linked%20Lists.ipynb)
14-
* Implementation
15-
* [Doubly Linked List Node](src/data-structures/doubly-linked-lists/DoublyLinkedListNode.js)
16-
* [Doubly Linked List Wrapper](src/data-structures/doubly-linked-lists/DoublyLinkedList.js)
17-
* Tests
18-
* [Doubly Linked List Node](src/data-structures/doubly-linked-lists/__test__/doubly-linked-list-node.spec.js)
19-
* [Doubly Linked List Wrapper](src/data-structures/doubly-linked-lists/__test__/doubly-linked-list.spec.js)
20-
* **TODO:** List of exercises`]
5+
- [Algorithmic Complexity](src/algorithmic-complexity/Algorithmic%20Complexity.ipynb)
6+
- [Data Structures](src/data-structures/README.md)
7+
8+
- [Singly Linked List](src/data-structures/singly-linked-lists/Linked%20Lists.ipynb)
9+
10+
- Implementation
11+
- [Singly Linked List Node](src/data-structures/singly-linked-lists/LinkedListNode.js)
12+
- [Singly Linked List Wrapper](src/data-structures/singly-linked-lists/LinkedList.js)
13+
- Tests
14+
- [Singly Linked List Node and Wrapper](src/data-structures/singly-linked-lists/__test__/linked-lists.spec.js)
15+
- [List of Exercises](src/data-structures/singly-linked-lists/exercises/README.md)
16+
17+
- [Doubly Linked List](src/data-structures/doubly-linked-lists/Doubly%20Linked%20Lists.ipynb)
18+
- Implementation
19+
- [Doubly Linked List Node](src/data-structures/doubly-linked-lists/DoublyLinkedListNode.js)
20+
- [Doubly Linked List Wrapper](src/data-structures/doubly-linked-lists/DoublyLinkedList.js)
21+
- Tests
22+
- [Doubly Linked List Node](src/data-structures/doubly-linked-lists/__test__/doubly-linked-list-node.spec.js)
23+
- [Doubly Linked List Wrapper](src/data-structures/doubly-linked-lists/__test__/doubly-linked-list.spec.js)
24+
- **TODO:** List of exercises`]

index.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ import DoublyLinkedList from "./src/data-structures/doubly-linked-lists/DoublyLi
33
const ll = new DoublyLinkedList();
44

55
const array = [
6-
{value: 1, key: 'test1'},
7-
{value: 2, key: 'test2'},
8-
{value: 3, key: 'test3'},
9-
{value: 4, key: 'test4'},
10-
{value: 5, key: 'test5'},
11-
{value: 6, key: 'test6'},
6+
{ value: 1, key: "test1" },
7+
{ value: 2, key: "test2" },
8+
{ value: 3, key: "test3" },
9+
{ value: 4, key: "test4" },
10+
{ value: 5, key: "test5" },
11+
{ value: 6, key: "test6" },
1212
];
1313

1414
ll.fromArray(array);
1515

16-
const stringifier = ({key, value}) => `\nKey: ${key} | Value: ${value}\n`;
16+
const stringifier = ({ key, value }) => `\nKey: ${key} | Value: ${value}\n`;
1717

1818
console.log(ll.toString(stringifier));
1919

2020
const finder = (val) => val.value === 4;
2121

22-
let node = ll.find(finder)
22+
let node = ll.find(finder);
2323

24-
console.log(node);
24+
console.log(node);

0 commit comments

Comments
 (0)