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

helpscript

v2.0.2

Published

Some functions that made some things.

Downloads

21

Readme

Helpscript

I made this module to help me to make some functions in my projects but you can use it if you want.

NOTE: Since version v2.0.0 I deleted all the previous functions an added new of them, so, if you're looking for a function that was in a previous version, it won't be in this one, sorry.

Instalation

npm i helpscript

Use

Import the function that you need and use it, see down below what functions are available.

const {someFunction} = require('helpscript')
// Or if your project uses import-export:
// import { someFunction } from 'helpscript'

console.log(someFunction())

Functions

areEmptyStrings

Returns true if one or more of the given strings is an empty string (''), useful in required forms that are validated by JavaScript.

const { areEmptyStrings } = require('helpscript')

if(areEmptyStrings(email, password, confirmPassword)){
    handleError()
}

// Now you know this aren't empty strings
makeSomething(email, password, confirmPassword)

Note: This function DOESN'T clean the values, so, if you pass a value like ' ', this won't be valued as empty string, if you want to make this, consider using:

const { clean, areEmptyStrings } = require('helpscript')
areEmptyStrings(...[email, password, confirmPassword].map(clean))

areEmptyValues

Returns true if one or more of the given values is falsy.

Falsy Values: 0, 0n, null, undefined, false, NaN or '' (empty string).

areNullishValues

Returns true if one or more of the given values is null or undefined.

clean

Cleans a string, triming it, lowercasing it ans normalizing it, useful to make searchs when you want to match for example "El Día Del Niño" with "el dia del nino".

const { clean } = require('helpscript')

clean('searCH From ínPut        ') // 'search from input'

Clean makes 3 things, trims the text, lowercases, and normalizes, if you dont want to make some of this, use the second parameter options.

clean('   My String', {lowercase:false}) // 'My String'

getDx

Gets the minimum number that makes a difference in the value

For example, if you add 3 + 1e-20 is still 3, but 3 + 1e-15 makes a difference but 100 + 1e-15 is still 100, and you need 1e-14 to make a difference.

When the value goes up, it also does the dx.

normalize

Normalizes a number between a given range and a condition

  • '()' excludes both numbers in the range.
  • '(]' excludes minimum and includes maximum.
  • '[)' includes minimum and excludes maximum.
  • '[]' includes both numbers in the range.
const { normalize } = require('helpscript')

// Example, normalizing a grade
normalize(11.3, [5, 10], '[]') // 10

now

Gets the date and milisecond of this moment (in UTC).

const { now } = require('helpscript')

const person = {
    name: 'John',
    lastname: 'Doe',
    created: now().time // The miliseconds are used
}

console.log('Now date is:', now().date) // The Date object is used

range

Returns an array of numbers by the given values (works like the range python function)

const { range } = require('helpscript')

range(5) // [0, 1, 2, 3, 4]
range(1, 6) // [1, 2, 3, 4, 5]
range(10, 20, 2) // [10, 12, 14, 16, 18]

An useful use can be for example if you want to make something n times and you are very lazy to make a for-loop.

const { range } = require('helpscript')

range(1, n + 1).forEach(value => {
    console.log('Hello', value)
})