Gathering detailed insights and metrics for cos-similarity
Gathering detailed insights and metrics for cos-similarity
Gathering detailed insights and metrics for cos-similarity
Gathering detailed insights and metrics for cos-similarity
npm install cos-similarity
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
7 Stars
95 Commits
2 Watchers
1 Branches
2 Contributors
Updated on Aug 12, 2024
Latest Version
2.0.0
Package Id
cos-similarity@2.0.0
Unpacked Size
4.53 kB
Size
2.08 kB
File Count
5
NPM Version
10.6.0
Node Version
20.11.0
Published on
Apr 30, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Computes the cosine similarity between two vectors
1npm install cos-similarity
cosSimilarity(vectorA, vectorB)
Returns the cosine similarity between the given vectorA
and vectorB
. Returns 0
when given a zero vector, []
, undefined
or nothing.
1import cosSimilarity from "cos-similarity"; 2 3cosSimilarity([1, 2, 4], [1, 0, 2]); // -> 0.8783100656536799 4cosSimilarity([1, 2, 0], [1, 2, 0]); // -> 1 5cosSimilarity([2, 0, 0], [0, 2, 0]); // -> 0 6cosSimilarity([-1, -2, 0], [1, 2, 0]); // -> -1
To run the benchmark, clone the repositry and run the bench script:
1npm run bench
benchmark time (avg) (min … max)
-------------------------------------------------------------------
• cosine similarity modules
-------------------------------------------------------------------
cos-similarity 249 ns/iter (247 ns … 319 ns)
compute-cosine-similarity 854 ns/iter (829 ns … 428 µs)
cosine-similarity 14'251 ns/iter (13'680 ns … 229 µs)
cosine-similarity-threshold 879 ns/iter (802 ns … 310 µs)
summary for cosine similarity modules
cos-similarity
3.43x faster than compute-cosine-similarity
3.53x faster than cosine-similarity-threshold
57.25x faster than cosine-similarity
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
2 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 0/18 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More