ItzYourBread / stubby.ts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CodeQL Repo Dependents npm version NPM Download

stubby.ts

It's powerful and full laziness module for JavaScript and TypeScript.

Docs

Random(input/min, max?)
import { Random } from "stubby.ts";

// Generate a random number between 0 and 100
const randomNumber = Random(0, 100);
console.log(randomNumber); // Output: a random number between 0 and 100

// Generate a random number between -10 and 10
const negativeRandomNumber = Random(-10, 10);
console.log(negativeRandomNumber); // Output: a random number between -10 and 10

// Generate a random string from an array
const fruits = ["Apple", "Banana", "Cherry", "Grape", "Kiwi"];
const randomFruit = Random(fruits);
console.log(randomFruit); // Output: a random fruit from the array

// Generate a random object from an array of objects
const people = [
  { name: "Alice", age: 25 },
  { name: "Bob", age: 30 },
  { name: "Charlie", age: 35 },
];
const randomPerson = Random(people);
console.log(randomPerson); // Output: a random person object from the array
SmallNumber(count, digits)
import { SmallNumber } from "stubby.ts";

let num = "143";
let digits = num.length + 1;

console.log(SmallNumber(num, digits)) // it wil print superscript numbers like ⁰¹²³⁴⁵⁶⁷⁸⁹
SystemInfo()
import { SystemInfo } from "stubby.ts";

console.log(SystemInfo().memory());
console.log(SystemInfo().memoryUsage());
console.log(SystemInfo().cpuUsage());
console.log(SystemInfo().cores());
console.log(SystemInfo().cpuBrand());
console.log(SystemInfo().uptime());
Replace(string, replacements)
import { Replace } from 'stubby.ts';

const paragraph = `
  %boyname% loves %girlname%, but %girlname% doesn't know yet.
`;

const replacements = {
  '%boyname%': 'Arif',
  '%girlname%': 'Afrin'
};

const loveStory = Replace(paragraph, replacements);

console.log(loveStory);

Thanks✨

Have a great day!😊

About


Languages

Language:TypeScript 98.6%Language:JavaScript 1.4%