Skip to content

Latest commit

 

History

History
87 lines (54 loc) · 1.72 KB

readme.md

File metadata and controls

87 lines (54 loc) · 1.72 KB

direction

Build Coverage Downloads Size

Detect direction: left-to-right, right-to-left, or neutral.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm install direction

Use

import {direction} from 'direction'

direction('A') // => 'ltr'
direction('anglais') // => 'ltr'
direction('بسيطة') // => 'rtl'
direction('@') // => 'neutral'

API

This package exports the following identifiers: direction. There is no default export.

direction(value)

Detect the direction of value (string?). Returns 'ltr', 'rtl', or 'neutral'.

CLI

Usage: direction [options] <words...>

Detect directionality: left-to-right, right-to-left, or neutral

Options:

  -h, --help           output usage information
  -v, --version        output version number

Usage:

# output directionality
$ direction @
# neutral

# output directionality from stdin
$ echo 'الانجليزية' | direction
# rtl

License

MIT © Titus Wormer