@poprank/rankings
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -141,3 +141,5 @@ "use strict"; | ||
return; | ||
minNonWeightComponent = Math.min(minNonWeightComponent, calculateBaseTraitScore(trait.traitCount, collectionSize, traitTypeArray.length)); | ||
if (minNonWeightComponent > calculateBaseTraitScore(trait.traitCount, collectionSize, traitTypeArray.length)) { | ||
minNonWeightComponent = Math.min(minNonWeightComponent, calculateBaseTraitScore(trait.traitCount, collectionSize, traitTypeArray.length)); | ||
} | ||
}); | ||
@@ -192,20 +194,28 @@ }); | ||
var trait = (_a = nft.traits.find(function (t) { return t.typeValue === traitType; })) !== null && _a !== void 0 ? _a : traitValuesOfThisType.find(function (t) { return t.category === 'None'; }); | ||
var value = trait.value, typeValue = trait.typeValue; | ||
var currTraitValueCount = traitValuesOfThisType.find(function (t) { return t.value === value; }).traitCount; | ||
var pushRatedTraitToCollectionTraits = function (rarity, count) { | ||
if (!collectionTraits[typeValue]) | ||
collectionTraits[typeValue] = []; | ||
if (!collectionTraits[typeValue].find(function (t) { return t.value === value; })) | ||
collectionTraits[typeValue].push((__assign(__assign({}, trait), { traitCount: count, rarityTraitSum: rarity }))); | ||
}; | ||
// For all non trait-count meta traits, don't calculate the rarity. If it's not none though, still | ||
// add it to the end traits array | ||
if (traitValuesOfThisType.find(function (t) { return t.category === 'Meta' && t.typeValue !== rarity_meta_1.TRAIT_COUNT; })) { | ||
if (trait.category !== 'None') | ||
if (trait.category !== 'None') { | ||
pushRatedTraitToCollectionTraits(0, currTraitValueCount); | ||
nftTraitsWithRarity.push(__assign(__assign({}, trait), { traitCount: 1, rarityTraitSum: 0 })); | ||
} | ||
return; | ||
} | ||
var value = trait.value, typeValue = trait.typeValue; | ||
var currTraitValueCount = traitValuesOfThisType.find(function (t) { return t.value === value; }).traitCount; | ||
var collectionTraitValueCountPairs = collectionTraitsNoRarity[typeValue]; | ||
var traitTypeCount = collectionTraitValueCountPairs.length; | ||
var currTraitRarity = (0, exports.calculateTraitScore)(currTraitValueCount, nfts.length, traitTypeCount, weight); | ||
if (!collectionTraits[typeValue]) | ||
collectionTraits[typeValue] = []; | ||
if (!collectionTraits[typeValue].find(function (t) { return t.value === value; })) | ||
collectionTraits[typeValue].push((__assign(__assign({}, trait), { traitCount: currTraitValueCount, rarityTraitSum: currTraitRarity }))); | ||
rarityTraitSum += currTraitRarity; | ||
nftTraitsWithRarity.push(__assign(__assign({}, trait), { traitCount: 1, rarityTraitSum: currTraitRarity })); | ||
// Push this trait to the collection-wide object if it's not there | ||
pushRatedTraitToCollectionTraits(currTraitRarity, currTraitValueCount); | ||
// Don't add "None" traits to the final array, they're implicit | ||
if (trait.category !== 'None') | ||
nftTraitsWithRarity.push(__assign(__assign({}, trait), { traitCount: 1, rarityTraitSum: currTraitRarity })); | ||
}); | ||
@@ -212,0 +222,0 @@ nftsWithRarity.push(__assign(__assign({}, nft), { traits: nftTraitsWithRarity, rarityTraitSum: +rarityTraitSum.toFixed(3) })); |
{ | ||
"name": "@poprank/rankings", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "PopRank's NFT rarity and aesthetic ranking logic", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
40392
530
0