node package manager

directionality

Determines the writing system's directionality based on characters tests.

directionality

Determines the writing system's directionality based on characters tests.

Installation

$ component install component/directionality

Example

var dir = require('directionality');
dir('الولايات المتحدة الأمريكية'); // 'right' 
dir('Hello world'); // 'left' 

Method

The decision is made based on the first character of the input string.

API

directionality(str)

Returns 'rtl' for right-to-left text, and 'ltr' for left-to-right text.

directionality.regex.ltr

Access the regular expression of ltr charecters.

directionality.regex.rtl

Access the regular expression of rtl charecters.

License

MIT