Skip to content

Commit

Permalink
Updating project
Browse files Browse the repository at this point in the history
  • Loading branch information
mesirendon committed Jul 27, 2024
1 parent 8b5eb13 commit 8d1fae0
Show file tree
Hide file tree
Showing 29 changed files with 3,675 additions and 3,623 deletions.
11 changes: 0 additions & 11 deletions .babelrc

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ name: CI

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 16.x, 18.x ]
node-version: [16.x, 18.x]

steps:
- name: Checkout repository
Expand All @@ -29,4 +29,4 @@ jobs:
run: npm t

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v3
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
.venv

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
Expand Down
2 changes: 2 additions & 0 deletions .mocharc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require:
- "@babel/register"
3 changes: 3 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@istanbuljs/nyc-config-babel"
}
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore artifacts:
build
coverage
.venv
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/index.js"
}
]
}
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,56 @@
# Data Structures and Algorithms

[![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)
[![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)

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

## Why JavaScript?

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.

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.

## The Book

Read all the content of [**Data Structures and Algorithms** here](content.md)

## Using this repository

### Prerequisites

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.

### Clone

```bash
git clone git@github.com:mesirendon/datastructures-and-algorithms-js.git
```

### Install dependencies

```bash
npm ci
```

### Run tests

#### All Tests

Running all tests will show a coverage report.

```bash
npm test
```

#### Specific

```bash
npm run test:case src/singly-linked-lists/__test__/linked-lists.spec.js
```

### Start the app

You can use the provided index.js as a playground by running in a console the following command.

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

## Disclaimer ⚠️

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.

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

[Trekhleb](https://github.com/trekhleb)'s [JavaScript Algorithms](https://github.com/trekhleb/javascript-algorithms) repository heavily inspires this repository.
17 changes: 17 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"presets": ["@babel/preset-env"],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-syntax-import-meta",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-json-strings",
"istanbul"
],
"env": {
"test": {
"plugins": [
"istanbul"
]
}
}
}
38 changes: 21 additions & 17 deletions content.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
[Back to README](README.md)

# Content
* [Algorithmic Complexity](src/algorithmic-complexity/Algorithmic%20Complexity.ipynb)
* [Data Structures](src/data-structures/README.md)
* [Singly Linked List](src/data-structures/singly-linked-lists/Linked%20Lists.ipynb)
* Implementation
* [Singly Linked List Node](src/data-structures/singly-linked-lists/LinkedListNode.js)
* [Singly Linked List Wrapper](src/data-structures/singly-linked-lists/LinkedList.js)
* Tests
* [Singly Linked List Node and Wrapper](src/data-structures/singly-linked-lists/__test__/linked-lists.spec.js)
* [List of Exercises](src/data-structures/singly-linked-lists/exercises/README.md)

* [Doubly Linked List](src/data-structures/doubly-linked-lists/Doubly%20Linked%20Lists.ipynb)
* Implementation
* [Doubly Linked List Node](src/data-structures/doubly-linked-lists/DoublyLinkedListNode.js)
* [Doubly Linked List Wrapper](src/data-structures/doubly-linked-lists/DoublyLinkedList.js)
* Tests
* [Doubly Linked List Node](src/data-structures/doubly-linked-lists/__test__/doubly-linked-list-node.spec.js)
* [Doubly Linked List Wrapper](src/data-structures/doubly-linked-lists/__test__/doubly-linked-list.spec.js)
* **TODO:** List of exercises`]
- [Algorithmic Complexity](src/algorithmic-complexity/Algorithmic%20Complexity.ipynb)
- [Data Structures](src/data-structures/README.md)

- [Singly Linked List](src/data-structures/singly-linked-lists/Linked%20Lists.ipynb)

- Implementation
- [Singly Linked List Node](src/data-structures/singly-linked-lists/LinkedListNode.js)
- [Singly Linked List Wrapper](src/data-structures/singly-linked-lists/LinkedList.js)
- Tests
- [Singly Linked List Node and Wrapper](src/data-structures/singly-linked-lists/__test__/linked-lists.spec.js)
- [List of Exercises](src/data-structures/singly-linked-lists/exercises/README.md)

- [Doubly Linked List](src/data-structures/doubly-linked-lists/Doubly%20Linked%20Lists.ipynb)
- Implementation
- [Doubly Linked List Node](src/data-structures/doubly-linked-lists/DoublyLinkedListNode.js)
- [Doubly Linked List Wrapper](src/data-structures/doubly-linked-lists/DoublyLinkedList.js)
- Tests
- [Doubly Linked List Node](src/data-structures/doubly-linked-lists/__test__/doubly-linked-list-node.spec.js)
- [Doubly Linked List Wrapper](src/data-structures/doubly-linked-lists/__test__/doubly-linked-list.spec.js)
- **TODO:** List of exercises`]
18 changes: 9 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ import DoublyLinkedList from "./src/data-structures/doubly-linked-lists/DoublyLi
const ll = new DoublyLinkedList();

const array = [
{value: 1, key: 'test1'},
{value: 2, key: 'test2'},
{value: 3, key: 'test3'},
{value: 4, key: 'test4'},
{value: 5, key: 'test5'},
{value: 6, key: 'test6'},
{ value: 1, key: "test1" },
{ value: 2, key: "test2" },
{ value: 3, key: "test3" },
{ value: 4, key: "test4" },
{ value: 5, key: "test5" },
{ value: 6, key: "test6" },
];

ll.fromArray(array);

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

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

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

let node = ll.find(finder)
let node = ll.find(finder);

console.log(node);
console.log(node);
Loading

0 comments on commit 8d1fae0

Please sign in to comment.