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

@vacom/vantage

v0.0.4

Published

A set of utilities in JavaScript

Downloads

6

Readme

VantageJS

This library is a set of utilities created in javascript to solve some of the common problems. These are some of the functions I write over my own projects and put them here to be reused in different scenarios and projects

VantageJS

IMPORTANTE NOTE! This library is very much in the process of being developed, it can be changed completely to something different. For now it is only used to share common functions in my own projects. Suggestions are welcome.

installation

Just install the dependency and start using

npm i @vacom/vantage or yarn add @vacom/vantage

How to import

After installing the dependency, just import the utility you need

import { guid } from "@vacom/vantage";

Utilities and Functions

Number Utilities

random

This function returns a random number based on the minimum and a maximum number

import { random } from "@vacom/vantage";

//default usage 0 - 10
random(); //output = 7

//usage min: 10 max: 100
random(min, max); //output = 85

guid

A string with random numbers is generated, this function can be useful for building dynamic ids

import { guid } from "@vacom/vantage";

//usage
guid(); //output = cb727975d2314f15

String Utilities

removeAccents

This function can be used to remove all accents. It can be useful for sensitive fields where only plain text is allowed.

import { removeAccents } from "@vacom/vantage";

//usage string = "Flávio"
removeAccents(string); //output = Flavio

formatUsername

Useful function to validate the username field, in case this does the wrong way. It is useful for removing accents, spaces and uppercase letters.

import { formatUsername } from "@vacom/vantage";

//usage string = "Flávio AJ Wéb"
formatUsername(string); //output = flavioajweb

handleExpression

Useful for validating expression, makes special characters not break the application. It can be useful for search fields or others.

import { handleExpression } from "@vacom/vantage";

//usage example search field
let search = new RegExp(handleExpression(searchQuery));

capitalizeFirstLetter

Useful for placing the first letter in uppercase. It can be used in welcome situations to the user or texts.

import { capitalizeFirstLetter } from "@vacom/vantage";

//usage string = "flavio"
capitalizeFirstLetter(string); //output = Flavio

validateEmail

Often the user does not correctly enter their email, this function validates this field. If the email is correct it returns true.

import { validateEmail } from "@vacom/vantage";

//usage string = "[email protected]"
validateEmail(string); //output = true

//usage string = "john@"
validateEmail(string); //output = false

//usage string = "john@mail"
validateEmail(string); //output = false

emailBlackList

Sometimes it is necessary to validate what type of email provider the user is registering, there are situations where these providers are temporary. This function allows you to create a bad list of mail providers where the email that is entered by the user is validated

import { emailBlackList } from "@vacom/vantage";

//default usage email = "[email protected]"
emailBlackList(email); //output = true

//default usage
//email = "[email protected]"
//list = ["demo", "mailinator", "maildrop"]
emailBlackList(email, list); //output = false

convertArrayOfObjectsToCSV

This function convert an array of data into the correct csv format

import { convertArrayOfObjectsToCSV } from "@vacom/vantage";

//usage content = [{name: "John", email: "[email protected]"}]
convertArrayOfObjectsToCSV({
  data: content
});

downloadCSV

This function uses the previous function to convert an array of data in the correct format of csv and then automatically downloads the file with the correct information to the user's machine

import { downloadCSV } from "@vacom/vantage";

//usage
// this function uses convertArrayOfObjectsToCSV behind
// args = {  filename: "name.csv" }
// data = [{name: "John", email: "[email protected]"}]
downloadCSV(args, data);
//output return and downloads the file

Browser Utilities

refreshPage

This function refreshes the page, is useful for large changes, or when user logout

import { refreshPage } from "@vacom/vantage";

//usage
refreshPage(); //output = page refresh

dynamicWidth

This function captures the width of the page, useful for placing dynamic sizes

import { dynamicWidth } from "@vacom/vantage";

//usage
dynamicWidth(); //output = 960

getUrlParam

import { getUrlParam } from  "@vacom/vantage";
This function through an url collects the data of a certain parameter
//usage string = "flavio"
getUrlParam("q", "https://dribbble.com/search?q=cards");
//output = cards