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

vic-library

v1.1.1

Published

A lightweight library with object, array, string, and mathematical functions.

Downloads

43

Readme

vic. v 1.1.1

Hey, so I made a light-weight library with functions that come in handy from time to time. Overtime, this will grow. There's some Leetcode questions in here too that I like to compile together in one place to study/refer to later on. Also contains some functions found in the Lodash library. Just helps to streamline workflow so you don't have to write functions you've used before over and over.

Update: Added some math functions

Install it using npm i vic-library

Functions:

(If you ctrl+f and find a few useful functions you might need, this library is great for you because it's not massive like the Lodash library, for example.)

vic.clamp(number, lower, upper)

Takes 3 arguments:

  • Integer
  • Lower bound (Int)
  • Upper bound (Int) Returns:
  • Integer If the integer provided is smaller than the lower bound, the function returns the lower bound as the final number.

vic.inRange(number, start, end)

Takes 3 arguments:

  • Integer
  • Start value (Int)
  • End value (Int) Returns:
  • Boolean Checks the provided integer is withing range of start value and end value. If outside of provided range, the function returns a value of false. NOTE If no end value is proved, start value becomes 0 and provided start value becomes end value. If the start value is larger than the end value, the function will swap the values. This functionality is provided as a fail-safe should the user pass in incorrect arguments.

vic.words(string)

Takes 1 argument:

  • String Returns:
  • Array Splits long strings into an array of each word found in the original string.

vic.pad(string, length)

Takes 2 arguments:

  • String
  • Length (Int) Returns:
  • String Adds padding (spaces) to each side of the array to meet the desired length provided.

vic.translateToWhaleTalk(string)

Takes 1 argument:

  • String Returns
  • String Translate given string into a whale-intelligable language. e and u found inside the string will be double. Filters out consonants. Returned string will be in all capitals.

vic.has(object, key)

Takes 2 arguments:

  • Object
  • Key Returns:
  • Boolean Returns true if provided object contains the key and the key contains a value. Returns false if the provided object does not contain the provided key or the key does not have a value. NOTE Currently doesn't work with nested values

vic.invert(object)

Takes 1 argument:

  • Object Returns:
  • Object Iterates through each key of the provided object and swaps the key and value. NOTE In the case of duplicate values in the object, subsequent values will overwrite property assignments of previous values.

vic.findKey(object, predicate)

Takes 2 arguments:

  • Object
  • A predicate function (return Boolean) Returns:
  • Object.key Iterates through each key / value pair and calls the provided predicate function to test the value at its corresponding key. Returns the first key with a truthy value. Returns undefined if no key is truthy.

vic.drop(array, number)

Takes 2 arguments:

  • Array
  • Integer Returns
  • Array Removes a value from an array at a given value.

vic.dropWhile(array, predicate)

Takes 2 arguments:

  • Object
  • A predicate function (takes 3 args: current index, current element index, and the provided array) Returns
  • Array Creates a new copy of the provided array, dropping elements from the beginning of the array until an element causes the predicate function to return a falsy value.

vic.chunk(array, size)

Takes 2 arguments:

  • Array
  • Size (Int) Returns:
  • Array Disjunction the provided array into an array of arrays at the provided size. NOTE If the array cannot be broken up evenly, the last array chunk will be truncated to math the provided size argument. NOTE If no size is supplied, it's value will be set to 1.

vic.romanToInt(string)

Takes 1 argument:

  • String Returns:
  • Integer Converts a given roman numeral as a string and returns the corresponding integer. The European Spanish language uses a lot of roman numerals so this is useful in translation scenarios.

vic.priceFormat(number)

Takes 1 argument:

  • Integer Returns:
  • String Formats a given integer into a string with the appropriate decimals, commas, and dollar sign. Currently configured to USD.

vic.solveQuadratic(a, b, c)

Takes 3 arguments:

  • Integer (A value of quadratic)
  • Integer (B value of quadratic)
  • Integer (C value of quadratic) Returns:
  • String || Array Finds x intercepts of parabola from quadratic equation (a^2x + bx + c) in an array. If no x intercepts are found, returns string format of imaginary solutions (i).

vic.factorial(number)

Takes1 argument:

  • Integer Returns:
  • Integer Finds factorial of any number Example: 5! = 5 * 4 * 3 * 2 * 1 = 120.