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

hitokoto-get-zhhant

v1.2.1

Published

A tiny tool for getting hitokoto in Tranditional Chinese from the official API.

Downloads

16

Readme

hitokoto-get-zhhant

中文Readme文檔 | English Readme

What is this?

This is a nodejs module for getting hitokoto response in Tranditional Chinese (zh-hant) and via the official API (https://v1.hitokoto.cn).

How does it work?

A simple async function handle API request and passes through OpenCC (performed in node).

Before you start

This is SLOW.

There are a bunch of hitokoto API clone on github and some of them provide offline database to make the whole process faster. However, this module uses the official API and then translate it via OpenCC, which is up to few times slower in compare to those with offline database. There are also offline database clone translated into Tranditional Chinese that don't need OpenCC or even nodejs. But as the hitokoto database is always updating and expanding, requesting from the official API can ensure you get all the new and fresh content. So please balance the pros and cons before starting or putting it in your project.

Install and Usage

Installing to your project

npm install hitokoto-get-zhhant --save

Using in your project

let hitokoto = require('hitokoto-get-zhhant').hitokoto;

hitokoto().then(...function here...)

For default, parameter for hitokoto() is undefined. You can add category code to specify a category of hitokoto you want to request. Details are further below.

You can use this to see if everything is working fine. If yes, the requested hitokoto will be returned in console in Transitional Chinese.

let hitokoto = require('hitokoto-get-zhhant').hitokoto;

hitokoto().then(function(text){
    console.log(text);
})

Requesting hitokoto for a specific category

hitokoto("cat");

Use category code as stated on hitokoto API doc. (Available options are [a,b,c,d,e,f,g]) When undefined, it will request hitokoto from all category. Please be aware that hitokoto API (see section 4) only accept specifying ONE category, so putting more then one cat will result in 404: Not found under specific category (as such category does not exist).

From v1.2.0, the script will tell if 'cat' is vaild (in which, if it is a,b,c,d,e,f,g), which will not call the API for request to shorten time and eliminate expected 404 from invaild 'cat' parameter.

Things to be fixed

  • Performance enhancement (there may still be room for improvement but maybe further optimization will wait until v2 API release)

License

I don't know much about licenses so I went with the same as OpenCC. That's it.