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-shuffle

v1.2.4

Published

A JS module for shuffling strings and other helper methods like alhpabet generation

Downloads

254

Readme

String-shuffle

A JS module for shuffling strings and other helper methods like alphabet generation

A quick reference

import * as shuffle from "string-shuffle";

console.log(shuffle.shuffleString("Hello World")); // dlH ooWler

console.log(shuffle.shuffleString("Hello World")); // rdlloH loWe

console.log(shuffle.shuffleString("Quick rown fox jumps over lazy dog")); // jvyilco owfxud nz  apuo rs rkeoQgm
console.log(shuffle.shuffleString("Quick rown fox jumps over lazy dog")); // jcf ro Qowkna goomvyxd puz er iusl

console.log(shuffle.shuffleString("[email protected]")); // [email protected]
console.log(shuffle.shuffleString("[email protected]")); // [email protected]

Other ways

import { shuffleString } from "string-shuffle";

console.log(shuffleString("Hello World")); // lHlWero odl
console.log(shuffleString("someRandomString")); // irdosaRenSomntgm
console.log(shuffleString("1234IsAnAmazingString@#$%^&*()")); // m41n(I&aA@Sn^i3%)sgzgi#2*rn$At

console.log(shuffleString("Hello World")); // lH oWlolrde
console.log(shuffleString("someRandomString")); // nitRsgoaSmrdeomn
console.log(shuffleString("1234IsAnAmazingString@#$%^&*()")); // t3nAnr@4Ii&n12gAgsa%m*(i$Sz)#^

Other included modules include

|Module|Functionality| |---|---| |alphabets| A method that contains all the lowercase,uppercase, numbers and symbols array| | lowerCaseLetters|List of all the Capital letters of the alphabet| | capitalize| A method to make the first letter of a word or statement to uppercase and retain others if they are not lowercase| | upperCaseLetters|List of all the lowercase letters of the alphabet| | numbers|List of numbers from 0-9| | symbols|Sample list of symbols| | generateRandomString| A method that generates a random strigg based on the number you pass as an argument| | generateShuffledPassword|Generates random paswords with combination of caps,lowercase,uppercase,numbers and symbols then shuffles the password to achieve randomness| | generateUnshuffledPassword|Generates the normal concatenated cobinaton of characters| | shuffleString|A method that shuffles the string you pass to it as an argument|

alphabets module

import { alphabets } from "string-shuffle";

const { alphabet, lowerCaseLetters, numbers, symbols, upperCaseLetters } =
  alphabets();

console.log(alphabet.join("")); //ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!"#$%&'()*+,-./

console.log(lowerCaseLetters.join("")); //abcdefghijklmnopqrstuvwxyz

console.log(numbers.join("")); //0123456789

Still the modules can be imported from the main package

- import { alphabets } from "string-shuffle";
+ import {lowerCaseLetters,numbers,symbols,upperCaseLetters} from "string-shuffle";

- const { alphabet, lowerCaseLetters, numbers, symbols, upperCaseLetters } = alphabets();

- console.log(alphabet.join("")); //ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!"#$%&'()*+,-./

console.log(lowerCaseLetters.join("")); //abcdefghijklmnopqrstuvwxyz

console.log(numbers.join("")); //0123456789

capitalize module

import { capitalize } from "string-shuffle";

console.log(capitalize("hello world")); // Hello world

console.log(capitalize("tetris")); // Tetris

console.log(capitalize("my name is a test name")); // My name is a test name

console.log(capitalize("A")); // A

console.log(capitalize("ABC")); // ABC

console.log(capitalize("123")); // 123

generateRandomString module

By default it shuffles the string

import { generateRandomString } from "string-shuffle";

console.log(generateRandomString(5)); // ye!o

console.log(generateRandomString(10)); // #m)tX&Kza8

console.log(generateRandomString(15)); // eTQa1ts$pA8*nwI

console.log(generateRandomString(20)); // Fryo*JEn1i&2Dp7rgqFK

console.log(generateRandomString(30)); // 8+Zs4,XaodpQxHMp,xUw8if0dy)TF+

generateUnshuffledPassword module

Disclaimer: Use this at your own risk. It's here for mock apps or just simple programs so be careful on the usage

import { generateUnshuffledPassword } from "string-shuffle";

console.log(generateUnshuffledPassword({})); // ey99
console.log(generateUnshuffledPassword({ lower: 1, upper: 2, num: 3, symb: 4 })); // pRI.##*369

console.log(generateUnshuffledPassword({ lower: 2, upper: 2, num: 2, symb: 2 })); // jmKE"+89

console.log(generateUnshuffledPassword({ lower: 4, upper: 4, num: 4, symb: 4 })); // gilwLEJW#/,%6959

console.log(generateUnshuffledPassword({ lower: 5, upper: 5, num: 5, symb: 5 })); // rkujyDFOUS%,.)'71677

generateShuffledPassword module

import { generateShuffledPassword, shuffleString } from "string-shuffle";

console.log(generateShuffledPassword(shuffleString)({})); // 3n3r

console.log(generateShuffledPassword(shuffleString)({ lower: 1, upper: 2, num: 3, symb: 4 })); // o9/B3*M&3*

console.log(generateShuffledPassword(shuffleString)({ lower: 2, upper: 2, num: 2, symb: 2 })); // O5g!8A/c

console.log(generateShuffledPassword(shuffleString)({ lower: 4, upper: 4, num: 4, symb: 4 })); // 3p!rP.YI*90z*n7Z

console.log(generateShuffledPassword(shuffleString)({ lower: 5, upper: 5, num: 5, symb: 5 })); // zS7&6*oKk7Wx)Nl'N18.