-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8bbe57c
Showing
22 changed files
with
10,514 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"root": true, | ||
"env": { | ||
"browser": true, | ||
"es6": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/strict", | ||
"prettier" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": ["./tsconfig.json"], | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"plugins": ["@typescript-eslint"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | ||
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages | ||
|
||
name: Node.js Package | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
- run: npm ci | ||
- run: npm test | ||
|
||
publish-npm: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm ci | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
/lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Ignore artifacts: | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,294 @@ | ||
# Class: DoublyLinkedList<T\> | ||
|
||
A doubly linked list. | ||
|
||
## Type parameters | ||
|
||
| Name | Description | | ||
| :--- | :--------------------------- | | ||
| `T` | The type of an item's value. | | ||
|
||
## Table of contents | ||
|
||
### Constructors | ||
|
||
- [constructor](API.md#constructor) | ||
|
||
### Properties | ||
|
||
- [length](API.md#length) | ||
|
||
### Methods | ||
|
||
- [append](API.md#append) | ||
- [get](API.md#get) | ||
- [getHead](API.md#gethead) | ||
- [getTail](API.md#gettail) | ||
- [popHead](API.md#pophead) | ||
- [popTail](API.md#poptail) | ||
- [prepend](API.md#prepend) | ||
- [pushAt](API.md#pushat) | ||
- [remove](API.md#remove) | ||
- [toArray](API.md#toarray) | ||
|
||
## Constructors | ||
|
||
### constructor | ||
|
||
• **new DoublyLinkedList**<`T`\>(`values?`, `...rest`) | ||
|
||
Appends the specified items to the list. | ||
|
||
#### Type parameters | ||
|
||
| Name | | ||
| :--- | | ||
| `T` | | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Default value | Description | | ||
| :-------- | :----------- | :------------ | :------------------------------- | | ||
| `values` | `T` \| `T`[] | `[]` | The starting items of the list. | | ||
| `...rest` | `T`[] | `undefined` | The starting items by spreading. | | ||
|
||
#### Defined in | ||
|
||
[index.ts:39](https://github.com/Vissie2/doubly-linky/blob/17d672b/src/index.ts#L39) | ||
|
||
## Properties | ||
|
||
### length | ||
|
||
• **length**: `number` = `0` | ||
|
||
#### Defined in | ||
|
||
[index.ts:31](https://github.com/Vissie2/doubly-linky/blob/17d672b/src/index.ts#L31) | ||
|
||
## Methods | ||
|
||
### append | ||
|
||
▸ **append**(`value`): `void` | ||
|
||
Appends (pushes) a new item to the list. | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
| :------ | :--- | :------------------- | | ||
| `value` | `T` | The value of a node. | | ||
|
||
#### Returns | ||
|
||
`void` | ||
|
||
void | ||
|
||
#### Defined in | ||
|
||
[index.ts:147](https://github.com/Vissie2/doubly-linky/blob/17d672b/src/index.ts#L147) | ||
|
||
--- | ||
|
||
### get | ||
|
||
▸ **get**(`index`): `T` | ||
|
||
Gets the value of the item at the specified `index`. | ||
|
||
**`Throws`** | ||
|
||
IndexError | ||
This exception is thrown if `index` doesn't exist in the list. | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
| :------ | :------- | :----------------------- | | ||
| `index` | `number` | The index from the item. | | ||
|
||
#### Returns | ||
|
||
`T` | ||
|
||
The value of the item. | ||
|
||
#### Defined in | ||
|
||
[index.ts:286](https://github.com/Vissie2/doubly-linky/blob/17d672b/src/index.ts#L286) | ||
|
||
--- | ||
|
||
### getHead | ||
|
||
▸ **getHead**(): `undefined` \| `T` | ||
|
||
Retrieves the value of the first item in the list if it exists. | ||
|
||
#### Returns | ||
|
||
`undefined` \| `T` | ||
|
||
The value of the item or `undefined`. | ||
|
||
#### Defined in | ||
|
||
[index.ts:296](https://github.com/Vissie2/doubly-linky/blob/17d672b/src/index.ts#L296) | ||
|
||
--- | ||
|
||
### getTail | ||
|
||
▸ **getTail**(): `undefined` \| `T` | ||
|
||
Retrieves the value of the last item in the list if it exists. | ||
|
||
#### Returns | ||
|
||
`undefined` \| `T` | ||
|
||
The value of the item or `undefined`. | ||
|
||
#### Defined in | ||
|
||
[index.ts:305](https://github.com/Vissie2/doubly-linky/blob/17d672b/src/index.ts#L305) | ||
|
||
--- | ||
|
||
### popHead | ||
|
||
▸ **popHead**(): `undefined` \| `T` | ||
|
||
Removes the first item from the list if it exists. | ||
|
||
#### Returns | ||
|
||
`undefined` \| `T` | ||
|
||
The value of the item or `undefined`. | ||
|
||
#### Defined in | ||
|
||
[index.ts:209](https://github.com/Vissie2/doubly-linky/blob/17d672b/src/index.ts#L209) | ||
|
||
--- | ||
|
||
### popTail | ||
|
||
▸ **popTail**(): `undefined` \| `T` | ||
|
||
Removes the last item from the list if it exists. | ||
|
||
#### Returns | ||
|
||
`undefined` \| `T` | ||
|
||
The value of the item or `undefined`. | ||
|
||
#### Defined in | ||
|
||
[index.ts:226](https://github.com/Vissie2/doubly-linky/blob/17d672b/src/index.ts#L226) | ||
|
||
--- | ||
|
||
### prepend | ||
|
||
▸ **prepend**(`value`): `void` | ||
|
||
Prepends (unshifts) a new item to the list. | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
| :------ | :--- | :------------------- | | ||
| `value` | `T` | The value of a node. | | ||
|
||
#### Returns | ||
|
||
`void` | ||
|
||
void | ||
|
||
#### Defined in | ||
|
||
[index.ts:119](https://github.com/Vissie2/doubly-linky/blob/17d672b/src/index.ts#L119) | ||
|
||
--- | ||
|
||
### pushAt | ||
|
||
▸ **pushAt**(`value`, `index`): `void` | ||
|
||
Inserts an item at the place of `index`. The item will | ||
end up below the item that was currently there. | ||
|
||
**`Throws`** | ||
|
||
IndexError | ||
This exception is thrown if `index` doesn't exist in the list. | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
| :------ | :------- | :------------------------------------ | | ||
| `value` | `T` | The value of the item. | | ||
| `index` | `number` | The index where the node will end up. | | ||
|
||
#### Returns | ||
|
||
`void` | ||
|
||
void | ||
|
||
#### Defined in | ||
|
||
[index.ts:180](https://github.com/Vissie2/doubly-linky/blob/17d672b/src/index.ts#L180) | ||
|
||
--- | ||
|
||
### remove | ||
|
||
▸ **remove**(`index`): `T` | ||
|
||
Removes the item at the place of `index`. | ||
|
||
**`Throws`** | ||
|
||
IndexError | ||
This exception is thrown if `index` doesn't exist in the list. | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
| :------ | :------- | :--------------------- | | ||
| `index` | `number` | The index of the node. | | ||
|
||
#### Returns | ||
|
||
`T` | ||
|
||
void | ||
|
||
#### Defined in | ||
|
||
[index.ts:247](https://github.com/Vissie2/doubly-linky/blob/17d672b/src/index.ts#L247) | ||
|
||
--- | ||
|
||
### toArray | ||
|
||
▸ **toArray**(): `T`[] | ||
|
||
Retrieves an array of all the values in the list. | ||
|
||
#### Returns | ||
|
||
`T`[] | ||
|
||
An array of all the values in the list. | ||
|
||
#### Defined in | ||
|
||
[index.ts:314](https://github.com/Vissie2/doubly-linky/blob/17d672b/src/index.ts#L314) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Ilon Vis | ||
|
||
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. |
Oops, something went wrong.