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

suouzuki

v1.0.2

Published

This library was created specifically for personal use, but you can also use it! It only contains things that I, suouzuki, need in my projects (especially projects related to Discord).

Downloads

8

Readme

Suouzuki.

This library was created specifically for personal use, but you can also use it! It only contains things that I, suouzuki, need in my projects (especially projects related to Discord).

Installation

To install it in your project is quite simple! Just use the code below

npm install suouzuki

> Utility

This topic has numerous functions, but I will only cover the main ones.

Oh, and to have the functions below, use the example code provided below.

const { util } = require("suouzuki");
util.isString("Hello World!"); // true

This is...

It checks if the value is indeed that, in the example above we used 'isString', which checks if it's a string, but there are various others such as:

isJSON(value) -> Check if the value is JSON or valid JSON.

isJSON({ name: "John", age: 30, city: "New York" }); // true
isJSON('{"name":"John","age":30,"city":"New York"}'); // true

isJSON('{"name":"John","age":30,"city":"New York"'); // false (invalid JSON)
isJSON([]); // false

isEmpty(value) -> Check if the value is empty. (String, Array, Object, Map)

isEmpty('  '); // true (empty string)
isEmpty([]); // true (empty array)
isEmpty(new Map()); // true (empty map)
isEmpty({}); // true (empty object)

isEmpty('Hello World!'); // false (non-empty string)
isEmpty([1, 2, 3]); // false (non-empty array)
isEmpty({ key: 'value' }); // false (non-empty object)

isPrimitive(value) -> Check if the value is a primitive (null, number, string, boolean, undefined, or symbol).

isPrimitive(42); // true
isPrimitive("Hello World!"); // true
isPrimitive({}); // false

isBoolean(value)* -> Check if the value is a Boolean.

isBoolean(false); // true
isBoolean("false"); // false

isString(value) -> Check if the value is a String.

isString("Hello World!"); // true
isString(42); // false

... -> And there are numerous functions like these that I can't mention all of.

String, Number, and Array

Useful functions for manipulating: String, Number, and Array. There are many more functions, but I'll only include two of each (my favorites for each).

- String

limit(string, limit, final) -> Limits the length of a string and adds a final character.

const limitedString = limit("Olá, eu me chamo Suouzuki e programo Node.js!", 20, "...");
// Returns: "Olá, eu me chamo Suo..."

verify(string, ...search) -> Verifies the presence of specific substrings in a string.

const searchResults = verify("Olá, quem é você?", "Olá", "você", "eu");
// Returns: [true, true, false]

...

- Number

toRoman(number) -> Convert a number to its Roman numeral representation.

toRoman(42) // "XLII"
toRoman(1999) // "MCMXCIX"

abbrev(number) -> Convert a large number to an abbreviated format (e.g., 1000 to 1K, 1000000 to 1M).

abbrev(1000) // "1K"
abbrev(1000000) // "1M"

...

- Array

get(array, search) -> Get an item from an array based on a search text using Fuse.js.

const arr = ["Nino.", "José.", "Suouzuki."];
const value = get(arr, "josé"); // [{ name: "José.", ID: 1, score: 0.02 }]

random(array, path) -> Returns a random element from an array, based on a probability value.

const arr = [
  { value: 'Suouzuki.', probability: 0.2 },
  { value: 'José.', probability: 0.3 },
  { value: 'Nino.', probability: 0.5 },
];

const randomElement = random(arr, 'probability'); // { value: 'Nino.', probability: 0.5 } or other

...

Error

It creates a custom error, allowing you to choose the name and description of the error.

Error.custom("myError", "Oops! An unexpected error occurred.");
// myError: Oops! An unexpected error occurred.

Collection

Creates a collector similar to discord.js but changing certain things.

const myCollection = new collection();
myCollection.set("value1", { test: true });
myCollection.set("value2", "hello");

Color

Adds color to texts using the 'colors' library.

console.log(color("<color=red>Hello</>, are you <style=random>okay?</>"));

> Discord

Utilities and functions for the discord.js library.

Oh, and to have the functions below, use the example code provided below.

const { discord } = require("suouzuki");

SlashCommandCreate

A class that dynamically creates slash commands (/).

const CommandSlash = new slashCommandCreate("mycommand", "my first slash command");
CommandSlash.addOption("string", { length: { max: 10, min: 5 }, required: true });