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 🙏

© 2026 – Pkg Stats / Ryan Hefner

string-player

v1.2.2

Published

This a package for playing with string very easily

Downloads

50

Readme

String Player

There are various string Manipulation function and class what Can yuo use

LIKE:-

import { log, MakePriceString, mekeLinkString,GenerateOTP,repleCaracter } from "string-player"

functionality of GenerateOTP Class

by default it return 6 charecters unique otp each time

import {GenerateOTP,log} from 'string-player'

let otp=new GenerateOTP();

log(otp.getPin())//returns 271633
log(otp.getPin())//returns 474316
log(otp.getPin())//returns 706210

You can get opt of more or lest Carecter :-

import {GenerateOTP,log} from 'string-player'

let less=new GenerateOTP(4);// 4 Charecters 
let more=new GenerateOTP(9);// 9 Charecters 


let opt_of_4_charecters=less.getPin() //return unique value like 7927
let opt_of_9_charecters=more.getPin();//return unique value like 640821514;


console.log({opt_of_4_charecters,opt_of_9_charecters});
//prints
// { opt_of_4_charecters: 7927,opt_of_9_charecters: 640821514 }

functionality of repleCaracter

import { log, repleCaracter } from "string-player"


log(repleCaracter(`
export function checkTimeString(time) {
    if (typeof time != 'string') throw 'not a correct time ' + time
    if (!time.includes(':')) throw 'not a correct time ' + time
    if (time.length !== 5) throw 'not a correct time ' + time
    time = time.split(':')
    if (time.length !== 2) throw 'not a correct time array'
    if (Number(time[0]).toString().toLowerCase == 'nan') throw 'not a correct time[0] ' + time[0]
    if (Number(time[1]).toString().toLowerCase == 'nan') throw 'not a correct time[1] ' + time[1]
    if (time[0] < 0 || time[0] > 23) throw 'not a correct time[1] ' + time[0]
    if (time[1] < 0 || time[1] > 59) throw 'not a correct time[1] ' + time[1]
    // log( time[0] > 11 ? Number(time[0]) - 11 : time[0])
    let string = (time[0] > 12 ? Number(time[0]) - 12 : time[0]) + ':' + time[1] + ' ' + (time[0] > 11 ? 'PM' : 'AM');
    return string
}`
))

prints

export function checkTimeString&#40;time&#41; &#123;
    if &#40;typeof time != &#39;string&#39;&#41; throw &#39;not a correct time &#39; + time
    if &#40;!time.includes&#40;&#39;:&#39;&#41;&#41; throw &#39;not a correct time &#39; + time
    if &#40;time.length !== 5&#41; throw &#39;not a correct time &#39; + time
    time = time.split&#40;&#39;:&#39;&#41;
    if &#40;time.length !== 2&#41; throw &#39;not a correct time array&#39;
    if &#40;Number&#40;time&#91;0&#93;&#41;.toString&#40;&#41;.toLowerCase == &#39;nan&#39;&#41; throw &#39;not a correct time&#91;0&#93; &#39; + time&#91;0&#93;
    if &#40;Number&#40;time&#91;1&#93;&#41;.toString&#40;&#41;.toLowerCase == &#39;nan&#39;&#41; throw &#39;not a correct time&#91;1&#93; &#39; + time&#91;1&#93;
    if &#40;time&#91;0&#93; < 0 || time&#91;0&#93; > 23&#41; throw &#39;not a correct time&#91;1&#93; &#39; + time&#91;0&#93;      
    if &#40;time&#91;1&#93; < 0 || time&#91;1&#93; > 59&#41; throw &#39;not a correct time&#91;1&#93; &#39; + time&#91;1&#93;      
    // log&#40; time&#91;0&#93; > 11 ? Number&#40;time&#91;0&#93;&#41; - 11 : time&#91;0&#93;&#41;
    let string = &#40;time&#91;0&#93; > 12 ? Number&#40;time&#91;0&#93;&#41; - 12 : time&#91;0&#93;&#41; + &#39;:&#39; + time&#91;1&#93; + &#39; &#39; + &#40;time&#91;0&#93; > 11 ? &#39;PM&#39; : &#39;AM&#39;&#41;;
    return string
&#125;

repleCrAll

repleCrAll is use for repling string array

import { log, repleCaracter ,repleCrAll} from "string-player"

//repling 3 strings
let [functions , arrowFunctions,print]=repleCrAll(['function(){}', `()=>{}`, `console.log('hello')]`]);
//printing repled strings
console.log({ functions, arrowFunctions, print });

// printed Data
// {
//     functions: 'function&#40;&#41;&#123;&#125;',      
//     arrowFunctions: '&#40;&#41;=>&#123;&#125;',       
//     print: 'console.log&#40;&#39;hello&#39;&#41;&#93;'
// }

functionality of MakePriceString

import { log,  MakePriceString} from "string-player"

let a = 500;
a=await MakePriceString(a);
log(a)

//returns  500.00

functionality of mekeLinkString

import { log, mekeLinkString } from "string-player"

let a = 'https://www.your-website.com/a b c d f g e l k p n m o k j l i p q r s';

log(mekeLinkString(a))
//prints https://www.your-website.com/a-b-c-d-f-g-e-l-k-p-n-m-o-k-j-l-i-p-q-r-s

functionality of makeUrlWithParams

let reqData={
    command :'INIT',
    total_bytes:10240
} 
log(makeUrlWithParams('https://upload.twitter.com/1.1/media/upload.json',reqData))
//returns 'https://upload.twitter.com/1.1/media/upload.json?command=INIT&total_bytes=10240

functionality of breakJsonData

import { breakJsonData, log } from "./index.js"

let data=JSON.stringify({
    A:'A',
    B:'B',
    C:'C',
    D:'D',
    bol:true,
    fool:false,
    arr:["alert","WebTransport","wet"],
    e:"we"
})

log(data);
//prints
//{"A":"A","B":"B","C":"C","D":"D","bol":true,"fool":false,"arr":["alert","WebTransport","wet"],"e":"we"}


data= breakJsonData(data)
log(data);

//prints
// {
//     "A":"A",
//     "B":"B",
//     "C":"C",
//     "D":"D",
//     "bol":true,
//     "fool":false,
//     "arr":[
//     "alert",
//     "WebTransport",
//     "wet"
//     ],
//     "e":"we"
// }

From [email protected] you can parse object on breckjsondata
import { breakJsonData, log } from "./index.js"


let data = {
    0: 0,
    1: 1,
    2: 2,
    3: 3,
    4: 4,
    5: 5,
    6: 6,
    7: 7,
    8: 8,
    9: 9,
    10: 10
}

log(data);

/* 
it prints
{
    '0': 0,
    '1': 1,
    '2': 2,
    '3': 3,
    '4': 4,
    '5': 5,
    '6': 6,
    '7': 7,
    '8': 8,
    '9': 9,
    '10': 10
}
    
*/

You can contribute also by joining github-github Repository

use of Validator

import Validator from "./_lib/Validator.js";

let validate=new Validator({giveError:false});

console.log(validate.isAllEmty(['e','',null,undefined]));
//prints false 


console.log(validate.isAllEmty(['',null,undefined]));
//prints true

check email



import Validator from "./_lib/Validator.js";

let isEmail = val => (new Validator()).isEmail(val);
console.log(isEmail('[email protected]'));
//prints true;

console.log(isEmail('[email protected]'));
//prints false;

console.log(isEmail('[email protected]'));
//prints false;

console.log(isEmail('mubtasim@@gmail.com'));
//prints false;

console.log(isEmail('[email protected]'));
//prints false;


console.log(isEmail('[email protected]'));
//prints true;

console.log(isEmail('mubtasim@gmai,l.com'));
//prints false;

console.log(isEmail('[[email protected]]'));
//prints false;

console.log(isEmail('[email protected]'));
//prints false;

isValidUrl


import { isValidUrl } from "./index.js";

let startingTime=Date.now();

for (let i = 0; i <= 1000; i++) {
    console.log(isValidUrl('https://x.com/search?q=Building&src=trend_click&vertical=trends'));
    if (i===1000) {
        let totalTime =Date.now()-startingTime;
        console.log('totalTime of Validating 1000 url is '+(totalTime/(1000))+'s');
        console.log('totalTime of Validating 1 url is '+(totalTime/(1000*1000))+'s');
    }
}

//totalTime of Validating 1000 url is 0.795s
//totalTime of Validating 1 url is 0.000795s

for replacing spaces from string you can use replaceMultySpaceArray or replaceMultySpace

let textWithoutMultySpace = replaceMultySpace(' fd      sfsdf     ');

Your Support will inspire me to create better packages for You

***Follow Me ***