Skip to content

A Javascript library that extends the native String object with methods to help when dealing with Arabic strings for node and the browser.

Notifications You must be signed in to change notification settings

ahmads/arabicString

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

#arabicString

A Javascript library that extends the native String object with methods to help when dealing with Arabic strings for node and the browser.

##Usage ###node

require('arabicString')

###browser

<script src="arabicString.js"></script>

##String#howArabic()

The percentage of Arabic letters in the String.

Example

'foobar'.howArabic()
//=> 0.0
'فوو bar'.howArabic()
//=> 0.5
'فوبار'.howArabic()
//=> 1.0

##String#howNotArabic()

The percentage of non-Arabic letters in the String.

Example

'فوبار'.howNotArabic()
//=> 0.0
'فوو bar'.howNotArabic()
//=> 0.5
'foobar'.howNotArabic()
//=> 1.0

##String#isArabic(threshold)

Is the String Arabic, based on a given threshold between 0 and 1. Defaults to 0.79.

Example

'فوو'.isArabic()
//=> true
'فوو bar baz'.isArabic(0.5)
//=> false

##String#hasArabic()

Does the String have any Arabic letter.

Example

'فوو bar'.hasArabic()
//=> ture
'foo bar'.hasArabic()
//=> false

##String#removeTashkel()

Will return the String without the diacritics.

Example

'مٌحمْد'.removeTashkel()
//=> 'محمد'
'وَتُرى الْكَوَاكِبِ فِي الْمَجَرَّةِ شَرَعَا*** مِثْلُ الظِّباءِ كوارعا فِي جَدْوَلِ'.removeTashkel()
//=> 'وترى الكواكب في المجرة شرعا *** مثل الظباء كوارعا في جدول'

License

(The MIT License)

Copyright (c) 2012 Ahmad Salman

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A Javascript library that extends the native String object with methods to help when dealing with Arabic strings for node and the browser.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages