Skip to content

Node package to mutate text into various formats.

License

Notifications You must be signed in to change notification settings

devayes/textmutant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

textmutant

Node package to mutate text into various other forms.

Install:

$ npm install textmutant

Examples:

const mutant = require('textmutant');

let text = 'Hello, how are you.';

console.log('Upper:', mutant.upper(text)); // Upper: HELLO, HOW ARE YOU.

console.log('Flip:', mutant.flip(text)); // Flip: ˙noʎ ǝɹɐ ʍoɥ 'ollǝH

console.log('Reverse:', mutant.reverse(text)); // Reverse: .uoy era woh ,olleH

console.log('Random:', mutant.random(text)); // Random: ˙oaleol,yw hu ro .He

console.log('Teen:', mutant.teen(text)); // Teen: HELlo, hOw are yOU.

console.log('Color to hex:', mutant.colortohex('hotpink')); // Color to hex: #ff69b4

var bin = mutant.toBinary(text);
console.log('Text to binary:', bin); // Text to binary: [binary stuff]
console.log('Binary to text:', mutant.fromBinary(bin)); // Binary to text: Hello, how are you.

Socket.io example

Mutate incoming text using short cuts (ie: /reverse text to reverse).

const mutant = require('textmutant');

// input example: /reverse Hello, how are you 
// output: .uoy era woh ,olleH
if (msg.charAt(0) == '/') {
    let func = msg.match(/^\/([a-zA-Z0-9]+)\s+/);
    if (func.length >= 1) {
        func = func[1]; 
    	if (func.length && typeof mutant[func] === 'function') { 
        	data.msg = mutant[func](msg.replace('/'+func+' ', ''));
    	}
    }
}

About

Node package to mutate text into various formats.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published