Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@datastructures-js/deque
Advanced tools
A performant double-ended queue (deque) implementation in javascript.
A performant double-ended queue (deque) implementation in javascript.
npm install --save @datastructures-js/deque
const { Deque } = require('@datastructures-js/deque');
import { Deque } from '@datastructures-js/deque';
// empty queue
const deque = new Deque();
// from an array
const deque = new Deque([1, 2, 3]);
// empty queue
const deque = new Deque<number>();
// from an array
const deque = new Deque<number>([1, 2, 3]);
// empty queue
const deque = Deque.fromArray([]);
// with elements
const list = [10, 3, 8, 40, 1];
const deque = Deque.fromArray(list);
// If the list should not be mutated, use a copy of it.
const deque = Deque.fromArray(list.slice());
// empty queue
const deque = Deque.fromArray<number>([]);
// with elements
const list = [10, 3, 8, 40, 1];
const deque = Deque.fromArray<number>(list);
adds an element at the front of the queue.
deque.pushFront(30).pushFront(20).pushFront(10);
adds an element at the back of the queue.
deque.pushBack(40).pushBack(50).pushBack(60);
peeks on the front element of the queue.
console.log(deque.front()); // 10
peeks on the back element of the queue.
console.log(deque.back()); // 60
removes and returns the front element in the queue.
console.log(deque.popFront()); // 10
console.log(deque.front()); // 20
removes and returns the back element in the queue.
console.log(deque.popBack()); // 60
console.log(deque.back()); // 50
checks if the queue is empty.
console.log(deque.isEmpty()); // false
returns the number of elements in the queue.
console.log(deque.size()); // 4
creates a shallow copy of the queue.
const deque2 = Deque.fromArray([{ id: 2 }, { id: 4 } , { id: 8 }]);
const clone = deque2.clone();
clone.popFront();
console.log(deque2.front()); // { id: 2 }
console.log(clone.front()); // { id: 4 }
returns a copy of the remaining elements as an array.
console.log(deque.toArray()); // [ 20, 30, 40, 50 ]
clears all elements from the queue.
deque.clear();
deque.size(); // 0
grunt build
The MIT License. Full License is here
FAQs
A performant double-ended queue (deque) implementation in javascript.
We found that @datastructures-js/deque demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.