A very simple JavaScript library written in vanilla js for scrambling text.

Overview

Scrambling Text

scrambling text sample

A very simple JavaScript library written in vanilla js for scrambling text.

Demo Page

main CI status Node.js Package status

Table of Contents

Installation

This module is distributed via npm which is bundled with node

npm i scrambling-text

Examples

Basic Example

// load 'scrambling-text' module.
import Scrambler from 'scrambling-text';

// create an instance of Scrambler.
const scrambler = new Scrambler();

// define a handler that is called whenever text is scrambled.
const handleScramble = (text) => {
  console.log(text);
}

// call scramble function with the text to be scrambled and handler.
scrambler.scramble('- Friedrich Nietzsche -', handleScramble);

// call scramble with the option to set the characters to use when scrambled.
scrambler.scramble(text, handleScramble, {
  characters: ['a', 'b', 'c'],
});

// Scrambler provides several characters.
console.log(Scrambler.CHARACTERS.DEFAULT);
console.log(Scrambler.CHARACTERS.ALPHABET);

React Example

import React, { useRef, useState, useEffect } from 'react';

// load 'scrambling-text' module.
import Scrambler from 'scrambling-text';

export default function ScramblingText() {
  // define the text to be scrambled as state.
  const [text, setText] = useState('- Friedrich Nietzsche -');
  // create an instance of Scrambler using useRef.
  const scramblerRef = useRef(new Scrambler());

  useEffect(() => {
    // call scramble function with the text to be scrambled and handler.
    scramblerRef.current.scramble(text, setText);
  }, []);

  return (
    <h1>
      {text}
    </h1>
  );
}

Demo Example

Sample code from demo site

LICENSE

MIT

You might also like...

Text annotation solution for websites. TypeScript and vanilla JavaScript version.

Text annotation solution for websites. TypeScript and vanilla JavaScript version.

Simple Text Annotations Use this small library when you need to add annotations to your website. Features show up / hide annotation on a element click

May 9, 2021

A lightweight vanilla JavaScript app for expanding and collapsing blocks of text.

A lightweight vanilla JavaScript app for expanding and collapsing blocks of text.

Read more button A lightweight vanilla javascript read more button for expanding and collapsing blocks of text. Features Choose how many text to keep

May 11, 2022

Obsidian plugin: Type text shortcuts that expand into javascript generated text.

Obsidian plugin: Type text shortcuts that expand into javascript generated text.

Obsidian Plugin - Text Expander JS (open beta) This Obsidian plugin allows the user to type text shortcuts that are replaced by (or "expanded into") j

Dec 27, 2022

This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way, this plugin works after page load.

This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way, this plugin works after page load.

Jquery-SingleImagePopup This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way

Aug 22, 2022

A form management library for SolidJS that is very lightweight and simple!

solform A form management library for SolidJS that is very lightweight and simple! Why solform Very easy, fast, lightweight and powerful! It has built

Nov 15, 2022

This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js

This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js. But in most cases, I would recommend you to use something like Express in a production project for productivity purposes.

Jul 19, 2022

A fast, vanilla JS customisable select box/text input plugin for modern browsers ⚡

choices A fast, vanilla, lightweight (~16kb gzipped 🎉 ), configurable select plugin for modern browsers. Similar to Select2 and Selectize but without

Aug 9, 2022

🌌 Fast, in-memory, full-text search engine written in TypeScript. Now in beta.

🌌  Fast, in-memory, full-text search engine written in TypeScript. Now in beta.

Installation You can install Lyra using npm, yarn, pnpm: npm i @nearform/lyra yarn add @nearform/lyra pnpm add @nearform/lyra Usage Lyra is quite simp

Dec 30, 2022
Comments
  • Optionally, change special characters to normal characters.

    Optionally, change special characters to normal characters.

    Hi, could I ask for a feature request?

    Adding an option to use normal alphabet characters for substitution instead of special characters. Something like:

    this.normalCharacters = ['a', 'b, 'c', 'd, 'e', 'f', … ];

    https://github.com/sogoagain/scrambling-text-js/blob/master/src/Scrambler.js#L3

    Thank you.

    opened by aitormendez 2
  • Controlling states

    Controlling states

    Hi there @sogoagain!

    The text scrambling you’ve implemented looks great.

    I’m trying to figure out whether it’s possible to control the states manually, instead of having to use a set timing. My use case is to display people cards in a game, and scramble random text properties, leaving people to respond based on their knowledge and insight offered by the other available (unscrambled) information – I would optimally then unscramble only after they answered, and not based on timing.

    I’m in no position to make any demands of course – any hints in the right direction would be appreciated!

    opened by Haraldson 1
Releases(1.2.0)
Owner
sogoagain
continuous improvement
sogoagain
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
An exercise in building a very minimal (and very stupid) in-memory SQL-like database for educational purposes.

Stupid Database This is an exercise in building a very minimal (and very stupid) in-memory SQL-like database for educational purposes. None of this co

Fabio Akita 196 Dec 20, 2022
A Very Good Documentation Site created by the Very Good Ventures Team 🦄

Very Good Docs Site Developed with ?? by Very Good Ventures ?? A Very Good Docs Site created by the Very Good Ventures Team. Generated by the Very Goo

Very Good Open Source 8 Nov 2, 2022
DateTimePickerComponent is a very lightweight and dependency-free web component written in pure JavaScript

DateTimePickerComponent Description DateTimePickerComponent is a very lightweight (just over 20KB) and dependency-free web component written in pure J

null 14 Dec 24, 2022
A lightweight scrollbar library written in vanilla javascript.

A lightweight, dependency-free scrollbar library written in vanilla javascript. Fully customisable via CSS Native scrolling behaviour preserved Vertic

Karl 56 Dec 4, 2022
A lightweight JavaScript library that renders text in a brilliant style by displaying strings of random characters before the actual text.

cryptoWriter.js A lightweight javascript library which creates brilliant text animation by rendering strings of random characters before the actual te

Keshav Bajaj 2 Sep 13, 2022
A Simple Text/Document Viewer written in JS

Doku Doku.js is a terminal ui text/document viewer that supports a custom documentation syntax called doky. Features Border colors. (all common termin

fezcoddy 5 Sep 9, 2022
Accordion Plugin written in Vanilla JavaScript.

Easy Accordion Accordion plugin written purely in JavaScript. Setup So, to start using the Easy Accordion plugin in your project, you can include the

Farhan Halai 1 Dec 16, 2020