crambleturbo
v1.0.0
Published
CrambleTurbo: A fun text scrambling library. NOT for security-critical applications.
Readme
::: container
CrambleTurbo Documentation
Welcome to the documentation for CrambleTurbo, a versatile text scrambling tool designed for creative transformations and fun text animations. Whether you want to jumble up a word or animate text transitions on your web pages, CrambleTurbo provides a variety of methods to suit your needs.
::: disclaimer
Disclaimer
CrambleTurbo is an experimental tool intended for creative and non-critical applications. DO NOT use this for any critical security options or sensitive text transformations. Its algorithms are not designed for secure encryption or data protection. :::
How to Use
To integrate CrambleTurbo into your project, follow these steps based on your environment:
1. Install via npm
For Node.js projects or environments that support npm:
npm install crambleturbo
2. Import CrambleTurbo into Your Project
After installation, you can import the module into your JavaScript files.
For CommonJS (Node.js):
const CrambleTurbo = require('crambleturbo');
const ct = new CrambleTurbo({ mode: 'full', duration: 2000 });
const scrambled = ct.scrambleText("Hello World");
console.log("Scrambled Text:", scrambled);
For ES Modules:
import CrambleTurbo from 'crambleturbo';
const ct = new CrambleTurbo({ mode: 'preserveFirstLast', duration: 3000 });
const scrambled = ct.scrambleText("Hello World");
console.log("Scrambled Text:", scrambled);
Using CrambleTurbo in Browser with Module Bundlers
If you're using bundlers like Webpack or Parcel, import CrambleTurbo as follows:
// Import CrambleTurbo
import CrambleTurbo from 'crambleturbo';
// Create an instance and scramble text
const ct = new CrambleTurbo({ mode: 'rotate', duration: 2500 });
const scrambled = ct.scrambleText("Hello World");
console.log("Scrambled Text:", scrambled);
API Overview
The CrambleTurbo class provides several methods to transform and
animate text:
- Constructor(options)
Options:mode: 'full' | 'preserveFirstLast' | 'rotate' | 'randomCase' (default: 'full')duration: Animation duration in milliseconds (default: 2000)
- scrambleText(text)
Scrambles an entire string by splitting it into words and processing each word based on the chosen mode. - scrambleWord(word, mode)
Scrambles a single word according to the specified mode. - animateScramble(element, newText, callback)
Animates the transition from random characters to the final scrambled text on a DOM element. - tickle()
A fun method that logs a silly, ticklish message (not intended for production use).
Example Code
Below are some examples demonstrating how to use CrambleTurbo:
1. Basic Text Scrambling
const CrambleTurbo = require('crambleturbo');
const ct = new CrambleTurbo({ mode: 'full' });
const originalText = "Hello World";
const scrambled = ct.scrambleText(originalText);
console.log("Original:", originalText);
console.log("Scrambled:", scrambled);
2. Preserving the First and Last Characters
const ct = new CrambleTurbo({ mode: 'preserveFirstLast' });
console.log(ct.scrambleText("Example")); // E.g., "Examlpe"
3. Animated Scramble in the Browser
<!-- Include your bundled script or CrambleTurbo via a module bundler -->
<div id="demo">Hello World</div>
<script>
const demoEl = document.getElementById("demo");
const ct = new CrambleTurbo({ mode: 'randomCase', duration: 3000 });
const scrambledText = ct.scrambleText(demoEl.textContent);
ct.animateScramble(demoEl, scrambledText, () => {
console.log("Animation complete!");
});
</script>
Frequently Encountered Issues
Here are some common issues you might face when using CrambleTurbo:
- Issue: "CrambleTurbo is not defined."
Solution: Ensure that you have installed the module via npm and imported it correctly. - Issue: "Unexpected output from scrambleText."
Solution: Verify that themodeoption is set correctly. Options include 'full', 'preserveFirstLast', 'rotate', and 'randomCase'.
Additional Information
The CrambleTurbo module is built primarily for fun text
transformations and creative animations. It is not designed for
cryptographic or security-critical applications. Use it responsibly and
avoid deploying it in environments that require secure text processing.
More Resources
For further details and advanced usage examples, explore additional documentation or check out our API overview.
API Overview » :::
