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

dev-utilz

v0.0.7

Published

Module intended to be used by developers to help with development

Downloads

8

Readme

dev-utilz

Utility functions to speedup development

Table of contents

Install

Install with npm:

$ npm install --save dev-utilz

String utilities

This library will support following string utility functions

isString

Check whether the given value is string or not. if valid string return tru else false.

usage

import { isString } from "dev-utilz";

console.log(isString("string")); // true
console.log(isString(1)); // false

isNotEmpty

Check whether the string is empty or not.

  • If empty return false else not.
  • If it's string, check whether it's empty or not else return false
  • If doTrim is true, trim the string before check. default value is false.
import { isNotEmpty } from "dev-utilz";

console.log(isNotEmpty("string")); // true
console.log(isNotEmpty(1)); // false
console.log(isNotEmpty("")); // false
console.log(isNotEmpty(" ")); // true
console.log(isNotEmpty(" ", true)); // false

returnValidString

If value is string return value else return empty string.

import { returnValidString } from "dev-utilz";

console.log(returnValidString("string")); // "string"
console.log(returnValidString(1)); // ""

capitalize

Capitalize the string

import { capitalize } from "dev-utilz";

console.log(capitalize("string")); // String
console.log(capitalize("test String")); // Test string

capitalizeAll

Capitalize each word in string

import { capitalizeAll } from "dev-utilz";

console.log(capitalizeAll("string")); // String
console.log(capitalizeAll("test string")); // Test String

throwErrorIfNotString

Throw error if value is not a string else return string

import { throwErrorIfNotString } from "dev-utilz";

console.log(throwErrorIfNotString("string")); // string
console.log(throwErrorIfNotString("")); // ""
console.log(throwErrorIfNotString(1)); // throw error

toLowerCase

Convert entire string to lowercase

import { toLowerCase } from "dev-utilz";

console.log(toLowerCase("string")); // string
console.log(toLowerCase("TEST String")); // test string

toUpperCase

Convert entire string to uppercase

import { toUpperCase } from "dev-utilz";

console.log(toUpperCase("string")); // STRING
console.log(toUpperCase("TEST String")); // TEST STRING

getFirstLetters

Function to get the first n letters of a string

import { getFirstLetters } from "dev-utilz";

console.log(getFirstLetters("string", 2)); // st

getSubString

Function to get substring from given string

import { getSubString } from "dev-utilz";
console.log(getSubString("John", 1, 3)); // oh

getLastLetters

Function to get the last n letters of a string

import { getLastLetters } from "dev-utilz";

console.log(getLastLetters("string", 2)); // ng

startWith

Check whether the string is start with given string

import { startWith } from "dev-utilz";
console.log(startWith("string", "str")); // true
console.log(startWith("TEST String", "John")); // false

endWith

Check whether the string is end with given string

import { endWith } from "dev-utilz";
console.log(endWith("string", "ing")); // true
console.log(endWith("TEST String", "John")); // false

times

Function to repeat string n times and return array

import { times } from "dev-utilz";
console.log(times("string", 2)); // ["string","string"]

padStart

Pads string on the left side if it's shorter than length. Padding characters are truncated if they exceed length.

import { padStart } from "dev-utilz";
console.log(padStart("abc", 6)); // '   abc'
console.log(padStart("abc", 6, "_")); // '___abc'

padEnd

Pads string on the right side if it's shorter than length. Padding characters are truncated if they exceed length.

import { padEnd } from "dev-utilz";
console.log(padEnd("abc", 6)); // 'abc   '
console.log(padEnd("abc", 6, "_")); // 'abc___'

stringSize

Gets the number of symbols in string.

import { stringSize } from "dev-utilz";
console.log(stringSize("qwerty")) // 6