Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@6degrees/arabic-strings

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@6degrees/arabic-strings

An NPM package that extends the native String object with methods to help when dealing with Arabic strings for node and the browser. > NPM updated package of @ahmads/arabicString repo

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

arabicStrings

An NPM package that extends the native String object with methods to help when dealing with Arabic strings for node and the browser.

NPM updated package of @ahmads/arabicString repo

Usage

node

const arabicString = require('@6degrees/arabic-strings');

String#howArabic()

The percentage of Arabic letters in the String.

Example

arabicString.howArabic('foobar');
//=> 0.0

arabicString.howArabic('فوو bar');
//=> 0.5

arabicString.howArabic('فوبار');
//=> 1.0

String#howNotArabic()

The percentage of non-Arabic letters in the String.

Example

arabicString.howNotArabic('فوبار');
//=> 0.0

arabicString.howNotArabic('فوو bar');
//=> 0.5

arabicString.howNotArabic('foobar');
//=> 1.0

String#isArabic(threshold)

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

Example

arabicString.isArabic('فوو');

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

String#hasArabic()

Does the String have any Arabic letter.

Example

arabicString.hasArabic('فوو bar');
//=> ture

arabicString.hasArabic('foo bar');
//=> false

String#removeTashkel()

Will return the String without the diacritics.

Example

arabicString.removeTashkel('مٌحمْد');
//=> 'محمد'

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

String#removeTatwel()

Will return the String without the diacritics.

Example

arabicString.removeTatwel('مــرحــبــا');
//=> 'مرحبا'

String#sanitize()

Will return the String without the diacritics, and clean characters.

Example

arabicString.sanitize(`أَنا الَّذي نَظَرَ الأَعمى إِلى أَدَبي ... وَأَسمَـعَت كَلِماتي مَن بِهِ صَمَمُ
أَنـامُ مِلءَ جُفوني عَن شَوارِدِهــا ... وَيَسهَرُ الخَلقُ جَرّاها وَيَختَصِمُ
وَجـــاهِلٍ مَدَّهُ في جَهلِهِ ضَحِكي ... حَتّى أَتَتهُ يَدٌ فَرّاسَــــــةٌ وَفَـــــمُ
`);
/*=> `انا الذي نظر الاعمي الي ادبي ... واسمعت كلماتي من به صمم
انام ملء جفوني عن شواردها ... ويسهر الخلق جراها ويختصم
وجاهل مده في جهله ضحكي ... حتي اتته يد فراسه وفم
`
*/

Credits

  • Original script [https://github.com/ahmads/arabicString]
  • Enhancements [https://github.com/ahmads/arabicString/pulls]
  • sanitization [https://github.com/ielashi/arabic-nlp]

License

(The MIT License)

Keywords

FAQs

Package last updated on 04 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc