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

utileo

v2.0.1

Published

JS library with most common utils.

Downloads

75

Readme

Utileo NPM version Downloads

A JS library for most commonly used utils

Utileo

Utils

  • Currency Utils
  • URL Utils
  • Common Utils
  • Geo Location Utils
  • History
  • Storage Utils
  • Date Utils

Getting Started (Installation)

yarn add utileo

or

npm i utileo --save-dev

Currency Formatter Methods

Method | Params | Description ----------------------------------|------------------|------------------------------------------ format | amount, isFloat | To display any and all amount-values, if isFloat is true, amount formatted to 2 decimal places parse | amount | To parse amount-value back to number-only beforeAPIRequest | amount | Before-submitting on any API-requests

Common Util Methods

Method | Params | Description ------------------------------------|------------------|--------------------------------------------------------------- validateName | string | Check if all characters in the string are alphabets validateOnlyNumber | string/number | Check if it is a number titleCase | string | Convert a string to title case camelize | string | Convert hello-world style strings to helloWorld style strings removeSpacesAndLowerCase | string | Converting to lower case and remove spaces in a string. Ex:My Name - myname replaceSpaceWithUnderscore | string | Converting space to underscore in a string. Ex:My Name - My_Name replaceSpecialCharsWithUnderscore | string | Replace special chars like @,$ to _ . Ex:abc@123%a$ - abc_123_a_ addKeyToObject | object | Adds key to objects getIndex | arr,object | Find index of an Item from Array of objects. toNumber | value | Convert a string to number partition | arr, criteria | Partition array into two arrays based on criteria isArray | value | Check for an Array isObject | value | Check for an Object isFunction | value | Check for a function isIOS | none | Check device type is IOS or not

Storage Util Methods

Method | Params | Description ----------------------------------|------------------|----------------------------------------- get | key | Get value from localstorage by key name set | key, value | Set value to localstorage has | key | Check key available in localstorage remove | key | Remove key from localstorage removeAll | - | Remove all items from localstorage

Geo Location Util Method

Method | Params | Description ----------------------------------|------------------|---------------------------- getLatLong | timeout | get lat and long

URL Parameter Method

Method | Params | Description ----------------------------------|----------------------|---------------------------- getURLParameter | qrString, paramName | get parameter value

Date Util Methods

Method | Params | Description ----------------------------------|------------------|--------------------------------------------------------------------- formatDate | date | Returns an object of day, month, year getCurrentDate | - | Returns current date getDateByDashFormat | date | Returns date with DD-MM-YYYY format getDateBySlashFormat | date | Returns date with DD/MM/YYYY format timestampToDate | timestamp | Converting timestamp to date Ex : 1560211200000 to Tue Jun 11 2019 getDateFromString | string | Converting string to date Ex : '6-11-2019' to Tue Jun 11 2019


Usage

import { CurrencyUtils, CommonUtils, StorageUtils, GeoLocationUtils, URLUtils, History, DateUtils } from 'utileo';

//---------------------------------- Currency Utils -------------------------//
CurrencyUtils.format('10000') // 10,000
CurrencyUtils.format('10000.1234',true) // 10,000.12
CurrencyUtils.parse('1,00,000') // 100000 

//---------------------------------- Common Utils -------------------------------------//
CommonUtils.validateName('only alphabets')// true
CommonUtils.validateOnlyNumber('1233')// true
CommonUtils.titleCase('main menu')// Main Menu
CommonUtils.camelize('main-menu')// mainMenu
CommonUtils.toNumber('1234')// 1234
CommonUtils.isArray([1,2,3]);// true
CommonUtils.isObject({"name": "abc", "age": 12})// true
CommonUtils.isFunction(CommonUtils.isObject);// true

var users = [
	{'user': 'barney', 'age': 36, 'active': false},
	{'user': 'fred', 'age': 40, 'active': true},
	{'user': 'pebbles', 'age': 1, 'active': false}
];

var groups = CommonUtils.partition(users, function (user) {
	return user.active;
});
// groups[0] has [{'user':'fred', 'age': 40, 'active': true}]
// groups[1] has [{'user':'barney', 'age': 36, 'active': false}, {'user': 'pebbles', 'age': 1, 'active': false}]

CommonUtils.getIndex(users,{'user': 'barney', 'age': 36, 'active': false});// 0

CommonUtils.addKeyToObject(users);// key(type) will be added
// [{type: "0", user: "barney", age: 36, active: false}
// {type: "1", user: "fred", age: 40, active: true}
// {type: "2", user: "pebbles", age: 1, active: false}]

//------------------------ Storage Utils -----------------------------//
StorageUtils.get('phoneNumber')// 9899224433
StorageUtils.set('phoneNumber',9899224433)
StorageUtils.has('phoneNumber')// true
StorageUtils.remove('token')
StorageUtils.removeAll()

//----------------------- Geo Location ----------------------------//
let latLong = GeoLocationUtils.getLatLong()// value of lat long
let latitude = latLong.lat
let longitude = latLong.long

//--------------------------------- URL Parameter ---------------------------------------//
var appVisa = URLUtils.getURLParameter(window.location.href, 'visa')// 12n23be3h3bhbbh34

//--------- History --------//
History.replace("/")
History.goBack()
History.push("/")

//------------------------------------------ Date Utils ------------------------------------------------//
const currDate = DateUtils.getCurrentDate();// Wed Jul 14 2020 13:07:57 GMT+0530 (India Standard Time)
const dateObj = DateUtils.formatDate(currDate);// {day: 14, month: 6, year: 2020}
DateUtils.getDateByDashFormat(currDate);// 14-07-2020
DateUtils.getDateBySlashFormat(currDate);// 14/07/2020
DateUtils.timestampToDate(1560211200000);// Tue Jun 11 2019 05:30:00 GMT+0530 (India Standard Time)
DateUtils.getDateFromString('2/10/2017');// Sat Feb 10 2017 00:00:00 GMT+0530 (India Standard Time)

Contributors

Here Contributors

License

MIT @bharatpe