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

string-features

v0.11.2

Published

Common things you need while working with strings

Downloads

16

Readme

String features

npm version npm npm GitHub Release Date Maintenance

String-features or simptly str as the name suggests is having all the features that you will normally require while working with strings. The cleaner and readable the code the better, with this motive i've created this package which is open for changes. If you want to make any cahnges just make the changes and update README. I'll update everything and add the name to contributers list.

Installation

  1. If you want to use this library, you first need to install the Node.js.

  2. When you install node.js, will also be installed npm.

  3. Please run the following command.

npm install --save string-features

Usage

var str = require('string-features');

Examples

Following are few examples, by all means this is not an exaustive list and you can do much more with many methods available for your use.

str.dashCase("fooBar") // foo-bar

str.underscoreCase("BatteryAAA") // battery_aaa

str.underscoreCase("coldWind") //cold_wind

str.removeHTMLTags("<html> <body> Javascript<body> is not Java") // Javascript is not Java

str.removeSpecialCharacters("coding$%-is%& fun", true) // codingisfun

str.reverse("Hello world") // dlrow olleH

str.isEmpty("   ") //true

str.isUpperCase("Hello") //false

str.isUpperCase("HELLO") //true

str.removeExtraSpaces("     wrong   spacing       here ")) // wrong spacing here

str.count('abcabc', 'abc') // 2 

Methods

  • titleCase

Converts string to title case. First letter of every word is capital rest all are lower case

str.titleCase("title case") // Title Case
str.titleCase("TItle cAse") // Title Case
  • toCamelCase

Converts string to camel case

str.toCamelCase("coding-is-fun")      // codingIsFun
str.toCamelCase("coding is fun")      // codingIsFun
str.toCamelCase("coding$% is%& fun")  // codingIsFun
  • removeSpecialCharacters

Removes special characters from string. You can also choose to remove spaces from the string by passsing second param as true default is false.

str.removeSpecialCharacters("coding$%-is%& fun", true)  // codingisfun
str.removeSpecialCharacters("coding$%-is%& fun", false) // codingis fun
  • reverse Reverse the input string.
str.reverse("Coding") // gnidoC
  • isEmpty Return true if the string is made up of whitespace or is null/undefined.
str.isEmpty("   ") //true
str.isEmpty(null)  //true
  • isUpperCase Return true if the string is made up of all capital letters.

  • isLowerCase Return true if the string is made up of all lower letters.

  • isNumeric Return true if the string is made up of all numbers.

isNaN(123)         // false
isNaN('123')       // false
isNaN('1e10000')   // false (This translates to Infinity, which is a number)
isNaN('foo')       // true
isNaN('10px')      // true
  • removeExtraSpaces Removes extra spaced from string.
str.removeExtraSpaces(" this contains   spaces ")) // this contains spaces
  • contains Check if string contains a substring.
str.contains("coding is fun", fun) // true
  • count Returns count of sub string in string.
str.count('abcabc', 'abc')      // 2 
str.count("this is ice", "is")  // 2
  • dashCase Converts string to dashed string.
str.dashCase("fooBar")  // foo-bar
str.dashCase("FooBar")  // -foo-bar
  • removeHTMLTags Removed all HTML tags from a string.
str.removeHTMLTags("<html> <body> Javascript<body> is not Java") // Javascript is not Java 
  • underscoreCase Convert the input string to underscore case
 str.underscoreCase(BatteryAAA) // battery_aaa
 str.underscoreCase(coldWind)   // cold_wind
  • endsWith Check if input string ends with given substring
 str.endsWith("Hello World", "World") // True
 str.endsWith("Hello#", "#")   // True
 str.endsWith("This is a test", "test") // True
 str.endsWith("This is a test", "st") // True