
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.
string_score
Advanced tools
Check it out http://joshaven.com/string_score
Simply include one of the string score JavaScript files and call the .score() method on any string.
npm install --save string_score
require("string_score");
Thats it! It will automatically add a .score() method to all JavaScript String object... "String".score("str");
(results are for example only... I may change the scoring algorithm without updating examples)
"hello world".score("axl") //=> 0
"hello world".score("ow") //=> 0.35454545454545455
"hello world".score("e") //=>0.1090909090909091 (single letter match)
"hello world".score("h") //=>0.5363636363636364 (single letter match plus bonuses for beginning of word and beginning of phrase)
"hello world".score("he") //=>0.5727272727272728
"hello world".score("hel") //=>0.6090909090909091
"hello world".score("hell") //=>0.6454545454545455
"hello world".score("hello") //=>0.6818181818181818
...
"hello world".score("hello worl") //=>0.8636363636363635
"hello world".score("hello world") //=> 1
// And then there is fuzziness
"hello world".score("hello wor1") //=>0 (the "1" in place of the "l" makes a mismatch)
"hello world".score("hello wor1",0.5) //=>0.6081818181818182 (fuzzy)
// Considers string length
'Hello'.score('h') //=>0.52
'He'.score('h') //=>0.6249999999999999 (better match becaus string length is closer)
// Same case matches better than wrong case
'Hello'.score('h') //=>0.52
'Hello'.score('H') //=>0.5800000000000001
// Acronyms are given a little more weight
"Hillsdale Michigan".score("HiMi") > "Hillsdale Michigan".score("Hills")
"Hillsdale Michigan".score("HiMi") < "Hillsdale Michigan".score("Hillsd")
Fully functional in the 100% of the tested browsers:
** IE 7 fails (stop running this script message) with 4000 iterations of the benchmark test. All other browsers tested survived this test, and in fact survive a larger number of iterations. The benchmark that is causing IE to choke is: 4000 iterations of 446 character string scoring a 70 character match.
This is the fastest and smallest javascript string scoring plugin that I am aware of. I have taken great joy in squeezing every millisecond I can out of this script. If you are aware of any ways to improve this script, please let me know.
string_score.js is faster and smaller and does more than either liquidmetal.js or quicksilver.js
The test: 4000 iterations of 446 character string scoring a 70-character match
** Tests run with jQuery 1.5 on Mac Book Pro 2.4GHz Core 2 Duo running Snow Leopard *** quicksilver & string_score both use the same test file because they are used in the same way, LiquidMetal has to be called differently so the test file was modified to work with the LiquidMetal Syntax.
Please notify me of any ports so I can have them listed here. Please also keep track of the string score version that you have ported from. For example, in your readme include a note like: ported from version 0.2
string_score.js does not have any external dependencies other than a reasonably new browser.
The tests located in the tests folder rely on the files located in the tests folder.
Please share your testing results with me if you are able to test under an unlisted browser.
Author Joshaven Potter
Thank you Lachie Cox and Quicksilver for inspiration.
Special thanks to all who contribute... and if you're not listed here please email me. ##Contributors Yesudeep Mangalapilly - Collaborator Eric Celeste Matt Duncan Bruno Lara Tavares
Licensed under the MIT license.
FAQs
String Scoring Algorithm packaged for NodeJS
The npm package string_score receives a total of 2,463 weekly downloads. As such, string_score popularity was classified as popular.
We found that string_score 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.

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.