@nftgo/gorarity
Version:
An algorithm to calculate rarity of NFT(how special it is), based on Jaccard Distance.
30 lines (29 loc) • 1.05 kB
TypeScript
import { Token } from './token';
import { StringTrait, TraitType } from './token-metadata';
import { TokenStandard } from './token-standard';
export type CollectionTrait = {
trait: StringTrait;
totalTokens: number;
};
export declare class Collection {
private _name;
private _tokens;
private _traitsFrequencyCounts;
constructor(tokens: Token[], name?: string);
get name(): string;
get tokens(): Token[];
get tokenTotalSupply(): number;
get traitsFrequencyCounts(): Map<string, Map<string, number>>;
tokenStandards(): TokenStandard[];
/**
* @description Return the number of tokens owning the trait.
* @param trait
*/
totalTokensWithTrait(trait: StringTrait): number;
extractNullTraits(): Map<TraitType, CollectionTrait>;
extractCollectionTraits(): Map<TraitType, CollectionTrait[]>;
/**
* @description Count the number of occurrence of each trait. Use traitName and traitValue to uniquely identify a trait.
*/
private deriveNormalizedTraitsFrequencyCounts;
}