Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including string-direction with all npm packages installed. Try it out:

var stringDirection = require("string-direction")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

string-direction v0.1.2

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.

Usage

#getDirection

var stringDirection = require('string-direction');

stringDirection.getDirection("Hello, world!"); // 'ltr'
stringDirection.getDirection("سلام دنیا"); // 'rtl'

#patch Patching String objects globally

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

require('string-direction').patch();

"Hello, world!".getDirection(); // "ltr"
"سلام دنیا".getDirection(); // "rtl"

Installation

String Direction works both in browser or NodeJS environment

Node

Install via NPM

npm install string-direction

Browser

Use script tag to include the library

Credits

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

License

MIT

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free