Determines the writing system's directionality based on characters tests.
JavaScript
Switch branches/tags
Nothing to show
Latest commit 04fd200 Oct 10, 2013 @jonathanong jonathanong Merge pull request #1 from repoify/add/repository
Add repository field to readme
Permalink
Failed to load latest commit information.
test initial commit Oct 15, 2012
.gitignore initial commit Oct 15, 2012
History.md Release 0.1.0 Oct 15, 2012
Makefile initial commit Oct 15, 2012
Readme.md Fixed typo [tootallnate] Oct 15, 2012
component.json initial commit Oct 15, 2012
index.js initial commit Oct 15, 2012
package.json add repository field to readme Aug 21, 2013

Readme.md

directionality

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

Installation

$ component install component/directionality

Example

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

Methodology

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).

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 characters.

directionality.regex.rtl

Access the regular expression of rtl characters.

License

MIT