Determines the writing system's directionality based on characters tests.
$ component install component/directionality
var dir = require('directionality');
dir('الولايات المتحدة الأمريكية'); // 'rtl'
dir('Hello world'); // 'ltr'
The decision is made based on the first character of the input string, testing for a range of unicode characters that belong to rtl or ltr languages (see API to learn how to access the regular expressions).
Returns 'rtl'
for right-to-left text, and 'ltr'
for
left-to-right text.
Access the regular expression of ltr characters.
Access the regular expression of rtl characters.
MIT