Gathering detailed insights and metrics for compare-func
Gathering detailed insights and metrics for compare-func
Gathering detailed insights and metrics for compare-func
Gathering detailed insights and metrics for compare-func
npm install compare-func
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
Node Version
NPM Version
16 Stars
63 Commits
4 Forks
3 Watching
4 Branches
5 Contributors
Updated on 04 Oct 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-4.4%
1,282,239
Compared to previous day
Last week
3.8%
7,692,858
Compared to previous week
Last month
23.4%
29,846,741
Compared to previous month
Last year
19.2%
266,294,728
Compared to previous year
Get a compare function for array to sort
1$ npm install --save compare-func
1var compareFunc = require('compare-func'); 2 3// sort by an object property 4[{x: 'b'}, {x: 'a'}, {x: 'c'}].sort(compareFunc('x')); 5//=> [{x: 'a'}, {x: 'b'}, {x: 'c'}] 6 7// sort by a nested object property 8[{x: {y: 'b'}}, {x: {y: 'a'}}].sort(compareFunc('x.y')); 9//=> [{x: {y: 'a'}}, {x: {y: 'b'}}] 10 11// sort by the `x` propery, then `y` 12[{x: 'c', y: 'c'}, {x: 'b', y: 'a'}, {x: 'b', y: 'b'}].sort(compareFunc(['x', 'y'])); 13//=> [{x: 'b', y: 'a'}, {x: 'b', y: 'b'}, {x: 'c', y: 'c'}] 14 15// sort by the returned value 16[{x: 'b'}, {x: 'a'}, {x: 'c'}].sort(compareFunc(function(el) { 17 return el.x; 18})); 19//=> [{x: 'a'}, {x: 'b'}, {x: 'c'}]
Returns a compare function for array to sort
Type: string
, function
or array
of either
If missing it sorts on itself.
The string can be a dot path to a nested object property.
MIT © Steve Mao
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
3 existing vulnerabilities detected
Details
Reason
Found 2/7 approved changesets -- score normalized to 2
Reason
2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1
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 2024-11-18
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