'hELLO wORLD!' ``` ### stringMutilator/charCase~snakeCase(string) ⇒ string
Change the case of given string to "Snake Case". **Kind**: inner method of [stringMutilator/charCase
](#module_stringMutilator/charCase) | Param | Type | | --- | --- | | string | string
| **Example** ```js stringMutilator.charCase.snakeCase('Hello World'); // > 'hello_world' ``` ### stringMutilator/charCase~camelCase(string) ⇒ string
Change the case of the given string to "Camel Case". **Kind**: inner method of [stringMutilator/charCase
](#module_stringMutilator/charCase) | Param | Type | | --- | --- | | string | string
| **Example** ```js stringMutilator.charCase.camelCase('Hello World'); // > 'helloWorld' ``` ### stringMutilator/charCase~kebabCase(string) ⇒ string
Change the case of the given string to "Kebap Case". **Kind**: inner method of [stringMutilator/charCase
](#module_stringMutilator/charCase) | Param | Type | | --- | --- | | string | string
| **Example** ```js stringMutilator.charCase.kebabCase('Hello World'); // > 'hello-world' ``` ### stringMutilator/charCase~dotCase(string) ⇒ string
Change the case of the given string to "Dot Case". **Kind**: inner method of [stringMutilator/charCase
](#module_stringMutilator/charCase) | Param | Type | | --- | --- | | string | string
| **Example** ```js stringMutilator.charCase.dotCase('Hello World'); // > 'hello.world' ``` ### stringMutilator/charCase~pascalCase(string) ⇒ string
Change the case of the given string to "Pascal Case". **Kind**: inner method of [stringMutilator/charCase
](#module_stringMutilator/charCase) | Param | Type | | --- | --- | | string | string
| **Example** ```js stringMutilator.charCase.pascalCase('Hello World'); // > 'HelloWorld' ``` ### stringMutilator/charCase~capitalize(string) ⇒ string
Change the case of the given string to "Capitalized". **Kind**: inner method of [stringMutilator/charCase
](#module_stringMutilator/charCase) | Param | Type | | --- | --- | | string | string
| **Example** ```js stringMutilator.charCase.capitalize('hello world'); // > 'Hello World' ``` ## stringMutilator/compressor Functions for compressing (pack/unpack etc.) strings. * [stringMutilator/compressor](#module_stringMutilator/compressor) * [~pack(string)](#module_stringMutilator/compressor..pack) ⇒ string
* [~unpack(string)](#module_stringMutilator/compressor..unpack) ⇒ string
* [~signature(string, [withEval])](#module_stringMutilator/compressor..signature) ⇒ string
### stringMutilator/compressor~pack(string) ⇒ string
Pack all characters of a 8-bit string. **Kind**: inner method of [stringMutilator/compressor
](#module_stringMutilator/compressor) | Param | Type | Description | | --- | --- | --- | | string | string
| A 8-bit string to pack. | **Example** ```js stringMutilator.compressor.pack('Hello World!'); // > '䡥汬漠坯牬搡' ``` ### stringMutilator/compressor~unpack(string) ⇒ string
Unpack a packed string. **Kind**: inner method of [stringMutilator/compressor
](#module_stringMutilator/compressor) | Param | Type | Description | | --- | --- | --- | | string | string
| The packed string to unpack. | **Example** ```js stringMutilator.compressor.unpack('䡥汬漠坯牬搡'); // > 'Hello World!' ``` ### stringMutilator/compressor~signature(string, [withEval]) ⇒ string
Return the given, packed string with the unpack signature. **Kind**: inner method of [stringMutilator/compressor
](#module_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** ```js stringMutilator.compressor.signature('䡥汬漠坯牬搡'); // > 'unescape(escape("䡥汬漠坯牬搡").replace(/u(..)/g, "$1%");' ``` ## stringMutilator Functions for mutilating strings. ## stringMutilator/unicode Functions for handle unicode stuff. * [stringMutilator/unicode](#module_stringMutilator/unicode) * [~fixSurrogates(string)](#module_stringMutilator/unicode..fixSurrogates) ⇒ string
* [~unfixSurrogates(string)](#module_stringMutilator/unicode..unfixSurrogates) ⇒ string
### stringMutilator/unicode~fixSurrogates(string) ⇒ string
Fix 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
](#module_stringMutilator/unicode) **See**: https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF | Param | Type | Description | | --- | --- | --- | | string | string
| The input string | **Example** ```js stringMutilator.unicode.fixSurrogates('Test: \uD801 \uDE80'); // > 'Test: ????' ``` ### stringMutilator/unicode~unfixSurrogates(string) ⇒ string
Remove the by `fixSurrogates` added blank high/low surrogates. **Kind**: inner method of [stringMutilator/unicode
](#module_stringMutilator/unicode) | Param | Type | Description | | --- | --- | --- | | string | string
| The input string | **Example** ```js stringMutilator.unfixSurrogates('Test: ????'); // > 'Test: \uD801 \uDE80' ``` ## flipBits(string) ⇒ string
Flip 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** ```js stringMutilator.flipBits('Hello World!'); // > 'ᄋレモモミᄄミヘモロ' ``` ## gobbledygook(string, [exclude]) ⇒ string
Applies `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** ```js stringMutilator.gobbledygook('Hello World'); // > ???????????????????????????????????? ``` ## jumble(string, [runs]) ⇒ string
Jumble 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** ```js stringMutilator.jumble('Hello World!'); // > 'Hlelo Wrlod!' ``` ## reverseBits(string) ⇒ string
Reverse 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** ```js stringMutilator.reverseBits('Hello World!'); // > 'ሀꘀ㘀㘀Ѐ一㘀☀萀' ``` ## reverse(string) ⇒ string
Reverse a string. **Kind**: global function | Param | Type | Description | | --- | --- | --- | | string | string
| The input string. | **Example** ```js stringMutilator.reverse('Hello World!'); // > '!dlroW olleH' ``` ## rockdotize(string, [regexp]) ⇒ string
Create a heavy metal like rockdot string. **Kind**: global function **See** - https://en.wikipedia.org/wiki/Metal_umlaut - https://github.com/bullgit/rockdotizer | 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** ```js stringMutilator.rockdotize('Hello World!'); // > 'Ḧël̈l̈ö Ẅör̈l̈d̈!' ``` ## rot13(string) ⇒ string
Rotate 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** ```js stringMutilator.rot13('Hello World!'); // > 'Uryyb Jbeyq!' ``` ## scramble(string) ⇒ string
Randomize the order of the characters in a string. **Kind**: global function | Param | Type | Description | | --- | --- | --- | | string | string
| The string to scramble. | **Example** ```js stringMutilator.scramble('Hello World!'); // > 'WorH!llo led' ``` ## shiftBits(string, [n]) ⇒ string
Rotate 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. | ## shift(string, [n]) ⇒ string
Shift 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** ```js stringMutilator.shift('Hello World!', 3); // > 'lo World!Hel' ``` ## toMANS(string, [type]) ⇒ string
Convert A-Z to **M**athematical **A**lpha**n**umeric **S**ymbols. 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** ```js stringMutilator.toMANS('Hello World!', 1); // > '????????????????????????????????????.' ``` ## 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
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。