|
1 |
| -# Character Printer |
| 1 | +<img alt="Ninja Print title" src="https://secure.servalldatasystems.com/servall_dev_files/ninja-print/ninja-print.png" height="180px" width="536.5px"> |
2 | 2 |
|
3 |
| -Character Printer is a utility for printing human-readable special characters. |
| 3 | +### *Finding those ninja characters* |
4 | 4 |
|
5 |
| -Are you ever working with low-level binary or string data that contains special characters (NUL, CR, LF, etc)? Unfortunately `console.log()` has no way to display special characters, making it difficult to determine exactly where they exist in a `String` or `Buffer`. Character Printer makes your life easy by printing out a human readable form of each character. |
| 5 | +<img alt="Ninja Print demo" src="https://secure.servalldatasystems.com/servall_dev_files/ninja-print/ninja-print.gif" height="225px" width="400px"> |
| 6 | + |
| 7 | +# What is it? |
| 8 | + |
| 9 | +Ninja Print is a utility for printing human-readable special characters. |
| 10 | + |
| 11 | +Are you ever working with binary or string data that contains special characters (NUL, CR, LF, etc)? Unfortunately standard print commands (`echo`, `printf`, `console.log`, etc) will not display special characters, making it difficult to determine exactly where they exist in a `string`. Ninja Print makes your life easy by printing out a human-readable form of each character. |
| 12 | + |
| 13 | +# Installation |
| 14 | + |
| 15 | +`ninprint` requires [NodeJS](https://nodejs.org) and [NPM](https://www.npmjs.com)/[Yarn](https://yarnpkg.com). |
6 | 16 |
|
7 |
| -## Installation |
8 | 17 | #### NPM
|
9 | 18 | ```bash
|
10 |
| -npm install character-printer |
| 19 | +npm install -g ninprint |
11 | 20 | ```
|
12 | 21 | #### Yarn
|
13 | 22 |
|
14 | 23 | ```bash
|
15 |
| -yarn add character-printer |
| 24 | +yarn global add ninprint |
16 | 25 | ```
|
17 | 26 |
|
18 |
| -## Examples |
19 |
| -```javascript |
20 |
| -const { printCharacters } = require("character-printer"); |
| 27 | +# Examples |
21 | 28 |
|
22 |
| -printCharacters("Hello world."); |
23 |
| -// Output: |
24 |
| -// H e l l o [SPACE] w o r l d . |
25 |
| - |
26 |
| -printCharacters("Line feed:\n"); |
27 |
| -// Output: |
28 |
| -// L i n e [SPACE] f e e d : [LF] |
| 29 | +You can pipe output from other processes into `ninprint`: |
| 30 | +```bash |
| 31 | +$ printf "From pipe: \0\r\n" | ninprint |
29 | 32 |
|
30 |
| -printCharacters("Carriage return:\r"); |
31 |
| -// Output: |
32 |
| -// C a r r i a g e [SPACE] r e t u r n : [CR] |
| 33 | +F r o m [SPACE] p i p e : [SPACE] [NUL] [CR] [LF] |
| 34 | +``` |
33 | 35 |
|
34 |
| -printCharacters("Null character:\0"); |
35 |
| -// Output: |
36 |
| -// N u l l [SPACE] c h a r a c t e r : [NUL] |
| 36 | +Anything sent to `stdin` will be processed: |
| 37 | +```bash |
| 38 | +$ printf "From file: \b\f\t" > test.bin |
| 39 | +$ ninprint < test.bin |
37 | 40 |
|
38 |
| -printCharacters(new Buffer([0x00, 0x01, 0x02, 0x03, 0x04, 0x05])); |
39 |
| -// Output: |
40 |
| -// [NUL] [SOH] [STX] [ETX] [EOT] [ENQ] |
| 41 | +F r o m [SPACE] f i l e : [SPACE] [BS] [FF] [TAB] |
41 | 42 | ```
|
42 | 43 |
|
43 |
| -## Command Line Interface (CLI) |
44 |
| -You can also use the command line interface to print characters from other processes or files using pipe. |
| 44 | +# Node Module |
| 45 | +You can also use `ninprint` as a Node/Webpack module. |
45 | 46 |
|
46 | 47 | #### NPM
|
47 | 48 | ```bash
|
48 |
| -npm install -g character-printer |
| 49 | +npm install ninprint |
49 | 50 | ```
|
50 | 51 | #### Yarn
|
51 | 52 |
|
52 | 53 | ```bash
|
53 |
| -yarn global add character-printer |
| 54 | +yarn add ninprint |
54 | 55 | ```
|
55 | 56 |
|
56 |
| -Examples: |
| 57 | +## Examples |
| 58 | +```javascript |
| 59 | +const { print: ninprint } = require("ninprint"); |
57 | 60 |
|
58 |
| -```bash |
59 |
| -$ printf "From pipe: \0\r\n" | character-printer |
| 61 | +ninprint("Hello world."); |
| 62 | +// Output: |
| 63 | +// H e l l o [SPACE] w o r l d . |
60 | 64 |
|
61 |
| -F r o m [SPACE] p i p e : [SPACE] [NUL] [CR] [LF] |
62 |
| -``` |
63 |
| -```bash |
64 |
| -$ printf "From file: \b\f\t" > test.bin |
65 |
| -$ character-printer < test.bin |
| 65 | +ninprint("Line feed:\n"); |
| 66 | +// Output: |
| 67 | +// L i n e [SPACE] f e e d : [LF] |
66 | 68 |
|
67 |
| -F r o m [SPACE] f i l e : [SPACE] [BS] [FF] [TAB] |
| 69 | +ninprint("Carriage return:\r"); |
| 70 | +// Output: |
| 71 | +// C a r r i a g e [SPACE] r e t u r n : [CR] |
| 72 | + |
| 73 | +ninprint("Null character:\0"); |
| 74 | +// Output: |
| 75 | +// N u l l [SPACE] c h a r a c t e r : [NUL] |
| 76 | + |
| 77 | +ninprint(new Buffer([0x00, 0x01, 0x02, 0x03, 0x04, 0x05])); |
| 78 | +// Output: |
| 79 | +// [NUL] [SOH] [STX] [ETX] [EOT] [ENQ] |
68 | 80 | ```
|
69 | 81 |
|
70 | 82 | # License
|
|
0 commit comments