Skip to content
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

feature: initial data structures #11

Closed
wants to merge 11 commits into from
7 changes: 2 additions & 5 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# don't ever lint node_modules
node_modules
# don't lint build output (make sure it's set to your correct build folder name)
dist
# don't lint nyc coverage output
coverage
# don't lint readme
README.md
README.md
*.config.*
31 changes: 31 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": ["standard-with-typescript", "eslint:recommended", "plugin:@typescript-eslint/recommended"],
"plugins": ["@typescript-eslint"],
"parserOptions": {
"ecmaVersion": "latest",
"project": "./tsconfig.eslint.json",
"sourceType": "module"
},
"rules": {
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/member-delimiter-style": "off",
"@typescript-eslint/prefer-readonly": "off",
"@typescript-eslint/semi": "off",
"@typescript-eslint/space-before-function-paren": "off",
"@typescript-eslint/strict-boolean-expressions": "off",
"@typescript-eslint/no-var-requires": "off",
"explicit-function-return-type": "off",
"generator-star-spacing": "off",
"member-delimiter-style": "off",
"no-eq-null": "off",
"no-template-curly-in-string": "off",
"prefer-function-type": "off",
"semi": "off",
"strict-boolean-expressions": "off"
}
}
2 changes: 1 addition & 1 deletion .github/workflows/pull.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
node-version: '18.x'
cache: 'npm'
- run: npm ci
- name: Build app
- name: Build lib
run: npm run build

lint:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install dependencies
run: npm ci

build:
lint-and-test:
needs: setup
runs-on: ubuntu-latest
steps:
Expand All @@ -34,16 +34,14 @@ jobs:
cache: 'npm'

- run: npm ci
- name: Build app
run: npm run build
- name: Lint TS
run: npm run lint
- name: Run tests
run: npm run test:ci

release:
name: Release
needs: [setup, build]
needs: [setup, lint-and-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -53,6 +51,8 @@ jobs:
cache: 'npm'

- run: npm ci
- name: Build lib
run: npm run build
- name: Release
run: npm run semantic-release
env:
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"trailingComma": "es5",
"trailingComma": "none",
"tabWidth": 2,
"singleQuote": true,
"printWidth": 120
Expand Down
Empty file removed CHANGELOG.md
Empty file.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Joshua D. Graber

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
42 changes: 40 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,42 @@
# Broccoli and Carrots
_Data Structures and Algorithms in Typescript_

TODO: Make README nice.
Data Structures and Algorithms in Typescript

## Overview

_Note: this is primarily for my own learning. I'll aim to keep test coverage at 100%, but I have made this to practice 1. DSA and 2. Publishing and maintaining an npm package. Test and confirm for yourself before importing and using._

## Data Structures

| Structure | Type | Notes |
| ----------------------------------- | -------- | ------------------------------------------------------------------------ |
| [Linked List][LinkedList] | Sequence | This is a [Doubly Linked List][DoublyLinkedListWiki] |
| [Stack][Stack] | Sequence | Uses a `LinkedList` with the tail as the head of the [Stack][StackWiki] |
| [Queue][Queue] | Sequence | Uses a `LinkedList` with the head as the front of the [Queue][QueueWiki] |
| [Deque (Double-ended Queue)][Deque] | Sequence | Uses a `LinkedList` with the head as the front of the [Deque][QueueWiki] |
| [Circular Buffer][CircularBuffer] | Sequence | Uses JS array as case of [Buffer][BufferWiki] |

## Algorithms

## References

[Jeff Zhang - Iruka - DSA in Typescript](https://github.com/jeffzh4ng/iruka)
[William Fiset - Algorithms - DSA in Java](https://github.com/williamfiset/Algorithms)
[Algorithms - Jeff Erickson](https://jeffe.cs.illinois.edu/teaching/algorithms/)

<!-- Link defs -->
<!-- Structures -->

[LinkedList]: ./src/data-structures/sequences/linked-list/index.ts
[Stack]: ./src/data-structures/sequences/stack/index.ts
[Queue]: ./src/data-structures/sequences/queues/queue/index.ts
[Deque]: ./src/data-structures/sequences/queues/deque/index.ts
[CircularBuffer]: ./src/data-structures/sequences/circular-buffer/index.ts

<!-- Algorithms -->
<!-- Resources -->

[DoublyLinkedListWiki]: https://en.wikipedia.org/wiki/Doubly_linked_list;
[StackWiki]: https://en.wikipedia.org/wiki/Stack_(abstract_data_type)
[QueueWiki]: https://en.wikipedia.org/wiki/Queue_(abstract_data_type)
[BufferWiki]: https://en.wikipedia.org/wiki/Circular_buffer
6 changes: 0 additions & 6 deletions eslintrc.js

This file was deleted.

20 changes: 13 additions & 7 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
module.exports = {
roots: ['<rootDir>/test'],
testMatch: ['**/__test__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
collectCoverage: true,
collectCoverageFrom: ['src/**/{!(b-tree),}.ts'],
roots: ['<rootDir>/test'],
testEnvironment: 'node',
preset: 'ts-jest',
testMatch: ['**/__test__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'],
collectCoverage: true,
collectCoverageFrom: ['src/**/{!(b-tree),}.ts'],
transform: {
'\\.[jt]s': 'ts-jest'
},
moduleNameMapper: {
'(.+)\\.js': '$1'
},
extensionsToTreatAsEsm: ['.ts']
};
Loading