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

starkstring

v0.4.4

Published

Persian language localization.

Downloads

442

Readme

NPM

install size dependencies

starkstring

A simple JavaScript library To use the most commonly used string operations.
Include functions of persian.js

TOC

install

$ yarn add starkstring

const starkString = require("starkstring").default;

//or

import starkString from "starkstring";

Functions

1) Convert Arabic characters to Persian

Used for converting Arabic characters to Persian.

Example:

starkString(" علي ")
  .trim() // Remove spaces
  .persianChar() // Convert arabic `ي` to persian `ی`
  .toString(); //Returns: "علی"

2) Convert to English numbers from Persian and arabic Number

Used for converting Persian and arabic Number to English numbers.

Example:

starkString("۳۴۵ ٤٥")
  .englishNumber()
  .toString(); //returns: 345 45

3) Convert to Persian numbers from Arabic and English Number

Used for converting Arabic and English numbers to Persian.

Example:

starkString("٣٤٥ 78")
  .persianNumber()
  .toString(); //returns: ۳۴۵ ۷۸

4) Convert to Arabic numbers from English and Persian Number

Used for converting Arabic and Persian numbers to English.

Example:

starkString("345")
  .arabicNumber()
  .toString(); //returns:  ٣٤٥

6) Decode Percent-encoding Characters in URLs

Used to normalize url

Example:

starkString(
  "fa.wikipedia.org/wiki/%D8%B5%D9%81%D8%AD%D9%87%D9%94_%D8%A7%D8%B5%D9%84%DB%8C",
)
  .fixURL()
  .toString(); //returns http://fa.wikipedia.org/wiki/%D8%B5%D9%81%D8%AD%D9%87%D9%94_%D8%A7%D8%B5%D9%84%DB%8C/

7) Change keyboard layout

Used for converting Persian char to English char.

Example:

starkString("لخخلمث")
  .switchKey()
  .toString(); //returns: google

8) Convert numbers to words

Used for representing numbers as Persian words.

Example:

starkString("1372")
  .digitsToWords()
  .toString(); //returns: یک هزار و سیصد و هفتاد و دو

9) Zero-width non-joiner correction

Example:

starkString("آمده ای ولی من رفته ام و می آییم")
  .halfSpace()
  .toString(); //returns: آمده‌ای ولی من رفته‌ام و می‌آییم

10) Integer number validation

Whether is value integer

Example:

starkString("344327905").isInteger(); // return true

starkString("34432.7905").isInteger(); // return false
starkString("g344327905").isInteger(); // return false

11) bank card number validation

Whether is value bank card

Example:

starkString("6104337638408961").isValidBankCard(); // return true

12) convert number to currency format

convert english number to currency format

Example:

starkString("120000.00")
  .currency()
  .toString(); // return 120,000.00

starkString("120000")
  .currency()
  .persianNumber()
  .toString(); // return ۱۲۰,۰۰۰

13) Parse Numbers

Remove anything expect numbers

Example:

starkString(" amount 12,000 dollar")
  .parseNumber()
  .toString(); // return 12000

14) security string

convert any char to star ("*")

Example:

starkString("password")
  .security()
  .toString(); // return ********

Chainable using

You can use all of the functions together with one StarkString instance.

Example:

starkString("علي٤2465")
  .persianChar()
  .englishNumber()
  .persianNumber()
  .toString(); //returns: علی۴۲۴۶۵

Contributing

This is a open-source project. Fork the project, complete the code and send pull request.