New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dqs

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dqs

Deques are a generalization of stacks and queues (the name is pronounced “deck” and is short for “double-ended queue”).

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Deque

this is just a implementation of Python deques in JS. Deques are a generalization of stacks and queues (the name is pronounced “deck” and is short for “double-ended queue”).

Though list objects support similar operations, they are optimized for fast fixed-length operations and incur O(n) memory movement costs for pop(0) and insert(0, v) operations which change both the size and position of the underlying data representation.

Install

npm install dqs 

Usage

let dqueue = require('dqs')

## Methods

insert(x)

Add x to the right side of the deque.

all

Return all the objects in an Array.

clear()

Remove all elements from the deque leaving it with length 0.

count(x)

Count the number of deque elements equal to x.

pop()

Remove and return an element from the right side of the deque. If no elements are present, raises an IndexError.

popleft()

Remove and return an element from the left side of the deque. If no elements are present, raises an IndexError.

let dq = new DQueue([2,3,0,1])
let v1 = dq.popLeft()
let v2 = dq.popLeft()

console.log(v1, v2) // 2 3
console.log(dq.all()) // [0,1]

rotate(n=1)

Rotate the deque n steps to the right. If n is negative, rotate to the left.

let dqueue = new DQS([2,3,0,1])
dqueue.rotate(-2)
//[0,1,2,3]

When the deque is not empty, rotating one step to the right is equivalent to d.appendleft(d.pop()), and rotating one step to the left is equivalent to d.append(d.popleft()).

FAQs

Package last updated on 27 Mar 2020

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

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