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

special-character-transliteration

v1.0.0

Published

This package sanitizes user input for creating slugs, URLs, or standard English text by converting special characters from 31 languages into English equivalents and removing emojis.

Downloads

67

Readme

SpecialCharacterTransliteration

Package Name: special-character-transliteration
Version: 1.0.0 Author: Saif ur Rahman

Functionality

The special-character-transliteration package provides utility functions to:

  1. Normalize special characters: Convert special characters such as Æ, Ŧ, etc., to their simple English transliterations.
  2. Remove emojis: Automatically detect and remove emojis from any string input😎❌.

This package is useful for sanitizing user input, especially for creating slugs, URLs, or handling input that requires standard English text.

How to Install

You can install the package via npm by running:

npm install special-character-transliteration


Step-by-Step Guide to Use the Package

  Step 1: Install the Package
    Copy the following command in your terminal to install the special-character-transliteration package in your project:
 
      npm install special-character-transliteration

  Step 2: Import the Package
    In your .ts or .js file, import the SpecialCharTransliterator class from the package like this:

      import { SpecialCharacterTransliterator } from 'special-character-transliteration';


  Step 3: Initialize the Transliterator
    Create an instance of SpecialCharacterTransliterator to access its methods.

      const transliterator = new SpecialCharacterTransliterator();


  Step 4: Normalize Special Characters
    To replace special characters with their English transliterations, use the normalizeString method.

      const input = "Æ Ŧ special characters";
      const result = transliterator.normalizeString(input);
      console.log(result);  // Output: "AE T special characters"


  Step 5: Remove Emojis from Text
    To remove emojis from a string, use the removeEmojis method.

      const emojiText = "Hello 😊 world 🌍";
      const noEmojis = transliterator.removeEmojis(emojiText);
      console.log(noEmojis);  // Output: "Hello world"


  Step 6: Use It in a Real Scenario (Example: Slug Sanitization)
    If you're working with form fields or user input that needs to be sanitized, such as a URL slug, here’s how you can integrate it:

      setSlug(event: Event) {
        const slug = (event.target as HTMLInputElement).value;

        // Normalize the slug to remove special characters
        const normalizedSlug = transliterator.normalizeString(slug);

        // Remove emojis from the slug
        const sanitizedSlug = transliterator.removeEmojis(normalizedSlug);

        // Set the sanitized value in your form control
        this.form?.controls['url'].setValue(sanitizedSlug.trim().toLowerCase());
      }