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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@igorskyflyer/scramble

v1.1.0

Published

🃏 Scrambles (rearranges randomly) Strings and Arrays. 🎋

Readme

📃 Table of Contents

🤖 Features

  • 🎯 Scrambles words while keeping first and last letters intact for readability
  • 🧩 Shuffles array elements with a proven Fisher Yates algorithm
  • ✂️ Optional whitespace trimming before scrambling text
  • 🛡️ Validates inputs and throws clear, descriptive errors
  • ⚡ Zero dependencies for lightweight, fast execution
  • 🔄 Pure functions that don’t mutate original data
  • 🧠 Works with any array type thanks to TypeScript generics
  • 📝 Well-documented with clear parameter and return descriptions
  • 🧪 Perfect for games, puzzles, mock data, and creative text effects

🕵🏼 Usage

Install it by executing any of the following, depending on your preferred package manager:

pnpm add @igorskyflyer/scramble
yarn add @igorskyflyer/scramble
npm i @igorskyflyer/scramble

🤹🏼 API

scrambleString(input: string, options?: IStringOptions): string

Scrambles the characters of each word in a given string.

input - The string to be scrambled.

ℹ️ NOTE

Since Fisher-Yates algorithm is used for scrambling, a length of > 3 is needed for a word to be able to get scrambled.

options - Options for scrambling, optional.

options are defined via an interface IStringOptions:

interface IStringOptions {
  trimWhitespace?: boolean
}

trimWhitespace, if true all whitespace is removed from the input string prior to scrambling its contents.

Returns the scrambled string.

Will throw an error if the input is not a string.


scrambleArray<ArrayType>(input: ArrayType[]): ArrayType[]

Scrambles the elements of an array.

input - The array to be scrambled.

Returns the scrambled array.

Will throw an error if the input is not an array.

🗒️ Examples

example.mts

import { scrambleString, scrambleArray } from '@igorskyflyer/scramble'

// these are just sample outputs
// since each invocation reorders
// elements randomly

console.log(scrambleString(
  'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
)) // returns 'Leorm isupm dloor sit aetm, ccotnsueetr asdincipig eitl.'

console.log(scrambleString(
  'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', { trimWhitespace: true }
)) // returns 'Lpetssgerodcsctcmuaunelrteiisoomirlait,toindmipe.'

console.log(scrambleArray([1, 2, 3, 4, 5, 6, 7, 8])) // [5, 7, 1, 4, 2, 8, 3, 6]

📝 Changelog

📑 The changelog is available here, CHANGELOG.md.

🪪 License

Licensed under the MIT license which is available here, MIT license.

💖 Support

🧬 Related

@igorskyflyer/uarray

🎉 Provides UArray, an Array type that supports negative indices/indexes, just wrap your regular JavaScript array with UArray() and you are all set! 🙌

@igorskyflyer/magic-string

🧵 An expressive and chainable library for advanced string manipulations. Supports appending, prepending, trimming, quoting, and path formatting with customizable whitespace handling. Makes advanced String manipulations a piece of cake. 🦥

@igorskyflyer/strip-html

🥞 Removes HTML code from the given string. Can even extract text-only from the given an HTML string. ✨

@igorskyflyer/extendable-string

🦀 ExtendableString allows you to create strings on steroids that have custom transformations applied to them, unlike common, plain strings. 🪀

@igorskyflyer/duoscribi

✒ DúöScríbî allows you to convert letters with diacritics to regular letters. 🤓

👨🏻‍💻 Author

Created by Igor Dimitrijević (@igorskyflyer).