๐Ÿš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more โ†’
Socket
DemoInstallSign in
Socket

github.com/deliaz/print-linked-list

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/deliaz/print-linked-list

v0.0.0-20180820191413-1cabbad2d562
Source
Go
Version published
Created
Source

Print Linked List

Pretty print for singly linked lists with loop detection

Build Status Coverage Status Npm package version

A โ†’ B โ†’ C โ†’ D โ†’ E โ†’ [null]

Install

npm i print-linked-list

Usage

I used that module when studying Linked Lists exercises. By default it utilizes console.log with colored output to show a list structure (see available options below).

Basic usage:

const printLinkedList = require('print-linked-list');

const list = new LinkedList('A');
list.append('B');
list.append('C');
list.append('D');
list.append('E');

printLinkedList(list);

Output:

A โ†’ B โ†’ C โ†’ D โ†’ E โ†’ [null]

It also has a loop detection. Example:

const printLinkedList = require('print-linked-list');

const list = new LinkedList('A');
list.append('B');
list.append('C');
list.append('D');
list.next.next.next.next = list.next.next; // making a loop

printLinkedList(list, {colors: false});

Output will be:

A โ†’ B โค‡ C โ†’ D โค‡ [loop]

The double arrow point on loop entry node.

Options:

  • nextName {String} Key name for next node prop. Default = "next"
  • valueName {String} Key name for value prop. Default = "value"
  • output {String} Result output method ("console" or "return"). Default = "console"
  • colors {Boolean} Use colors in console output. Default = true

FAQs

Package last updated on 20 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts