New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aryth/rank

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aryth/rank - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

55

dist/index.cjs.js

@@ -5,33 +5,26 @@ 'use strict';

/**
*
* @param {*[]} ar
* @param {function(*,*):number} comparer Compare 'prev' & 'next' element in an array. If return < 0, 'prev' comes first. If return > 0, 'next' comes first.
* @param {function(*):boolean} [filter]
* @return {number[]} Rank order array, where 0 denote the first.
*/
const rank = (ar, comparer, filter) => {
const sorted = (!filter ? ar.slice() : ar.filter(filter)).sort(comparer);
return ar.map(x => sorted.indexOf(x));
};
/**
*
* @param {*[]} ar
* @param {number[]} ranks array of the same length as 'arr', containing rank order of 'arr', 0 comes first.
* @return {*[]}
*/
var RankVector = require('@aryth/rank-vector');
var RankMatrix = require('@aryth/rank-matrix');
var RankColumn = require('@aryth/rank-column');
var ComparerCollection = require('@aryth/comparer');
const reorderBy = (ar, ranks) => {
const ve = Array(ar.length);
const {
NUM_ASC,
NUM_DESC,
STR_ASC,
STR_DESC
} = ComparerCollection;
const {
rank: rankVector
} = RankVector;
const {
rank: rankMatrix
} = RankMatrix;
const {
ColumnRank,
MutateRank
} = RankColumn;
for (let [i, ord] of ranks.entries()) ve[ord] = ar[i];
return ve;
};
const STR_ASC = (a, b) => a.localeCompare(b);
const STR_DESC = (a, b) => b.localeCompare(a);
const NUM_ASC = (a, b) => a - b;
const NUM_DESC = (a, b) => b - a;
exports.ColumnRank = ColumnRank;
exports.MutateRank = MutateRank;
exports.NUM_ASC = NUM_ASC;

@@ -41,3 +34,3 @@ exports.NUM_DESC = NUM_DESC;

exports.STR_DESC = STR_DESC;
exports.rank = rank;
exports.reorderBy = reorderBy;
exports.rankMatrix = rankMatrix;
exports.rankVector = rankVector;

@@ -1,32 +0,23 @@

/**
*
* @param {*[]} ar
* @param {function(*,*):number} comparer Compare 'prev' & 'next' element in an array. If return < 0, 'prev' comes first. If return > 0, 'next' comes first.
* @param {function(*):boolean} [filter]
* @return {number[]} Rank order array, where 0 denote the first.
*/
const rank = (ar, comparer, filter) => {
const sorted = (!filter ? ar.slice() : ar.filter(filter)).sort(comparer);
return ar.map(x => sorted.indexOf(x));
};
/**
*
* @param {*[]} ar
* @param {number[]} ranks array of the same length as 'arr', containing rank order of 'arr', 0 comes first.
* @return {*[]}
*/
import * as RankVector from '@aryth/rank-vector';
import * as RankMatrix from '@aryth/rank-matrix';
import * as RankColumn from '@aryth/rank-column';
import * as ComparerCollection from '@aryth/comparer';
const reorderBy = (ar, ranks) => {
const ve = Array(ar.length);
const {
NUM_ASC,
NUM_DESC,
STR_ASC,
STR_DESC
} = ComparerCollection;
const {
rank: rankVector
} = RankVector;
const {
rank: rankMatrix
} = RankMatrix;
const {
ColumnRank,
MutateRank
} = RankColumn;
for (let [i, ord] of ranks.entries()) ve[ord] = ar[i];
return ve;
};
const STR_ASC = (a, b) => a.localeCompare(b);
const STR_DESC = (a, b) => b.localeCompare(a);
const NUM_ASC = (a, b) => a - b;
const NUM_DESC = (a, b) => b - a;
export { NUM_ASC, NUM_DESC, STR_ASC, STR_DESC, rank, reorderBy };
export { ColumnRank, MutateRank, NUM_ASC, NUM_DESC, STR_ASC, STR_DESC, rankMatrix, rankVector };
{
"name": "@aryth/rank",
"version": "0.0.6",
"version": "0.0.7",
"description": "A math util library",

@@ -17,2 +17,8 @@ "main": "dist/index.cjs.js",

},
"dependencies": {
"@aryth/comparer": "^0.0.7",
"@aryth/rank-column": "^0.0.7",
"@aryth/rank-matrix": "^0.0.7",
"@aryth/rank-vector": "^0.0.7"
},
"repository": {

@@ -33,3 +39,3 @@ "type": "git",

"homepage": "https://github.com/hoyeungw/aryth#readme",
"gitHead": "2439c9922ca5c0f3b46e0bc91495355877f07cdb"
"gitHead": "60dc39d0a05d205a93131c0e12af701f8bb7c094"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc