{"id":18396718,"url":"https://github.com/igorskyflyer/npm-scramble","last_synced_at":"2026-01-06T16:39:24.267Z","repository":{"id":251644743,"uuid":"837749636","full_name":"igorskyflyer/npm-scramble","owner":"igorskyflyer","description":"🃏 Scrambles (rearranges randomly) Strings and Arrays. 🎋","archived":false,"fork":false,"pushed_at":"2024-08-04T20:10:49.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-07T09:37:33.895Z","etag":null,"topics":["algorithm","array","back-end","fisher-yates-shuffle","igorskyflyer","javascript","js","node","random","scramble","shuffle","string","ts","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@igor.dvlpr/scramble","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/igorskyflyer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"igorskyflyer"}},"created_at":"2024-08-03T23:04:00.000Z","updated_at":"2024-08-04T20:10:52.000Z","dependencies_parsed_at":"2024-08-04T19:44:19.850Z","dependency_job_id":"face6ae6-85ac-477f-b8b5-0e4a4cec3674","html_url":"https://github.com/igorskyflyer/npm-scramble","commit_stats":null,"previous_names":["igorskyflyer/npm-scramble"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorskyflyer%2Fnpm-scramble","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorskyflyer%2Fnpm-scramble/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorskyflyer%2Fnpm-scramble/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorskyflyer%2Fnpm-scramble/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igorskyflyer","download_url":"https://codeload.github.com/igorskyflyer/npm-scramble/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245756354,"owners_count":20667144,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","array","back-end","fisher-yates-shuffle","igorskyflyer","javascript","js","node","random","scramble","shuffle","string","ts","typescript"],"created_at":"2024-11-06T02:14:38.957Z","updated_at":"2026-01-06T16:39:24.261Z","avatar_url":"https://github.com/igorskyflyer.png","language":"TypeScript","funding_links":["https://ko-fi.com/igorskyflyer"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/igorskyflyer/npm-scramble/main/media/scramble.png\" alt=\"Icon of ScRaMbLe\" width=\"256\" height=\"256\"\u003e\n  \u003ch1\u003eScRaMbLe\u003c/h1\u003e\n\u003c/div\u003e\n\n\u003cbr\u003e\n\n\u003ch4 align=\"center\"\u003e\n  🃏 Scrambles (rearranges randomly) Strings and Arrays. 🎋\n\u003c/h4\u003e\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## 📃 Table of Contents\n\n- [Features](#-features)\n- [Usage](#-usage)\n- [API](#-api)\n  - [scrambleString()](#scramblestringinput-string-options-istringoptions-string)\n  - [scrambleArray()](#scramblearrayarraytypeinput-arraytype-arraytype)\n- [Examples](#️-examples)\n- [Changelog](#-changelog)\n- [Support](#-support)\n- [License](#-license)\n- [Related](#-related)\n- [Author](#-author)\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## 🤖 Features\n\n- 🎯 Scrambles words while keeping first and last letters intact for readability\n- 🧩 Shuffles array elements with a proven Fisher Yates algorithm\n- ✂️ Optional whitespace trimming before scrambling text\n- 🛡️ Validates inputs and throws clear, descriptive errors\n- ⚡ Zero dependencies for lightweight, fast execution\n- 🔄 Pure functions that don’t mutate original data\n- 🧠 Works with any array type thanks to TypeScript generics\n- 📝 Well-documented with clear parameter and return descriptions\n- 🧪 Perfect for games, puzzles, mock data, and creative text effects\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## 🕵🏼 Usage\n\nInstall it by executing any of the following, depending on your preferred package manager:\n\n```bash\npnpm add @igorskyflyer/scramble\n```\n\n```bash\nyarn add @igorskyflyer/scramble\n```\n\n```bash\nnpm i @igorskyflyer/scramble\n```\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## 🤹🏼 API\n\n### `scrambleString(input: string, options?: IStringOptions): string`\n\n*Scrambles the characters of each word in a given string.*  \n\n`input` - The string to be scrambled.  \n\n\u003cbr\u003e\n\n\u003e ℹ️ **NOTE**\n\u003e\n\u003e Since `Fisher-Yates` algorithm is used for scrambling, a length of \u003e 3 is needed for a word to be able to get scrambled.\n\u003e\n\n\u003cbr\u003e\n\n`options` - Options for scrambling, **optional**.\n\n\u003cbr\u003e\n\n`options` are defined via an interface `IStringOptions`:\n\n```ts\ninterface IStringOptions {\n  trimWhitespace?: boolean\n}\n```\n\n\u003cbr\u003e\n\n`trimWhitespace`, if true all whitespace is removed from the input string prior to scrambling its contents.\n\n\u003cbr\u003e\n\nReturns the scrambled string.  \n\nWill throw an error if the input is not a string.\n\n---\n\n### `scrambleArray\u003cArrayType\u003e(input: ArrayType[]): ArrayType[]`\n\n*Scrambles the elements of an array.*  \n\n`input` - The array to be scrambled.  \n\n\u003cbr\u003e\n\nReturns the scrambled array.  \n\nWill throw an error if the input is not an array.\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## 🗒️ Examples\n\n`example.mts`\n```ts\nimport { scrambleString, scrambleArray } from '@igorskyflyer/scramble'\n\n// these are just sample outputs\n// since each invocation reorders\n// elements randomly\n\nconsole.log(scrambleString(\n  'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'\n)) // returns 'Leorm isupm dloor sit aetm, ccotnsueetr asdincipig eitl.'\n\nconsole.log(scrambleString(\n  'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', { trimWhitespace: true }\n)) // returns 'Lpetssgerodcsctcmuaunelrteiisoomirlait,toindmipe.'\n\nconsole.log(scrambleArray([1, 2, 3, 4, 5, 6, 7, 8])) // [5, 7, 1, 4, 2, 8, 3, 6]\n\n```\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## 📝 Changelog\n\n📑 The changelog is available here, [CHANGELOG.md](https://github.com/igorskyflyer/npm-scramble/blob/main/CHANGELOG.md).\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## 🪪 License\n\nLicensed under the MIT license which is available here, [MIT license](https://github.com/igorskyflyer/npm-scramble/blob/main/LICENSE).\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## 💖 Support\n\n\u003cdiv align=\"center\"\u003e\n  I work hard for every project, including this one and your support means a lot to me!\n  \u003cbr\u003e\n  Consider buying me a coffee. ☕\n  \u003cbr\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://ko-fi.com/igorskyflyer\" target=\"_blank\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/igorskyflyer/igorskyflyer/main/assets/ko-fi.png\" alt=\"Donate to igorskyflyer\" width=\"180\" height=\"46\"\u003e\u003c/a\u003e\n  \u003cbr\u003e\n  \u003cbr\u003e\n  \u003cem\u003eThank you for supporting my efforts!\u003c/em\u003e 🙏😊\n\u003c/div\u003e\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## 🧬 Related\n\n[@igorskyflyer/uarray](https://www.npmjs.com/package/@igorskyflyer/uarray)\n\n\u003e _🎉 Provides UArray, an Array type that supports negative indices/indexes, just wrap your regular JavaScript array with UArray() and you are all set! 🙌_\n\n\u003cbr\u003e\n\n[@igorskyflyer/magic-string](https://www.npmjs.com/package/@igorskyflyer/magic-string)\n\n\u003e _🧵 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. 🦥_\n\n\u003cbr\u003e\n\n[@igorskyflyer/strip-html](https://www.npmjs.com/package/@igorskyflyer/strip-html)\n\n\u003e _🥞 Removes HTML code from the given string. Can even extract text-only from the given an HTML string. ✨_\n\n\u003cbr\u003e\n\n[@igorskyflyer/extendable-string](https://www.npmjs.com/package/@igorskyflyer/extendable-string)\n\n\u003e _🦀 ExtendableString allows you to create strings on steroids that have custom transformations applied to them, unlike common, plain strings. 🪀_\n\n\u003cbr\u003e\n\n[@igorskyflyer/duoscribi](https://www.npmjs.com/package/@igorskyflyer/duoscribi)\n\n\u003e _✒ DúöScríbî allows you to convert letters with diacritics to regular letters. 🤓_\n\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n## 👨🏻‍💻 Author\nCreated by **Igor Dimitrijević** ([*@igorskyflyer*](https://github.com/igorskyflyer/)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figorskyflyer%2Fnpm-scramble","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figorskyflyer%2Fnpm-scramble","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figorskyflyer%2Fnpm-scramble/lists"}