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 🙏

© 2025 – Pkg Stats / Ryan Hefner

anytool

v1.0.2

Published

Collection of useful methods and classes.

Downloads

13

Readme

Anytool, a staticly collection of useful methods and classes!

npm install anytool

Basic Usage

import * as Anytool from "anytool"; // es6 syntax
// const Anytool = require("anytool"); // common javascript syntax

Or

import { randomNumber, unique, } from "anytool"; // es6 syntax
// const { randomNumber, unique, } = require("anytool"); // common javascript syntax

Methods

randomItem(array, limit, unique)

| argument | type | optional | description | default | | :------- | :-------------: | :------: | :--------------------------------------------------------------------------: | :-----: | | array | Array | Object | | Any array | | limit | Number | yes | Limit of randomly picked items, will return array of items, wheter specified | | unique | Boolean | yes | Array of randomly picked items must be unique | |

Examples

randomItem([1, 2, 3, 4]); // 3
randomItem([1, 2, 3, 4], 2); // [2, 3], might be [2, 2]
randomItem([1, 2, 3, 4], 2, true); // [2, 1]
randomItem({name1: "Dann", name2: "Not Dann", name3: "Always Dann"}); // ["name2", "Not Dann"], [key, value]
randomItem({name1: "Dann", name2: "Not Dann", name3: "Always Dann"}, 2); // [["name3", "Always Dann"], ["name2", "Not Dann"]]

unique(array)

| argument | type | optional | description | default | | :------- | :---: | :------: | :---------: | :-----: | | array | Array | | Any Array |

Examples

unique([1, 2, 3, 3, 4, 5, 5, 6]); // [1, 2, 3, 4, 5, 6]

equal(primary, secondary1, secondary2, ..., secondaryN)

| argument | type | optional | description | default | | :-------- | :---: | :------: | :--------------------------------: | :-----: | | primary | any | | Any Value to check with | | secondary | any | | Values to check with primary value |

Examples

equal(1, 1); // true
equal(1, "1"); // 
equal(1, 1, 2, 1); // 
equal([1, 2], [1, 2], [1, 2]); // true
equal([1, 2], [2, 1]); // 
equal({name: "Vardan"}, {"name": "Vardan"}); // true
equal({name: "Vardan", age: 18}, {age: 18, "name": "Vardan"}); // true
equal({name: "Vardan", age: 18}, {age: 18, "name": "Vardan"}, {name: "Diana", age: 18}); // 

randomNumber(min, max, dontRound)

| argument | type | optional | description | default | | :-------- | :-----: | :------: | :---------------------------------------: | :-----: | | min | Number | | Minumum value of range | | max | Number | | Maximum value of range | | dontRound | Boolean | yes | Wheter the respone must be a float number | |

Examples

randomNumber(1, 20); // **13**
randomNumber(1, 10, true); // 3.2317609836...

shortenText(text)

| argument | type | optional | description | default | | :------- | :----: | :------: | :---------: | :-----: | | text | String | | Any Text |

Examples

shortenText("Give me your love and I'll give you my sunshine", 10); // "Give me .."

currencyFormat(number)

| argument | type | optional | description | default | | :------- | :----: | :------: | :---------: | :-----: | | number | Number | | Any number |

Examples

currencyFormat(1437); // 1.4k
currencyFormat(3133917); // 3.1M

formatNumber(number, locale)

| argument | type | optional | description | default | | :------- | :--------------------------------------------------------------------------------------------------------------------------------------: | :------: | :---------------: | :-----: | | number | Number | | Any number | | locale | Locale String | yes | Locale of country | en-us |

Examples

formatNumber(12345679); // 123,456,789
formatNumber(123456789, "ru-ru"); // 123 456,789
formatNumber(123456789, "ar-EG"); // ١٢٣٤٥٦٫٧٨٩

removeFromArray(array, filter)

| argument | type | optional | description | default | | :------- | :-------------: | :------: | :------------------------------------------: | :-----: | | array | Array | | Any Array | | filter | any | #Index | | Element of array or index (formant #Index) |

Examples

removeFromArray([1, 2, 3, 4], "#2"); // [1, 2, 4];
removeFromArray(["Dann", "Gago", "Meri", "Gago"], "Gago"); // ["Dann", "Meri"]

removeFromArrayExtended(array, filter)

| argument | type | optional | description | default | | :------- | :---------------------------------------------------------------: | :------: | :------------------------------------------: | :-----: | | array | Array | | Any Array | | filter | RemoveFromArrayExtendedOptions | | Element of array or index (formant #Index) |

Examples

removeFromArrayExtended(["Dann", "Gago", "Meri", "Gago"], {indexes: [1, 3]}); // ["Dann", "Meri"]
removeFromArrayExtended(["Dann", "Gago", "Meri", "Gago"], {elements: ["Dann", "Meri"]}); // ["Gago", "Gago"]
removeFromArrayExtended(["Dann", "Gago", "Meri", "Gago"], {elements: ["Dann"], indexes: [3]}); // ["Gago", "Meri"]

uuid(length, options)

| argument | type | optional | description | default | | :------- | :-------------------------: | :------: | :-----------------: | :-----: | | length | Number | | Length of unique id | | options | UuidOptions | yes | Type and Style |

Examples

uuid(10); // "d12Lc01dsL"
uuid(10, {only: "<>?"}); // "<<>?><<>?>"
uuid(10, {letters: "only"}); // "skFqlcPOcH"
uuid(10, {letters: "only", letterType: "lowercase"}); // "skdxchqkpo", default "both"
uuid(10, {numbers: "only"}); // "3789123752"
uuid(10, {letters: "only", aditional: "@#$"}); // "FDj$dx@A#x"

resultOf(numbers, operation)

| argument | type | optional | description | default | | :-------- | :----------------------: | :------: | :---------: | :-----: | | numbers | Number[] | | Any Numbers | | operation | "*" | "/" | "+" | "-" | yes | Operation | "+" |

Examples

resultOf([1, 2, 3]); // 6, default "+"
resultOf([1, 2, 3], "+"); // 6
resultOf([1, 2, 3], "*"); // 6
resultOf([1, 2, 3], "-"); // -4
resultOf([1, 2, 3], "/"); // 0.1666666666666667

reverseString(text)

| argument | type | optional | description | default | | :------- | :----: | :------: | :---------: | :-----: | | text | String | | Any text |

Examples

reverseString("Hello everyone!"); // "!enoyreve olleH"

memoize(fn, doIf)

| argument | type | optional | description | default | | :------- | :------------------------: | :------: | :-----------------------------------------------: | :-----: | | fn | Function | | Any Function | | doIf | Function (returns boolean) | yes | Do filtering function when cached value was found |

Examples

memoize((array1, array2) => array1.every(value => array2.includes(value)));
memoize((array1, array2) => array1.every(value => array2.includes(value)), (prevArgs, nextArgs) => {
   if (prevArgs[0][0] !== nextArgs[0][0])
      return false;

   return true;
});

numberArray(start, end)

| argument | type | optional | description | default | | :------- | :----: | :------: | :------------: | :-----: | | start | Number | | Start of range | 0 | | end | Number | yes | End of a range | start |

Examples

numberArray(5); // [1, 2, 3, 4, 5]
numberArray(5, 10); // [6, 7, 8, 9, 10]

Classes

See File

Extended Map for holding values new Chest()

Usage examples

JavaScript

const ages = new Chest();

ages.set("Dann", 18);

TypeScript

const ages = new Chest<string, number>();

ages.set("Dann", 18);

ages.set("Gago", "18"); // error

Some methods

ages.first(); // first value
ages.random(); // random value
ages.delete("Dann"); // delete item
ages.setMany(age => age < 18, 18); // Setting new values after filtering
ages.has("Dann"); // Wheter there is item with spec. key
ages.hasAll("Dann", "Gago"); // Wheter there are all spec. keys
ages.hasAny("Dann", "Gago"); // Wheter there is at least one key of spec keys

See File

Simple Cooldown system new Cooldown(time)

| argument | type | optional | description | default | | :------- | :----: | :------: | :---------------------------: | :-----: | | time | Number | | Cooldown time in milliseconds |

Examples

const commandLimiter = new Cooldown(5000);

console.log(commandLimiter.isLimited(anyUser.id))

Types

| key | valueType | description | | :------: | :-------: | :------------------------------------------: | | indexes | Number[] | Array of element indexes to be removed | | elements | any[] | Elements that, when matched, will be removed |

| key | valueType | description | example | | :--------: | :----------------------------------: | :--------------------------------------------------------: | :--------: | | only | String | Use only these characteres | dj*24_cx@" | | numbers | "only" | false | Use only numbers 0-9 or false for disabling numbers | "only | | letters | "only" | false | Use only letters a-z or A-Z or false for disabling letters | "only | | aditional | String | Use aditional symbols | "_^&?>" | | letterType | "uppercase" | "lowercase" | "both" | Letter type (default is "both") | "lowercase |