Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Get n-grams in JavaScript.
npm:
$ npm install n-gram
Component:
$ component install wooorm/n-gram
Bower:
$ bower install n-gram
var nGram = require('n-gram');
nGram.bigram('n-gram'); // ['n-', '-g', 'gr', 'ra', 'am']
nGram(2)('n-gram'); // ['n-', '-g', 'gr', 'ra', 'am']
nGram.trigram('n-gram'); // ['n-g', '-gr', 'gra', 'ram']
nGram(6)('n-gram'); // ['n-gram']
nGram(7)('n-gram'); // []
Factory returning a function that converts a given string to n-grams.
Want padding? Use something like the following: nGram(2)(' ' + value + ' ');
Shortcut for nGram(2)
Shortcut for nGram(3)
$ npm run install-benchmark # Just once of course.
$ npm run benchmark
On a MacBook Air, it runs about 506,112 op/s on a ssentence.
nGram -- this module
506,112 op/s » bigrams on a sentence
1,510 op/s » bigrams on an article
510,072 op/s » trigrams on a sentence
2,334 op/s » trigrams on an article
488,316 op/s » ten-grams on a sentence
2,449 op/s » ten-grams on an article
madbence/ngram
489,850 op/s » bigrams on a sentence
2,923 op/s » bigrams on an article
467,247 op/s » trigrams on a sentence
4,019 op/s » trigrams on an article
478,506 op/s » ten-grams on a sentence
3,889 op/s » ten-grams on an article
ngram
126,431 op/s » bigrams on a sentence
2,614 op/s » bigrams on an article
172,970 op/s » trigrams on a sentence
2,912 op/s » trigrams on an article
200,743 op/s » ten-grams on a sentence
2,927 op/s » ten-grams on an article
MIT © Titus Wormer
FAQs
Get n-grams from text
The npm package n-gram receives a total of 95,634 weekly downloads. As such, n-gram popularity was classified as popular.
We found that n-gram demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.