-
Notifications
You must be signed in to change notification settings - Fork 1
/
template-readme.hbs
185 lines (125 loc) · 4.14 KB
/
template-readme.hbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# string-mutilator
A JavaScript library for mutilate strings.
[![MIT license][license-badge]][license]
## Motivation background
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`][mutilator] come into my mind.
> mutilator (plural mutilators)
> 1. 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.
## Demo
A [comprehensive demo][pseudo-cipherer-demo] of all functions can be found in
the demonstration of this library/package in the demo project
[`pseudeo-chiperer`][pseudo-cipherer-repo].
## Table of content
1. [Modules](#user-content-module)
2. [Functions](#user-content-functions)
3. [Involutory functions](#user-content-involutory-functions)
4. [Using the CLI](#user-content-using-the-cli)
{{>main}}
## Involutory functions
> An [involutory function][involution], is a function f that is its own inverse.
### List of involutory functions
* [`flipBits`](#flipBits)
* [`reverse`](#reverse)
* [`reverseBits`](#reverseBits)
* [`rot13`](#rot13)
**Example**
```js
import { rot13 } from '@0x04/string-mutilator';
rot13(rot13('Hello World!')) === 'Hello World!';
// > true
```
### List of involutory functions with negated arguments
* [`charCase.invert`](#module_stringMutilator/charCase..invert)
* [`shift`](#shift)
* [`shiftBits`](#shiftBits)
**Example**
```js
import { shift } from '@0x04/string-mutilator';
shift(shift('Hello World!', 5), -5) === 'Hello World!';
// > true
```
### List of involutory functions with counter function
* [`compressor.pack`](#module_stringMutilator/compressor..pack) / [`compressor.unpack`](#module_stringMutilator/compressor..unpack)
* [`unicode.fixSurrogates`](#module_stringMutilator/unicode..fixSurrogates) / [`unicode.unfixSurrogates`](#module_stringMutilator/unicode..unfixSurrogates)
**Examples**
```js
import { compressor } from '@0x04/string-mutilator';
compressor.unpack(compressor.pack('Hello World!')) === 'Hello World!';
// > true
```
### List of non involutory functions
* [`compressor.signature`](#module_stringMutilator/compressor..signature)
* [`gobbledygook`](#gobbledygook)
* [`jumble`](#jumble)
* [`rockdotize`](#rockdotize)
* [`scramble`](#scramble)
* [`toMANS`](#toMANS)
```js
import { jumble } from '@0x04/string-mutilator';
jumble(jumble('Hello World!')) === 'Hello World!';
// > false
```
## Using the CLI
### Install
**To use it in your project**
```bash
$ npm install --save @0x04/string-mutilator
```
**To use it globally**
```bash
$ npm install --global @0x04/string-mutilator
```
### General usage
```plain
$ 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
```
## License
© 2019 by [Oliver Kühn][0x04]. Released under the [MIT license][license].
<!-- Badges -->
[license-badge]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
[license]: ./license
<!-- Links -->
[0x04]: mailto:[email protected]
[pseudo-cipherer-demo]: https://0x04.github.io/pseudo-cipherer
[pseudo-cipherer-repo]: https://github.com/0x04/pseudo-cipherer
<!-- Appendix -->
[involution]: https://en.wikipedia.org/wiki/Involution_(mathematics)
[mutilator]: https://en.wiktionary.org/wiki/mutilator