openRerity core algorithm JS implementation use sky personal js lib
npm i openrarity
npm test
// normal rank
// same rank
npm run benchmark
/* gen Collection items: 100,000 Rarity calc time: 651 ms -- Mac M2
{ v: 1.010524265698629, toeknId: 53076, rank: 1 },
{ v: 1.009992300140172, toeknId: 10548, rank: 2 },
'.....',
{ v: 0.9894947869513546, toeknId: 44396, rank: 100000 }
*/
npm run cov
/*
----------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
----------------|---------|----------|---------|---------|-------------------
*/
const tokenScore = require('openrarity')
let metaData2 = [
{
trait1: 'value1',
trait2: 'value1',
trait3: 'value1'
},
{
trait1: 'value1',
trait2: 'value1',
trait3: 'value1'
},
{
trait1: 'value2',
trait2: 'value1',
trait3: 'value3'
},
{
trait1: 'value2',
trait2: 'value2',
trait3: 'value3'
},
{
trait1: 'value3 ',
trait2: 'value3',
trait3: 'value3'
}
]
let r = tokenScore(metaData2)
/*
=>
[
{ v: 1.3926137488801251, toeknId: 4, rank: 1 },
{ v: 1.1338031424711967, toeknId: 3, rank: 2 },
{ v: 0.8749925360622679, toeknId: 0, rank: 3 },
{ v: 0.8749925360622679, toeknId: 1, rank: 3 },
{ v: 0.7235980365241422, toeknId: 2, rank: 4 }
]
*/
- Generate trait value map without undefined(blank) trait
- Generate undefined(blank) trait for every token
- Generate trait value stats include traitEntropy
- Generate token trait probability list