![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
shuffled-priority-queue
Advanced tools
A priority queue that shuffles elements with the same priority.
A priority queue that shuffles elements with the same priority.
npm install shuffled-priority-queue
const spq = require('shuffled-priority-queue')
const queue = spq()
queue.add({
priority: 0,
value: 'hello'
})
queue.add({
priority: 0,
value: 'world'
})
queue.add({
priority: 1,
value: 'welt'
})
queue.add({
priority: 2,
value: 'verden'
})
console.log(queue.shift()) // returns {value: 'verden'}
console.log(queue.shift()) // returns {value: 'welt'}
console.log(queue.shift()) // returns {value: 'hello'} or {value: 'world'}
console.log(queue.shift()) // returns {value: 'hello'} or {value: 'world'}
console.log(queue.shift()) // returns null (empty queue)
const queue = spq()
Create a new queue.
value = queue.add(value)
Add a new value to the queue. The value is returned for convenience
If you set value.priority
to a number, it'll be added to the queue at that priority.
queue.remove(value)
Remove a value from the queue.
bool = queue.has(value)
Check if a value is in the queue.
value = queue.shift()
Shift the next value off the queue.
The value returned will have the highest priority off the queue. If multiple values have the same priority a random one is returned.
value = queue.head()
Same as shift()
but does not mutate the queue.
value = queue.pop()
Same as shift()
but returns a value with the lowest priority.
value = queue.tail()
Same as pop()
but does not mutate the queue.
queue.length
Property containing how many items are in the queue
for (const value of queue)
Iterate the queue from highest priority to lowest using the for of
syntax
value = queue.next([prevValue])
Iterate the queue from highest priority to lowest.
let prevValue = null
while (prevValue = queue.next(prevValue)) {
console.log('value:', prevValue)
}
value = queue.prev([prevValue])
Iterate the queue from lowest priority to highest.
let prevValue = null
while (prevValue = queue.prev(prevValue)) {
console.log('value:', prevValue)
}
MIT
FAQs
A priority queue that shuffles elements with the same priority.
We found that shuffled-priority-queue 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.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.