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

kyz

v0.0.5

Published

Collection of useful functions

Downloads

34

Readme

⚙️ Installation

npm i kyz

CDN Links:

📖 Usage

▪ Import

// ES6
import kyz from "kyz";

// commonjs
const kyz = require("kyz");

[!NOTE]
Make sure to console.log() the values to see the output!

Appembed

▸ Import
import { Appembed } from 'kyz';      // ES6
const { Appembed } = require('kyz'); // Commonjs
▸ Usage
const embed_link = new Appembed()
    .setAuthor('wad')
    .setOembed('https://awwd')
    .build();

console.log(embed_link);

▪ Prevent console logs

kyz.unconsole();                // Disable all console logs

kyz.unconsole(["log", "info"]); // Disable specific ones
kyz.unconsole(["log"]);

▪ Generate UUIDs

kyz.uuid();

▪ Normalize URL

kyz.normalize("test.com#hash?query=hello"); // "http://test.com/#hash?query=hello"

▪ Check if IP format is valid or not

// ▸ IPv4
kyz.validIPFormat("192.168.0.1"); // True
kyz.validIPFormat("10.0.0");      // False

// ▸ IPv6
kyz.validIPFormat("2001:0db8:85a3:0000:0000:8a2e:0370:7334", "v6"); // True
kyz.validIPFormat("hello world", "v6");                             // False

▪ Check if string has emoji

kyz.hasEmoji("Hello 🚀 world!");          // True
kyz.hasEmoji("The weather is ☀️ today!"); // True
kyz.hasEmoji("String 69!");               // False
kyz.hasEmoji("I ♥ NY");                   // False

▪ Check if absolute URL or not

// ▸ string
kyz.isAbsoluteUrl('https://www.example.com/path'); // True

// ▸ array
const urls = [
    'http://localhost:3000',
    'ftp://ftp.example.com/file.zip',
    '/path',
    'example.com',
    'C:\\path\\to\\file.txt'
];

kyz.isAbsoluteUrl(urls); // [true, true, false, false, false]

▪ Prepend protocol

kyz.prependProtocol("www.example.com");            // "https://www.example.com"
kyz.prependProtocol("localhost")                   // "https://localhost"

// default protocol is always set to "https"
kyz.prependProtocol("ftp://www.example.com");      // "https://www.example.com"

kyz.prependProtocol("example.com", "ftp");         // "ftp://example.com"
kyz.prependProtocol("https://example.com", "ftp"); // "ftp://example.com"

▪ Milliseconds to readable format

kyz.cleanMs(60000)     // "1m"
kyz.cleanMs(3600000)   // "1h"
kyz.cleanMs(86400000)  // "1d"
kyz.cleanMs(123456789) // "1d 10h 17m 36s"

▪ Solve and verify quadratics

// ▸ Solve
kyz.quadratic(1, -4, 4);         // arguments - (a, b, c)
                                 // [2, 2]

// ▸ Verify
kyz.quadratic(1, -4, 4, [2, 2]); // arguments - (a, b, c, [root1, root2])
                                 // True

▪ Repeat Repeat Repeat

// ▸ string
kyz.repeat(30, "hello");

// ▸ array
kyz.repeat(30, ["hello", "hi"]);

▪ Find nearest and check palindrome

// ▸ Check
kyz.palindrome.check(999);     // True
kyz.palindrome.check('madam'); // True

// ▸ Find nearest
kyz.palindrome.nearest(98);   // 99
kyz.palindrome.nearest('98'); // 99

kyz.palindrome.nearest('awd'); // undefined

▪ Random item from

// ▸ Map
kyz.randomItemFrom(new Map([
    ['red', '#FF0000'],
    ['green', '#00FF00'],
    ['blue', '#0000FF']
])); // "#0000FF"

// ▸ Array
kyz.randomItemFrom(['apple', 'banana', 'orange', 'pear']); // "pear"

// ▸ String
kyz.randomItemFrom('0123456789'); // "6"

// ▸ Dictionary
kyz.randomItemFrom({
    cat: 'fluffy',
    dog: 'rover',
    bird: 'tweety',
    fish: 'goldie'
}); // "tweety"

Support me on PatreonCheck out my socials