New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

taskwizard

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

taskwizard

A versatile package containing useful code snippets for simple tasks

latest
npmnpm
Version
1.0.0
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

Welcome to Taskwizard 🦄

Version License: MIT

A versatile package containing useful code snippets for simple tasks

🏠 Homepage

Table of Contents

Prerequisites

  • node >=10

Installation

npm install taskwizard

Usage

TaskWizard can be imported using CommonJS or ES6 syntax. It also supports TypeScript.

import taskwizard from "taskwizard";
const taskwizard = require("taskwizard");

TaskMap

import { TaskMap } from "taskwizard";

const cacheSize = 2;
const cache = new TaskMap(cacheSize);

cache.set("key1", "value1");
cache.set("key2", "value2");

const valueForKey1 = cache.get("key1");
console.log(valueForKey1); //"value1".

const hasKey2 = cache.has("key2");
console.log(hasKey2); //true.

cache.set("key3", "value3");
console.log(cache.get("key1")) //undefined

Search Files Recursively

import { searchFilesRecursive } from "taskwizard";

const folderPath = "/path/to/folder";
const fileExtensions = [".js", ".ts"];
const files = await searchFilesRecursive(folderPath, fileExtensions);
console.log(files); // Expected: An array of absolute file paths.

Fetch Buffer from URL

import { fetchBuffer } from "taskwizard";

const url = "https://example.com/image.png";
const result = await fetchBuffer(url);
const buffer = result.buffer;
console.log(result); // { success: true/false, status: HTTP status code, buffer: Buffer content }.

Calculate Percentage Bar

import { calculatePercentageBar } from "taskwizard";

const options = { currentValue: 75, totalValue: 100, numBars: 10 };
// You can customize the bars however you want add options:
// { fillEmoji: "💛", emptyEmoji: "🤍" }
const percentageBar = calculatePercentageBar(options);
console.log(percentageBar); // ▰▰▰▰▰▰▰▱▱ 75%

Compact Number

import { compactNumber } from "taskwizard";

const numberToFormat = 12300;
const formattedNumber = compactNumber(numberToFormat);
console.log(formattedNumber) //12.3k

Format Time from Seconds

import { formatTimeFromSeconds } from "taskwizard";

const seconds = 3780;
const formattedTime = formatTimeFromSeconds(seconds);
console.log(formattedTime); // 1 hour 3 minutes

Get Country Information

import { getInfoFlag, isValidCode, isValidEmoji, isValidFlagName, isValidFlag, getLanguagesFromCode, getLanguagesFromEmoji } from "taskwizard";

const flag = "🇺🇸";
const countryInfo = getInfoFlag(flag);
console.log(countryInfo); // Expected: Information related to the country.

const countryCode = "us";
const isValidCountryCode = isValidCode(countryCode);
console.log(isValidCountryCode); // Expected: true or false.

const isValidCountryEmoji = isValidEmoji(flag);
console.log(isValidCountryEmoji); // Expected: true or false.

const countryName = "United States of America";
const isValidFlagName = isValidFlagName(countryName);
console.log(isValidFlagName); // Expected: true or false.

const isValidFlagValue = isValidFlag(flag);
console.log(isValidFlagValue); // Expected: true or false.

const languagesFromCode = getLanguagesFromCode(countryCode);
console.log(languagesFromCode); // Expected: An array of languages.

const languagesFromEmoji = getLanguagesFromEmoji("🇨🇴");
console.log(languagesFromEmoji); // Expected: An array of languages.

Calculate Difference in Hours

import { diffHours } from "taskwizard";

const date1 = new Date("2023-01-01T12:00:00Z");
const date2 = new Date("2023-01-02T18:30:00Z");
const hoursDifference = diffHours(date2, date1);
console.log(hoursDifference); // 31

Other useful methods are also available for some validations.

  • discordColors
  • isDiscordEmoji
  • isDiscordInviteLink
  • isValidEmail
  • isHex

Author

👤 NoBody

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

with ❤️ by NoBody

Keywords

utils

FAQs

Package last updated on 13 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts