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

@honmameiko/covid-19-datalist

v2.0.0

Published

Developed based on TypeScript and React.This component shows the latest Data in a format of list on COVID-19 (coronavirus) and will be updated daily.Check out the data source [Here](https://github.com/owid/covid-19-data/tree/master/public/data)

Downloads

2

Readme

@honmameiko/covid-19-datalist

Developed based on TypeScript and React.This component shows the latest Data in a format of list on COVID-19 (coronavirus) and will be updated daily.Check out the data source Here

Installation

npm install @honmameiko/covid-19-datalist

Usage

import React, { useState, useEffect } from 'react'
import { getData, MergeCountryStatistics } from './common/utils/getCovidData'
import {ListDataSet,ListItem,ListColumn,RankOrder} from './List'
import List from './List'
function customShowCountry(country:string):JSX.Element{
  return(
    <div>{country}</div>
  )
}
const pageSplitNumber=10
function getCurrentPageStatistics(listLatestData:ListDataSet,currentPageNumber:number):ListDataSet{
  let beginIndex=(currentPageNumber-1)*pageSplitNumber
  return listLatestData.slice(beginIndex,beginIndex+pageSplitNumber)
}
export default function App() {
  const [allStatistics, setAllStatistics] = useState<MergeCountryStatistics>({})
  const [listLatestData, setListLatestData] = useState<ListDataSet>([])
  const [currentPageNumber, setCurrentPageNumber] = useState<number>(1)
  function switchPage(newPageNumber:number):void{
    let pageLength=Math.ceil(Object.keys(allStatistics).length/pageSplitNumber)
    if(newPageNumber>pageLength) {
      setCurrentPageNumber(pageLength)
      return
    }else if(newPageNumber<1){
      setCurrentPageNumber(1)
      return
    }
    setCurrentPageNumber(newPageNumber)
  }
  function reOrderData(column:ListColumn,order:RankOrder):void{
    let columnName=ListColumn[column] as keyof ListItem
    let orderFunc:(prev:ListItem,last:ListItem)=>number
    if(order===0) 
      orderFunc=(prev:ListItem,last:ListItem)=>{
        if(isNaN(parseFloat(prev[columnName]))||isNaN(parseFloat(last[columnName]))){
          return prev[columnName].localeCompare(last[columnName])
        }else{
          return parseFloat(prev[columnName])-parseFloat(last[columnName])
        }
      }
    else 
      orderFunc=(prev:ListItem,last:ListItem)=>{
        if(isNaN(parseFloat(prev[columnName]))||isNaN(parseFloat(last[columnName]))){
          return last[columnName].localeCompare(prev[columnName])
        }else{
          return parseFloat(last[columnName])-parseFloat(prev[columnName])
        }
      }
    let dataInNewOrder=listLatestData.sort(orderFunc)
    setListLatestData([...dataInNewOrder])
    setCurrentPageNumber(1)
  }
  useEffect(function () {
    getData().then(data => {
      setAllStatistics(data)
      const tempListLatestData:ListDataSet=[]
      for (let item in data) {
        let country = item
        let lastIndex = data[item].length - 1
        let population = data[item][lastIndex].population
        let total_case = data[item][lastIndex].total_case
        let total_death = data[item][lastIndex].total_death
        tempListLatestData.push(
          {country,population,total_case,total_death}
        )
      }
      setListLatestData(tempListLatestData)
    })
  },[])
  return (
    <div className="App">
      <div className="left-fill-up"></div>
      <div className="container">
        <List 
          data={getCurrentPageStatistics(listLatestData,currentPageNumber)} 
          showCountry={customShowCountry}
          switchPage={switchPage}
          currentPageNumber={currentPageNumber}
          pageLength={Math.ceil(Object.keys(allStatistics).length/pageSplitNumber)}
          reOrderData={reOrderData}
        />
      </div>
      <div className="right-fill-up"></div>
    </div>
  )
}

SnapShot

demo.png