Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
circular-stack
Advanced tools
A fixed-size auto-overwriting stack implementation.
npm install circular-stack --save
Import the script:
<script src="https://joker876.github.io/circular-stack/circular-stack.min.js">
And import the class from a global object:
new CircularStack.CircularStack(/* capacity */);
import CircularStack from 'circular-stack';
new CircularStack<T = any>(capacity: number);
CircularStack constructor takes the stack's maximum capacity as its only argument. Capacity is optional, and defaults to 100
.
The type of the elements can also be specified explicitly. The default type is any
.
const stack = new CircularStack(50);
// or with specified type
const stack = new CircularStack<number>(50);
size
- the amount of elements on the stack.capacity
- the meximum number of elements on the stack. Exceeding this value will cause the elements to be overwritten when pushed.stack.push(item: T): void
Pushes a new item onto the stack.
If the size of the stack reaches the capacity, it overwrites the oldest item.
stack.push(5);
stack.pop(): T | undefined
Removes the top element on the stack, and returns it.
If the stack is empty, returns undefined
.
stack.push(1);
stack.push(2);
stack.push(3);
stack.pop(); // >>>>> 3
stack.pop(); // >>>>> 2
stack.pop(); // >>>>> 1
stack.pop(); // >>>>> undefined
stack.peek(): T | undefined
Returns the top element of the stack without removing it.
If the stack is empty, returns undefined
.
stack.push(1);
stack.peek(); // >>>>> 1
stack.peek(); // >>>>> 1
stack.clear(): void
Clears all elements from the stack.
stack.push(1);
stack.push(2);
stack.push(3);
stack.clear();
stack.peek(); // >>>>> undefined
FAQs
A fixed-size auto-overwriting stack.
The npm package circular-stack receives a total of 1 weekly downloads. As such, circular-stack popularity was classified as not popular.
We found that circular-stack 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.