Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typescript-data-structures

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescript-data-structures - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

1

helper-classes.d.ts

@@ -7,1 +7,2 @@ export declare class LinkedListNode {

}
export declare type Condition = (value: any) => boolean;

@@ -1,2 +0,2 @@

import { LinkedListNode } from './helper-classes';
import { Condition, LinkedListNode } from './helper-classes';
export declare class LinkedList {

@@ -10,3 +10,12 @@ private head;

has(value: any): LinkedListNode;
search(value: any): any;
search(value: any): LinkedListNode[];
}
export declare class BinarySearchTree {
value: any;
private left;
private right;
private condition;
constructor(value: any);
setInsertCondition(cb: Condition): void;
insert(value: any): void;
}

@@ -81,1 +81,38 @@ "use strict";

exports.LinkedList = LinkedList;
var BinarySearchTree = /** @class */ (function () {
function BinarySearchTree(value) {
this.value = value;
this.left = null;
this.right = null;
this.condition = null;
}
BinarySearchTree.prototype.setInsertCondition = function (cb) {
this.condition = cb;
};
BinarySearchTree.prototype.insert = function (value) {
var _this = this;
if (this.condition === null) {
this.condition = function () {
return value > _this.value;
};
}
if (!this.condition(value)) {
if (!this.left) {
this.left = new BinarySearchTree(value);
}
else {
this.left.insert(value);
}
}
else {
if (!this.right) {
this.right = new BinarySearchTree(value);
}
else {
this.right.insert(value);
}
}
};
return BinarySearchTree;
}());
exports.BinarySearchTree = BinarySearchTree;

2

package.json
{
"name": "typescript-data-structures",
"version": "1.0.1",
"version": "1.1.0",
"description": "A collection of TypeScript classes to create and use common data structures",

@@ -5,0 +5,0 @@ "author": "RCMiron",

@@ -31,12 +31,20 @@ # TSDS - TypeScript Data Structures

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 or null
search | value: any | array of nodes that contain the value or null
Method | Parameters | Returns | What it does
--- | --- | --- | ---
addToHead | value: any | void | adds new node and sets the head pointer to it, the old head becomes the new head's next
addToTail | value: any | void | adds new node and sets the tail pointer to it, the old tail becomes the new tail's prev
removeHead | value: any | head.value | removes head and sets new head to old head's next
removeTail | value: any | tail.value | removes tail and sets new tail to old tail's prev
has | value: any | LinkedListNode | returns first node that contains the value or null
search | value: any | LinkedListNode[] | returns array of nodes that contain the value or null
### BinarySearchTree
Method | Parameters | Returns | What it does
--- | --- | --- | ---
setInsertCondition | (value) => boolean | void | sets insertion rule
insert | value: any | void | inserts new node according to insert condition; if condition is not set, insertion will be done by simple comparison
## Contributing

@@ -47,3 +55,3 @@

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/RCMiron/TSDS/tags).

@@ -50,0 +58,0 @@ ## Authors

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc