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

js-tools-base

v1.3.0

Published

A lightweight javascript tool library for various needs

Downloads

10

Readme

js-tools-base

NPM Version A lightweight javascript tool library for various needs.

Version 1.2.0

List of tools: isObject, isEmptyOrOnlySpacesString, getTimeZone, doesObjectHaveEmptyProps, isSorted, shuffleArray, generateRandomIntList, randomInt.

Installation

$ npm install js-tools-base

Usage

const { ExampleTool } = require("js-tools-base");

List of tools

isObject(object)

Check is that object in argument of function or not.

console.log(isObject({ "id": 123, "message": "hello Iphone" })); //true
console.log(isObject('some string')); //false

isEmptyOrOnlySpacesString(string)

Checks is string empty or has only spaces.

console.log(isEmptyOrOnlySpacesString('Apple')); //false
console.log(isEmptyOrOnlySpacesString('')); //true
console.log(isEmptyOrOnlySpacesString('    ')); //true
console.log(isEmptyOrOnlySpacesString('Ap  p le')); //false

getTimeZone()

Gets the requester's time zone.

console.log(getTimeZone()); //europe/kiev

doesObjectHaveEmptyProperties(object)

checks does object have blank properties.

const obj = {
    name: "John",
    dataOfBirth: "",
    externalId: 2548,
    email: "[email protected]",
    mobile: ""
}

const data = {
    name: "Sal",
    dataOfBirth: "12.12.2012",
    externalId: 83838,
    email: "[email protected]",
    mobile: "122344566"
}
console.log(doesObjectHaveEmptyProps(obj)); //dataOfBirth is empty, mobile is empty, other keys are filled
console.log(doesObjectHaveEmptyProps(data)); //other keys are filled

IsSorted(array)

Checks is sorted array in argument of function or not.

console.log(isSorted([1,3,4,9,13])); //true
console.log(isSorted([5, 7, 1, 67])); //false

shuffleArray(array)

Shuffles the values of an array, returning a new array.

let arr = [4, 6, 7, 9];
console.log(shuffleArray(arr)); //[7, 4, 9, 6]

generateRandomIntList(length, max)

Generates an array with random int values. First argument is the length of array, second is the max possible integer.

console.log(generateRandomIntList(8, 100)); //[ 41, 4, 52, 9, 82, 50, 19, 60 ]
console.log(generateRandomIntList(5, 5)); //[ 1, 0, 2, 0, 4 ]

randomInt(min, max)

Generates an integer between the minimum given value and the maximum given value.

console.log(randomInt(3, 576)); // 207
console.log(randomInt(50, 60)); // 58

capitalizeFirstLetter(string)

Capitalizes the first letter of a string.

console.log(capitalizeFirstLetter('hello')); // Hello
console.log(capitalizeFirstLetter('')); // ''

debounce(func, wait) Debounces a function to limit its execution rate.

const log = debounce(() => console.log('Debounced!'), 1000);
log();
log();
log(); // Only this call will log 'Debounced!' after 1 second

getQueryParams(url) Parses URL query parameters into an object.

console.log(getQueryParams('https://example.com?page=1&sort=asc')); // { page: '1', sort: 'asc' }

flattenArray(arr) Flattens a nested array.

console.log(flattenArray([1, [2, [3, [4]], 5]])); // [1, 2, 3, 4, 5]

Follow me and my email to cooperate

Twitter

[email protected]

at least if one of the tools you like, please star the repo. if you have free time feel free to contribute to this library

To do

add to do