GithubHelp home page GithubHelp logo

n-shar-ma / unicode-emoji-toolkit Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 6.27 MB

A lightweight, 0 dependency emoji utility library that actually works as you would expect. (Digits are not emojis!) Detect emojis, filter out non emojis or vice-versa, and much more

Home Page: https://www.npmjs.com/package/unicode-emoji-toolkit

License: MIT License

JavaScript 100.00%
emoji emoji-unicode unicode vanilla-javascript-library utility lightweight regex emojis hacktoberfest

unicode-emoji-toolkit's Introduction

unicode-emoji-toolkit

A lightweight, 0 dependency emoji utility library that actually works as you would expect. (Digits are not emojis!) Detect emojis, filter out non emojis or vice-versa, and much more

unicode-emoji-toolkit differs from other libraries that deal with emojis and regex, by being opinionated and NOT treating digits [0-9], # and * as emojis, despite the Unicode Standard officially including them in Emoji characters.

Most people, including me, do not consider these characters to be emojis, and hence this library was born. As you might expect, it still counts #️⃣,*️⃣ and 0️⃣-9️⃣ as emojis

Installation

Using npm:

npm install unicode-emoji-toolkit

or

npm i unicode-emoji-toolkit

Usage

  • Import the library
const emj = require("unicode-emoji-toolkit")
  • boolean hasEmojis(str: string)
console.log(emj.hasEmojis("💜abc1️⃣"))
// true
  • boolean hasNoEmojis(str: string)
console.log(emj.hasNoEmojis("abc1#"))
// true
  • boolean hasOnlyEmojis(str: string)
console.log(emj.hasOnlyEmojis("🆗❤🧡💛💲💚💝💜1️⃣"))
// true
  • string removeEmojis(str: string)
console.log(emj.removeEmojis("💜abc1️⃣"))
// "abc"
  • string removeNonEmojis(str: string)
console.log(emj.removeNonEmojis("💜abc1️⃣"))
// "💜1️⃣"

Contributing

Pull requests for any bug fixes or enhancements are welcome!

  • Do create an issue before before starting work on a PR.
  • After forking and cloning this repositry to your local machine, run npm install to install the developement dependency(jest) for testing.
  • After making the proposed changes locally, add tests and update the usage section in the README if and as required.
  • Bump up the version by running npm version [major | minor | patch] according to the changes made. Refer to SemVer for more help.
  • Be sure to run all tests using npm run test before pushing, and make a PR only if all tests pass.

License

MIT

unicode-emoji-toolkit's People

Contributors

dependabot[bot] avatar n-shar-ma avatar

Stargazers

 avatar

Watchers

 avatar

unicode-emoji-toolkit's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.