
Security News
curl Shuts Down Bug Bounty Program After Flood of AI Slop Reports
A surge of AI-generated vulnerability reports has pushed open source maintainers to rethink bug bounties and tighten security disclosure processes.
ordered-set
Advanced tools
`ordered-set` is a performant ES6 Set subclass that allows control over iteration order.
ordered-set is a performant ES6 Set subclass that allows control
over iteration order.
Simply provide the set with the ordering function to use and it will
do the rest.
const OrderedSet = require('ordered-set')
let orderedSet = new OrderedSet()
orderedSet.use(mySortingFunction)
orderedSet.add(item)
orderedSet.add(item2)
for (let setItem of orderedSet) {
// iterates in order defined by mySortingFunction
}
npm install ordered-set
Although the code is compiled and published as ES5, there are some ES6 standard library features required:
Install es6-shim or 6to5. traceur also works well. Unfortunately, did not have luck using the more lightweight & modular es6-set & es6-symbol.
You'll need to install an ES6 polyfill yourself, such as those listed above. There is not one included with the package on purpose – this may seem like malpractice and I normally would advise against any kind of implicit dependencies but after battling with these issues across multiple projects I've concluded npm currently has no suitable workflow for anything that mutates the global environment i.e. must be a singleton.
I feel this should be best-practice for language polyfills – by omitting a transpiler you're free to use this with whatever transpiler you're already using.
This lib could be easily reworked to not require these ES6 features but the intended audience is people already compiling to ES6, or those interested in doing so.
const OrderedSet = require('ordered-set')
// Default sortFunction is numeric, ascending:
// (a, b) => a - b
let orderedSet = new OrderedSet()
orderedSet.add(2)
orderedSet.add(1)
orderedSet.add(3)
orderedSet.forEach(item => console.log('orderedSet default sortFunction', item))
// orderedSet default sortFunction 1
// orderedSet default sortFunction 2
// orderedSet default sortFunction 3
.use(fn)orderedSet.use((a, b) => b - a) // e.g. reversed ordering
orderedSet.forEach(item => console.log('orderedSet custom sortFunction', item))
// orderedSet custom sortFunction 3
// orderedSet custom sortFunction 2
// orderedSet custom sortFunction 1
let regularSet = new Set()
regularSet.add(2)
regularSet.add(1)
regularSet.add(3)
regularSet.forEach(item => console.log('regular set', item))
// regular set 2
// regular set 1
// regular set 3
orderedSet = new OrderedSet([3,2,1])
orderedSet.add(0)
console.log('orderedSet.size', orderedSet.size) // set.size 4
orderedSet.delete(0)
console.log('orderedSet.size', orderedSet.size) // set.size 3
MIT
FAQs
`ordered-set` is a performant ES6 Set subclass that allows control over iteration order.
We found that ordered-set 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
A surge of AI-generated vulnerability reports has pushed open source maintainers to rethink bug bounties and tighten security disclosure processes.

Product
Scan results now load faster and remain consistent over time, with stable URLs and on-demand rescans for fresh security data.

Product
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.