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

my-lib

v2.1.0

Published

library of recurring, unconnected functions

Downloads

230

Readme

CircleCI Coverage Status

my-lib

Library of recurring, unconnected but pure functions

Install and usage

Install the package as npm package. Provided are a umd-formatted file in the dist folder to require or to just load

<script src="../../node_modules/dist/myLib.js"></script>
<script src="https://unpkg.com/my-lib@latest"></script>

and an es-module in the module folder to import the separate functions or to import all

import { isAlphaNumeric } from 'my-lib'
import * as myLib from 'my-lib'

API

arrayCombination(array1, array2)

Find unique values from both arrays

Parameters

  • array1 (unknown[])
  • array2 (unknown[])

Return type

the combination

unknown[]

arrayFromCommaSeparatedList(commaSeparatedList)

Process comma separated list to a sanitised array with normalised strings

Parameters

  • commaSeparatedList (string)

Return type

array with separate strings

string[]

arrayFromQuery(cssQuery)

Create a genuine array from a css-query

Parameters

  • cssQuery (string)

Return type

array with Elements

Node[]

arrayIntersection(array1, array2)

Find unique values appearing in both arrays

Parameters

  • array1 (any[])
  • array2 (any[])

Return type

the intersection

unknown[]

deepClone(variable)

Recursively copy all indivisible data to new object Pay attention to Date and RegExp objects

Parameters

  • variable (any)

Return type

the same data with different references

any

forceStringify(value)

Try generic ways to produce a string, an empty string if necessary

Parameters

  • value (any)

Return type

string represention of anything

string

greet()

The sake of package; log the console

Return type

void

hasOwnProperty(object, prop)

Check for existence of property in object

Parameters

  • object (Record<string, unknown>)
  • prop (string)

Return type

the object has the property as its own property -- not inheriting it

boolean

isAlphaNumeric(word)

Test for being a string consisting of letters and/or digits, for being undelimited

Parameters

  • word (string)

Return type

consists of letters and/or digits only

boolean

isAttachedToDom(elm)

Check node for being part of the DOM

Parameters

  • elm (Element)

Return type

true when the node is on the webpage

boolean

isChar(char)

Test value for being a character; a string with a length of one

Parameters

  • char (string)

Return type

is a single character

boolean

isDigit(char)

Test value for being a string representation of a digit

Parameters

  • char (string)

Return type

is a number 0-9

boolean

isEqualSigns(...nums)

Check all arguments for being a number with the same sign (Zero is sign-neutral)

Parameters

  • nums (number[])

Return type

equality

boolean

isExactMatch(word, regex)

Check for a match covering the string entirely

Parameters

  • word (string)
  • regex (RegExp)

Return type

all characters of the word were described in regex

boolean

isFundamental(value)

Check value for indivisible: string, number, boolean, bigint, symbol, undefined, null, function

Parameters

  • value (unknown)

Return type

boolean

isLetter(char)

Test value for being a letter

Parameters

  • char (string)

Return type

char is a letter

boolean

isLower(char)

Test value for being a lowercase letter

Parameters

  • char (string)

Return type

char is a lower-case letter

boolean

isPrimitive(value)

Check value for being a primitive but leave out the anti-value undefined;

Parameters

  • value (unknown)

Return type

is a primitive

boolean

isUpper(char)

Test value for being an uppercase letter

Parameters

  • char (string)

Return type

char is a upper-case letter

boolean

isUsableNumber(...nums)

Test for values with which calculations can be done

Parameters

  • nums (number[])

Return type

every argument is a usable number

boolean

isWrappedPrimitive(value)

Check the variable for living in an object wrapper These can be generated by new String / Number etc. see https://developer.mozilla.org/en-US/docs/Glossary/Primitive

Parameters

  • value (unknown)

Return type

is a wrapped primitive

boolean

mathAvg(seq)

Calculate average of array with Numbers

Parameters

  • seq (number[])

Return type

the average of the numbers

number

mathSum(seq)

Calculate sum of array with Numbers

Parameters

  • seq (number[])

Return type

the sum of the numbers

number

roundAtDecimals(origin, decimals)

Round at decimals

Parameters

  • origin (number)
  • decimals (number)

Return type

the rounded number

number

roundAtDigits(origin, digits)

Round at digits; round with significance

Parameters

  • origin (number)
  • digits (number)

Return type

the rounded number

number

roundAtDigitsExponent(origin, digits)

Round at digits to exponential notation; round with significance

Parameters

  • origin (number)
  • digits (number)

Return type

the rounded number as exponent

string

stringify(value)

Convert anything to a string, an empty string if necessary. Expect sensible but not consistent cross-environment behaviour on functions.

Parameters

  • value (any)

Return type

string represention of anything

string

Demo

see demo folder