npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

arli

v0.0.1

Published

Tools for an Arabic development

Downloads

2

Readme

Arli - Tools for an Arabic development

Usage

node

$ npm install arli

bower

$ bower install arli

browser

<script src="arli.min.js"></script>

API

.arabize(str, [options])

Convert some characters to make the text more Arabian.

Arguments
  • str (string): The string to convert.
  • [options=['date', 'number', 'dash', 'char']] (array): Decide which features to use in the output.

You can use those features: char, dash or dash-extra, date or date-reverse, number.

  • char: Arabic characters.
  • dash: Remove Arabic dashes.
  • dash-extra: Remove the extra Arabic dashes.
  • date: Arabic date format.
  • date-reverse: Reversed Arabic date format.
  • number: Arabic numbers.
Returns

(string) an Arabian string.

Example
arli.arabize('0123456789%(,;*)?');
// => '۰۱۲۳۴۵۶۷۸۹٪﴾،؛٭﴿؟''

arli.arabize('0123456789%(,;*)?', ['char']);
// => '0123456789٪﴾،؛٭﴿؟''

.count(str, [type])

Count the matched characters in the string.

Arguments
  • str (string): The string to count in.
  • [type] (string): A regular expression pattern to be used.

You can use other patterns: all, digit, every, letter, strict, punct.

See pattern options for more information.

Returns

(number) the number of the matched characters in the string.

Example
arli.count('Hello!');
// => 0

arli.count('Hello! مرحبا');
// => 5

arli.count('Hello! مرحبا ۱۲۳', 'digit');
// => 3

.countRest(str, [type])

Count the non matched characters in the string.

Arguments
  • str (String): The string to count in.
  • [type] (String): A regular expression pattern to be used.

You can use other patterns: all, digit, every, letter, strict, punct.

See pattern options for more information.

Returns

(Number) the number of the non matched characters in the string.

Example
arli.countRest('Hello!');
 => 6
arli.countRest('Hello! مرحبا');
 => 7
arli.countRest('Hello! مرحبا ۱۲۳', 'digit');
 => 13

.dateize(str, [reverse])

Convert a date string to an Arabic format.

Arguments
  • str (String): The string to convert.
  • [reverse] (Boolean): Reverse the month and day in the output if set to true.
Returns

(String) an Arabic date format

Example
arli.dateize('20,11,2015 20/11/2015 20-11-2015 20.11.2015 20 11 2015');
 => '20؍11؍2015 20؍11؍2015 20؍11؍2015 20؍11؍2015 20؍11؍2015'
arli.dateize('20/11/2015', true);
 => '11؍20؍2015'  Past it to an RTL env to see it right

.extract(str, [type])

Output the matched characters from the string.

Arguments
  • str (String): The string to output from.
  • [type] (String): A regular expression pattern to be used.

You can use other patterns: all, digit, every, letter, strict, punct.

See pattern options for more information.

Returns

(String) the matched characters.

Example
arli.extract('Hello مرحبا');
 => 'مرحبا'
arli.extract('Hello مرحبا ۱۲۳', 'digit');
 => '۱۲۳'

.has(str, [type])

Checks if the string has the matched pattern.

Arguments
  • str (String): The string to check.
  • [type] (String): A regular expression pattern to be used.

You can use other patterns: all, digit, every, letter, strict, punct.

See pattern options for more information.

Returns

(Boolean) true if the pattern match, else otherwise.

Example
arli.has('Hello مرحبا');
 => true
arli.has('Hello مرحبا ۱۲۳', 'digit');
 => true
arli.has('Hello مرحبا', 'digit');
 => false

.how(str, [type])

Calculate the percentage of the matched pattern in the string.

Arguments
  • str (String): The string to calculate in.
  • [type] (String): A regular expression pattern to be used.

You can use other patterns: all, digit, every, letter, strict, punct.

See pattern options for more information.

Returns

(Number) the percentage of the matched pattern.

Example
arli.how('Hello مرحبا');
 => 45.45454545454545
arli.how('Hello مرحبا،،،، ۱۲۳', 'char');
 => 26.31578947368421

.howRest(str, [type])

Calculate the percentage of the non matched pattern in the string.

Arguments
  • str (String): The string to calculate in.
  • [type] (String): A regular expression pattern to be used.

You can use other patterns: all, digit, every, letter, strict, punct.

See pattern options for more information.

Returns

(Number) the percentage of the non matched pattern.

Example
arli.howRest('Hello مرحبا');
 => 54.54545454545455
arli.howRest('Hello مرحبا،،،، ۱۲۳', 'char');
 => 73.6842105263158

.numerize(str)

Convert a number string to an Arabic format.

Arguments
  • str (String): The string to convert.
Returns

(String) an Arabic date format

Example
arli.numerize('0123456789');
 => '۰۱۲۳۴۵۶۷۸۹'

.remove(str, [type])

Output the non matched characters from the string.

Arguments
  • str (String): The string to output from.
  • [type] (String): A regular expression pattern to be used.

You can use other patterns: all, digit, every, letter, strict, punct.

See pattern options for more information.

Returns

(String) the non matched characters.

Example
arli.remove('Hello مرحبا');
 => 'Hello '
arli.remove('Hello مرحبا ۱۲۳', 'digit');
 => 'Hello  مرحبا'

.removeDash(str, [extra])

Remove the dash or Tatweel character from the string.

Arguments
  • str (String): The string to remove from.
  • [extra] (Boolean): Leave a single dash if set to true
Returns

(String) the new prepared string.

Example
arli.removeDash('مرحبــــــــــا');
 => 'مرحبا'
arli.removeDash('مرحبــــــــــا', true);
 => 'مرحبـا'

Pattern options

  • all: All Arabic standard characters.
  • digit: Arabic numbers.
  • every: Every Arabic characters.
  • letter: Arabic letters.
  • strict: Strict Arabic characters.
  • punct: Arabic punctuation.

LICENCE

Copyright (c) 2015 Mohamed Elkebir [email protected]

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.