Skip to content

kszongic/mirror-text-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@kszongic/mirror-text-cli

npm version license

Reverse / mirror text with proper Unicode grapheme cluster support. Zero dependencies.

Install

npm install -g @kszongic/mirror-text-cli

Usage

# Reverse characters
mirror-text "Hello World"
# dlroW olleH

# Handles emoji correctly (grapheme clusters)
echo "Hello 👨‍👩‍👧‍👦" | mirror-text
# 👨‍👩‍👧‍👦 olleH

# Reverse line order
printf "line1\nline2\nline3" | mirror-text --lines
# line3
# line2
# line1

# Reverse word order
mirror-text --words "one two three"
# three two one

# Reverse both lines and characters
printf "abc\ndef" | mirror-text --both
# fed
# cba

Options

Flag Description
-l, --lines Reverse order of lines
-w, --words Reverse word order (keep characters)
-b, --both Reverse characters AND line order
-h, --help Show help
-v, --version Show version

Why?

[...str].reverse() breaks on emoji like 👨‍👩‍👧‍👦. This CLI uses Intl.Segmenter for correct grapheme cluster reversal.

License

MIT © kszongic

Releases

No releases published

Packages

 
 
 

Contributors