Observed since 20 Oct, 22:33 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
@0x04/string-mutilator
A JavaScript library for mutilate strings.
A JavaScript library for mutilate strings.
Most of the code from this project was created during a personal codegolf competition to distort the appearance of strings as much as possible but without actually destroying their contents.
So the name mutilator come into my mind.
mutilator (plural mutilators)
- Agent noun of mutilate; one who mutilates.
This sounds unnecessarily brutal for now, but I assure you that no strings will be harmed permanently, as long as the functions are used correctly. :smirk:
So I decided to combine these "strange" functions into one library. More or less just for fun.
A comprehensive demo of all functions can be found in
the demonstration of this library/package in the demo project
pseudeo-chiperer.
Functions for manipulating the letter case of strings.
Functions for compressing (pack/unpack etc.) strings.
Functions for mutilating strings.
Functions for handle unicode stuff.
stringFlip the character bits of a string. The 16 character bits of 'A' are
00000000 01000001 - if we flip the bits (so every 0 becomes 1 and vice
versa) they look like this 11111111 10111110. This means that 'A'
(U+0041) becomes 'ᄒ' (U+FFBE).
stringApplies toMANS to all characters with a random type.
For example 'Hello World' turns into '𝐇𝖾𝓵𝗹𝘰 𝔚𝗈𝒓𝔩𝔡'.
stringJumble the letters of all words in a string, except the first and last one, to keep it readable.
stringReverse the character bits of a string. The 16 character bits of 'A' are
00000000 01000001 - if we reverse the bits they look like this
10000010 00000000. This means that 'A' (U+0041) becomes '舀'
(U+8200).
stringReverse a string.
stringCreate a heavy metal like rockdot string.
stringRotate the character indexes of a string by 13 digits.
stringRandomize the order of the characters in a string.
stringRotate the character bits of a string. The 16 character bits of 'A' are
00000000 01000001 - if we shift the bits by -4 n digits they look like
this 00010000 00000100. This means that 'A' (U+0041) becomes 'င'
(U+1004).
stringShift the characters of a string by n digits.
stringConvert A-Z to Mathematical Alphanumeric Symbols.
List of type values:
type | Unicode name |
|---|---|
| 0 | Mathematical Bold * |
| 1 | Mathematical Italic * |
| 2 | Mathematical Bold Italic * |
| 3 | Mathematical Script Capital * |
| 4 | Mathematical Bold Script * |
| 5 | Mathematical Fraktur * |
| 6 | Mathematical Double-Struck * |
| 7 | Mathematical Bold Fraktur * |
| 8 | Mathematical Sans-Serif * |
| 9 | Mathematical Sans-Serif Bold * |
| 10 | Mathematical Sans-Serif Italic * |
| 11 | Mathematical Sans-Serif Bold Italic * |
| 12 | Mathematical Monospace * |
Functions for manipulating the letter case of strings.
stringstringstringstringstringstringstringstringInvert the case of letters in a string.
Kind: inner method of stringMutilator/charCase
| Param | Type | Default | Description |
|---|---|---|---|
| string | string | The string to be case inverted. | |
| [every] | number | 0 | Only invert every n letter. |
Example
stringMutilator.charCase.invert('Hello World!');
// > 'hELLO wORLD!'
stringChange the case of given string to "Snake Case".
Kind: inner method of stringMutilator/charCase
| Param | Type |
|---|---|
| string | string |
Example
stringMutilator.charCase.snakeCase('Hello World');
// > 'hello_world'
stringChange the case of the given string to "Camel Case".
Kind: inner method of stringMutilator/charCase
| Param | Type |
|---|---|
| string | string |
Example
stringMutilator.charCase.camelCase('Hello World');
// > 'helloWorld'
stringChange the case of the given string to "Kebap Case".
Kind: inner method of stringMutilator/charCase
| Param | Type |
|---|---|
| string | string |
Example
stringMutilator.charCase.kebabCase('Hello World');
// > 'hello-world'
stringChange the case of the given string to "Dot Case".
Kind: inner method of stringMutilator/charCase
| Param | Type |
|---|---|
| string | string |
Example
stringMutilator.charCase.dotCase('Hello World');
// > 'hello.world'
stringChange the case of the given string to "Pascal Case".
Kind: inner method of stringMutilator/charCase
| Param | Type |
|---|---|
| string | string |
Example
stringMutilator.charCase.pascalCase('Hello World');
// > 'HelloWorld'
stringChange the case of the given string to "Capitalized".
Kind: inner method of stringMutilator/charCase
| Param | Type |
|---|---|
| string | string |
Example
stringMutilator.charCase.capitalize('hello world');
// > 'Hello World'
Functions for compressing (pack/unpack etc.) strings.
stringstringstringstringPack all characters of a 8-bit string.
Kind: inner method of stringMutilator/compressor
| Param | Type | Description |
|---|---|---|
| string | string | A 8-bit string to pack. |
Example
stringMutilator.compressor.pack('Hello World!');
// > '䡥汬漠坯牬搡'
stringUnpack a packed string.
Kind: inner method of stringMutilator/compressor
| Param | Type | Description |
|---|---|---|
| string | string | The packed string to unpack. |
Example
stringMutilator.compressor.unpack('䡥汬漠坯牬搡');
// > 'Hello World!'
stringReturn the given, packed string with the unpack signature.
Kind: inner method of stringMutilator/compressor
| Param | Type | Default | Description |
|---|---|---|---|
| string | string | The packed string to signature. | |
| [withEval] | boolean | false | Determine if the result includes a eval command for executing code. |
Example
stringMutilator.compressor.signature('䡥汬漠坯牬搡');
// > 'unescape(escape("䡥汬漠坯牬搡").replace(/u(..)/g, "$1%");'
Functions for mutilating strings.
Functions for handle unicode stuff.
stringstringstringFix unpaired high/low surrogates by adding a blank high/low surrogate
(U+D800 or U+DC00) to the designated location. An unpaired surrogate can
lead to problems, for example by copying it to the clipboard could result in
a Replacement Character � (U+FFFD). For example if the string is
'\uD801' it will be altered to '\uD801\uDC00' ('𐐀') or '\uDE80' to
'\uD800\uDE80' ('𐊀').
Kind: inner method of stringMutilator/unicode
See: https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
| Param | Type | Description |
|---|---|---|
| string | string | The input string |
Example
stringMutilator.unicode.fixSurrogates('Test: \uD801 \uDE80');
// > 'Test: 𐐀 𐊀'
stringRemove the by fixSurrogates added blank high/low surrogates.
Kind: inner method of stringMutilator/unicode
| Param | Type | Description |
|---|---|---|
| string | string | The input string |
Example
stringMutilator.unfixSurrogates('Test: 𐐀 𐊀');
// > 'Test: \uD801 \uDE80'
stringFlip the character bits of a string. The 16 character bits of 'A' are
00000000 01000001 - if we flip the bits (so every 0 becomes 1 and vice
versa) they look like this 11111111 10111110. This means that 'A'
(U+0041) becomes 'ᄒ' (U+FFBE).
Kind: global function
| Param | Type | Description |
|---|---|---|
| string | string | The input string. |
Example
stringMutilator.flipBits('Hello World!');
// > 'ᄋレモモミᄄミヘモロ'
stringApplies toMANS to all characters with a random type.
For example 'Hello World' turns into '𝐇𝖾𝓵𝗹𝘰 𝔚𝗈𝒓𝔩𝔡'.
Kind: global function
| Param | Type | Default | Description |
|---|---|---|---|
| string | string | The input string | |
| [exclude] | array | [ 1, 2 ] | Exclude specific type of toMANS |
Example
stringMutilator.gobbledygook('Hello World');
// > 𝐇𝖾𝓵𝗹𝘰 𝔚𝗈𝒓𝔩𝔡
stringJumble the letters of all words in a string, except the first and last one, to keep it readable.
Kind: global function
See: https://www.mnn.com/lifestyle/arts-culture/stories/why-your-brain-can-read-jumbled-letters
| Param | Type | Default | Description |
|---|---|---|---|
| string | string | The input string. | |
| [runs] | number | 3 | The number of attempts to get a real randomized word string. |
Example
stringMutilator.jumble('Hello World!');
// > 'Hlelo Wrlod!'
stringReverse the character bits of a string. The 16 character bits of 'A' are
00000000 01000001 - if we reverse the bits they look like this
10000010 00000000. This means that 'A' (U+0041) becomes '舀'
(U+8200).
Kind: global function
| Param | Type | Description |
|---|---|---|
| string | string | The input string. |
Example
stringMutilator.reverseBits('Hello World!');
// > 'ሀꘀ㘀㘀Ѐ一㘀☀萀'
stringReverse a string.
Kind: global function
| Param | Type | Description |
|---|---|---|
| string | string | The input string. |
Example
stringMutilator.reverse('Hello World!');
// > '!dlroW olleH'
stringCreate a heavy metal like rockdot string.
Kind: global function
See
| Param | Type | Default | Description |
|---|---|---|---|
| string | string | The string to rockdotize. | |
| [regexp] | RegExp | <RegExp /\w/gi> | A RegExp to select every character that should get rockdotized. |
Example
stringMutilator.rockdotize('Hello World!');
// > 'Ḧël̈l̈ö Ẅör̈l̈d̈!'
stringRotate the character indexes of a string by 13 digits.
Kind: global function
See: https://en.wikipedia.org/wiki/ROT13
| Param | Type | Description |
|---|---|---|
| string | string | The input string. |
Example
stringMutilator.rot13('Hello World!');
// > 'Uryyb Jbeyq!'
stringRandomize the order of the characters in a string.
Kind: global function
| Param | Type | Description |
|---|---|---|
| string | string | The string to scramble. |
Example
stringMutilator.scramble('Hello World!');
// > 'WorH!llo led'
stringRotate the character bits of a string. The 16 character bits of 'A' are
00000000 01000001 - if we shift the bits by -4 n digits they look like
this 00010000 00000100. This means that 'A' (U+0041) becomes 'င'
(U+1004).
Kind: global function
| Param | Type | Default | Description |
|---|---|---|---|
| string | string | The input string. | |
| [n] | number | 1 | Number of digits to rotate the character bit. Positive for right rotation, negative for left rotation. |
stringShift the characters of a string by n digits.
Kind: global function
| Param | Type | Default | Description |
|---|---|---|---|
| string | string | The string to shift. | |
| [n] | number | 1 | Number of digits to rotate the characters. Positive for right rotation, negative for left rotation. |
Example
stringMutilator.shift('Hello World!', 3);
// > 'lo World!Hel'
stringConvert A-Z to Mathematical Alphanumeric Symbols.
List of type values:
type | Unicode name |
|---|---|
| 0 | Mathematical Bold * |
| 1 | Mathematical Italic * |
| 2 | Mathematical Bold Italic * |
| 3 | Mathematical Script Capital * |
| 4 | Mathematical Bold Script * |
| 5 | Mathematical Fraktur * |
| 6 | Mathematical Double-Struck * |
| 7 | Mathematical Bold Fraktur * |
| 8 | Mathematical Sans-Serif * |
| 9 | Mathematical Sans-Serif Bold * |
| 10 | Mathematical Sans-Serif Italic * |
| 11 | Mathematical Sans-Serif Bold Italic * |
| 12 | Mathematical Monospace * |
Kind: global function
See: https://unicode-table.com/en/blocks/mathematical-alphanumeric-symbols
| Param | Type | Default | Description |
|---|---|---|---|
| string | string | The input string. | |
| [type] | number | 0 | A number between 0 and 12. |
Example
stringMutilator.toMANS('Hello World!', 1);
// > '𝐻𝑒𝑙𝑙𝑜 𝑊𝑜𝑟𝑙𝑑.'
An involutory function, is a function f that is its own inverse.
Example
import { rot13 } from '@0x04/string-mutilator';
rot13(rot13('Hello World!')) === 'Hello World!';
// > true
Example
import { shift } from '@0x04/string-mutilator';
shift(shift('Hello World!', 5), -5) === 'Hello World!';
// > true
Examples
import { compressor } from '@0x04/string-mutilator';
compressor.unpack(compressor.pack('Hello World!')) === 'Hello World!';
// > true
import { jumble } from '@0x04/string-mutilator';
jumble(jumble('Hello World!')) === 'Hello World!';
// > false
To use it in your project
$ npm install --save @0x04/string-mutilator
To use it globally
$ npm install --global @0x04/string-mutilator
$ string-mutilator --help
Functions for mutilating strings.
Usage
$ string-mutilator <function> <string> [argument]...
Functions
charCase.invert
compressor.pack
compressor.unpack
compressor.signature
charCase.snakeCase
charCase.camelCase
charCase.kebabCase
charCase.dotCase
charCase.pascalCase
charCase.capitalize
flipBits
gobbledygook
jumble
reverse
reverseBits
rockdotize
rot13
scramble
shift
shiftBits
toMANS
unicode.fixSurrogates
unicode.unfixSurrogates
Examples
$ string-mutilator shift "Hello World!" 6
$ string-mutilator charCase.invert "Hello World!"
$ string-mutilator toMANS "Hello World!" 4
© 2019 by Oliver Kühn. Released under the MIT license.
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
@babel/cliEnvironment{
"local_name": "@babel/cli",
"alias": false,
"peer_metadata": null
} | 7.5.5 | development |
@babel/coreEnvironment{
"local_name": "@babel/core",
"alias": false,
"peer_metadata": null
} | 7.5.5 | development |
@babel/plugin-proposal-class-propertiesEnvironment{
"local_name": "@babel/plugin-proposal-class-properties",
"alias": false,
"peer_metadata": null
} | 7.5.5 | development |
@babel/plugin-proposal-object-rest-spreadEnvironment{
"local_name": "@babel/plugin-proposal-object-rest-spread",
"alias": false,
"peer_metadata": null
} | 7.5.5 | development |
@babel/plugin-transform-modules-umdEnvironment{
"local_name": "@babel/plugin-transform-modules-umd",
"alias": false,
"peer_metadata": null
} | ^7.9.0 | development |
@babel/preset-envEnvironment{
"local_name": "@babel/preset-env",
"alias": false,
"peer_metadata": null
} | 7.5.5 | development |
@babel/registerEnvironment{
"local_name": "@babel/register",
"alias": false,
"peer_metadata": null
} | ^7.9.0 | development |
avaEnvironment{
"local_name": "ava",
"alias": false,
"peer_metadata": null
} | ^2.4.0 | development |
jsdoc-to-markdownEnvironment{
"local_name": "jsdoc-to-markdown",
"alias": false,
"peer_metadata": null
} | ^5.0.3 | development |
rimrafEnvironment{
"local_name": "rimraf",
"alias": false,
"peer_metadata": null
} | 2.6.3 | development |
Source distribution
{
"integrity": "sha512-IhVzH09Rk0IaYdgr1uO5geEz6kqeVp2spcHOJ98/FN6F3XpYX2l0chs2wtC5ZpW1e55+Xj9T+R9abs6C7dsu2w==",
"shasum": "9025f29a14beec7c6556cfcd1e02a935c2201511",
"tarball": "https://registry.npmjs.org/@0x04/string-mutilator/-/string-mutilator-1.0.0.tgz",
"fileCount": 18,
"unpackedSize": 43277,
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeeW49CRA9TVsSAnZWagAAlEgP+wY4Us8TMoCyfCFJRBeU\naQYc/aMP2mvZzPRz+9BnGDgUAZXpcnvir4wd4v1FWuWueS9vuAGoqO0FFX7M\ne/7LaAXYaaJmwMx0JoGdyQMea/6/QNZ+pRmLBVfZPfh9oVdyYG80ytTz/Ap/\nsTT+XFHzUuLAoJieadPs0jq2HMLWD9Ox0J7nyKqNgfbs4mPCjTUhg6U+nVgf\nnX1QLKpwFhiyz8TrWrN0QtQle1RlbnbSZN8KoU0c3AFmgvnH4TZY4HRt/qOZ\nZWQCsx5r3YnTqXennFC+S1IyYIy6O68x9718gXBB0F8u0naS6WqJN7M5bUQe\nqGLpsA3P2I59QtExkw3hg9A4CLaJ7vjvn+DC35tF0Ko5Sd8L2C25EmSkpePX\nhar3XTmYLUbnDQdh9cgOV46GxlZUq/8FJyX26IKqS8PYpyqRmNNpgsDQYpWt\nkjWT1gxjeUhQVtXtcSU15INwiH7/EUsnld33dCwYO4ckJrogdlO8hif3a04H\nQ2zgPCYbz3AOYjQkRCpJ2BsAhMEbBHbza18SxRGQwfAr38qd1Pt5YQ9A9HMN\nMntZZJQ7iLyoauKjAkFcF0uL8uc1J1LS1XzHSVTQmv4w5DtCwSdM8JlERpNM\nkmXjpnpaqnD6U44/b/wpQM4D0eeJzQvpNN2y2d3TaZurTMFGFxvYEA7gAsEw\nq0Wk\r\n=J0k3\r\n-----END PGP SIGNATURE-----\r\n",
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEUCIAyy22ElwsZ/5WskJ/x1ISfDN0sn8eMgKA4wNOOUGw37AiEAmtLPEDGWVu1W2Y/0R4xMcQFLMaiVdsDpjhdYHpXaRjM="
}
]
}Observed since 20 Oct, 22:33 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:d01e126ee6f0a664df3da23fc399451c757a9c71f8b3f97a2ec8dfd7da253317