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

osas-string-utils

v1.0.8

Published

A String Utility Package

Downloads

23

Readme

Osas-String-Utils

This is a mini string utility that aims to help you out with string manipulations

Usage

Installation

npm i osas-string-utils

Random Strings

Generate Random Strings Example

test.js

const {randStringGen } =require('osas-string-utils');

/***
 To generate any length of random strings,
 you send the length of string you intend to
 generate as the first arguement of the function
 then also the type which could be number only,
 alphabets only or alphanumeric
***/

const main = async() => {
    // using callbacks

  /*** 
To Generate only alphabets,
 you must supply the character "b" as the
 function's arguement
***/
  randStringGen(8, "b", (err, res)=>{
    if(err) console.log(err);
    else console.log(res);
  
  }); 
/***
The function above should output an
 8 character long random alphabet strings
***/




/*** 
To generate only number digits you must supply
 the number 1 as  string argument and also
 as the second function's arguement
***/
  randStringGen(4, "1", (err, res)=>{
     if(err) console.log(err);
     else console.log(res);
   
  });
/***
The function above should output a
 4 character long random numeric strings
***/






/***
To generate an alphanumeric set of strings
 you must pass "1b" as the function's
 second arguement
***/
randStringGen(0, "1b", (err, res)=>{
     if(err) console.log(err);
     else console.log(res); 
  
  });
/***
The function above should output an error because 0 is an invalid length
***/


randStringGen(12, "1b", (err, res)=>{
     if(err) console.log(err);
     else console.log(res); 
  
  });
/***
The function above should output a
 12 character long alphanumeric random string
***/








  //promises
  randStringGen(0, "b")
  .then((res)=>{
    console.log(res)
  })
  .catch((err)=>{
    console.log(err)
  })


  randStringGen(20, "1b")
  .then((res)=>{
    console.log(res)
  })
  .catch((err)=>{
    console.log(err)
  })
}




main();
  

String To Sentence Case

Convert String to Sentence Case Example

test.js

const {toSentenceCase } =require('osas-string-utils');




const main = async() => {
// Using Callbacks

 toSentenceCase("osagie osemwota anthony", (err, res)=>{
  if(err) console.log(err);
  else console.log(res);
}); 
/***
The example above should output
 Osagie Osemwota Anthony
***/
toSentenceCase("", (err, res)=>{
  if(err) console.log(err);
  else console.log(res);
}); // should output an error


toSentenceCase(0, (err, res)=>{
  if(err) console.log(err);
  else console.log(res);
}); // should output an error
}

// Using Promises
toSentenceCase(0)
.then((res)=>{
  console.log(res);
})
.catch((err)=>{
  console.log(err)
})// should output an error


toSentenceCase("")
  .then((res) => {
    console.log(res);
  })
  .catch((err) => {
    console.log(err);
  });// should output an error


  toSentenceCase("osagie osemwota anthony")
    .then((res) => {
      console.log(res);
    })
    .catch((err) => {
      console.log(err);
    });
/***
The example above should output
 Osagie Osemwota Anthony
***/

main();