@@ -23,6 +23,13 @@ So I decided to combine these "strange" functions into one library.
2323More or less just for fun.
2424
2525
26+ ## Demo
27+
28+ A [ comprehensive demo] [ pseudo-cipherer-demo ] of all functions can be found in
29+ the demonstration of this library/package in the demo project
30+ [ ` pseudeo-chiperer ` ] [ pseudo-cipherer-repo ] .
31+
32+
2633## Table of content
2734
28351 . [ Modules] ( #user-content-module )
@@ -52,23 +59,24 @@ More or less just for fun.
5259
5360<dl >
5461<dt ><a href =" #flipBits " >flipBits(string)</a > ⇒ <code >string</code ></dt >
55- <dd ><p >Flip the character bits of a string. The 16 character bits of ' ; A' ; are
62+ <dd ><p >Flip the character bits of a string. The 16 character bits of < code > ' ; A' ; </ code > are
5663<code >00000000 01000001</code > - if we flip the bits (so every 0 becomes 1 and vice
57- versa) they look like this <code >11111111 10111110</code >. This means that ' ; A' ; (0x41)
58- becomes ' ; ᄒ' ; (0xFFBE ).</p >
64+ versa) they look like this <code >11111111 10111110</code >. This means that < code > ' ; A' ; </ code >
65+ (< code >U+0041</ code >) becomes < code > ' ; ᄒ' ; </ code > (< code >U+FFBE</ code > ).</p >
5966</dd >
6067<dt ><a href =" #gobbledygook " >gobbledygook(string, [exclude])</a > ⇒ <code >string</code ></dt >
6168<dd ><p >Applies <code >toMANS</code > to all characters with a random <code >type</code >.
62- For example <code >Hello World</code > turns into <code >𝐇𝖾𝓵𝗹𝘰 𝔚𝗈𝒓𝔩𝔡</code >.</p >
69+ For example <code >&# 39 ; Hello World&# 39 ; </code > turns into <code >&# 39 ; 𝐇𝖾𝓵𝗹𝘰 𝔚𝗈𝒓𝔩𝔡&# 39 ; </code >.</p >
6370</dd >
6471<dt ><a href =" #jumble " >jumble(string, [runs])</a > ⇒ <code >string</code ></dt >
6572<dd ><p >Jumble the letters of all words in a string,
6673except the first and last one, to keep it readable.</p >
6774</dd >
6875<dt ><a href =" #reverseBits " >reverseBits(string)</a > ⇒ <code >string</code ></dt >
69- <dd ><p >Reverse the character bits of a string. The 16 character bits of ' ; A' ; are
76+ <dd ><p >Reverse the character bits of a string. The 16 character bits of < code > ' ; A' ; </ code > are
7077<code >00000000 01000001</code > - if we reverse the bits they look like this
71- <code >10000010 00000000</code >. This means that ' ; A' ; (0x41) becomes ' ; 舀' ; (0x8200).</p >
78+ <code >10000010 00000000</code >. This means that <code >' ; A' ; </code > (<code >U+0041</code >) becomes <code >' ; 舀' ; </code >
79+ (<code >U+8200</code >).</p >
7280</dd >
7381<dt ><a href =" #reverse " >reverse(string)</a > ⇒ <code >string</code ></dt >
7482<dd ><p >Reverse a string.</p >
@@ -83,9 +91,10 @@ except the first and last one, to keep it readable.</p>
8391<dd ><p >Randomize the order of the characters in a string.</p >
8492</dd >
8593<dt ><a href =" #shiftBits " >shiftBits(string, [n])</a > ⇒ <code >string</code ></dt >
86- <dd ><p >Rotate the character bits of a string. The 16 character bits of ' ; A' ; are
94+ <dd ><p >Rotate the character bits of a string. The 16 character bits of < code > ' ; A' ; </ code > are
8795<code >00000000 01000001</code > - if we shift the bits by -4 <code >n</code > digits they look like
88- this <code >00010000 00000100</code >. This means that ' ; A' ; (0x41) becomes ' ; င' ; (0x1004).</p >
96+ this <code >00010000 00000100</code >. This means that <code >' ; A' ; </code > (<code >U+0041</code >) becomes <code >' ; င' ; </code >
97+ (<code >U+1004</code >).</p >
8998</dd >
9099<dt ><a href =" #shift " >shift(string, [n])</a > ⇒ <code >string</code ></dt >
91100<dd ><p >Shift the characters of a string by <code >n</code > digits.</p >
@@ -257,14 +266,24 @@ Functions for handle unicode stuff.
257266
258267### stringMutilator/unicode~ fixSurrogates(string) ⇒ <code >string</code >
259268Fix unpaired high/low surrogates by adding a blank high/low surrogate
260- (U+D800 or U+DC00) to the required location.
269+ (` U+D800 ` or ` U+DC00 ` ) to the designated location. An unpaired surrogate can
270+ lead to problems, for example by copying it to the clipboard could result in
271+ a Replacement Character � (` U+FFFD ` ). For example if the string is
272+ ` '\uD801' ` it will be altered to ` '\uD801\uDC00' ` (` '𐐀' ` ) or ` '\uDE80' ` to
273+ ` '\uD800\uDE80' ` (` '𐊀' ` ).
261274
262275** Kind** : inner method of [ <code >stringMutilator/unicode</code >] ( #module_stringMutilator/unicode )
276+ ** See** : https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
263277
264278| Param | Type | Description |
265279| --- | --- | --- |
266280| string | <code >string</code > | The input string |
267281
282+ ** Example**
283+ ``` js
284+ stringMutilator .unicode .fixSurrogates (' Test: \uD801 \uDE80 ' );
285+ // > 'Test: 𐐀 𐊀'
286+ ```
268287<a name =" module_stringMutilator/unicode..unfixSurrogates " ></a >
269288
270289### stringMutilator/unicode~ unfixSurrogates(string) ⇒ <code >string</code >
@@ -276,13 +295,18 @@ Remove the by `fixSurrogates` added blank high/low surrogates.
276295| --- | --- | --- |
277296| string | <code >string</code > | The input string |
278297
298+ ** Example**
299+ ``` js
300+ stringMutilator .unfixSurrogates (' Test: 𐐀 𐊀' );
301+ // > 'Test: \uD801 \uDE80'
302+ ```
279303<a name =" flipBits " ></a >
280304
281305## flipBits(string) ⇒ <code >string</code >
282- Flip the character bits of a string. The 16 character bits of 'A' are
306+ Flip the character bits of a string. The 16 character bits of ` 'A' ` are
283307` 00000000 01000001 ` - if we flip the bits (so every 0 becomes 1 and vice
284- versa) they look like this ` 11111111 10111110 ` . This means that 'A' (0x41)
285- becomes 'ᄒ' (0xFFBE ).
308+ versa) they look like this ` 11111111 10111110 ` . This means that ` 'A' `
309+ ( ` U+0041 ` ) becomes ` 'ᄒ' ` ( ` U+FFBE ` ).
286310
287311** Kind** : global function
288312
@@ -299,7 +323,7 @@ stringMutilator.flipBits('Hello World!');
299323
300324## gobbledygook(string, [ exclude] ) ⇒ <code >string</code >
301325Applies ` toMANS ` to all characters with a random ` type ` .
302- For example ` Hello World ` turns into ` 𝐇𝖾𝓵𝗹𝘰 𝔚𝗈𝒓𝔩𝔡 ` .
326+ For example ` ' Hello World' ` turns into ` ' 𝐇𝖾𝓵𝗹𝘰 𝔚𝗈𝒓𝔩𝔡' ` .
303327
304328** Kind** : global function
305329
@@ -335,9 +359,10 @@ stringMutilator.jumble('Hello World!');
335359<a name =" reverseBits " ></a >
336360
337361## reverseBits(string) ⇒ <code >string</code >
338- Reverse the character bits of a string. The 16 character bits of 'A' are
362+ Reverse the character bits of a string. The 16 character bits of ` 'A' ` are
339363` 00000000 01000001 ` - if we reverse the bits they look like this
340- ` 10000010 00000000 ` . This means that 'A' (0x41) becomes '舀' (0x8200).
364+ ` 10000010 00000000 ` . This means that ` 'A' ` (` U+0041 ` ) becomes ` '舀' `
365+ (` U+8200 ` ).
341366
342367** Kind** : global function
343368
@@ -424,9 +449,10 @@ stringMutilator.scramble('Hello World!');
424449<a name =" shiftBits " ></a >
425450
426451## shiftBits(string, [ n] ) ⇒ <code >string</code >
427- Rotate the character bits of a string. The 16 character bits of 'A' are
452+ Rotate the character bits of a string. The 16 character bits of ` 'A' ` are
428453` 00000000 01000001 ` - if we shift the bits by -4 ` n ` digits they look like
429- this ` 00010000 00000100 ` . This means that 'A' (0x41) becomes 'င' (0x1004).
454+ this ` 00010000 00000100 ` . This means that ` 'A' ` (` U+0041 ` ) becomes ` 'င' `
455+ (` U+1004 ` ).
430456
431457** Kind** : global function
432458
@@ -496,6 +522,11 @@ stringMutilator.toMANS('Hello World!', 1);
496522
497523### List of involutory functions
498524
525+ * [ ` flipBits ` ] ( #flipBits )
526+ * [ ` reverse ` ] ( #reverse )
527+ * [ ` reverseBits ` ] ( #reverseBits )
528+ * [ ` rot13 ` ] ( #rot13 )
529+
499530** Example**
500531
501532``` js
@@ -505,25 +536,50 @@ rot13(rot13('Hello World!')) === 'Hello World!';
505536// > true
506537```
507538
508- * [ ` charCase.invert ` ] ( #module_stringMutilator/charCase.invert )
509- * [ ` flipBits ` ] ( #flipBits )
510- * [ ` reverse ` ] ( #reverse )
511- * [ ` reverseBits ` ] ( #reverseBits )
512- * [ ` rot13 ` ] ( #rot13 )
513-
514539### List of involutory functions with negated arguments
515540
541+ * [ ` charCase.invert ` ] ( #module_stringMutilator/charCase..invert )
542+ * [ ` shift ` ] ( #shift )
543+ * [ ` shiftBits ` ] ( #shiftBits )
544+
516545** Example**
517546
518- ```
547+ ``` js
519548import { shift } from ' @0x04/string-mutilator' ;
520549
521550shift (shift (' Hello World!' , 5 ), - 5 ) === ' Hello World!' ;
522551// > true
523552```
524553
525- * [ ` shift ` ] ( #shift )
526- * [ ` shiftBits ` ] ( #shiftBits )
554+ ### List of involutory functions with counter function
555+
556+ * [ ` compressor.pack ` ] ( #module_stringMutilator/compressor..pack ) / [ ` compressor.unpack ` ] ( #module_stringMutilator/compressor..unpack )
557+ * [ ` unicode.fixSurrogates ` ] ( #module_stringMutilator/unicode..fixSurrogates ) / [ ` unicode.unfixSurrogates ` ] ( #module_stringMutilator/unicode..unfixSurrogates )
558+
559+ ** Examples**
560+
561+ ``` js
562+ import { compressor } from ' @0x04/string-mutilator' ;
563+
564+ compressor .unpack (compressor .pack (' Hello World!' )) === ' Hello World!' ;
565+ // > true
566+ ```
567+
568+ ### List of non involutory functions
569+
570+ * [ ` compressor.signature ` ] ( #module_stringMutilator/compressor..signature )
571+ * [ ` gobbledygook ` ] ( #gobbledygook )
572+ * [ ` jumble ` ] ( #jumble )
573+ * [ ` rockdotize ` ] ( #rockdotize )
574+ * [ ` scramble ` ] ( #scramble )
575+ * [ ` toMANS ` ] ( #toMANS )
576+
577+ ``` js
578+ import { jumble } from ' @0x04/string-mutilator' ;
579+
580+ jumble (jumble (' Hello World!' )) === ' Hello World!' ;
581+ // > false
582+ ```
527583
528584
529585## Using the CLI
@@ -590,7 +646,8 @@ $ string-mutilator --help
590646
591647<!-- Links -->
592648[ 0x04 ] : mailto:ok@0x04.de
593-
649+ [ pseudo-cipherer-demo ] : https://0x04.github.io/pseudo-cipherer
650+ [ pseudo-cipherer-repo ] : https://github.com/0x04/pseudo-cipherer
594651
595652<!-- Appendix -->
596653[ involution ] : https://en.wikipedia.org/wiki/Involution_(mathematics)
0 commit comments