typescript-data-structures
Advanced tools
Comparing version 0.0.7 to 1.0.0
@@ -0,1 +1,2 @@ | ||
import { LinkedListNode } from './helper-classes'; | ||
export declare class LinkedList { | ||
@@ -8,2 +9,4 @@ private head; | ||
removeTail(): any; | ||
has(value: any): LinkedListNode; | ||
search(value: any): any; | ||
} |
26
index.js
@@ -57,4 +57,30 @@ "use strict"; | ||
}; | ||
LinkedList.prototype.has = function (value) { | ||
var currentNode = this.head; | ||
while (currentNode) { | ||
if (currentNode.value = value) { | ||
return currentNode; | ||
} | ||
currentNode = currentNode.next; | ||
} | ||
return null; | ||
}; | ||
LinkedList.prototype.search = function (value) { | ||
var currentNode = this.head; | ||
var result = []; | ||
while (currentNode) { | ||
if (currentNode.value === value) { | ||
result.push(currentNode); | ||
} | ||
currentNode = currentNode.next; | ||
} | ||
if (result.length && result.length > 1) { | ||
return result; | ||
} | ||
else { | ||
return -1; | ||
} | ||
}; | ||
return LinkedList; | ||
}()); | ||
exports.LinkedList = LinkedList; |
{ | ||
"name": "typescript-data-structures", | ||
"version": "0.0.7", | ||
"version": "1.0.0", | ||
"description": "A collection of TypeScript classes to create and use common data structures", | ||
@@ -5,0 +5,0 @@ "author": "RCMiron", |
@@ -28,2 +28,14 @@ # TSDS - TypeScript Data Structures | ||
``` | ||
## API | ||
###LinkedList | ||
Method | Paramenters | Returns | ||
--- | --- | --- | ||
addToHead | value: any | void | ||
addToTail | value: any | void | ||
removeHead | value: any | head.value | ||
removeTail | value: any | tail.value | ||
has | value: any | first node that contains the value | ||
search | value: any | array of nodes that contain the value or -1 | ||
## Contributing | ||
@@ -40,2 +52,6 @@ | ||
## Aknowledgements | ||
[Eric Traub - Data Structures in Javascript](https://www.udemy.com/learning-data-structures-in-javascript-from-scratch) | ||
## License | ||
@@ -42,0 +58,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
6353
113
1
59