string-direction

String Direction is a JavaScript library for detection of direction of String objects in JavaScript.

String Direction

String Direction is a JavaScript library for detection of direction of String objects in JavaScript.

var stringDirection = require('string-direction');
 
stringDirection.getDirection("Hello, world!"); // 'ltr' 
stringDirection.getDirection("سلام دنیا"); // 'rtl' 

By using patch() method a getDirection method will be exposed in String object.

require('string-direction').patch();
 
"Hello, world!".getDirection(); // "ltr" 
"سلام دنیا".getDirection(); // "rtl" 

String Direction works both in browser or NodeJS environment

Install via NPM

npm install string-direction

Use script tag to include the library

This library is influenced by string-direction Ruby library by Marc Busqué

MIT