New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@blac-sheep/character-count

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blac-sheep/character-count

A simple utility to count characters in a string equally.

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

Character Count

Counting characters in a string seems like a trivial thing until emojis get involved. This simple function will allow you to count emojis in a string as a single character each.

Installation

This library is provided as an UMD module that can be installed by adding the files manually to your project or via a package manager.

Yarn

yarn add @blac-sheep/character-count

NPM

npm install @blac-sheep/character-count

Adding it manually

<script src="character-count.min.js"></script>

Usage

NodeJS

const characterCount = require('@blac-sheep/character-count').default;

ES6

import characterCount from '@blac-sheep/character-count';

Browser

const characterCount = CharacterCount.default;

Examples

countCharacters('Hi there! 👩🏿‍🦽'); // returns: 11
countCharacters('🤲🏿'); // returns: 1
countCharacters('👩‍👧‍👧'); // returns: 1
countCharacters('👩‍👧‍👧👩‍👧‍👧'); // returns: 2
countCharacters('👩‍👧‍👧👩‍👧‍👧👩‍👧‍👧'); // returns: 3
countCharacters('😀'); // returns: 1

License

This library is released under the MIT license.

Keywords

count

FAQs

Package last updated on 16 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts