npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

non-fungible-ranker

v0.1.2

Published

Module for calculating the statistics of an nft collection

Downloads

4

Readme

non-fungible-ranker

Rank your nft collection choosing the algorithm you prefer. This package can retrieves and parse the collection metadata from different sources and rank every nft using different score strategy.

Install

npm install non-fungible-ranker

Usage

const NFR = require('non-fungible-ranker')

const options = {
    source: {
        type: 'filesystem',
        path: './inputs/json',
    },
    collection: {
        attributes: ['Background','Skin', 'Jowls', 'Mouth', 'Eyes', 'Clothes', 'Headwear'],
        supply: 10000
    },
    ranker: {
        type: 'rarityScore'
    }
}

const ranker = NFR(options)

const stats = await ranker.rankCollection()
console.log(stats)
/*
 * ...
 * { id: '1082.json', score: 0.000001280426016987394 },
 * { id: '1083.json', score: 0.0000013304025676832715 },
 * { id: '1084.json', score: 0.0000013001667264310755 },
 * { id: '1085.json', score: 0.000001254020708824398 },
 * { id: '1086.json', score: 0.0000012871439413840163 },
 * { id: '1087.json', score: 0.0000012583142946898313 },
 * ...
 */

Options

Options must be an object with the following fields

const options = {
    source: { ... },
    collection: { ... },
    ranker: { ... }
}

Source

Source fields must be used to choose and customize a source reader. Each source reader can have different mandatory fields.

Filesystem source reader:
const source = { 
    type: 'filesystem', 
    path: '/home/user/collection/folder' 
}

The path should refer a folder in the filesystem where all the nft metadata json are stored.

Collection

Collection field take care of all the aspect of the nft collection. Only the listed attributes will be used for rank the nft

const collection = { 
    supply: 42, 
    attributes: ['Background', 'Clothes', 'Eyes', 'Fur', 'Har', 'Mouth' ]
}

Ranker

With this field you can choose and customize the rank algorithm

const ranker = { 
    type: 'rarityScore',
}

Available rankers:

  • traitRarity: The simpler algorithm, each nft will be scored based on his rarest trait
  • averageTraitRarity: Sum of the average rarity of every nft traits
  • statisticalRarity: Multiply the nft traits rarities together
  • rarityScore: The commonly used algorithm, each nft will be scored based on the rarity of all his traits on the entire collection