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

vn-str

v0.4.0

Published

Vietnamese string processing library.

Downloads

495

Readme

Read this in other languages: Tiếng Việt.

What is this?

✂ Vietnamese string processing library.

Installation

Using npm:

$ npm install --save vn-str

Using yarn:

$ yarn add vn-str

Using CDN:

<!-- When using CDN you can call all function in vnStr variable. -->
<script src="https://tronghieu60s.github.io/vn-str/dist/index.js"></script>

Usage

1. Number To Text Vietnamese

Example:

var vnStr = require("vn-str");
var str = vnStr.numToText(54);
console.log(str); // => "năm mươi tư"

2. Remove Vietnamese Tones

Example:

var vnStr = require("vn-str");
var str = vnStr.rmVnTones("Trường Sa Hoàng Sa là của Việt Nam");
console.log(str); // => "Truong Sa Hoang Sa la cua Viet Nam"

3. Remove Non-Alphanumeric Vietnamese Characters

Example:

var vnStr = require("vn-str");
var str = vnStr.rmNonAlphanumeric("Anh ta đã sưu tập nhiều các đồ vật kỳ lạ: trứng chim, tem, nắp chai, dây và cúc áo.");
console.log(str); // => "Anh ta đã sưu tập nhiều các đồ vật kỳ lạ trứng chim tem nắp chai dây và cúc áo"

4. Convert String Vietnamese To Unicode Telex / VNI

Example:

var vnStr = require("vn-str");
var str = "Trường Sa, Hoàng Sa là của Việt Nam";

var strTelex = vnStr.strToTelex(str);
console.log(strTelex); // => "Truwowfng Sa, Hoafng Sa laf cura Vieejt Nam"

var strVNI = vnStr.strToVNI(str);
console.log(strVNI); // => "Tru7o72ng Sa, Hoa2ng Sa la2 cu3a Vie65t Nam"

5. Check Vietnamese Phone Number

Example:

var vnStr = require("vn-str");
var isVietnamesePhone = vnStr.isVietnamesePhoneNumber("+84957507468");
console.log(isVietnamesePhone); // => true

6. Check Vietnamese Tones

Example:

var vnStr = require("vn-str");
var isVietnameseTones = vnStr.isVietnameseTones("Chào em, anh đứng đây từ chiều");
console.log(isVietnameseTones); // => true

7. Check Sentences With Offensive Words

Data: https://github.com/blue-eyes-vn/vietnamese-offensive-words

Example:

var vnStr = require("vn-str");
var hasOffensiveWords = vnStr.hasOffensiveWords("đây là một câu bình thường, cho đến khi thêm từ chửi bậy, đm.");
console.log(hasOffensiveWords); // => true

Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please create an issue.