Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A set of utilities in JavaScript

License

NotificationsYou must be signed in to change notification settings

vacom/vantage

Repository files navigation

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

npmi @vacom/vantageoryarnadd @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 - 10random();//output = 7//usage min: 10 max: 100random(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";//usageguid();//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 fieldletsearch=newRegExp(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 = "john@mail.com"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 = "flavio@demo.com"emailBlackList(email);//output = true//default usage//email = "flavio@gmail.com"//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: "john@mail.com"}]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: "john@mail.com"}]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";//usagerefreshPage();//output = page refresh

dynamicWidth

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

import{dynamicWidth}from"@vacom/vantage";//usagedynamicWidth();//output = 960

getUrlParam

import{getUrlParam}from"@vacom/vantage";Thisfunctionthroughanurlcollectsthedataofacertainparameter//usage string = "flavio"getUrlParam("q","https://dribbble.com/search?q=cards");//output = cards

About

A set of utilities in JavaScript

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp