
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
most-common
Advanced tools
Get the _n_ most common elements and their counts from the most common to the least.
Get the n most common elements and their counts from the most common to the least.
$ npm i --save most-common
const mostCommon = require('most-common');
const words = [
'javascript',
'php',
'node',
'python',
'node',
'mocha',
'nlp',
'chai',
'nlp',
'most-common',
'array',
'string',
'nlp'
];
console.log(mostCommon(words, 3));
/*
[{
token: 'nlp',
count: 3
}, {
token: 'node',
count: 2
}, {
token: 'javascript',
count: 1
}]
*/
const pangram = 'The quick brown fox jumps over the lazy dog';
console.log(mostCommon(pangram, 3));
/*
[{
token: ' ',
count: 8
}, {
token: 'o',
count: 4
}, {
token: 'e',
count: 3
}]
*/
// Exclude whitespace
console.log(mostCommon(pangram, 3, { excludeWhitespace: true }));
/*
[{
token: 'o',
count: 4
}, {
token: 'e',
count: 3
}, {
token: 'u',
count: 2
}]
*/
$ npm test
Contributions are appreciated.
MIT-licensed. See LICENSE.
If this project has been helpful in any way, and you want to treat me a cup of coffee, please donate :)
FAQs
Get the _n_ most common elements and their counts from the most common to the least.
We found that most-common 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.