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

algorithms_and_data_structures

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

algorithms_and_data_structures - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

package.json
{
"name": "algorithms_and_data_structures",
"version": "0.0.2",
"version": "0.0.3",
"description": "Algorithms and data structures in javascript.",

@@ -5,0 +5,0 @@ "scripts": {

@@ -43,2 +43,20 @@

LinkedList.prototype.reverse = function reverse() {
if(this._length == 0)
return;
this._tail = this._head;
var prev = null;
var next = this._head._next;
while(true) {
this._head._next = prev;
prev = this._head;
if(next == null)
break
this._head = next;
next = next._next;
}
}
LinkedList.prototype[Symbol.iterator] = function iterator() {

@@ -45,0 +63,0 @@ var curr = undefined;

@@ -8,3 +8,3 @@

test('stack: push and pop', () => {
test('stack', () => {
var stack = new LinkedList();

@@ -19,3 +19,3 @@ stack.pushFirst('hello');

test('queue: add and remove', () => {
test('queue', () => {
var queue = new LinkedList();

@@ -30,4 +30,15 @@ queue.pushLast('hello');

test('reverse stack', () => {
var stack = new LinkedList();
stack.pushFirst('hello');
stack.pushFirst('sweet');
stack.pushFirst('world');
stack.reverse();
expect(stack.popFirst()).toBe('hello');
expect(stack.popFirst()).toBe('sweet');
expect(stack.popFirst()).toBe('world');
});
//Testing iterator

@@ -34,0 +45,0 @@ /*

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